View Javadoc
1   // ******************************************************************************
2   //
3   // Title:       Force Field X.
4   // Description: Force Field X - Software for Molecular Biophysics.
5   // Copyright:   Copyright (c) Michael J. Schnieders 2001-2024.
6   //
7   // This file is part of Force Field X.
8   //
9   // Force Field X is free software; you can redistribute it and/or modify it
10  // under the terms of the GNU General Public License version 3 as published by
11  // the Free Software Foundation.
12  //
13  // Force Field X is distributed in the hope that it will be useful, but WITHOUT
14  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16  // details.
17  //
18  // You should have received a copy of the GNU General Public License along with
19  // Force Field X; if not, write to the Free Software Foundation, Inc., 59 Temple
20  // Place, Suite 330, Boston, MA 02111-1307 USA
21  //
22  // Linking this library statically or dynamically with other modules is making a
23  // combined work based on this library. Thus, the terms and conditions of the
24  // GNU General Public License cover the whole combination.
25  //
26  // As a special exception, the copyright holders of this library give you
27  // permission to link this library with independent modules to produce an
28  // executable, regardless of the license terms of these independent modules, and
29  // to copy and distribute the resulting executable under terms of your choice,
30  // provided that you also meet, for each linked independent module, the terms
31  // and conditions of the license of that module. An independent module is a
32  // module which is not derived from or based on this library. If you modify this
33  // library, you may extend this exception to your version of the library, but
34  // you are not obligated to do so. If you do not wish to do so, delete this
35  // exception statement from your version.
36  //
37  // ******************************************************************************
38  package ffx.numerics.multipole;
39  
40  import static org.junit.Assert.assertEquals;
41  
42  import java.util.Arrays;
43  import java.util.Collection;
44  
45  import ffx.utilities.FFXTest;
46  import org.junit.Test;
47  import org.junit.runner.RunWith;
48  import org.junit.runners.Parameterized;
49  import org.junit.runners.Parameterized.Parameters;
50  
51  /**
52   * Parameterized Test of the MultipoleTensor class.
53   *
54   * @author Michael J. Schnieders
55   * @since 1.0
56   */
57  @RunWith(Parameterized.class)
58  public class MultipoleTensorTest extends FFXTest {
59  
60    private final int order;
61    private final int tensorCount;
62    private final String info;
63  
64    // Water Dimer O-O interaction
65    protected static final double[] xyz = {2.97338529, 0.0, 0.03546452, 0.0};
66    // Rotated multipole at site I.
67    protected final static double[] Qi = {-0.51966,
68        0.06979198988239577, 0.0, 0.0289581620819011,
69        0.024871041044109393, -0.1170771231287098, 0.09220608208460039,
70        0.0, -0.03374891685535346, 0.0};
71    // Rotated multipole at site K.
72    protected final static double[] Qk = {-0.51966,
73        0.05872406108747119, 0.0, 0.047549780780788455,
74        0.048623413357888695, -0.1170771231287098, 0.06845370977082109,
75        0.0, -0.04662811558421081, 0.0};
76  
77    // Permanent multipole Coulomb energy and torque.
78    protected final static double permanentEnergy = 0.08861401274679;
79    protected final static double[] permTorqueI = {0.0, 0.00039200904382, 0.0};
80    protected final static double[] permTorqueK = {0.0, -0.00400122461628, 0.0};
81    // Permanent multipole Ewald energy and torque.
82    protected final static double permanentEnergyEwald = 0.001275693067120;
83    protected final static double[] permTorqueIEwald = {0.0, -0.000304652548761, 0.0};
84    protected final static double[] permTorqueKEwald = {0.0, -0.000745949268609, 0.0};
85  
86    // Water Dimer O-O Coulomb mutual polarization Energy, grad and torque in vacuum
87    protected final static double scaleMutual = 1.0;
88    protected final static double[] Ui = {0.04886563833303603, 0.0, -0.0018979726219775425};
89    protected final static double[] Uk = {-0.040839567654139396, 0.0, -5.982126263609587E-4};
90    protected final static double polarizationEnergyCoulomb = -0.002576831234958;
91    protected final static double[] polarGradICoulomb = {-0.003233364149133, 0.0, 0.000081374809911};
92    protected final static double[] polarTorqueICoulomb = {0.0, 0.000015759704950, 0.0};
93    protected final static double[] polarTorqueKCoulomb = {0.0, 0.000340863064066, 0.0};
94    // Water Dimer O-O Thole correction for mutual Polarization energy, grad and torque in vacuum.
95    protected final static double polarizationEnergyThole = 0.000000036672468;
96    protected final static double[] polarGradIThole = {0.000001005045968, 0.0, 0.000000090221488};
97    protected final static double[] polarTorqueIThole = {0.0, 0.000000072500602, 0.0};
98    protected final static double[] polarTorqueKThole = {0.0, 0.000000151677615, 0.0};
99  
100   // Water Dimer O-O Coulomb mutual polarization Energy, grad and torque under Ewald.
101   protected final static double[] UiEwald = {0.017212550663556914, 0.0, 0.0026849371538929636};
102   protected final static double[] UkEwald = {0.0020051189004858657, 0.0, 0.005476556978973183};
103   protected final static double polarizationEnergyEwald = -0.000078870483232;
104   protected final static double[] polarGradIEwald = {-0.000345793382509, 0.0, 0.000025382496373};
105   protected final static double[] polarTorqueIEwald = {0.0, -0.000003385814434, 0.0};
106   protected final static double[] polarTorqueKEwald = {0.0, 0.000080790360336, 0.0};
107 
108   public MultipoleTensorTest(String info, int order) {
109     this.info = info;
110     this.order = order;
111     this.tensorCount = MultipoleTensor.tensorCount(order);
112   }
113 
114   @Parameters
115   public static Collection<Object[]> data() {
116     return Arrays.asList(
117         new Object[][] {
118             {
119                 "Order 6", 6
120             },
121             {
122                 "Order 5", 5
123             },
124             {
125                 "Order 4", 4
126             }
127         });
128   }
129 
130   /**
131    * Test of tensorCount method, of class MultipoleTensor.
132    *
133    * @since 1.0
134    */
135   @Test
136   public void tensorCountTest() {
137     int result = MultipoleTensor.tensorCount(order);
138     assertEquals(info, tensorCount, result);
139   }
140 
141   /** Test of ti method, of class MultipoleTensor. */
142   @Test
143   public void tensorIndexTest() {
144     int dx = 1;
145     int dy = 0;
146     int dz = 0;
147     int expResult = 1;
148     int result = MultipoleTensor.ti(dx, dy, dz, order);
149     assertEquals(info, expResult, result);
150   }
151 
152 }