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.potential.nonbonded.pme;
39  
40  import static ffx.potential.parameters.ForceField.ELEC_FORM.PAM;
41  import static ffx.utilities.PropertyGroup.ElectrostaticsFunctionalForm;
42  import static java.lang.String.format;
43  
44  import ffx.potential.parameters.ForceField;
45  import ffx.potential.parameters.ForceField.ELEC_FORM;
46  import ffx.utilities.FFXProperty;
47  
48  import java.util.logging.Logger;
49  
50  /**
51   * Scale factors and masking rules for electrostatics.
52   */
53  public class ScaleParameters {
54  
55    private static final Logger logger = Logger.getLogger(ScaleParameters.class.getName());
56  
57    private static final double DEFAULT_MPOLE_12_SCALE = 0.0;
58    private static final double DEFAULT_MPOLE_13_SCALE = 0.0;
59    private static final double DEFAULT_MPOLE_14_SCALE = 1.0;
60    private static final double DEFAULT_MPOLE_15_SCALE = 1.0;
61    private static final double DEFAULT_CHG_12_SCALE = 0.0;
62    private static final double DEFAULT_CHG_13_SCALE = 0.0;
63    private static final double DEFAULT_CHG_14_SCALE = 2.0;
64    private static final double DEFAULT_CHG_15_SCALE = 1.0;
65  
66    /**
67     * The interaction energy between 1-2 multipoles is scaled by m12scale.
68     */
69    @FFXProperty(name = "mpole-12-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "0.0",
70        description = """
71            Provides a multiplicative scale factor that is applied to permanent atomic multipole
72            electrostatic interactions between 1-2 connected atoms, i.e., atoms that are directly bonded.
73            The default value of 0.0 is used, if the mpole-12-scale property is not given
74            in either the parameter file or the property file.
75            """)
76    @FFXProperty(name = "chg-12-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "0.0",
77        description = """
78            Provides a multiplicative scale factor that is applied to charge-charge electrostatic
79            interactions between 1-2 connected atoms, i.e., atoms that are directly bonded.
80            The default value of 0.0 is used, if the chg-12-scale keyword is not given
81            in either the parameter file or the property file.
82            """)
83    public final double m12scale;
84  
85    /**
86     * The interaction energy between 1-3 multipoles is scaled by m13scale.
87     */
88    @FFXProperty(name = "mpole-13-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "0.0",
89        description = """
90            Provides a multiplicative scale factor that is applied to permanent atomic multipole
91            electrostatic interactions between 1-3 connected atoms, i.e., atoms separated by two covalent bonds.
92            The default value of 0.0 is used, if the mpole-13-scale keyword is not given
93            in either the parameter file or the property file.
94            """)
95    @FFXProperty(name = "chg-13-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "0.0",
96        description = """
97            Provides a multiplicative scale factor that is applied to charge-charge electrostatic
98            interactions between 1-3 connected atoms, i.e., atoms separated by two covalent bonds.
99            The default value of 0.0 is used, if the chg-13-scale keyword is not given
100           in either the parameter file or the property file.
101           """)
102   public final double m13scale;
103 
104   /**
105    * The interaction energy between 1-4 multipoles is scaled by m14scale.
106    */
107   @FFXProperty(name = "mpole-14-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "1.0",
108       description = """
109           Provides a multiplicative scale factor that is applied to permanent atomic multipole
110           electrostatic interactions between 1-4 connected atoms, i.e., atoms separated by three covalent bonds.
111           The default value of 1.0 is used, if the mpole-14-scale keyword is not given
112           in either the parameter file or the property file.
113           """)
114   @FFXProperty(name = "chg-14-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "1.0",
115       description = """
116           Provides a multiplicative scale factor that is applied to charge-charge electrostatic
117           interactions between 1-4 connected atoms, i.e., atoms separated by three covalent bonds.
118           The default value of 1.0 is used, if the chg-14-scale keyword is not given
119           in either the parameter file or the property file.
120           """)
121   public final double m14scale;
122 
123   /**
124    * The interaction energy between 1-5 multipoles is scaled by m15scale.
125    */
126   @FFXProperty(name = "mpole-15-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "1.0",
127       description = """
128           Provides a multiplicative scale factor that is applied to permanent atomic multipole
129           electrostatic interactions between 1-5 connected atoms, i.e., atoms separated by four covalent bonds.
130           The default value of 1.0 is used, if the mpole-15-scale keyword is not given
131           in either the parameter file or the property file.
132           """)
133   @FFXProperty(name = "chg-15-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "1.0",
134       description = """
135           Provides a multiplicative scale factor that is applied to charge-charge electrostatic
136           interactions between 1-5 connected atoms, i.e., atoms separated by four covalent bonds.
137           The default value of 1.0 is used, if the chg-15-scale keyword is not given
138           in either the parameter file or the property file.
139           """)
140   public final double m15scale;
141 
142   private static final double DEFAULT_DIRECT_11_SCALE = 0.0;
143   private static final double DEFAULT_DIRECT_12_SCALE = 1.0;
144   private static final double DEFAULT_DIRECT_13_SCALE = 1.0;
145   private static final double DEFAULT_DIRECT_14_SCALE = 1.0;
146 
147   /**
148    * DIRECT-11-SCALE factor.
149    */
150   @FFXProperty(name = "direct-11-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "0.0",
151       description = """
152           Provides a multiplicative scale factor that is applied to the permanent (direct) field
153           due to atoms within a polarization group during an induced dipole calculation,
154           i.e., atoms that are in the same polarization group as the atom being polarized.
155           The default value of 0.0 is used, if the direct-11-scale keyword is not given
156           in either the parameter file or the property file.
157           """)
158   public final double d11scale;
159 
160   /**
161    * The DIRECT_12_SCALE factor is assumed to be 1.0. If this assumption is violated by a keyword,
162    * FFX will exit.
163    */
164   @FFXProperty(name = "direct-12-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "1.0",
165       description = """
166           Provides a multiplicative scale factor that is applied to the permanent (direct) field
167           due to atoms in 1-2 polarization groups during an induced dipole calculation,
168           i.e., atoms that are in polarization groups directly connected to the group containing the atom being polarized.
169           The default value of 0.0 is used, if the direct-12-scale keyword is not given
170           in either the parameter file or the property file.
171           """)
172   public final double d12scale;
173 
174   /**
175    * The DIRECT_13_SCALE factor is assumed to be 1.0. If this assumption is violated by a keyword,
176    * FFX will exit.
177    */
178   @FFXProperty(name = "direct-13-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "1.0",
179       description = """
180           Provides a multiplicative scale factor that is applied to the permanent (direct) field
181           due to atoms in 1-3 polarization groups during an induced dipole calculation,
182           i.e., atoms that are in polarization groups separated by one group from the group containing the atom being polarized.
183           The default value of 0.0 is used, if the direct-13-scale keyword is not given
184           in either the parameter file or the property file.
185           """)
186   public final double d13scale;
187 
188   /**
189    * The DIRECT_14_SCALE factor is assumed to be 1.0. If this assumption is violated by a keyword,
190    * FFX will exit.
191    */
192   @FFXProperty(name = "direct-14-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "1.0",
193       description = """
194           Provides a multiplicative scale factor that is applied to the permanent (direct) field
195           due to atoms in 1-4 polarization groups during an induced dipole calculation,
196           i.e., atoms that are in polarization groups separated by two groups from the group containing the atom being polarized.
197           The default value of 1.0 is used, if the direct-14-scale keyword is not given
198           in either the parameter file or the property file.
199           """)
200   public final double d14scale;
201 
202   private static final double DEFAULT_POLAR_12_SCALE = 0.0;
203   private static final double DEFAULT_POLAR_13_SCALE = 0.0;
204   private static final double DEFAULT_POLAR_14_SCALE = 1.0;
205   private static final double DEFAULT_POLAR_15_SCALE = 1.0;
206 
207   /**
208    * The interaction energy between a permanent multipole and polarizable site that are 1-2 is scaled
209    * by p12scale.
210    */
211   @FFXProperty(name = "polar-12-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "0.0",
212       description = """
213           Provides a multiplicative scale factor that is applied to polarization interactions
214           between 1-2 connected atoms located in different polarization groups.
215           The default value of 0.0 is used, if the polar-12-scale keyword is not given
216           in either the parameter file or the property file.
217           """)
218   public final double p12scale;
219 
220   /**
221    * The interaction energy between a permanent multipole and polarizable site that are 1-3 is scaled
222    * by p13scale.
223    */
224   @FFXProperty(name = "polar-13-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "0.0",
225       description = """ 
226           Provides a multiplicative scale factor that is applied to polarization interactions
227           between 1-3 connected atoms located in different polarization groups.
228           The default value of 0.0 is used, if the polar-13-scale keyword is not given
229           in either the parameter file or the property file.
230           """)
231   public final double p13scale;
232 
233   /**
234    * The interaction energy between a permanent multipole and polarizable site that are 1-4 is scaled
235    * by p14scale.
236    */
237   @FFXProperty(name = "polar-14-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "1.0",
238       description = """
239           Provides a multiplicative scale factor that is applied to polarization interactions
240           between 1-4 connected atoms located in different polarization groups.
241           The default value of 1.0 is used, if the polar-14-scale keyword is not given
242           in either the parameter file or the property file.
243           """)
244   public final double p14scale;
245 
246   /**
247    * The interaction energy between a permanent multipole and polarizable site that are 1-5 is scaled
248    * by p15scale. Only 1.0 is supported.
249    */
250   @FFXProperty(name = "polar-15-scale", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "1.0",
251       description = """
252           Provides a multiplicative scale factor that is applied to polarization interactions
253           between 1-5 connected atoms located in different polarization groups.
254           The default value of 1.0 is used, if the polar-15-scale keyword is not given
255           in either the parameter file or the property file.
256           """)
257   public final double p15scale;
258 
259   private static final double DEFAULT_POLAR_12_INTRA = 0.0;
260 
261   private static final double DEFAULT_POLAR_13_INTRA = 0.0;
262 
263   private static final double DEFAULT_POLAR_14_INTRA = 0.5;
264 
265   private static final double DEFAULT_POLAR_15_INTRA = 1.0;
266 
267   /**
268    * An intra-12-scale factor other than 0.0 is not supported and will cause FFX to exit.
269    */
270   @FFXProperty(name = "polar-12-intra", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "0.0",
271       description = """
272           Provides a multiplicative scale factor that is applied to polarization interactions
273           between 1-2 connected atoms located in the same polarization group.
274           The default value of 0.0 is used, if the polar-12-intra keyword is not given
275           in either the parameter file or the property file.
276           """)
277   public final double intra12Scale;
278   /**
279    * An intra-13-scale factor other than 0.0 is not supported and will cause FFX to exit.
280    */
281   @FFXProperty(name = "polar-13-intra", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "0.0",
282       description = """
283           Provides a multiplicative scale factor that is applied to polarization interactions
284           between 1-3 connected atoms located in the same polarization group.
285           The default value of 0.0 is used, if the polar-13-intra keyword is not given
286           in either the parameter file or the property file.
287           """)
288   public final double intra13Scale;
289   /**
290    * Provides a multiplicative scale factor that is applied to polarization interactions between 1-4
291    * connected atoms located in the same polarization group.
292    */
293   @FFXProperty(name = "polar-14-intra", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "0.5",
294       description = """
295           Provides a multiplicative scale factor that is applied to polarization interactions
296           between 1-4 connected atoms located in the same polarization group.
297           The default value of 0.5 is used, if the polar-14-intra keyword is not given
298           in either the parameter file or the property file.
299           """)
300   public final double intra14Scale;
301   /**
302    * An intra-15-scale factor other than 1.0 is not supported and will cause FFX to exit.
303    */
304   @FFXProperty(name = "polar-15-intra", propertyGroup = ElectrostaticsFunctionalForm, defaultValue = "1.0",
305       description = """
306           Provides a multiplicative scale factor that is applied to polarization interactions
307           between 1-5 connected atoms located in the same polarization group.
308           The default value of 1.0 is used, if the polar-15-intra keyword is not given
309           in either the parameter file or the property file.
310           """)
311   public final double intra15Scale;
312 
313   public ScaleParameters(ELEC_FORM elecForm, ForceField forceField) {
314     if (elecForm == PAM) {
315       double m12 = forceField.getDouble("MPOLE_12_SCALE", DEFAULT_MPOLE_12_SCALE);
316       if (m12 > 1.0) {
317         m12 = 1.0 / m12;
318       }
319       m12scale = m12;
320       double m13 = forceField.getDouble("MPOLE_13_SCALE", DEFAULT_MPOLE_13_SCALE);
321       if (m13 > 1.0) {
322         m13 = 1.0 / m13;
323       }
324       m13scale = m13;
325       double m14 = forceField.getDouble("MPOLE_14_SCALE", DEFAULT_MPOLE_14_SCALE);
326       if (m14 > 1.0) {
327         m14 = 1.0 / m14;
328       }
329       m14scale = m14;
330       double m15 = forceField.getDouble("MPOLE_15_SCALE", DEFAULT_MPOLE_15_SCALE);
331       if (m15 > 1.0) {
332         m15 = 1.0 / m15;
333       }
334       m15scale = m15;
335     } else {
336       double m12 = forceField.getDouble("CHG_12_SCALE", DEFAULT_CHG_12_SCALE);
337       if (m12 > 1.0) {
338         m12 = 1.0 / m12;
339       }
340       m12scale = m12;
341       double m13 = forceField.getDouble("CHG_13_SCALE", DEFAULT_CHG_13_SCALE);
342       if (m13 > 1.0) {
343         m13 = 1.0 / m13;
344       }
345       m13scale = m13;
346       double m14 = forceField.getDouble("CHG_14_SCALE", DEFAULT_CHG_14_SCALE);
347       if (m14 > 1.0) {
348         m14 = 1.0 / m14;
349       }
350       m14scale = m14;
351       double m15 = forceField.getDouble("CHG_15_SCALE", DEFAULT_CHG_15_SCALE);
352       if (m15 > 1.0) {
353         m15 = 1.0 / m15;
354       }
355       m15scale = m15;
356     }
357 
358     // Multiplicative scale factors applied to polarization interactions between connected
359     // atoms located in the same polarization group.
360     intra12Scale = forceField.getDouble("POLAR_12_INTRA", DEFAULT_POLAR_12_INTRA);
361     if (intra12Scale != 0.0) {
362       logger.severe(format(" Unsupported polar-12-intra parameter: %8.6f", intra12Scale));
363     }
364     intra13Scale = forceField.getDouble("POLAR_13_INTRA", DEFAULT_POLAR_13_INTRA);
365     if (intra13Scale != 0.0) {
366       logger.severe(format(" Unsupported polar-13-intra parameter: %8.6f", intra13Scale));
367     }
368     intra14Scale = forceField.getDouble("POLAR_14_INTRA", DEFAULT_POLAR_14_INTRA);
369     intra15Scale = forceField.getDouble("POLAR_15_INTRA", DEFAULT_POLAR_15_INTRA);
370     if (intra15Scale != 1.0) {
371       logger.severe(format(" Unsupported polar-15-intra parameter: %8.6f", intra15Scale));
372     }
373 
374     // Polarization groups masking rules.
375     d11scale = forceField.getDouble("DIRECT_11_SCALE", DEFAULT_DIRECT_11_SCALE);
376     d12scale = forceField.getDouble("DIRECT_12_SCALE", DEFAULT_DIRECT_12_SCALE);
377     d13scale = forceField.getDouble("DIRECT_13_SCALE", DEFAULT_DIRECT_13_SCALE);
378     d14scale = forceField.getDouble("DIRECT_14_SCALE", DEFAULT_DIRECT_14_SCALE);
379     if (d12scale != 1.0) {
380       logger.severe(format(" Unsupported direct-12-scale parameter: %8.6f", d12scale));
381     }
382     if (d13scale != 1.0) {
383       logger.severe(format(" Unsupported direct-13-scale parameter: %8.6f", d13scale));
384     }
385     if (d14scale != 1.0) {
386       logger.severe(format(" Unsupported direct-14-scale parameter: %8.6f", d14scale));
387     }
388 
389     // Polarization energy masking rules.
390     p12scale = forceField.getDouble("POLAR_12_SCALE", DEFAULT_POLAR_12_SCALE);
391     p13scale = forceField.getDouble("POLAR_13_SCALE", DEFAULT_POLAR_13_SCALE);
392     p14scale = forceField.getDouble("POLAR_14_SCALE", DEFAULT_POLAR_14_SCALE);
393     p15scale = forceField.getDouble("POLAR_15_SCALE", DEFAULT_POLAR_15_SCALE);
394     if (p15scale != 1.0) {
395       logger.severe(format(" Unsupported polar-15-scale parameter: %8.6f", p15scale));
396     }
397   }
398 }