Class MultipoleTensor

java.lang.Object
ffx.numerics.multipole.MultipoleTensor
Direct Known Subclasses:
CoulombTensorGlobal, CoulombTensorQI

public abstract class MultipoleTensor extends Object
The abstract MultipoleTensor is extended by classes that compute derivatives of 1/|r| via recursion to arbitrary order using Cartesian multipoles in either a global frame or a quasi-internal frame.
This class serves as the abstract parent to both and defines all shared logic. Non-abstract methods are declared final to disallow unnecessary overrides.
Since:
1.0
Author:
Michael J. Schnieders
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final CoordinateSystem
    The coordinate system in use (global or QI).
    protected final double[]
    These are the "source" terms for the recursion for the Coulomb operator (1/R).
    protected final int
    Order plus one.
    protected final int
    im = (Order plus one)^2.
    protected final int
    in = (Order plus one)^3.
    protected final int
    Order plus 1.
    protected Operator
    The OPERATOR in use.
    protected final int
    Order of the tensor recursion (5th is needed for AMOEBA forces).
    protected double
    Separation distance.
    protected double
    Separation distance squared.
    protected final int
    Size = (order + 1) * (order + 2) * (order + 3) / 6;
    protected final int
    No derivatives.
    protected final double[]
    Store the auxiliary tensor memory to avoid memory consumption.
    protected final int
    First derivative with respect to z.
    protected final int
    Second derivative with respect to z.
    protected final int
    Third derivative with respect to z.
    protected final int
    Fourth derivative with respect to z.
    protected final int
    Fifth derivative with respect to z.
    protected final int
    Sixth derivative with respect to z.
    protected final int
    First derivative with respect to y.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Second derivative with respect to y.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Third derivative with respect to y.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Fourth derivative with respect to y.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Fifth derivative with respect to y.
    protected final int
    Derivatives with respect to y and z.
    protected final int
    Sixth derivative with respect to y.
    protected final int
    First derivative with respect to x.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Second derivative with respect to x.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Third derivative with respect to x.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Fourth derivative with respect to x.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Derivatives with respect to x, y and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Fifth derivative with respect to x.
    protected final int
    Derivatives with respect to x and z.
    protected final int
    Derivatives with respect to x and y.
    protected final int
    Sixth derivative with respect to x.
    protected final double[]
    Store the work array to avoid memory consumption.
    protected double
    Xk - Xi.
    protected double
    Yk - Yi.
    protected double
    Zk - Zi.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MultipoleTensor(CoordinateSystem coordinates, int order)
    Constructor for MultipoleTensor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    Compute the field components due to charge I at site K.
    protected abstract void
    Compute the field components due to multipole K at site I.
    protected void
    codePotentialMultipoleI(PolarizableMultipole mI, double[] T, int l, int m, int n, StringBuilder sb)
    Collect the potential its partial derivatives at K due to multipole moments at the origin.
    protected void
    codePotentialMultipoleISIMD(PolarizableMultipole mI, double[] T, int l, int m, int n, StringBuilder sb)
    Collect the potential its partial derivatives at K due to multipole moments at the origin using SIMD instructions.
    protected void
    codePotentialMultipoleK(PolarizableMultipole mK, double[] T, int l, int m, int n, StringBuilder sb)
    Collect the potential its partial derivatives at the origin due to multipole moments at site K.
    protected void
    codePotentialMultipoleKSIMD(PolarizableMultipole mK, double[] T, int l, int m, int n, StringBuilder sb)
    Collect the potential its partial derivatives at the origin due to multipole moments at site K using SIMD instructions.
    protected abstract String
    codeTensorRecursion(double[] r, double[] tensor)
    This function is a driver to collect elements of the Cartesian multipole tensor.
    protected double
    contractMultipoleI(PolarizableMultipole mI, double[] T, int l, int m, int n)
    Contract multipole moments with their respective electrostatic potential derivatives.
    protected abstract void
    dipoleIPotentialAtK(double uxi, double uyi, double uzi, int order)
    Compute the induced dipole field components due to site I at site K.
    protected abstract void
    dipoleKPotentialAtI(double uxk, double uyk, double uzk, int order)
    Compute the induced dipole field components due to site K at site I.
    protected final void
    dipoleTorque(PolarizableMultipole m, double[] torque)
    Compute the torque on a permanent dipole.
    void
    Generate the tensor using hard-coded methods or via recursion.
    final void
    generateTensor(double[] r)
    For the MultipoleTensorTest class and testing.
    double
    getd2EdZ2.
    double
    getdEdZ.
    protected final void
    getTensor(double[] T)
    Load the tensor components.
    void
    log(double[] tensor)
    log.
    protected final double
    Contract a multipole with the potential and its derivatives.
    double
    Permanent multipole energy.
    double
    multipoleEnergyAndGradient(PolarizableMultipole mI, PolarizableMultipole mK, double[] Gi, double[] Gk, double[] Ti, double[] Tk)
    Permanent multipole energy and gradient.
    protected final void
    Compute the permanent multipole gradient.
    protected abstract void
    Compute the field components due to multipole I at site K.
    protected abstract void
    Compute the field components due to multipole K at site I.
    protected final void
    Compute the torque on a permanent multipole.
    protected abstract void
    noStorageRecursion(double[] tensor)
    This method is a driver to collect elements of the Cartesian multipole tensor given the recursion relationships implemented by the method "Tlmnj", which can be called directly to get a single tensor element.
    protected abstract void
    noStorageRecursion(double[] r, double[] tensor)
    This method is a driver to collect elements of the Cartesian multipole tensor given the recursion relationships implemented by the method "Tlmnj", which can be called directly to get a single tensor element.
    protected abstract void
    Hard coded computation of the Cartesian multipole tensors up to 1st order.
    protected abstract void
    Hard coded computation of the Cartesian multipole tensors up to 2nd order.
    protected abstract void
    Hard coded computation of the Cartesian multipole tensors up to 3rd order.
    protected abstract void
    Hard coded computation of the Cartesian multipole tensors up to 4th order.
    protected abstract void
    Hard coded computation of the Cartesian multipole tensors up to 5th order, which is needed for quadrupole-quadrupole forces.
    protected abstract void
    Hard coded computation of the Cartesian multipole tensors up to 6th order, which is needed for quadrupole-quadrupole forces and orthogonal space sampling.
    protected final double
    Contract an induced dipole with the potential and its derivatives.
    double
    Polarization Energy.
    double
    polarizationEnergyAndGradient(PolarizableMultipole mI, PolarizableMultipole mK, double inductionMask, double energyMask, double mutualMask, double[] Gi, double[] Ti, double[] Tk)
    Polarization Energy and Gradient.
    protected final double
    Contract an induced dipole with the potential and its derivatives.
    protected final void
    potentialMultipoleI(PolarizableMultipole mI, double[] T, int l, int m, int n)
    Collect the field at R due to Q multipole moments at the origin (site I).
    protected abstract void
    Compute the field components due to quadrupole I at site K.
    protected abstract void
    Compute the field components due to multipole K at site I.
    protected final void
    Compute the torque on a permanent quadrupole.
    protected abstract void
    recursion(double[] tensor)
    This method is a driver to collect elements of the Cartesian multipole tensor using recursion relationships and storing intermediate values.
    protected abstract void
    recursion(double[] r, double[] tensor)
    This method is a driver to collect elements of the Cartesian multipole tensor using recursion relationships and storing intermediate values.
    final void
    setR(double[] r)
    Set the separation vector.
    abstract void
    setR(double dx, double dy, double dz)
    Set the separation vector.
    protected final void
    setTensor(double[] T)
    Set the tensor components.
    protected abstract void
    source(double[] T000)
    Generate source terms for the Challacombe et al. recursion.
    protected final int
    ti(int dx, int dy, int dz)
    The index is based on the idea of filling tetrahedron.
    protected abstract double
    Tlmnj(int l, int m, int n, int j, double[] r, double[] T000)
    This routine implements the recurrence relations for computation of any Cartesian multipole tensor in ~O(L^8) time, where L is the total order l + m + n, given the auxiliary elements T0000.
    double
    totalEnergy(PolarizableMultipole mI, PolarizableMultipole mK, double scaleEnergy, double[] energyComponents)
    Permanent Multipole + Polarization Energy.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • order

      protected final int order
      Order of the tensor recursion (5th is needed for AMOEBA forces).
    • o1

      protected final int o1
      Order plus 1.
    • il

      protected final int il
      Order plus one.
    • im

      protected final int im
      im = (Order plus one)^2.
    • in

      protected final int in
      in = (Order plus one)^3.
    • size

      protected final int size
      Size = (order + 1) * (order + 2) * (order + 3) / 6;
    • operator

      protected Operator operator
      The OPERATOR in use.
    • coulombSource

      protected final double[] coulombSource
      These are the "source" terms for the recursion for the Coulomb operator (1/R).
    • work

      protected final double[] work
      Store the work array to avoid memory consumption. Note that rather than use an array for intermediate values, a 4D matrix was tried. It was approximately 50% slower than the linear work array.
    • T000

      protected final double[] T000
      Store the auxiliary tensor memory to avoid memory consumption.
    • coordinates

      protected final CoordinateSystem coordinates
      The coordinate system in use (global or QI).
    • R

      protected double R
      Separation distance.
    • r2

      protected double r2
      Separation distance squared.
    • x

      protected double x
      Xk - Xi.
    • y

      protected double y
      Yk - Yi.
    • z

      protected double z
      Zk - Zi.
    • t000

      protected final int t000
      No derivatives.
    • t100

      protected final int t100
      First derivative with respect to x.
    • t010

      protected final int t010
      First derivative with respect to y.
    • t001

      protected final int t001
      First derivative with respect to z.
    • t200

      protected final int t200
      Second derivative with respect to x.
    • t020

      protected final int t020
      Second derivative with respect to y.
    • t002

      protected final int t002
      Second derivative with respect to z.
    • t110

      protected final int t110
      Derivatives with respect to x and y.
    • t101

      protected final int t101
      Derivatives with respect to x and z.
    • t011

      protected final int t011
      Derivatives with respect to y and z.
    • t300

      protected final int t300
      Third derivative with respect to x.
    • t030

      protected final int t030
      Third derivative with respect to y.
    • t003

      protected final int t003
      Third derivative with respect to z.
    • t210

      protected final int t210
      Derivatives with respect to x and y.
    • t201

      protected final int t201
      Derivatives with respect to x and z.
    • t120

      protected final int t120
      Derivatives with respect to x and y.
    • t021

      protected final int t021
      Derivatives with respect to y and z.
    • t102

      protected final int t102
      Derivatives with respect to x and z.
    • t012

      protected final int t012
      Derivatives with respect to y and z.
    • t111

      protected final int t111
      Derivatives with respect to x, y and z.
    • t400

      protected final int t400
      Fourth derivative with respect to x.
    • t040

      protected final int t040
      Fourth derivative with respect to y.
    • t004

      protected final int t004
      Fourth derivative with respect to z.
    • t310

      protected final int t310
      Derivatives with respect to x and y.
    • t301

      protected final int t301
      Derivatives with respect to x and z.
    • t130

      protected final int t130
      Derivatives with respect to x and y.
    • t031

      protected final int t031
      Derivatives with respect to y and z.
    • t103

      protected final int t103
      Derivatives with respect to x and z.
    • t013

      protected final int t013
      Derivatives with respect to y and z.
    • t220

      protected final int t220
      Derivatives with respect to x and y.
    • t202

      protected final int t202
      Derivatives with respect to x and z.
    • t022

      protected final int t022
      Derivatives with respect to y and z.
    • t211

      protected final int t211
      Derivatives with respect to x, y and z.
    • t121

      protected final int t121
      Derivatives with respect to x, y and z.
    • t112

      protected final int t112
      Derivatives with respect to x, y and z.
    • t500

      protected final int t500
      Fifth derivative with respect to x.
    • t050

      protected final int t050
      Fifth derivative with respect to y.
    • t005

      protected final int t005
      Fifth derivative with respect to z.
    • t410

      protected final int t410
      Derivatives with respect to x and y.
    • t401

      protected final int t401
      Derivatives with respect to x and z.
    • t140

      protected final int t140
      Derivatives with respect to x and y.
    • t041

      protected final int t041
      Derivatives with respect to y and z.
    • t104

      protected final int t104
      Derivatives with respect to x and z.
    • t014

      protected final int t014
      Derivatives with respect to y and z.
    • t320

      protected final int t320
      Derivatives with respect to x and y.
    • t302

      protected final int t302
      Derivatives with respect to x and z.
    • t230

      protected final int t230
      Derivatives with respect to x and y.
    • t032

      protected final int t032
      Derivatives with respect to y and z.
    • t203

      protected final int t203
      Derivatives with respect to x and z.
    • t023

      protected final int t023
      Derivatives with respect to y and z.
    • t311

      protected final int t311
      Derivatives with respect to x, y and z.
    • t131

      protected final int t131
      Derivatives with respect to x, y and z.
    • t113

      protected final int t113
      Derivatives with respect to x, y and z.
    • t221

      protected final int t221
      Derivatives with respect to x, y and z.
    • t212

      protected final int t212
      Derivatives with respect to x, y and z.
    • t122

      protected final int t122
      Derivatives with respect to x, y and z.
    • t600

      protected final int t600
      Sixth derivative with respect to x.
    • t060

      protected final int t060
      Sixth derivative with respect to y.
    • t006

      protected final int t006
      Sixth derivative with respect to z.
    • t510

      protected final int t510
      Derivatives with respect to x and y.
    • t501

      protected final int t501
      Derivatives with respect to x and z.
    • t150

      protected final int t150
      Derivatives with respect to x and y.
    • t051

      protected final int t051
      Derivatives with respect to y and z.
    • t105

      protected final int t105
      Derivatives with respect to x and z.
    • t015

      protected final int t015
      Derivatives with respect to y and z.
    • t420

      protected final int t420
      Derivatives with respect to x and y.
    • t402

      protected final int t402
      Derivatives with respect to x and z.
    • t240

      protected final int t240
      Derivatives with respect to x and y.
    • t042

      protected final int t042
      Derivatives with respect to y and z.
    • t204

      protected final int t204
      Derivatives with respect to x and z.
    • t024

      protected final int t024
      Derivatives with respect to y and z.
    • t411

      protected final int t411
      Derivatives with respect to x, y and z.
    • t141

      protected final int t141
      Derivatives with respect to x, y and z.
    • t114

      protected final int t114
      Derivatives with respect to x, y and z.
    • t330

      protected final int t330
      Derivatives with respect to x and y.
    • t303

      protected final int t303
      Derivatives with respect to x and z.
    • t033

      protected final int t033
      Derivatives with respect to y and z.
    • t321

      protected final int t321
      Derivatives with respect to x, y and z.
    • t231

      protected final int t231
      Derivatives with respect to x, y and z.
    • t213

      protected final int t213
      Derivatives with respect to x, y and z.
    • t312

      protected final int t312
      Derivatives with respect to x, y and z.
    • t132

      protected final int t132
      Derivatives with respect to x, y and z.
    • t123

      protected final int t123
      Derivatives with respect to x, y and z.
    • t222

      protected final int t222
      Derivatives with respect to x, y and z.
  • Constructor Details

    • MultipoleTensor

      public MultipoleTensor(CoordinateSystem coordinates, int order)
      Constructor for MultipoleTensor.
      Parameters:
      coordinates - a CoordinateSystem object.
      order - The order of the tensor.
  • Method Details

    • getd2EdZ2

      public double getd2EdZ2()
      getd2EdZ2.
      Returns:
      a double.
    • getdEdZ

      public double getdEdZ()
      getdEdZ.
      Returns:
      a double.
    • log

      public void log(double[] tensor)
      log.
      Parameters:
      tensor - an array of
      invalid reference
      double
      objects.
    • multipoleEnergy

      public double multipoleEnergy(PolarizableMultipole mI, PolarizableMultipole mK)
      Permanent multipole energy.
      Parameters:
      mI - PolarizableMultipole at site I.
      mK - PolarizableMultipole at site K.
      Returns:
      a double.
    • multipoleEnergyAndGradient

      public double multipoleEnergyAndGradient(PolarizableMultipole mI, PolarizableMultipole mK, double[] Gi, double[] Gk, double[] Ti, double[] Tk)
      Permanent multipole energy and gradient.
      Parameters:
      mI - PolarizableMultipole at site I.
      mK - PolarizableMultipole at site K.
      Gi - Coordinate gradient at site I.
      Gk - Coordinate gradient at site K.
      Ti - Torque at site I.
      Tk - Torque at site K.
      Returns:
      the permanent multipole energy.
    • polarizationEnergy

      public double polarizationEnergy(PolarizableMultipole mI, PolarizableMultipole mK, double scaleEnergy)
      Polarization Energy.
      Parameters:
      mI - PolarizableMultipole at site I.
      mK - PolarizableMultipole at site K.
      scaleEnergy - a double.
      Returns:
      a double.
    • polarizationEnergyAndGradient

      public double polarizationEnergyAndGradient(PolarizableMultipole mI, PolarizableMultipole mK, double inductionMask, double energyMask, double mutualMask, double[] Gi, double[] Ti, double[] Tk)
      Polarization Energy and Gradient.
      Parameters:
      mI - PolarizableMultipole at site I.
      mK - PolarizableMultipole at site K.
      inductionMask - a double.
      energyMask - a double.
      mutualMask - a double.
      Gi - an array of
      invalid reference
      double
      objects.
      Ti - an array of
      invalid reference
      double
      objects.
      Tk - an array of
      invalid reference
      double
      objects.
      Returns:
      a double.
    • totalEnergy

      public double totalEnergy(PolarizableMultipole mI, PolarizableMultipole mK, double scaleEnergy, double[] energyComponents)
      Permanent Multipole + Polarization Energy.
      Parameters:
      mI - PolarizableMultipole at site I.
      mK - PolarizableMultipole at site K.
      scaleEnergy - a double.
      energyComponents - The permanent and induced energy components.
      Returns:
      a double.
    • setR

      public final void setR(double[] r)
      Set the separation vector.
      Parameters:
      r - The separation vector.
    • setR

      public abstract void setR(double dx, double dy, double dz)
      Set the separation vector.
      Parameters:
      dx - Separation along the X-axis.
      dy - Separation along the Y-axis.
      dz - Separation along the Z-axis.
    • generateTensor

      public final void generateTensor(double[] r)
      For the MultipoleTensorTest class and testing.
      Parameters:
      r - an array of
      invalid reference
      double
      objects.
    • generateTensor

      public void generateTensor()
      Generate the tensor using hard-coded methods or via recursion.
    • source

      protected abstract void source(double[] T000)
      Generate source terms for the Challacombe et al. recursion.
      Parameters:
      T000 - Location to store the source terms.
    • ti

      protected final int ti(int dx, int dy, int dz)
      The index is based on the idea of filling tetrahedron.

      1/r has an index of 0.
      derivatives of x are first; indices from 1..o for d/dx..(d/dx)^o
      derivatives of x and y are second; base triangle of size (o+1)(o+2)/2
      derivatives of x, y and z are last; total size (o+1)*(o+2)*(o+3)/6

      This function is useful to set up masking constants:
      static int Tlmn = ti(l,m,n,order)
      For example the (d/dy)^2 (1/R) storage location:
      static int T020 = ti(0,2,0,order)

      Parameters:
      dx - int The number of d/dx operations.
      dy - int The number of d/dy operations.
      dz - int The number of d/dz operations.
      Returns:
      int in the range (0..binomial(order + 3, 3) - 1)
    • contractMultipoleI

      protected double contractMultipoleI(PolarizableMultipole mI, double[] T, int l, int m, int n)
      Contract multipole moments with their respective electrostatic potential derivatives.
      Parameters:
      mI - PolarizableMultipole at site I.
      T - array of electrostatic potential and partial derivatives
      l - apply (d/dx)^l to the potential
      m - apply (d/dy)^l to the potential
      n - apply (d/dz)^l to the potential
      Returns:
      the contracted interaction.
    • potentialMultipoleI

      protected final void potentialMultipoleI(PolarizableMultipole mI, double[] T, int l, int m, int n)
      Collect the field at R due to Q multipole moments at the origin (site I).
      Parameters:
      mI - PolarizableMultipole at site I.
      T - Electrostatic potential and partial derivatives
      l - apply (d/dx)^l to the potential
      m - apply (d/dy)^l to the potential
      n - apply (d/dz)^l to the potential
    • codeTensorRecursion

      protected abstract String codeTensorRecursion(double[] r, double[] tensor)

      This function is a driver to collect elements of the Cartesian multipole tensor. Collecting all tensors scales slightly better than O(order^4).

      For a multipole expansion truncated at quadrupole order, for example, up to order 5 is needed for energy gradients. The number of terms this requires is binomial(5 + 3, 3) or 8! / (5! * 3!), which is 56.

      The packing of the tensor elements for order = 1
      tensor[0] = 1/|r|
      tensor[1] = -x/|r|^3
      tensor[2] = -y/|r|^3
      tensor[3] = -z/|r|^3

      Parameters:
      r - The separation vector.
      tensor - The tensor elements.
      Returns:
      The tensor recursion code.
      Since:
      1.0
    • codePotentialMultipoleI

      protected void codePotentialMultipoleI(PolarizableMultipole mI, double[] T, int l, int m, int n, StringBuilder sb)
      Collect the potential its partial derivatives at K due to multipole moments at the origin.
      Parameters:
      mI - PolarizableMultipole at site I.
      T - Electrostatic potential and partial derivatives.
      l - apply (d/dx)^l to the potential.
      m - apply (d/dy)^l to the potential.
      n - apply (d/dz)^l to the potential.
      sb - Append the code to the StringBuilder.
    • codePotentialMultipoleISIMD

      protected void codePotentialMultipoleISIMD(PolarizableMultipole mI, double[] T, int l, int m, int n, StringBuilder sb)
      Collect the potential its partial derivatives at K due to multipole moments at the origin using SIMD instructions.
      Parameters:
      mI - PolarizableMultipole at site I.
      T - Electrostatic potential and partial derivatives.
      l - apply (d/dx)^l to the potential.
      m - apply (d/dy)^l to the potential.
      n - apply (d/dz)^l to the potential.
      sb - Append the code to the StringBuilder.
    • codePotentialMultipoleK

      protected void codePotentialMultipoleK(PolarizableMultipole mK, double[] T, int l, int m, int n, StringBuilder sb)
      Collect the potential its partial derivatives at the origin due to multipole moments at site K.
      Parameters:
      mK - PolarizableMultipole at site I.
      T - Electrostatic potential and partial derivatives.
      l - apply (d/dx)^l to the potential.
      m - apply (d/dy)^l to the potential.
      n - apply (d/dz)^l to the potential.
      sb - Append the code to the StringBuilder.
    • codePotentialMultipoleKSIMD

      protected void codePotentialMultipoleKSIMD(PolarizableMultipole mK, double[] T, int l, int m, int n, StringBuilder sb)
      Collect the potential its partial derivatives at the origin due to multipole moments at site K using SIMD instructions.
      Parameters:
      mK - PolarizableMultipole at site I.
      T - Electrostatic potential and partial derivatives.
      l - apply (d/dx)^l to the potential.
      m - apply (d/dy)^l to the potential.
      n - apply (d/dz)^l to the potential.
      sb - Append the code to the StringBuilder.
    • multipoleEnergy

      protected final double multipoleEnergy(PolarizableMultipole m)
      Contract a multipole with the potential and its derivatives.
      Parameters:
      m - PolarizableMultipole at the site of the potential.
      Returns:
      The permanent multipole energy.
    • multipoleGradient

      protected final void multipoleGradient(PolarizableMultipole m, double[] g)
      Compute the permanent multipole gradient.
      Parameters:
      m - PolarizableMultipole at the site of the potential.
      g - The atomic gradient.
    • multipoleTorque

      protected final void multipoleTorque(PolarizableMultipole m, double[] torque)
      Compute the torque on a permanent multipole.
      Parameters:
      m - PolarizableMultipole at the site of the potential.
      torque - an array of
      invalid reference
      double
      objects.
    • dipoleTorque

      protected final void dipoleTorque(PolarizableMultipole m, double[] torque)
      Compute the torque on a permanent dipole.
      Parameters:
      m - PolarizableMultipole at the site of the potential.
      torque - an array of
      invalid reference
      double
      objects.
    • quadrupoleTorque

      protected final void quadrupoleTorque(PolarizableMultipole m, double[] torque)
      Compute the torque on a permanent quadrupole.
      Parameters:
      m - PolarizableMultipole at the site of the potential.
      torque - an array of
      invalid reference
      double
      objects.
    • polarizationEnergy

      protected final double polarizationEnergy(PolarizableMultipole m)
      Contract an induced dipole with the potential and its derivatives.
      Parameters:
      m - PolarizableMultipole at the site of the potential.
      Returns:
      The polarization energy.
    • polarizationEnergyS

      protected final double polarizationEnergyS(PolarizableMultipole m)
      Contract an induced dipole with the potential and its derivatives.
      Parameters:
      m - PolarizableMultipole at the site of the potential.
      Returns:
      The polarization energy.
    • getTensor

      protected final void getTensor(double[] T)
      Load the tensor components.
      Parameters:
      T - an array of
      invalid reference
      double
      objects.
    • setTensor

      protected final void setTensor(double[] T)
      Set the tensor components.
      Parameters:
      T - an array of
      invalid reference
      double
      objects.
    • noStorageRecursion

      protected abstract void noStorageRecursion(double[] tensor)
      This method is a driver to collect elements of the Cartesian multipole tensor given the recursion relationships implemented by the method "Tlmnj", which can be called directly to get a single tensor element. It does not store intermediate values of the recursion, causing it to scale O(order^8). For order = 5, this approach is a factor of 10 slower than recursion.
      Parameters:
      tensor - double[] length must be at least binomial(order + 3, 3).
    • noStorageRecursion

      protected abstract void noStorageRecursion(double[] r, double[] tensor)
      This method is a driver to collect elements of the Cartesian multipole tensor given the recursion relationships implemented by the method "Tlmnj", which can be called directly to get a single tensor element. It does not store intermediate values of the recursion, causing it to scale O(order^8). For order = 5, this approach is a factor of 10 slower than recursion.
      Parameters:
      r - double[] vector between two sites.
      tensor - double[] length must be at least binomial(order + 3, 3).
    • Tlmnj

      protected abstract double Tlmnj(int l, int m, int n, int j, double[] r, double[] T000)
      This routine implements the recurrence relations for computation of any Cartesian multipole tensor in ~O(L^8) time, where L is the total order l + m + n, given the auxiliary elements T0000.
      It implements the recursion relationships in brute force fashion, without saving intermediate values. This is useful for finding a single tensor, rather than all binomial(L + 3, 3).
      The specific recursion equations (41-43) and set of auxiliary tensor elements from equation (40) can be found in Challacombe et al.
      Parameters:
      l - int The number of (d/dx) operations.
      m - int The number of (d/dy) operations.
      n - int The number of (d/dz) operations.
      j - int j = 0 is the Tlmn tensor, j .GT. 0 is an intermediate.
      r - double[] The {x,y,z} coordinates.
      T000 - double[] Initial auxiliary tensor elements from Eq. (40).
      Returns:
      double The requested Tensor element (intermediate if j .GT. 0).
      Since:
      1.0
    • recursion

      protected abstract void recursion(double[] tensor)
      This method is a driver to collect elements of the Cartesian multipole tensor using recursion relationships and storing intermediate values. It scales approximately O(order^4).
      Parameters:
      tensor - double[] length must be at least binomial(order + 3, 3).
    • recursion

      protected abstract void recursion(double[] r, double[] tensor)
      This method is a driver to collect elements of the Cartesian multipole tensor using recursion relationships and storing intermediate values. It scales approximately O(order^4).
      Parameters:
      r - double[] vector between two sites.
      tensor - double[] length must be at least binomial(order + 3, 3).
    • order1

      protected abstract void order1()
      Hard coded computation of the Cartesian multipole tensors up to 1st order.
    • order2

      protected abstract void order2()
      Hard coded computation of the Cartesian multipole tensors up to 2nd order.
    • order3

      protected abstract void order3()
      Hard coded computation of the Cartesian multipole tensors up to 3rd order.
    • order4

      protected abstract void order4()
      Hard coded computation of the Cartesian multipole tensors up to 4th order.
    • order5

      protected abstract void order5()
      Hard coded computation of the Cartesian multipole tensors up to 5th order, which is needed for quadrupole-quadrupole forces.
    • order6

      protected abstract void order6()
      Hard coded computation of the Cartesian multipole tensors up to 6th order, which is needed for quadrupole-quadrupole forces and orthogonal space sampling.
    • multipoleIPotentialAtK

      protected abstract void multipoleIPotentialAtK(PolarizableMultipole mI, int order)
      Compute the field components due to multipole I at site K.
      Parameters:
      mI - PolarizableMultipole at site I.
      order - Compute derivatives of the potential up to this order. Order 0: Electrostatic potential (E000) Order 1: First derivatives: d/dX is E100, d/dY is E010, d/dZ is E001. Order 2: Second derivatives: d2/dXdX is E200, d2/dXdY is E110 (needed for quadrupole energy) Order 3: 3rd derivatives: (needed for quadrupole forces).
    • chargeIPotentialAtK

      protected abstract void chargeIPotentialAtK(PolarizableMultipole mI, int order)
      Compute the field components due to charge I at site K.
      Parameters:
      mI - PolarizableMultipole at site I.
      order - Compute derivatives of the potential up to this order. Order 0: Electrostatic potential (E000) Order 1: First derivatives: d/dX is E100, d/dY is E010, d/dZ is E001. Order 2: Second derivatives: d2/dXdX is E200, d2/dXdY is E110 (needed for quadrupole energy) Order 3: 3rd derivatives: (needed for quadrupole forces).
    • dipoleIPotentialAtK

      protected abstract void dipoleIPotentialAtK(double uxi, double uyi, double uzi, int order)
      Compute the induced dipole field components due to site I at site K.
      Parameters:
      uxi - X-dipole component.
      uyi - Y-dipole component.
      uzi - Z-dipole component.
      order - Potential order.
    • quadrupoleIPotentialAtK

      protected abstract void quadrupoleIPotentialAtK(PolarizableMultipole mI, int order)
      Compute the field components due to quadrupole I at site K.
      Parameters:
      mI - PolarizableMultipole at site I.
      order - Compute derivatives of the potential up to this order. Order 0: Electrostatic potential (E000) Order 1: First derivatives: d/dX is E100, d/dY is E010, d/dZ is E001. Order 2: Second derivatives: d2/dXdX is E200, d2/dXdY is E110 (needed for quadrupole energy) Order 3: 3rd derivatives: (needed for quadrupole forces).
    • multipoleKPotentialAtI

      protected abstract void multipoleKPotentialAtI(PolarizableMultipole mK, int order)
      Compute the field components due to multipole K at site I.
      Parameters:
      mK - PolarizableMultipole at site K.
      order - Compute derivatives of the potential up to this order. Order 0: Electrostatic potential (E000) Order 1: First derivatives: d/dX is E100, d/dY is E010, d/dZ is E001. Order 2: Second derivatives: d2/dXdX is E200, d2/dXdY is E110 (needed for quadrupole energy) Order 3: 3rd derivatives: (needed for quadrupole forces).
    • chargeKPotentialAtI

      protected abstract void chargeKPotentialAtI(PolarizableMultipole mK, int order)
      Compute the field components due to multipole K at site I.
      Parameters:
      mK - PolarizableMultipole at site K.
      order - Compute derivatives of the potential up to this order. Order 0: Electrostatic potential (E000) Order 1: First derivatives: d/dX is E100, d/dY is E010, d/dZ is E001. Order 2: Second derivatives: d2/dXdX is E200, d2/dXdY is E110 (needed for quadrupole energy) Order 3: 3rd derivatives: (needed for quadrupole forces).
    • dipoleKPotentialAtI

      protected abstract void dipoleKPotentialAtI(double uxk, double uyk, double uzk, int order)
      Compute the induced dipole field components due to site K at site I.
      Parameters:
      uxk - X-dipole component.
      uyk - Y-dipole component.
      uzk - Z-dipole component.
      order - Potential order.
    • quadrupoleKPotentialAtI

      protected abstract void quadrupoleKPotentialAtI(PolarizableMultipole mK, int order)
      Compute the field components due to multipole K at site I.
      Parameters:
      mK - PolarizableMultipole at site K.
      order - Compute derivatives of the potential up to this order. Order 0: Electrostatic potential (E000) Order 1: First derivatives: d/dX is E100, d/dY is E010, d/dZ is E001. Order 2: Second derivatives: d2/dXdX is E200, d2/dXdY is E110 (needed for quadrupole energy) Order 3: 3rd derivatives: (needed for quadrupole forces).