The solvent forces acting on the atoms in a molecule may be calculated using the CalcForces method. The components of the forces are set to a float array of length 3N, where N is the number of atoms. The components of the gradient are equal in magnitude to the force, but have the opposite sign.
1 /*******************************************************************************
2 * Copyright (C) 2006, 2008 OpenEye Scientific Software, Inc.
3 ******************************************************************************/
4 package openeye.examples.oezap;
5
6 import openeye.oechem.*;
7 import openeye.oezap.*;
8
9 public class ZapForces {
10 public static void main(String argv[]) {
11 if (argv.length != 1) {
12 System.err.println("usage: ZapForces <molfile>");
13 System.exit(1);
14 }
15
16 OEZap zap = new OEZap();
17 zap.SetInnerDielectric(1.0f);
18 zap.SetGridSpacing(0.5f);
19
20 oemolistream ifs = new oemolistream();
21 if (!ifs.open(argv[0])) {
22 System.err.println("Unable to open file for reading: " + argv[0]);
23 System.exit(1);
24 }
25 OEGraphMol mol = new OEGraphMol();
26 while (oechem.OEReadMolecule(ifs, mol)) {
27 System.out.println("\nForce Components for " + mol.GetTitle()
28 + ", in kT/Angstrom");
29 System.out.println("Index\tElement\t-dE/dx\t\t-dE/dy\t\t-dE/dz");
30 OEFloatArray forces = new OEFloatArray(mol.GetMaxAtomIdx() * 3);
31 oechem.OEAssignBondiVdWRadii(mol);
32 oechem.OEMMFFAtomTypes(mol);
33 oechem.OEMMFF94PartialCharges(mol);
34 zap.SetMolecule(mol);
35 zap.CalcForces(forces.ptrCast());
36 OEAtomBaseIter aiter = mol.GetAtoms();
37 while (aiter.hasNext()) {
38 OEAtomBase atom = aiter.next();
39 System.out.println(atom.GetIdx() + "\t"
40 + oechem.OEGetAtomicSymbol(atom.GetAtomicNum()) + "\t"
41 + forces.getItem(atom.GetIdx()) + "\t"
42 + forces.getItem(atom.GetIdx() + 1) + "\t"
43 + forces.getItem(atom.GetIdx() + 2));
44 }
45 }
46 ifs.close();
47 }
48 }