Got rid of some of the hard-coded units in the plumed interface

This commit is contained in:
Gareth Tribello
2018-11-03 18:13:28 +00:00
parent badfdd7433
commit cb8c51e353

View File

@ -102,39 +102,27 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
// LAMMPS units wrt kj/mol - nm - ps // LAMMPS units wrt kj/mol - nm - ps
// Set up units // Set up units
if (force->boltz == 1.0) { if(strcmp(update->unit_style,"lj") == 0) {
// LAMMPS units lj // LAMMPS units lj
p->cmd("setNaturalUnits"); p->cmd("setNaturalUnits");
} else { } else {
// Conversion factor from LAMMPS energy units to kJ mol-1 (units of PLUMED)
double energyUnits=1.0; double energyUnits=1.0;
double lengthUnits=1.0; // LAMMPS units real :: kcal/mol;
double timeUnits=1.0; if (strcmp(update->unit_style,"real") == 0) energyUnits=4.184;
if (force->boltz == 0.0019872067) { // LAMMPS units metal :: eV;
// LAMMPS units real :: kcal/mol; angstrom; fs else if (strcmp(update->unit_style,"metal") == 0) energyUnits=96.48530749925792;
energyUnits=4.184; // LAMMPS units si :: Joule;
lengthUnits=0.1; else if (strcmp(update->unit_style,"si") == 0) energyUnits=0.001;
timeUnits=0.001; // LAMMPS units cgs :: erg;
} else if (force->boltz == 8.617343e-5) { else if (strcmp(update->unit_style,"cgs") == 0) energyUnits=6.0221418e13;
// LAMMPS units metal :: eV; angstrom; ps // LAMMPS units electron :: Hartree;
energyUnits=96.48530749925792; else if (strcmp(update->unit_style,"electron") == 0) energyUnits=2625.5257;
lengthUnits=0.1; else error->all(FLERR,"Odd LAMMPS units, plumed cannot work with that");
timeUnits=1.0; // Conversion factor from LAMMPS length units to nm (units of PLUMED)
} else if (force->boltz == 1.3806504e-23) { double lengthUnits=0.1/force->angstrom;
// LAMMPS units si :: Joule, m; s // Conversion factor from LAMMPS time unit to ps (units of PLUMED)
energyUnits=0.001; double timeUnits=0.001/force->femtosecond;
lengthUnits=1.e-9;
timeUnits=1.e-12;
} else if (force->boltz == 1.3806504e-16) {
// LAMMPS units cgs :: erg; cms;, s
energyUnits=6.0221418e13;
lengthUnits=1.e-7;
timeUnits=1.e-12;
} else if (force->boltz == 3.16681534e-6) {
// LAMMPS units electron :: Hartree, bohr, fs
energyUnits=2625.5257;
lengthUnits=0.052917725;
timeUnits=0.001;
} else error->all(FLERR,"Odd LAMMPS units, plumed cannot work with that");
p->cmd("setMDEnergyUnits",&energyUnits); p->cmd("setMDEnergyUnits",&energyUnits);
p->cmd("setMDLengthUnits",&lengthUnits); p->cmd("setMDLengthUnits",&lengthUnits);
p->cmd("setMDTimeUnits",&timeUnits); p->cmd("setMDTimeUnits",&timeUnits);