Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 199 additions & 0 deletions examples/run/dp-lammps-MC+MD/param.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
{
"type_map": [
"Sr",
"Pb",
"Ti",
"O"
],
"mass_map": [
87.62,
207.2,
47.867,
15.999
],
"init_data_prefix": "./data",
"init_data_sys": [
"deepmd"
],
"sys_configs": [
[
"someplace/POSCAR"
]
],
"_comment": " 00.train ",
"numb_models": 4,
"default_training_param": {
"model": {
"type_map": [
"Sr",
"Pb",
"Ti",
"O"
],
"descriptor": {
"type": "se_e2_a",
"sel": "auto",
"rcut_smth": 0.5,
"rcut": 6.0,
"neuron": [
25,
50,
100
],
"resnet_dt": false,
"axis_neuron": 16,
"seed": 1
},
"fitting_net": {
"neuron": [
240,
240,
240
],
"resnet_dt": true,
"seed": 1
}
},
"learning_rate": {
"type": "exp",
"start_lr": 0.001,
"stop_lr": 3.51e-08,
"decay_steps": 2000
},
"loss": {
"type": "ener",
"start_pref_e": 0.02,
"limit_pref_e": 1,
"start_pref_f": 1000,
"limit_pref_f": 1,
"start_pref_v": 0.0,
"limit_pref_v": 0.0
},
"training": {
"set_prefix": "set",
"stop_batch": 400000,
"batch_size": "auto",
"disp_file": "lcurve.out",
"disp_freq": 1000,
"numb_test": 4,
"save_freq": 1000,
"save_ckpt": "model.ckpt",
"disp_training": true,
"time_training": true,
"profiling": false,
"profiling_file": "timeline.json",
"_comment": "that's all"
}
},
"model_devi_dt": 0.002,
"model_devi_skip": 0,
"model_devi_f_trust_lo": 0.1,
"model_devi_f_trust_hi": 0.2,
"model_devi_clean_traj": true,
"model_devi_jobs": [
{
"_idx": 0,
"ensemble": "npt",
"sys_idx": [
0
],
"trj_freq": 10,
"rev_mat": {
"lmp": {
"${MC_NSTEPS}": [
50
],
"${MD_NSTEPS}": [
1000
],
"${PRES}": [
0,
100
],
"${TEMP_MD}": [
100,
300
],
"${TEMP_MC}": [
100,
300
],
"${RANDOM_SEED}": [
15196
],
"${ELEMENT_TYPE_1}": [
1
],
"${ELEMENT_TYPE_2}": [
2
],
"${N_LOOP}": [
10
]
}
},
"template": {
"lmp": "template/lammps.in"
}
},
{
"_idx": 1,
"ensemble": "npt",
"press": [
1,
100
],
"sys_idx": [
0
],
"trj_freq": 10,
"rev_mat": {
"lmp": {
"${MC_NSTEPS}": [
50
],
"${MD_NSTEPS}": [
1000
],
"${PRES}": [
0,
100
],
"${TEMP_MD}": [
100
],
"${TEMP_MC}": [
100
],
"${RANDOM_SEED}": [
15196
],
"${ELEMENT_TYPE_1}": [
1
],
"${ELEMENT_TYPE_2}": [
2
],
"${N_LOOP}": [
10
]
}
},
"template": {
"lmp": "template/lammps.in"
}
}
],
"fp_style": "vasp",
"shuffle_poscar": false,
"fp_task_max": 100,
"fp_task_min": 10,
"fp_pp_path": "workplace",
"fp_pp_files": [
"POTCAR_Sr",
"POTCAR_Pb",
"POTCAR_Ti",
"POTCAR_O"
],
"fp_incar": "workplace/INCAR"
}
55 changes: 55 additions & 0 deletions examples/run/dp-lammps-MC+MD/template/lammps.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
variable MD_NSTEPS equal ${MD_NSTEPS}
variable MC_NSTEPS equal ${MC_NSTEPS}
variable THERMO_FREQ equal 10
variable TEMP_MD equal ${TEMP_MD}
variable TEMP_MC equal ${TEMP_MC}
variable PRES equal ${PRES}
variable TAU_T equal 0.100000
variable TAU_P equal 0.500000
variable RANDOM_SEED equal ${RANDOM_SEED}
variable ELEMENT_TYPE_1 equal ${ELEMENT_TYPE_1}
variable ELEMENT_TYPE_2 equal ${ELEMENT_TYPE_2}
variable N_LOOP equal ${N_LOOP}

#Initialization
units metal
boundary p p p
atom_style atomic
neighbor 1.0 bin

#read data
read_data conf.lmp
mass 1 87.620000
mass 2 207.200000
mass 3 47.867000
mass 4 15.999000

# read in the potentia
pair_style deepmd ../graph.001.pb ../graph.000.pb ../graph.003.pb ../graph.002.pb out_freq ${THERMO_FREQ} out_file model_devi.out
pair_coeff

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pair_coeff
--> pair coeff * *

to be compatible with the latest version of lammps


# output observables
thermo_style custom step temp pe ke etotal press vol lx ly lz xy xz yz
thermo ${THERMO_FREQ}
dump dpgen_dump all custom ${THERMO_FREQ} traj/*.lammpstrj id type x y z

timestep 0.002000

variable loop1 loop ${N_LOOP}
label runloop1

# Monte Carlo followed by short md
fix mc1 all atom/swap 1 1 500 ${TEMP_MC} ke no semi-grand no types ${ELEMENT_TYPE_1} ${ELEMENT_TYPE_2}
run ${MC_NSTEPS}
unfix mc1

velocity all create ${TEMP_MD} ${RANDOM_SEED}
velocity all zero linear
fix md1 all npt temp ${TEMP_MD} ${TEMP_MD} ${TAU_T} iso ${PRES} ${PRES} ${TAU_P}
run ${MD_NSTEPS}
unfix md1

variable idx equal "(v_loop1-1)"
write_data conf.${idx}.lmp
next loop1
jump SELF runloop1
33 changes: 33 additions & 0 deletions tests/test_lammps_mc_md_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import json
import unittest
from pathlib import Path


class TestLammpsMcMdExample(unittest.TestCase):
def test_template_placeholders_and_dump_command(self):
"""The example must become runnable after applying its revision matrix."""
example = Path(__file__).parents[1] / "examples" / "run" / "dp-lammps-MC+MD"
template = (example / "template" / "lammps.in").read_text()
parameters = json.loads((example / "param.json").read_text())
replacements = parameters["model_devi_jobs"][0]["rev_mat"]["lmp"]

rendered = template
for placeholder, values in replacements.items():
self.assertIn(placeholder, template)
rendered = rendered.replace(placeholder, str(values[0]))

variable_lines = [
line for line in rendered.splitlines() if line.startswith("variable")
]
self.assertFalse(any("${" in line for line in variable_lines))
self.assertNotIn('RANDOM_SEED}"', rendered)

dump_line = next(
line for line in template.splitlines() if line.startswith("dump")
)
self.assertGreaterEqual(len(dump_line.split()), 9)
self.assertIn("traj/*.lammpstrj", dump_line)


if __name__ == "__main__":
unittest.main()