Search in sources :

Example 1 with RealSpaceEnergy

use of ffx.realspace.RealSpaceEnergy in project ffx by mjschnie.

the class RefinementEnergy method setLambda.

/**
 * {@inheritDoc}
 */
@Override
public void setLambda(double lambda) {
    for (MolecularAssembly molecularAssembly : molecularAssemblies) {
        ForceFieldEnergy forceFieldEnergy = molecularAssembly.getPotentialEnergy();
        forceFieldEnergy.setLambda(lambda);
    }
    if (data instanceof DiffractionData) {
        XRayEnergy xRayEnergy = (XRayEnergy) dataEnergy;
        xRayEnergy.setLambda(lambda);
    } else if (data instanceof RealSpaceData) {
        RealSpaceEnergy realSpaceEnergy = (RealSpaceEnergy) dataEnergy;
        realSpaceEnergy.setLambda(lambda);
    }
}
Also used : MolecularAssembly(ffx.potential.MolecularAssembly) RealSpaceData(ffx.realspace.RealSpaceData) ForceFieldEnergy(ffx.potential.ForceFieldEnergy) RealSpaceEnergy(ffx.realspace.RealSpaceEnergy)

Example 2 with RealSpaceEnergy

use of ffx.realspace.RealSpaceEnergy in project ffx by mjschnie.

the class RefinementEnergy method getdEdXdL.

/**
 * {@inheritDoc}
 */
@Override
public void getdEdXdL(double[] gradient) {
    double weight = data.getWeight();
    if (thermostat != null) {
        kTScale = Thermostat.convert / (thermostat.getTargetTemperature() * Thermostat.kB);
    }
    int assemblysize = molecularAssemblies.length;
    /**
     * Compute the chemical energy and gradient.
     */
    for (int i = 0; i < assemblysize; i++) {
        ForceFieldEnergy forcefieldEnergy = molecularAssemblies[i].getPotentialEnergy();
        Arrays.fill(gChemical[i], 0.0);
        forcefieldEnergy.getdEdXdL(gChemical[i]);
    }
    for (int i = 0; i < assemblysize; i++) {
        for (int j = 0; j < nXYZ; j++) {
            gradient[j] += gChemical[i][j];
        }
    }
    /**
     * Normalize gradients for multiple-counted atoms.
     */
    if (assemblysize > 1) {
        for (int i = 0; i < nXYZ; i++) {
            gradient[i] /= assemblysize;
        }
    }
    for (int i = 0; i < nXYZ; i++) {
        gradient[i] *= kTScale;
    }
    /**
     * Compute the X-ray target energy and gradient.
     */
    if (gXray == null || gXray.length != nXYZ) {
        gXray = new double[nXYZ];
    } else {
        for (int j = 0; j < nXYZ; j++) {
            gXray[j] = 0.0;
        }
    }
    if (data instanceof DiffractionData) {
        XRayEnergy xRayEnergy = (XRayEnergy) dataEnergy;
        xRayEnergy.getdEdXdL(gXray);
    } else if (data instanceof RealSpaceData) {
        RealSpaceEnergy realSpaceEnergy = (RealSpaceEnergy) dataEnergy;
        realSpaceEnergy.getdEdXdL(gXray);
    }
    // Add the chemical and X-ray gradients.
    for (int i = 0; i < nXYZ; i++) {
        gradient[i] += weight * gXray[i];
    }
}
Also used : RealSpaceData(ffx.realspace.RealSpaceData) ForceFieldEnergy(ffx.potential.ForceFieldEnergy) RealSpaceEnergy(ffx.realspace.RealSpaceEnergy)

Example 3 with RealSpaceEnergy

use of ffx.realspace.RealSpaceEnergy in project ffx by mjschnie.

the class RefinementEnergy method getdEdL.

/**
 * {@inheritDoc}
 */
@Override
public double getdEdL() {
    double dEdL = 0.0;
    if (thermostat != null) {
        kTScale = Thermostat.convert / (thermostat.getTargetTemperature() * Thermostat.kB);
    }
    int assemblysize = molecularAssemblies.length;
    /**
     * Compute the chemical energy and gradient.
     */
    for (int i = 0; i < assemblysize; i++) {
        ForceFieldEnergy forceFieldEnergy = molecularAssemblies[i].getPotentialEnergy();
        double curdEdL = forceFieldEnergy.getdEdL();
        dEdL += (curdEdL - dEdL) / (i + 1);
    }
    dEdL *= kTScale;
    double weight = data.getWeight();
    if (data instanceof DiffractionData) {
        XRayEnergy xRayEnergy = (XRayEnergy) dataEnergy;
        dEdL += weight * xRayEnergy.getdEdL();
    } else if (data instanceof RealSpaceData) {
        RealSpaceEnergy realSpaceEnergy = (RealSpaceEnergy) dataEnergy;
        dEdL += weight * realSpaceEnergy.getdEdL();
    }
    return dEdL;
}
Also used : RealSpaceData(ffx.realspace.RealSpaceData) ForceFieldEnergy(ffx.potential.ForceFieldEnergy) RealSpaceEnergy(ffx.realspace.RealSpaceEnergy)

Aggregations

ForceFieldEnergy (ffx.potential.ForceFieldEnergy)3 RealSpaceData (ffx.realspace.RealSpaceData)3 RealSpaceEnergy (ffx.realspace.RealSpaceEnergy)3 MolecularAssembly (ffx.potential.MolecularAssembly)1