All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.actelion.research.chem.forcefield.mmff.MMFFPositionConstraint Maven / Gradle / Ivy

There is a newer version: 2024.11.2
Show newest version
package com.actelion.research.chem.forcefield.mmff;

import com.actelion.research.chem.StereoMolecule;

public class MMFFPositionConstraint implements EnergyTerm {
	private double[] refPos;
	private boolean[] constrained;
	private double k;
	private double d;
	
	
	public MMFFPositionConstraint (StereoMolecule mol, double k, double d) {
		refPos = new double[3*mol.getAllAtoms()];
		constrained = new boolean[mol.getAllAtoms()];
		for(int a=0;ad)
				prefactor = dist-d;
			else 
				prefactor = 0.0;
			energy+=0.5*k*prefactor*prefactor;
		}
		return energy;
	}

	@Override
	public void getGradient(double[] pos, double[] grad) {
		for(int a=0;ad)
				prefactor = dist-d;
			else 
				prefactor = 0.0;
			grad[a] += prefactor*dx/Math.max(dist, 1E-08);
			grad[a+1] += prefactor*dy/Math.max(dist, 1E-08);
			grad[a+2] += prefactor*dz/Math.max(dist, 1E-08);
		}

	}
		
	

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy