use of ffx.potential.parameters.PolarizeType in project ffx by mjschnie.
the class ParticleMeshEwald method assignPolarizationGroups.
protected void assignPolarizationGroups() {
/**
* Find directly connected group members for each atom.
*/
List<Integer> group = new ArrayList<>();
for (int i = 0; i < nAtoms; i++) {
Atom a = atoms[i];
if (a.getIndex() - 1 != i) {
logger.severe(" Atom indexing is not consistent in PME.");
}
}
for (Atom ai : atoms) {
group.clear();
Integer index = ai.getIndex() - 1;
group.add(index);
PolarizeType polarizeType = ai.getPolarizeType();
if (polarizeType != null) {
if (polarizeType.polarizationGroup != null) {
growGroup(group, ai);
Collections.sort(group);
ip11[index] = new int[group.size()];
int j = 0;
for (int k : group) {
ip11[index][j++] = k;
}
} else {
ip11[index] = new int[group.size()];
int j = 0;
for (int k : group) {
ip11[index][j++] = k;
}
}
} else {
String message = "The polarize keyword was not found for atom " + (index + 1) + " with type " + ai.getType();
logger.severe(message);
}
}
/**
* Find 1-2 group relationships.
*/
int[] mask = new int[nAtoms];
List<Integer> list = new ArrayList<>();
List<Integer> keep = new ArrayList<>();
for (int i = 0; i < nAtoms; i++) {
mask[i] = -1;
}
for (int i = 0; i < nAtoms; i++) {
list.clear();
for (int j : ip11[i]) {
list.add(j);
mask[j] = i;
}
keep.clear();
for (int j : list) {
Atom aj = atoms[j];
ArrayList<Bond> bonds = aj.getBonds();
for (Bond b : bonds) {
Atom ak = b.get1_2(aj);
int k = ak.getIndex() - 1;
if (mask[k] != i) {
keep.add(k);
}
}
}
list.clear();
for (int j : keep) {
for (int k : ip11[j]) {
list.add(k);
}
}
Collections.sort(list);
ip12[i] = new int[list.size()];
int j = 0;
for (int k : list) {
ip12[i][j++] = k;
}
}
/**
* Find 1-3 group relationships.
*/
for (int i = 0; i < nAtoms; i++) {
mask[i] = -1;
}
for (int i = 0; i < nAtoms; i++) {
for (int j : ip11[i]) {
mask[j] = i;
}
for (int j : ip12[i]) {
mask[j] = i;
}
list.clear();
for (int j : ip12[i]) {
for (int k : ip12[j]) {
if (mask[k] != i) {
if (!list.contains(k)) {
list.add(k);
}
}
}
}
ip13[i] = new int[list.size()];
Collections.sort(list);
int j = 0;
for (int k : list) {
ip13[i][j++] = k;
}
}
}
use of ffx.potential.parameters.PolarizeType in project ffx by mjschnie.
the class ParticleMeshEwald method growGroup.
/**
* A recursive method that checks all atoms bonded to the seed atom for
* inclusion in the polarization group. The method is called on each newly
* found group member.
*
* @param group XYZ indeces of current group members.
* @param seed The bonds of the seed atom are queried for inclusion in the
* group.
*/
private void growGroup(List<Integer> group, Atom seed) {
List<Bond> bonds = seed.getBonds();
for (Bond bi : bonds) {
Atom aj = bi.get1_2(seed);
int tj = aj.getType();
boolean added = false;
PolarizeType polarizeType = seed.getPolarizeType();
for (int type : polarizeType.polarizationGroup) {
if (type == tj) {
Integer index = aj.getIndex() - 1;
if (!group.contains(index)) {
group.add(index);
added = true;
break;
}
}
}
if (added) {
growGroup(group, aj);
}
}
}
use of ffx.potential.parameters.PolarizeType in project ffx by mjschnie.
the class ForceFieldFilter method parsePolarize.
private void parsePolarize(String input, String[] tokens) {
if (tokens.length < 4) {
logger.log(Level.WARNING, "Invalid POLARIZE type:\n{0}", input);
}
try {
int atomType = Integer.parseInt(tokens[1]);
double polarizability = Double.parseDouble(tokens[2]);
double thole = Double.parseDouble(tokens[3]);
int entries = tokens.length - 4;
int[] polarizationGroup = null;
if (entries > 0) {
polarizationGroup = new int[entries];
for (int i = 4; i < tokens.length; i++) {
polarizationGroup[i - 4] = Integer.parseInt(tokens[i]);
}
}
PolarizeType polarizeType = new PolarizeType(atomType, polarizability, thole, polarizationGroup);
forceField.addForceFieldType(polarizeType);
// polarizeType.log();
} catch (NumberFormatException e) {
String message = "Exception parsing POLARIZE type:\n" + input + "\n";
logger.log(Level.SEVERE, message, e);
}
}
Aggregations