Search in sources :

Example 1 with SharedDouble

use of edu.rit.pj.reduction.SharedDouble in project ffx by mjschnie.

the class BondedTerm method reduceEsvDeriv.

public void reduceEsvDeriv() {
    if (esvTerm) {
        // logf(" :: %.6f from %s", esvDerivLocal, this.toString());
        esvDerivShared.addAndGet(esvDerivLocal);
        if (decomposeEsvDeriv) {
            Class<? extends BondedTerm> source = this.getClass();
            SharedDouble dub = decompositionMap.get(source);
            if (dub == null) {
                decompositionMap.put(source, new SharedDouble(esvDerivLocal));
            } else {
                dub.addAndGet(esvDerivLocal);
            }
        }
        esvDerivLocal = 0.0;
    }
}
Also used : SharedDouble(edu.rit.pj.reduction.SharedDouble)

Example 2 with SharedDouble

use of edu.rit.pj.reduction.SharedDouble in project ffx by mjschnie.

the class ParticleMeshEwaldQI method attachExtendedSystem.

/**
 * Attach system with extended variable such as titrations.
 */
public void attachExtendedSystem(ExtendedSystem system) {
    // Set object handles.
    esvTerm = true;
    esvSystem = system;
    numESVs = esvSystem.size();
    // Update atoms and reinitialize arrays.
    /* Only include ExtH atoms in the PME arrays.
         * The background heavy atoms have their multipoles interpolated into
         * the foreground outside this class. */
    setAtoms(esvSystem.getExtendedAtoms(), esvSystem.getExtendedMolecule());
    // Allocate shared derivative storage.
    esvPermRealDeriv_shared = new SharedDouble[numESVs];
    esvPermSelfDeriv_shared = new SharedDouble[numESVs];
    esvPermRecipDeriv_shared = new SharedDouble[numESVs];
    esvInducedRealDeriv_shared = new SharedDouble[numESVs];
    esvInducedSelfDeriv_shared = new SharedDouble[numESVs];
    esvInducedRecipDeriv_shared = new SharedDouble[numESVs];
    for (int i = 0; i < numESVs; i++) {
        esvPermRealDeriv_shared[i] = new SharedDouble(0.0);
        esvPermSelfDeriv_shared[i] = new SharedDouble(0.0);
        esvPermRecipDeriv_shared[i] = new SharedDouble(0.0);
        esvInducedRealDeriv_shared[i] = new SharedDouble(0.0);
        esvInducedSelfDeriv_shared[i] = new SharedDouble(0.0);
        esvInducedRecipDeriv_shared[i] = new SharedDouble(0.0);
    }
    esvDirectDipole = new double[nAtoms][3];
    esvDirectDipoleCR = new double[nAtoms][3];
    esvInducedDipole = new double[nAtoms][3];
    esvInducedDipoleCR = new double[nAtoms][3];
    updateEsvLambda();
    logger.info(format(" Attached extended system (%d variables) to PME.\n", numESVs));
}
Also used : SharedDouble(edu.rit.pj.reduction.SharedDouble)

Example 3 with SharedDouble

use of edu.rit.pj.reduction.SharedDouble in project ffx by mjschnie.

the class ExtendedSystem method getDerivative.

private double getDerivative(int esvID) {
    final double temperature = (config.forceRoomTemp) ? ExtConstants.roomTemperature : currentTemperature;
    final boolean p = config.decomposeDeriv;
    ExtendedVariable esv = esvList.get(esvID);
    double esvDeriv = 0.0;
    final String format = " %-20.20s %2.2s %9.4f";
    if (config.biasTerm) {
        final double dBias = esv.getTotalBiasDeriv(temperature, true);
        if (p) {
            sb.append(format("  Biases:", "", dBias));
        }
        final double dDiscr = esv.getDiscrBiasDeriv();
        if (p) {
            sb.append(format("    Discretizer:", ">", dDiscr));
        }
        if (esv instanceof TitrationESV) {
            final double dPh = ((TitrationESV) esv).getPhBiasDeriv(temperature);
            if (p) {
                sb.append(format("    Acidostat:", ">", dPh));
            }
        }
        esvDeriv += dBias;
    }
    if (config.vanDerWaals) {
        final double dVdw = vdw.getEsvDerivative(esvID);
        if (p) {
            sb.append(format("  VanDerWaals:", "", dVdw));
        }
        esvDeriv += dVdw;
    }
    if (config.electrostatics) {
        final double permanent = pme.getEsvDeriv_Permanent(esvID);
        esvDeriv += permanent;
        if (p) {
            sb.append(format("  PermanentElec:", "", permanent));
        }
        double permReal = pme.getEsvDeriv_PermReal(esvID);
        double permSelf = pme.getEsvDeriv_PermSelf(esvID);
        double permRecip = pme.getEsvDeriv_PermRecip(esvID);
        if (p) {
            sb.append(format("    PermReal:", ">", permReal));
        }
        if (p) {
            sb.append(format("    PermRcpSelf:", ">", permSelf));
        }
        if (p) {
            sb.append(format("    PermRecipMpole:", ">", permRecip));
        }
        if (config.polarization) {
            final double induced = pme.getEsvDeriv_Induced(esvID);
            esvDeriv += induced;
            if (p) {
                sb.append(format("  Polarization:", "", induced));
            }
            double indReal = pme.getEsvDeriv_IndReal(esvID);
            double indSelf = pme.getEsvDeriv_IndSelf(esvID);
            double indRecip = pme.getEsvDeriv_IndRecip(esvID);
            if (p) {
                sb.append(format("    IndReal:", ">", indReal));
            }
            if (p) {
                sb.append(format("    IndSelf:", ">", indSelf));
            }
            if (p) {
                sb.append(format("    IndRecip:", ">", indRecip));
            }
        }
    }
    if (config.bonded) {
        final double dBonded = esv.getBondedDeriv();
        if (p) {
            sb.append(format("  Bonded:", "", dBonded));
        }
        esvDeriv += dBonded;
        /* If desired, decompose bonded contribution into component types from foreground and background. */
        if (config.decomposeBonded) {
            // Foreground portion:
            double fgSum = 0.0;
            HashMap<Class<? extends BondedTerm>, SharedDouble> fgMap = esv.getBondedDerivDecomp();
            for (SharedDouble dub : fgMap.values()) {
                fgSum += dub.get();
            }
            if (p) {
                sb.append(format("    Foreground:", ">", fgSum));
            }
            for (Class<? extends BondedTerm> clas : fgMap.keySet()) {
                if (p) {
                    sb.append(format("      " + clas.getName().replaceAll("ffx.potential.bonded.", "") + ":", ">>", fgMap.get(clas).get()));
                }
            }
            // Background portion:
            double bgSum = 0.0;
            HashMap<Class<? extends BondedTerm>, SharedDouble> bgMap = esv.getBackgroundBondedDerivDecomp();
            for (SharedDouble dub : bgMap.values()) {
                bgSum += dub.get();
            }
            if (p) {
                sb.append(format("    Background:", ">", bgSum));
            }
            for (Class<? extends BondedTerm> clas : bgMap.keySet()) {
                if (p) {
                    sb.append(format("      " + clas.getName().replaceAll("ffx.potential.bonded.", "") + ":", ">>", bgMap.get(clas).get()));
                }
            }
        }
    }
    if (Double.isNaN(esvDeriv) || !Double.isFinite(esvDeriv)) {
        logger.warning(format("NaN/Inf lambda derivative: %s", this));
    }
    if (p) {
        sb.insert(0, format(" %-21.21s %-2.2s %9.4f", format("dUd%s:", esv.getName()), "", esvDeriv));
    }
    if (p) {
        logger.info(sb.toString());
    }
    return esvDeriv;
}
Also used : BondedTerm(ffx.potential.bonded.BondedTerm) SharedDouble(edu.rit.pj.reduction.SharedDouble)

Example 4 with SharedDouble

use of edu.rit.pj.reduction.SharedDouble in project ffx by mjschnie.

the class VanDerWaals method updateEsvLambda.

/**
 * Only unshared atoms are treated as extended by VdW since heavy atom radii
 * are assumed constant. Under AMOEBA'13, this assumption is violated only
 * by Cys-SG, Asp-OD[12], and Glu-OD[12].
 */
public void updateEsvLambda() {
    if (!esvTerm) {
        // TODO: figure out when/why this is happening
        return;
    }
    numESVs = esvSystem.size();
    if (esvLambdaSwitch == null || esvLambdaSwitch.length < nAtoms) {
        esvLambdaSwitch = new double[nAtoms];
        esvSwitchDeriv = new double[nAtoms];
        atomEsvID = new int[nAtoms];
        fill(esvLambdaSwitch, 1.0);
        fill(esvSwitchDeriv, 0.0);
        fill(atomEsvID, -1);
    }
    for (int i = 0; i < nAtoms; i++) {
        if (esvSystem.isUnshared(i)) {
            esvAtoms[i] = true;
            esvLambda[i] = esvSystem.getLambda(i);
            esvLambdaSwitch[i] = esvSystem.getLambdaSwitch(i);
            esvSwitchDeriv[i] = esvSystem.getSwitchDeriv(i);
            atomEsvID[i] = esvSystem.getEsvIndex(i);
        }
    }
    if (esvDeriv == null || esvDeriv.length < numESVs) {
        esvDeriv = new SharedDouble[numESVs];
        for (int i = 0; i < numESVs; i++) {
            esvDeriv[i] = new SharedDouble(0.0);
        }
    }
    initSoftCore(true);
}
Also used : SharedDouble(edu.rit.pj.reduction.SharedDouble)

Aggregations

SharedDouble (edu.rit.pj.reduction.SharedDouble)4 BondedTerm (ffx.potential.bonded.BondedTerm)1