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.openmm;
39
40 import com.sun.jna.Pointer;
41 import com.sun.jna.ptr.DoubleByReference;
42 import com.sun.jna.ptr.IntByReference;
43 import com.sun.jna.ptr.PointerByReference;
44
45 import java.nio.DoubleBuffer;
46 import java.nio.IntBuffer;
47
48 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_Boolean.OpenMM_True;
49 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_addComputedValue;
50 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_addEnergyParameterDerivative;
51 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_addExclusion;
52 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_addFunction;
53 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_addGlobalParameter;
54 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_addInteractionGroup;
55 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_addParticle;
56 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_addPerParticleParameter;
57 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_addTabulatedFunction;
58 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_create;
59 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_createExclusionsFromBonds;
60 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_destroy;
61 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getComputedValueParameters;
62 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getCutoffDistance;
63 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getEnergyFunction;
64 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getEnergyParameterDerivativeName;
65 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getExclusionParticles;
66 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getFunctionParameters;
67 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getGlobalParameterDefaultValue;
68 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getGlobalParameterName;
69 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getInteractionGroupParameters;
70 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getNonbondedMethod;
71 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getNumComputedValues;
72 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getNumEnergyParameterDerivatives;
73 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getNumExclusions;
74 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getNumFunctions;
75 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getNumGlobalParameters;
76 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getNumInteractionGroups;
77 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getNumParticles;
78 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getNumPerParticleParameters;
79 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getNumTabulatedFunctions;
80 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getParticleParameters;
81 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getPerParticleParameterName;
82 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getSwitchingDistance;
83 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getTabulatedFunction;
84 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getTabulatedFunctionName;
85 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getUseLongRangeCorrection;
86 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_getUseSwitchingFunction;
87 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setComputedValueParameters;
88 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setCutoffDistance;
89 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setEnergyFunction;
90 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setExclusionParticles;
91 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setFunctionParameters;
92 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setGlobalParameterDefaultValue;
93 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setGlobalParameterName;
94 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setInteractionGroupParameters;
95 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setNonbondedMethod;
96 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setParticleParameters;
97 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setPerParticleParameterName;
98 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setSwitchingDistance;
99 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setUseLongRangeCorrection;
100 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_setUseSwitchingFunction;
101 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_updateParametersInContext;
102 import static edu.uiowa.jopenmm.OpenMMLibrary.OpenMM_CustomNonbondedForce_usesPeriodicBoundaryConditions;
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168 public class CustomNonbondedForce extends Force {
169
170
171
172
173
174
175 public CustomNonbondedForce(String energy) {
176 super(OpenMM_CustomNonbondedForce_create(energy));
177 }
178
179
180
181
182
183
184
185
186 public int addComputedValue(String name, String expression) {
187 return OpenMM_CustomNonbondedForce_addComputedValue(pointer, name, expression);
188 }
189
190
191
192
193
194
195 public void addEnergyParameterDerivative(String name) {
196 OpenMM_CustomNonbondedForce_addEnergyParameterDerivative(pointer, name);
197 }
198
199
200
201
202
203
204
205
206 public int addExclusion(int particle1, int particle2) {
207 return OpenMM_CustomNonbondedForce_addExclusion(pointer, particle1, particle2);
208 }
209
210
211
212
213
214
215
216
217
218
219 public int addFunction(String name, PointerByReference function, double min, double max) {
220 return OpenMM_CustomNonbondedForce_addFunction(pointer, name, function, min, max);
221 }
222
223
224
225
226
227
228
229
230 public int addGlobalParameter(String name, double value) {
231 return OpenMM_CustomNonbondedForce_addGlobalParameter(pointer, name, value);
232 }
233
234
235
236
237
238
239
240
241 public int addInteractionGroup(IntSet group1, IntSet group2) {
242 return OpenMM_CustomNonbondedForce_addInteractionGroup(pointer, group1.getPointer(), group2.getPointer());
243 }
244
245
246
247
248
249
250
251 public int addParticle(DoubleArray parameters) {
252 return OpenMM_CustomNonbondedForce_addParticle(pointer, parameters.getPointer());
253 }
254
255
256
257
258
259
260
261 public int addPerParticleParameter(String name) {
262 return OpenMM_CustomNonbondedForce_addPerParticleParameter(pointer, name);
263 }
264
265
266
267
268
269
270
271
272 public int addTabulatedFunction(String name, PointerByReference function) {
273 return OpenMM_CustomNonbondedForce_addTabulatedFunction(pointer, name, function);
274 }
275
276
277
278
279
280
281
282 public void createExclusionsFromBonds(BondArray bonds, int bondCutoff) {
283 OpenMM_CustomNonbondedForce_createExclusionsFromBonds(pointer, bonds.getPointer(), bondCutoff);
284 }
285
286
287
288
289 @Override
290 public void destroy() {
291 if (pointer != null) {
292 OpenMM_CustomNonbondedForce_destroy(pointer);
293 pointer = null;
294 }
295 }
296
297
298
299
300
301
302
303
304 public void getComputedValueParameters(int index, PointerByReference name, PointerByReference expression) {
305 OpenMM_CustomNonbondedForce_getComputedValueParameters(pointer, index, name, expression);
306 }
307
308
309
310
311
312
313 public double getCutoffDistance() {
314 return OpenMM_CustomNonbondedForce_getCutoffDistance(pointer);
315 }
316
317
318
319
320
321
322 public String getEnergyFunction() {
323 Pointer p = OpenMM_CustomNonbondedForce_getEnergyFunction(pointer);
324 if (p == null) {
325 return null;
326 }
327 return p.getString(0);
328 }
329
330
331
332
333
334
335
336 public String getEnergyParameterDerivativeName(int index) {
337 Pointer p = OpenMM_CustomNonbondedForce_getEnergyParameterDerivativeName(pointer, index);
338 if (p == null) {
339 return null;
340 }
341 return p.getString(0);
342 }
343
344
345
346
347
348
349
350
351 public void getExclusionParticles(int index, IntByReference particle1, IntByReference particle2) {
352 OpenMM_CustomNonbondedForce_getExclusionParticles(pointer, index, particle1, particle2);
353 }
354
355
356
357
358
359
360
361
362 public void getExclusionParticles(int index, IntBuffer particle1, IntBuffer particle2) {
363 OpenMM_CustomNonbondedForce_getExclusionParticles(pointer, index, particle1, particle2);
364 }
365
366
367
368
369
370
371
372
373
374
375 public void getFunctionParameters(int index, PointerByReference name, PointerByReference function, DoubleByReference min, DoubleByReference max) {
376 OpenMM_CustomNonbondedForce_getFunctionParameters(pointer, index, name, function, min, max);
377 }
378
379
380
381
382
383
384
385
386
387
388 public void getFunctionParameters(int index, PointerByReference name, PointerByReference function, DoubleBuffer min, DoubleBuffer max) {
389 OpenMM_CustomNonbondedForce_getFunctionParameters(pointer, index, name, function, min, max);
390 }
391
392
393
394
395
396
397
398 public double getGlobalParameterDefaultValue(int index) {
399 return OpenMM_CustomNonbondedForce_getGlobalParameterDefaultValue(pointer, index);
400 }
401
402
403
404
405
406
407
408 public String getGlobalParameterName(int index) {
409 Pointer p = OpenMM_CustomNonbondedForce_getGlobalParameterName(pointer, index);
410 if (p == null) {
411 return null;
412 }
413 return p.getString(0);
414 }
415
416
417
418
419
420
421
422
423 public void getInteractionGroupParameters(int index, PointerByReference group1, PointerByReference group2) {
424 OpenMM_CustomNonbondedForce_getInteractionGroupParameters(pointer, index, group1, group2);
425 }
426
427
428
429
430
431
432 public int getNonbondedMethod() {
433 return OpenMM_CustomNonbondedForce_getNonbondedMethod(pointer);
434 }
435
436
437
438
439
440
441 public int getNumComputedValues() {
442 return OpenMM_CustomNonbondedForce_getNumComputedValues(pointer);
443 }
444
445
446
447
448
449
450 public int getNumEnergyParameterDerivatives() {
451 return OpenMM_CustomNonbondedForce_getNumEnergyParameterDerivatives(pointer);
452 }
453
454
455
456
457
458
459 public int getNumExclusions() {
460 return OpenMM_CustomNonbondedForce_getNumExclusions(pointer);
461 }
462
463
464
465
466
467
468
469 @Deprecated
470 public int getNumFunctions() {
471 return OpenMM_CustomNonbondedForce_getNumFunctions(pointer);
472 }
473
474
475
476
477
478
479 public int getNumGlobalParameters() {
480 return OpenMM_CustomNonbondedForce_getNumGlobalParameters(pointer);
481 }
482
483
484
485
486
487
488 public int getNumInteractionGroups() {
489 return OpenMM_CustomNonbondedForce_getNumInteractionGroups(pointer);
490 }
491
492
493
494
495
496
497 public int getNumParticles() {
498 return OpenMM_CustomNonbondedForce_getNumParticles(pointer);
499 }
500
501
502
503
504
505
506 public int getNumPerParticleParameters() {
507 return OpenMM_CustomNonbondedForce_getNumPerParticleParameters(pointer);
508 }
509
510
511
512
513
514
515 public int getNumTabulatedFunctions() {
516 return OpenMM_CustomNonbondedForce_getNumTabulatedFunctions(pointer);
517 }
518
519
520
521
522
523
524
525 public void getParticleParameters(int index, PointerByReference parameters) {
526 OpenMM_CustomNonbondedForce_getParticleParameters(pointer, index, parameters);
527 }
528
529
530
531
532
533
534
535 public String getPerParticleParameterName(int index) {
536 Pointer p = OpenMM_CustomNonbondedForce_getPerParticleParameterName(pointer, index);
537 if (p == null) {
538 return null;
539 }
540 return p.getString(0);
541 }
542
543
544
545
546
547
548 public double getSwitchingDistance() {
549 return OpenMM_CustomNonbondedForce_getSwitchingDistance(pointer);
550 }
551
552
553
554
555
556
557
558 public PointerByReference getTabulatedFunction(int index) {
559 return OpenMM_CustomNonbondedForce_getTabulatedFunction(pointer, index);
560 }
561
562
563
564
565
566
567
568 public String getTabulatedFunctionName(int index) {
569 Pointer p = OpenMM_CustomNonbondedForce_getTabulatedFunctionName(pointer, index);
570 if (p == null) {
571 return null;
572 }
573 return p.getString(0);
574 }
575
576
577
578
579
580
581 public int getUseLongRangeCorrection() {
582 return OpenMM_CustomNonbondedForce_getUseLongRangeCorrection(pointer);
583 }
584
585
586
587
588
589
590 public int getUseSwitchingFunction() {
591 return OpenMM_CustomNonbondedForce_getUseSwitchingFunction(pointer);
592 }
593
594
595
596
597
598
599
600
601 public void setComputedValueParameters(int index, String name, String expression) {
602 OpenMM_CustomNonbondedForce_setComputedValueParameters(pointer, index, name, expression);
603 }
604
605
606
607
608
609
610 public void setCutoffDistance(double distance) {
611 OpenMM_CustomNonbondedForce_setCutoffDistance(pointer, distance);
612 }
613
614
615
616
617
618
619 public void setEnergyFunction(String expression) {
620 OpenMM_CustomNonbondedForce_setEnergyFunction(pointer, expression);
621 }
622
623
624
625
626
627
628
629
630 public void setExclusionParticles(int index, int particle1, int particle2) {
631 OpenMM_CustomNonbondedForce_setExclusionParticles(pointer, index, particle1, particle2);
632 }
633
634
635
636
637
638
639
640
641
642
643 public void setFunctionParameters(int index, String name, PointerByReference function, double min, double max) {
644 OpenMM_CustomNonbondedForce_setFunctionParameters(pointer, index, name, function, min, max);
645 }
646
647
648
649
650
651
652
653 public void setGlobalParameterDefaultValue(int index, double value) {
654 OpenMM_CustomNonbondedForce_setGlobalParameterDefaultValue(pointer, index, value);
655 }
656
657
658
659
660
661
662
663 public void setGlobalParameterName(int index, String name) {
664 OpenMM_CustomNonbondedForce_setGlobalParameterName(pointer, index, name);
665 }
666
667
668
669
670
671
672
673
674 public void setInteractionGroupParameters(int index, PointerByReference group1, PointerByReference group2) {
675 OpenMM_CustomNonbondedForce_setInteractionGroupParameters(pointer, index, group1, group2);
676 }
677
678
679
680
681
682
683 public void setNonbondedMethod(int method) {
684 OpenMM_CustomNonbondedForce_setNonbondedMethod(pointer, method);
685 }
686
687
688
689
690
691
692
693 public void setParticleParameters(int index, PointerByReference parameters) {
694 OpenMM_CustomNonbondedForce_setParticleParameters(pointer, index, parameters);
695 }
696
697
698
699
700
701
702
703 public void setPerParticleParameterName(int index, String name) {
704 OpenMM_CustomNonbondedForce_setPerParticleParameterName(pointer, index, name);
705 }
706
707
708
709
710
711
712 public void setSwitchingDistance(double distance) {
713 OpenMM_CustomNonbondedForce_setSwitchingDistance(pointer, distance);
714 }
715
716
717
718
719
720
721 public void setUseLongRangeCorrection(int use) {
722 OpenMM_CustomNonbondedForce_setUseLongRangeCorrection(pointer, use);
723 }
724
725
726
727
728
729
730 public void setUseSwitchingFunction(int use) {
731 OpenMM_CustomNonbondedForce_setUseSwitchingFunction(pointer, use);
732 }
733
734
735
736
737
738
739 public void updateParametersInContext(Context context) {
740 if (context.hasContextPointer()) {
741 OpenMM_CustomNonbondedForce_updateParametersInContext(pointer, context.getPointer());
742 }
743 }
744
745
746
747
748
749
750 @Override
751 public boolean usesPeriodicBoundaryConditions() {
752 int pbc = OpenMM_CustomNonbondedForce_usesPeriodicBoundaryConditions(pointer);
753 return pbc == OpenMM_True;
754 }
755 }