The response in the pressure due to the Berendsen barostat is related to the bulk modulus (compressibility). For the press/berendsen fix in LAMMPS, you can either compute the bulk modulus of your system and use the modulus keyword and pdamp or use the default value of modulus and set pdamp to get the desired response.
This package automatically sets pdamp for the Berendsen barostat in LAMMPS by fitting to a target time to the set point pressure,
The value of pdamp is chosen so that
If you don't need any extra LAMMPS packages and you are using conda, then installing pylammpsmpi will also install LAMMPS.
conda install pylammpsmpi -c conda-forge
Installing pylammpsmpi using pip will not install LAMMPS. If you are using pip for all of your python packages, then you must compile LAMMPS yourself even if you don't need any extra LAMMPS packages.
pip install pylammpsmpi
If you need any extra LAMMPS packages, you must compile LAMMPS yourself and use pip to install pylammpsmpi. LAMMPS must be installed as a library and with the python module. The calphy package documentation explains how to do this. Also, see the LAMMPS documentation for installing with the python module. Note that you should install any other LAMMPS packages you need using additional -D
flags with the cmake
command.
Inputs must be provided in a JSON file. See examples/Ni_EAM_solid/input/config.json for an example. The following keys are required:
- CORES: The number of cores to use for the simulation(s).
- TSTART: The temperature in LAMMPS units.
- PSET: The set point pressures in LAMMPS units. This should be a list of two numbers regardless of the number of simulation stages, but the first number will be ignored if you are only simulating stage 2. See the section on LAMMPS input file(s) below for more details on stages.
- SIM_TIME_STAGE2: The simulatin time in LAMMPS units for stage 2. See the section on LAMMPS input file(s) below for more details on stages.
- PDAMP_INITIAL: Initial guess for pdamp. Currently, guesses that are way too high can be dealt with in stage 2, but your pressure may not reach the set point in stage 1 if you are using a Berendsen barostat there. If that happens, your initial pressure for stage 2 could be too close to the set point pressure for stage 2 and you will need to lower your guess and restart from stage 1. This is not a problem if you are simulating stage 2 only or not using a Berendsen barostat in stage 1. The code will warn you or throw an error if your initial pressure is too close to your set point pressure in stage 2. Guesses that are way too low may cause problems, and there are no checks or fixes currently implemented for that case. Therefore, it is best to start with a high guess if you are unsure. See the section on LAMMPS input file(s) below for more details on stages.
- T_TARGET: Desired time for pressure to get 99% of the way from
$P_0$ to$P_{set}$ in LAMMPS units. - DT_TOL: Tolerance for stopping the simulation. Stop when
$dt = \left|t_{set} - t_{target}\right| <$ DT_TOL. - INDIR: Name of the Directory containing the LAMMPS input file(s). The input files include the LAMMPS input file(s), POTENTIAL_file, and optionally stage1.data which is used to start stage 2. See the section on LAMMPS input file(s) below for more details on stages.
- POTENTIAL_FILE: Name of the file to be included in the LAMMPS input file(s) that defines the potential function(s) for the interactions between atoms. This file must be in INDIR. See examples/Ni_EAM_solid/input/potential.lmp for an example.
- LAMMPS_INPUT
- STAGE2
- TEMPLATE: Name of the LAMMPS input file template for stage 2. This file must be in INDIR. See examples/Ni_EAM_solid/input/stage2_template.lmp for an example. See the section on LAMMPS input file(s) below for more details.
- INPUT: Name of the LAMMPS input file for stage 2. This file will be created from the template and written to INDIR. See the section on LAMMPS input file(s) below for more details.
- STAGE2
- OUTDIR: Name of directory to write output files to. This directory will be created if it does not exist.
The following keys are not required if not simulating stage 1 (see the section on LAMMPS input file(s) below for more details on stages):
- LAMMPS_INPUT
- STAGE1:
- TEMPLATE: Name of the LAMMPS input file template for stage 1. This file must be in INDIR. See examples/Ni_EAM_solid/input/stage1_template.lmp for an example. See the section on LAMMPS input file(s) below for more details.
- INPUT: Name of the LAMMPS input file for stage 1. This file will be created from the template and written to INDIR. See the section on LAMMPS input file(s) below for more details.
- STAGE1:
To estimate
The LAMMPS input file(s) are generated from template files. The template files are the same as the LAMMPS input files except that the following keywords are replaced with values from the JSON input file: [TSTART], [PSET], [SIM_TIME], [PDAMP_INITIAL], [POTENTIAL_FILE]. The names in [] mostly match the keys from the JSON input file section above. The exception is [SIM_TIME] which is replaced with the value for the SIM_TIME_STAGE2 key from the JSON file. [PSET] is replaced with the first value in the list from the JSON input file for stage 1, and with the second value in the list for stage 2. Only [PDAMP_INITIAL] is strictly required in the template file(s), but using [TSTART], [PSET], and [SIM_TIME] is advised. Obviously, the temperature in stage 1 and stage 2 must be the same, so it is advisable to use [TSTART] in both template files. The set point pressure used in the stage 2 simulation must be the same as the value in the JSON file since the fitting treats it as a constant obtained from the JSON file. The simulation time in stage 2 must match the value of SIM_TIME_STAGE2 in the JSON file since the simulation time from the JSON file is compared to
variable t equal time
variable p equal press
fix writepressure all print 10 "$t $p" &
file [PRESSURE_FILE] screen no
The template files must be in INDIR. The LAMMPS input files are written to INDIR. Examples of template files are provided in examples/Ni_EAM_solid/input/stage1_template.lmp and examples/Ni_EAM_solid/input/stage2_template.lmp.
The first consideration when choosing set point pressure(s) is that you should avoid phase transitions. If stage 1 and stage 2 end in different phases, then the value of pdamp you obtain will not be reasonable. Second, the set point pressures for stage 1 and stage 2 should be chosen so that
The green points represent "good" values of
from set_Berendsen_Pdamp import SetBerendsenPdamp
set_pdamp = SetBerendsenPdamp('examples/Ni_EAM_solid/input/config.json')
set_pdamp()
python set_berendsen_pdamp.py examples/Ni_EAM_solid/input/config.json