public static OBMol obminimizeUFF(OBMol mol, double crit, int steps) { bool sd = false; bool cut = false; bool newton = false; bool hydrogens = true; double rvdw = 6.0; double rele = 10.0; int freq = 10; //var watch = Stopwatch.StartNew(); OBForceField ff = OBForceField.FindForceField("UFF"); //watch.Stop(); //watch.Start(); ff.Setup(mol); ff.SetVDWCutOff(rvdw); ff.SetElectrostaticCutOff(rele); ff.SetUpdateFrequency(freq); ff.EnableCutOff(cut); ff.ConjugateGradientsInitialize(steps, crit); bool done = true; while (done) { done = ff.ConjugateGradientsTakeNSteps(1); //ff.GetCoordinates(mol); } ff.GetCoordinates(mol); //watch.Stop();//doesn't look like there is much I can do to optimize this, energy minimization just takes time return(mol); }
public static bool averagepairwiseangle(OBMol mol, ref double avgangle) { VectorVecInt mapping = new VectorVecInt(); if (findcarboxylates(mol, ref mapping)) { double sum = 0; List <double> angles = new List <double>(); if (mapping.Count > 1) { OBAtom c1 = mol.GetAtom(mapping[0][1]); OBAtom a1 = mol.GetAtom(mapping[0][3]); OBAtom c2 = mol.GetAtom(mapping[1][1]); OBAtom a2 = mol.GetAtom(mapping[1][3]); double pangle = pairwiseangle(c1, a1, c2, a2); angles.Add(pangle); sum += pangle; OBForceField MMFF94 = OBForceField.FindForceField("MMFF94"); MMFF94.Setup(mol); for (int i = 0; i < 300; i++) { MMFF94.MolecularDynamicsTakeNSteps(1, 300, 1.2, 1); MMFF94.GetCoordinates(mol); pangle = pairwiseangle(c1, a1, c2, a2); //this function is sufficiently fast that it does not need to be optimized, molecular dynamics takes about 15 milliseconds per step, this take practically nothing angles.Add(pangle); sum += pangle; } avgangle = sum / angles.Count; return(true); } else { return(false); } } else { return(false); } }
public static OBMol conformersearch(OBMol mol, int steps) { bool cut = false; bool newton = false; bool hydrogens = true; double rvdw = 6.0; double rele = 10.0; int freq = 10; OBForceField rotsearch = OBForceField.FindForceField("MMFF94"); rotsearch.Setup(mol); rotsearch.SetVDWCutOff(rvdw); rotsearch.SetElectrostaticCutOff(rele); rotsearch.SetUpdateFrequency(freq); rotsearch.EnableCutOff(cut); rotsearch.RandomRotorSearch((uint)steps); //rotsearch.WeightedRotorSearch(3,10);//this is very computationally expensive rotsearch.GetCoordinates(mol); return(mol); }