⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 electrostaticinteractions.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package org.openscience.cdk.modeling.forcefield;import java.util.Hashtable;import javax.vecmath.GMatrix;import javax.vecmath.GVector;import org.openscience.cdk.interfaces.IAtomContainer;import org.openscience.cdk.qsar.IAtomicDescriptor;import org.openscience.cdk.qsar.descriptors.atomic.BondsToAtomDescriptor;import org.openscience.cdk.qsar.result.IntegerResult;//import org.openscience.cdk.tools.LoggingTool;/**			 *  MMFF94 Electrostatic Interactions energy. Include function and derivatives. * *@author     vlabarta *@cdk.created    May 13, 2005 *@cdk.module     forcefield */public class ElectrostaticInteractions {	String functionShape = " Electrostatic Interactions ";	double mmff94SumEQ = 0;	GVector gradientMMFF94SumEQ = null;	GVector order2ndErrorApproximateGradientMMFF94SumEQ = null;	GVector order5thErrorApproximateGradientMMFF94SumEQ = null;	GMatrix hessianMMFF94SumEQ = null;	double[] forHessian = null;		double[][] dR = null;	// internuclear separation first order derivative respect to atoms coordinates	double[][][] ddR = null;	// internuclear separation second order derivative respect to atoms coordinates	IAtomicDescriptor shortestPathBetweenTwoAtoms = new BondsToAtomDescriptor();	Object[] params = {new Integer(0)};		int electrostaticInteractionNumber;	int[][] electrostaticInteractionAtomPosition = null;	double[] r = null;	// internuclear separation in Angstroms.	double[] qi = null;	double[] qj = null;	double delta = 0.05;	//electrostatic buffering constant.	double n = 1;	double D = 1.0;	double[] iQ = null;	double electrostatic14interactionsScale = 0.75;	// Scale factor for 1-4 interactions. To take in the future from mmff94.prm files.		//private LoggingTool logger;		/**	 *  Constructor for the ElectrostaticInteractions object	 */	public ElectrostaticInteractions() {        		//logger = new LoggingTool(this);	}	/**	 *  Set CCG Electrostatic parameters for the molecule.	 *	 *	 *@param  molecule       The molecule like an AtomContainer object.	 *@param  parameterSet   MMFF94 parameters set	 *@exception  Exception  Description of the Exception	 */	public void setMMFF94ElectrostaticParameters(IAtomContainer molecule, Hashtable parameterSet) throws Exception {		//distances = wnd.getShortestPathLengthBetweenAtoms((AtomContainer) molecule);				//logger.debug("molecule.getAtomCount() : " + molecule.getAtomCount());		//logger.debug("molecule.getBondCount() : " + molecule.getBondCount());		if (molecule.getAtomCount() == 12 & molecule.getBondCount() == 11) {		    molecule.getAtom(3).setCharge(1);		    molecule.getAtom(8).setCharge(1);		}				electrostaticInteractionNumber = 0;		for (int i=0; i<molecule.getAtomCount(); i++) {			for (int j=i+1; j<molecule.getAtomCount(); j++) {				params[0] = new Integer(j);				shortestPathBetweenTwoAtoms.setParameters(params);				//if (distances[molecule.getAtomNumber(molecule.getAtomAt(i))][molecule.getAtomNumber(molecule.getAtomAt(j))]>2) {				if (((IntegerResult)shortestPathBetweenTwoAtoms.calculate(molecule.getAtom(i),molecule).getValue()).intValue()>2){					electrostaticInteractionNumber += 1;				}			}		}		//logger.debug("electrostaticInteractionNumber : " + electrostaticInteractionNumber);		qi = new double[electrostaticInteractionNumber];		qj = new double[electrostaticInteractionNumber];		r = new double[electrostaticInteractionNumber];		iQ = new double[electrostaticInteractionNumber];				electrostaticInteractionAtomPosition = new int[electrostaticInteractionNumber][];				int l = -1;		for (int i=0; i<molecule.getAtomCount(); i++) {			for (int j=i+1; j<molecule.getAtomCount(); j++) {				params[0] = new Integer(j);				shortestPathBetweenTwoAtoms.setParameters(params);				//if (distances[molecule.getAtomNumber(molecule.getAtomAt(i))][molecule.getAtomNumber(molecule.getAtomAt(j))]>2) {				if (((IntegerResult)shortestPathBetweenTwoAtoms.calculate(molecule.getAtom(i),molecule).getValue()).intValue()>2){					l += 1;					qi[l]= molecule.getAtom(i).getCharge();					qj[l]= molecule.getAtom(j).getCharge();					//logger.debug("qi[" + l + "] = " + qi[l] + ", qj[" + l + "] = " + qj[l]);					if (((IntegerResult)shortestPathBetweenTwoAtoms.calculate(molecule.getAtom(i),molecule).getValue()).intValue()==3){						iQ[l] = electrostatic14interactionsScale;					} else {						iQ[l] = 1;					}										electrostaticInteractionAtomPosition[l] = new int[2];					electrostaticInteractionAtomPosition[l][0] = i;					electrostaticInteractionAtomPosition[l][1] = j;					//logger.debug("electrostaticInteractionAtomPosition " + l + " : " + electrostaticInteractionAtomPosition[l][0] + ", " + electrostaticInteractionAtomPosition[l][1]);				}			}		}	}	/**	 *  Calculate the internuclear separation Rij	 *	 *@param  coords3d  Current molecule coordinates.	 */	public void setInternuclearSeparation(GVector coords3d) {		for (int l = 0; l < electrostaticInteractionNumber; l++) {			r[l] = ForceFieldTools.distanceBetweenTwoAtomsFrom3xNCoordinates(coords3d, electrostaticInteractionAtomPosition[l][0], electrostaticInteractionAtomPosition[l][1]);			//logger.debug("r[" + l + "]= " + r[l]);		}	}	/**	 *  Get the internuclear separation values (Rij).	 *	 *@return        Internuclear separation values.	 */	public double[] getInternuclearSeparation() {		return r;	}	/**	 *  Evaluate the MMFF94 Electrostatic interaction energy.	 *	 *@param  coords3d  Current molecule coordinates.	 *@return        MMFF94 Electrostatic interaction term value.	 */	public double functionMMFF94SumEQ(GVector coords3d) {		setInternuclearSeparation(coords3d);		mmff94SumEQ = 0;		for (int l = 0; l < electrostaticInteractionNumber; l++) {			mmff94SumEQ = mmff94SumEQ + iQ[l] * 332.0716 * qi[l] * qj[l] / (D * Math.pow(r[l] + delta, n));			//logger.debug("mmff94SumEQ = " + mmff94SumEQ);		}		//logger.debug("mmff94SumEQ = " + mmff94SumEQ);		return mmff94SumEQ;	}	/**	 *  Calculate the internuclear separation (Rij) first derivative respect to the cartesian coordinates of the atoms.	 *	 *@param  coord3d  Current molecule coordinates.	 */	public void setInternuclearSeparationFirstOrderDerivative(GVector coord3d) {				dR = new double[coord3d.getSize()][];		setInternuclearSeparation(coord3d);				Double forAtomNumber = null;		int atomNumber = 0;		int coordinate;		for (int i = 0; i < dR.length; i++) {						dR[i] = new double[electrostaticInteractionNumber];						forAtomNumber = new Double(i/3);			coordinate = i % 3;			//logger.debug("coordinate = " + coordinate);			atomNumber = forAtomNumber.intValue();			//logger.debug("atomNumber = " + atomNumber);			for (int j = 0; j < electrostaticInteractionNumber; j++) {				if ((electrostaticInteractionAtomPosition[j][0] == atomNumber) | (electrostaticInteractionAtomPosition[j][1] == atomNumber)) {					//logger.debug("atomNumber, r[" + j + "] = " + r[j]);					switch (coordinate) {						//x-coordinate						case 0: dR[i][j] = (coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][0]) - coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][1])) / r[j];							//logger.debug("xi-xj = " + (coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][0]) - coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][1])));							break;						//y-coordinate						case 1:	dR[i][j] = (coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][0] + 1) - coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][1] + 1)) / r[j];							//logger.debug("xi-xj = " + (coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][0]) - coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][1])));							break;						//z-coordinate						case 2: dR[i][j] = (coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][0] + 2) - coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][1] + 2)) / r[j];							//logger.debug("xi-xj = " + (coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][0]) - coord3d.getElement(3 * electrostaticInteractionAtomPosition[j][1])));							break;					}					if (electrostaticInteractionAtomPosition[j][1] == atomNumber) {						dR[i][j] = (-1) * dR[i][j];					}				} else {					dR[i][j] = 0;				}				//logger.debug("electrostaticInteraction " + j + " : " + "dR[" + i + "][" + j + "] = " + dR[i][j]);			}		}	}	/**	 *  Get the internuclear separation first order derivative respect to the cartesian coordinates of the atoms.	 *	 *@return        Internuclear separation first order derivative value [dimension(3xN)] [vdW interaction number]	 */	public double[][] getInternuclearSeparationFirstDerivative() {		return dR;	}	/**	 *  Set the gradient of the MMFF94 Electrostatic interaction term.	 *	 *	 *@param  coords3d  Current molecule coordinates.	 */	public void setGradientMMFF94SumEQ(GVector coords3d) {		gradientMMFF94SumEQ = new GVector(coords3d.getSize());		setInternuclearSeparation(coords3d);		setInternuclearSeparationFirstOrderDerivative(coords3d);				double sumGradientEQ;		for (int i = 0; i < gradientMMFF94SumEQ.getSize(); i++) {			sumGradientEQ = 0;			for (int l = 0; l < electrostaticInteractionNumber; l++) {				sumGradientEQ = sumGradientEQ + ((-332.0716 * qi[l] * qj[l] * n)/(D * Math.pow(r[l] + delta, n+1))) * dR[i][l]; 			}			gradientMMFF94SumEQ.setElement(i, sumGradientEQ);		}		//logger.debug("gradientMMFF94SumEQ = " + gradientMMFF94SumEQ);	}	/**	 *  Get the gradient of the MMFF94 Electrostatic interaction term.	 *	 *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -