1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package ffx.potential.openmm;
39
40 import ffx.openmm.DoubleArray;
41 import ffx.openmm.Force;
42 import ffx.openmm.IntArray;
43 import ffx.openmm.CustomCompoundBondForce;
44 import ffx.potential.bonded.OutOfPlaneBend;
45 import ffx.potential.parameters.OutOfPlaneBendType;
46
47 import java.util.logging.Level;
48 import java.util.logging.Logger;
49
50 import static edu.uiowa.jopenmm.OpenMMAmoebaLibrary.OpenMM_KJPerKcal;
51 import static java.lang.String.format;
52
53
54
55
56 public class OutOfPlaneBendForce extends CustomCompoundBondForce {
57
58 private static final Logger logger = Logger.getLogger(OutOfPlaneBendForce.class.getName());
59
60
61
62
63
64
65 public OutOfPlaneBendForce(OpenMMEnergy openMMEnergy) {
66 super(4, openMMEnergy.getOutOfPlaneEnergyString());
67 OutOfPlaneBend[] outOfPlaneBends = openMMEnergy.getOutOfPlaneBends();
68 if (outOfPlaneBends == null || outOfPlaneBends.length < 1) {
69 return;
70 }
71
72 addPerBondParameter("k");
73 setName("OutOfPlaneBend");
74
75 IntArray particles = new IntArray(0);
76 DoubleArray parameters = new DoubleArray(0);
77 for (OutOfPlaneBend outOfPlaneBend : outOfPlaneBends) {
78 OutOfPlaneBendType outOfPlaneBendType = outOfPlaneBend.outOfPlaneBendType;
79 int i1 = outOfPlaneBend.getAtom(0).getXyzIndex() - 1;
80 int i2 = outOfPlaneBend.getAtom(1).getXyzIndex() - 1;
81 int i3 = outOfPlaneBend.getAtom(2).getXyzIndex() - 1;
82 int i4 = outOfPlaneBend.getAtom(3).getXyzIndex() - 1;
83 double k = OpenMM_KJPerKcal * outOfPlaneBendType.forceConstant * outOfPlaneBendType.opBendUnit;
84 particles.append(i1);
85 particles.append(i2);
86 particles.append(i3);
87 particles.append(i4);
88 parameters.append(k);
89 addBond(particles, parameters);
90 particles.resize(0);
91 parameters.resize(0);
92 }
93 particles.destroy();
94 parameters.destroy();
95 int forceGroup = openMMEnergy.getMolecularAssembly().getForceField().getInteger("OUT_OF_PLANE_BEND_FORCE_GROUP", 0);
96 setForceGroup(forceGroup);
97 logger.info(format(" Out-of-Plane Bends: %10d", outOfPlaneBends.length));
98 logger.fine(format(" Force Group: %10d", forceGroup));
99 }
100
101
102
103
104
105
106
107 public static Force constructForce(OpenMMEnergy openMMEnergy) {
108 OutOfPlaneBend[] outOfPlaneBends = openMMEnergy.getOutOfPlaneBends();
109 if (outOfPlaneBends == null || outOfPlaneBends.length < 1) {
110 return null;
111 }
112 return new OutOfPlaneBendForce(openMMEnergy);
113 }
114
115
116
117
118
119
120 public void updateForce(OpenMMEnergy openMMEnergy) {
121 OutOfPlaneBend[] outOfPlaneBends = openMMEnergy.getOutOfPlaneBends();
122 if (outOfPlaneBends == null || outOfPlaneBends.length < 1) {
123 return;
124 }
125
126 IntArray particles = new IntArray(0);
127 DoubleArray parameters = new DoubleArray(0);
128 int index = 0;
129 for (OutOfPlaneBend outOfPlaneBend : outOfPlaneBends) {
130 OutOfPlaneBendType outOfPlaneBendType = outOfPlaneBend.outOfPlaneBendType;
131 int i1 = outOfPlaneBend.getAtom(0).getXyzIndex() - 1;
132 int i2 = outOfPlaneBend.getAtom(1).getXyzIndex() - 1;
133 int i3 = outOfPlaneBend.getAtom(2).getXyzIndex() - 1;
134 int i4 = outOfPlaneBend.getAtom(3).getXyzIndex() - 1;
135 double k = OpenMM_KJPerKcal * outOfPlaneBendType.forceConstant * outOfPlaneBendType.opBendUnit;
136 particles.append(i1);
137 particles.append(i2);
138 particles.append(i3);
139 particles.append(i4);
140 parameters.append(k);
141 setBondParameters(index++, particles, parameters);
142 particles.resize(0);
143 parameters.resize(0);
144 }
145 particles.destroy();
146 parameters.destroy();
147
148 updateParametersInContext(openMMEnergy.getContext());
149 }
150 }