diff --git a/README.md b/README.md index 852cbbb4..e78b821f 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,20 @@ deepmodeling, deepmd, dpti, free energy, phase diagram
The user will get Gibbs (Helmholtz) free energy of a system at different temperature and pressure conditions. With these free energy results, the user could determine the phase transition points and coexistence curve on the pressure-volume phase diagram. -useful docs: +useful links: github README.md: [https://github.com/deepmodeling/dpti/README.md](https://github.com/deepmodeling/dpti/README.md) -some discussion notes: [https://www.yuque.com/dpti/manual/ilzmlb](https://www.yuque.com/dpti/manual/ilzmlb) +On Bohrium Platform: +Bohrium notebook: +The basic usage of dpti, commands and examples: +https://www.bohrium.com/notebooks/82544159178 -intruction to free energy calculation: +Demo site: +https://www.bohrium.com/apps/dpti + + +intruction to free energy calculation via thermodynamic integration method: [https://nb.bohrium.dp.tech/detail/18465833825](https://nb.bohrium.dp.tech/detail/18465833825) @@ -50,6 +57,29 @@ At first, dpti is a collection of python scripts to generate LAMMPS input script
In dpti, there are many MD simulations tasks and scripts need to be run sequentially or concurrently. Before and after these MD simulation tasks, we may run a lot of MD scirpts to prepare the input files or analyze the logs to extract the useful data.

Then the dpti developers use apache-airflow to resolve the MD tasks dependencies and managing running tasks.
+# directory structure + +useful directories: + + +# +``` +dpti/ # main directory for dpti python modules +dpti/lib/ usefule libs for numberical integration and analysis, free energy calculation, etc. + +# example dir structure + +examples/ # examples dir +examples/Sn_High_Pressure/ # example for Sn high pressure phase diagram +examples/water_SCAN/ # example for water phase diagram + +# developer tools + +tests/ # unittests +docker/ # dockerfile +conda/ conda release +``` + # Software Usage: @@ -65,6 +95,40 @@ the CLI entry: dpti --help ``` +``` +# example dir: +cd examples/Sn_High_Pressure/ + +#download the models: +wget https://huggingface.co/Felix5572/Sn-SCAN-Compressed/resolve/main/graph.pb -O Sn_SCAN_compressed.pb +``` + +general useful commands: + +``` +# NPT +dpti equi gen npt.json -e npt-xy -t 200 -p 20000 -o NPT_sim/ +# cd NPT_sim/new_job/ +dpti equi extract ./ -o npt_avg.lmp + +# NVT +dpti equi gen equi_settings.json --ensemble nvt -t 200 -p 20000 --conf-npt ./NPT_sim/new_job/ -o NVT_sim/ +# cd NVT_sim/new_job/ +dpti equi extract ./ -o nvt_last_dump.lmp + +# HTI +dpti hti gen hti.json -s three-step -o HTI_sim/ +# dpti hti_water gen hti_water.json -o HTI_water/ +# dpti hti_ice gen hti_ice.json -s three-step -o HTI_ice/ +dpti hti compute ./new_job/ -t gibbs --npt ../NPT_sim/new_job/ + +# TI +dpti ti gen ti_settings.json -o TI_sim/ +dpti ti compute ./TI_sim/new_job/ --hti ../HTI_sim/new_job/ +``` + + + ### Equi(npt and nvt simulation) The following scripts are used to generate essential tools. @@ -83,8 +147,12 @@ This is an example for HTI three-step simulations. ``` cd examples/hti/ -dpti hti --help -dpti hti gen hti.json -s three-step +dpti hti gen hti.json -s three-step -o HTI_sim/ +# dpti hti_water gen hti_water.json -o HTI_water/ +# dpti hti_ice gen hti_ice.json -s three-step -o HTI_ice/ + +# After the lammps simulations. +dpti hti compute ./new_job/ -t gibbs --npt ../NPT_sim/new_job/ ``` ### TI @@ -110,6 +178,11 @@ In order to generate TI path changing temperature, we use dpti ti gen ti.p.json ``` +After the TI simulations. Calculate the free energy values lines with the corresponding HTI results. +``` +dpti ti compute ./TI_sim/new_job/ --hti ../HTI_sim/new_job/ +``` + ### GDI An example for finding coexisting line between Sn `beta` and `alpha` phase. @@ -123,61 +196,6 @@ cd examples/gdi/ dpti gdi pb.json machine.json -g gdidata.json ``` - -## For airflow workflow: - -Sometimes, we need to do **high-throughput** calculations(which means we need to calculate a series of temperature, pressure points for multiple phases). - -It would be a great burden for users to execute these tasks manually and monitor the tasks' execution. - -We provide the workflow tools based on apache-airflow workflow framework. - ->we refer this docs [airflow official docs](https://airflow.apache.org/docs/apache-airflow/stable/index.html) for more instructions. - - -### TI_Workflow -We implement a workflow de -implemented at `workflow/DpFreeEnergy.py` - -example dir and json: -``` -cd examples/ -cat examples/FreeEnergy.json -``` - -Requirement: setup apache-airflow or use the docker version dpti -``` -docker run --name dpti -p 9999:8080 -it deepmodeling/dpti:latest /bin/bash -docker exec -it dpti /bin/bash -``` -Then we provide a basic example for apache-airflow usage - -``` -# pwd at /home/airflow/ -cd dpti/examples/ -airflow dags trigger TI_taskflow --conf $(printf "%s" $(cat FreeEnergy.json)) -``` - - - -**Input:** Lammps structure file. - -**Output:** free energy values at given temperature and pressure. - -**Parameters:** Given temperature(or the range), Given pressure(or therange), force field,Lammps simulation ensemble and etc. - -we implement a workflow called TI_taskflow: -It includes these steps: -1. npt simulation to get lattice constant. -2. nvt simulation. -3. HTI: free energy at given temperature and pressure -4. TI: free energy values at the given range of temperature/pressure. - -### website to manage and monitor these jobs. - - - - `` @@ -200,19 +218,17 @@ dpti --help ## docker image: ``` -docker pull deepmodeling/dpti +docker pull yfb222333/dpti-lammps-fep:latest ``` -The useful files and command see [this file](docker/README.md - -## Manually installation ->the [Dockerfile](docker/Dockerfile) at `docker/` dir may be helpful for mannually installation. +On Bohrium Platform, Image address: +https://www.bohrium.com/image/detail/dpti/dpti -dpti use apache-airflow as workflow framework, and dpdispatcher to interact with the HPC systems (slurm or PBS). +## Manually installation +>the [Dockerfile](docker/Dockerfile) at `docker/` dir may be helpful for mannually installation. -airflow use realation database (PostgreSQL, MySQL or Sqlite) as backend to store the metadata, DAGs definetion and nodes state etc. ### install dpti and dpdispatcher. @@ -223,7 +239,13 @@ cd dpti/ pip install . ``` -### install postgresql backend +Note: dpti's lammps command requires Lammps package to be installed. (with USER-FEP and USER-DEEPMD packages enabled) + + + + + + # 🚀Quick Start ## with docker -```docker pull deepmodeling/dpti``` - -further information(useful command and files, examples):see [docker README.md](docker/README.md) - -## manually - -```bash - # copy dpti'workflow file - cp /path-to-dpti/workflow/DpFreeEnergy.py ~/airflow/dags/ - - # create a workdir and copy example files - cp /path-to-dpti/examples/*json /path-to-a-work-dir/ - - # start our airflow job - cd /path-to-a-work-dir/ - cat ./airflow.sh - - airflow dags trigger TI_taskflow --conf $(printf "%s" $(cat FreeEnergy.json)) - -``` - - - -## - -## 🕹install postgresql database -Airflow use relation database as backend. And PostgreSQL is widely used in airflow community.
- - -### install database -airflow's introduction on how to set up database backend: [apache-airflow:set up database](https://airflow.apache.org/docs/apache-airflow/stable/howto/set-up-database.html) -```bash -# install apache-airflow postgresql module -pip install apache-airflow-providers-postgres - -# install postgresql -yum install postgresql - -# enable postgresql service -systemctl start postgresql - -# enter posgresql -psql +```docker pull yfb222333/dpti-lammps-fep:latest``` -``` - - - -### create database and database user -```sql -CREATE DATABASE airflow_db1; -CREATE USER airflow_user1 WITH PASSWORD 'airflow_user1'; -GRANT ALL PRIVILEGES ON DATABASE airflow_db1 TO airflow_user1; -``` - -### - -### configure airflow configure file to connect database -configure ~/airflow/airflow.cfg
+Image usage: ``` -# change the following item with the sql above -# sql_alchemy_conn = sqlite:////home/fengbo/airflow/airflow.db -# sql_alchemy_conn = postgres://airflow:airflow@localhost:5432/airflow -sql_alchemy_conn = postgresql+psycopg2://:@:/ -``` - -### configure apache-airflow -reset db and webserver scheduler -``` -# reset db -airflow db init -# -D flag represent daemonize -airflow webserver # -p 8080 -D -airflow scheduler # -D -``` - -### airflow webserver - -If things work well, we could type the ip and prot in the web Browser and use the web service to monitor and manage the tasks operated by apache-airflow. - -We refer to this doc [apache-airflow webserver guide](https://airflow.apache.org/docs/apache-airflow/stable/security/webserver.html) for further information. - -after login(usually with default username and password:airflow, airflow) - -[![template_webserver.png](https://s11.ax1x.com/2024/02/19/pFYmlWj.png)](https://imgse.com/i/pFYmlWj) +# Usage Instructions: +# 1. Run container: +# docker run -it --gpus all dpti-lammps-fep -
- - - -### ssh to use the webserver - -Sometime, apache-airflow runs on remote machine and user can `ssh` to contect to the cloud server by command like ` ssh -L localhost:8080:localhost:8080 user1@67.xxx.xxx.25`  and visit [http://localhost:8080/](http://localhost:8080/) to monitor the free energy calculation tasks process. +# 2. (in container)Test commands: +# dp -h +# lmp -h +# cd deepmd-fep-testcase/ && lmp -i in.lammps -### apache-airflow: further instruction +# 3. Build commands: +# # Build base image +# docker build --target dpti-devel-base --tag dpti-devel-base:latest -f dp-lammps-fep.Dockerfile ./ -The backend of this software is based on the software `airflow`. The following command can start the calculation. - -
-
The first command is used for calculate the free energy of solid.
The second command is used for calculate the free energy of liquid.
- -```bash -airflow trigger_dag HTI_taskflow --conf $(printf "%s" $(cat FreeEnergy.json)) -airflow trigger_dag TI_taskflow --conf $(printf "%s" $(cat FreeEnergy.meam.json)) +# # Build final image (two methods): +# # Method 1: Direct build +# docker build --tag dpti-lammps-fep:latest -f dp-lammps-fep.Dockerfile ./ +# # Method 2: Build with cache from base +# docker build --cache-from dpti-devel-base:latest --tag dpti-lammps-fep:latest -f dp-lammps-fep.Dockerfile ./ ``` -#### FreeEnergy.json - -We usually want to calculate the free energy of a metal at a specific pressure or temperature. And the crystal structure of the metal can be various. For example, we want to calculate the free energy of metal Sn of bcc structure at 200 K and 50000 bar (5GPa). In order to caculate the per atom free energy of metal Sn. First, We must prepare a configuration file named bcc.lmp and modify the [FreeEnergy.json](#ULX0o) or [FreeEnergyLiquid.json](#WuLBQ) and modify the key-value pair like "structure": "bcc", "target_temp": 200, "target_press" : 50000. And decide whether to integrate along the t(temperature) path or along the p(pressure) path . Modify the "path" key-value pair for this. The key-value pair "ensemble" for lammps MD simulation. Usually the ensemble shoule be consistent with the crystal intrinsic structure. That means we should set "npt-iso" for structure "bcc" to keep the simulation box changes simultaneously in x, y, z directions. - -#### ti-path json -Modify the ti.t.json or ti.p.json, and change the key-value pair "temps" or "press" . For ti.t.json, the tar_temp of FreeEnergy.json must be in the list which the key-value pair "temps" of ti.t.json represents. And similarly for ti.p.json, the tar_press of FreeEnergy.json must be in the list which the key-value pair "temps" of ti.t.json represents. - -#### workflow -1. Use the command `airflow trigger_dag`  mentioned above. This command will start a [airflow dag](https://airflow.apache.org/docs/apache-airflow/stable/concepts.html).This dag is wrote and maintained by the dpti software developer. It is used to make the calculation to be done more autocally . The user could monitor the task state and calculation procedure at [a website](#2aabcbd6). The user can also rerun, restart, delete the whole calculation or some part of the calculations. -2. Wait until the calculation finish. Usually the whole procedure continues for about 6 to 10 hours. The calculations will be done autocally. -3. Find the results in [Results Show](#2aabcbd6) part. The user could use the tables and data of it and plot the curve. - - - - -# 📌Calculation Results and files - -
For each step, the result files are located at the corresponding location.
For example, we start a calculation at `/home/user1/metal_Sn/1_free_energy/400K-0bar-bcc-t`
-
For NPT MD simulation, the result file will locate at `/home/user1/metal_Sn/1_free_energy/400K-0bar-bcc-t/NPT_sim/result`
-
For TI simulation the result will locate at `/home/fengbo/4_Sn/1_free_energy/400K-0bar-bct-t/TI_sim/result`
-
You may want to use the result file and datas of TI_sim/result and plot the free_energy vs T curve for different structure and find the crossing point.
- -For HTI simulation the result will locate at `/home/fengbo/4_Sn/1_free_energy/400K-0bar-bct-t/HTI_sim/result`, a pure txt file. - -The hti out file at -`new_job/02.spring_off/hti.out` which records the integration node on the path is also helpful. - - -# 💎The procedure of the free energy calculations - -
To calculate out Gibbs (or Helmholtz) free energy of the materials, there are four steps.
- -1. NPT MD simulation -1. NVT MD simulation -1. Hamiltonian thermodynamic integration -4. thermodynamic integration - - ## NPT simulation @@ -441,26 +343,11 @@ Integrating along the isothermal or isobaric path, We will know the free energy
There are diffefrent json files desinged for different usage.
-1. FreeEnergy.json   control the whole workflow 1. npt.json -3. nvt.json +2. nvt.json 3. hti.json or hti.liquid.json -3. ti.t.json or ti.p.json +4. ti.t.json or ti.p.json -## FreeEnergy.json - -
FreeEnergy calculation settings for solid - -| Field | Type | Example | Discription | -| --- | --- | --- | --- | -| target_temp | positive integer | 200 | the temperature of HTI | -| target_press | non-negative integer | 50000 | unit :bar.the pressure of HTI | -| work_base_dir | string | "/home/user1/metal_Sn" | see note1. work  directory.  | -| ti_path | "t" or "p" | "t" | thermodynamic integration along temperature or pressure | -| conf_lmp | string | "bct.lmp" | see note1. the materials structure to be calculated | -| ens | string | "npt-iso" | MD simulation ensemble in lammps | -| if_liquid | bool | false | if simulate liquid | - @@ -644,22 +531,6 @@ then the last 49000 points will be grouped into 49000/100==490 chunks. The average value the of the 100 point value in each chunk will treated as chunk value. And the 490 chunk values will also be averaged as the final result value for this MD. -### FreeEnergy.json -The json file controls the whole calculation process. -And for each step, it uses corresponding `npt.json` `nvt.json` `hti.json` `ti.json` - - - -| Field | Type | Example | Description | -| --- | --- | --- | --- | -| target_temp | integer | 200 | target simulation temperature unit:K | -| target_pres | integer | 20000 | target simulation pressure unit:Bar.(20000Bar==2GPa) | -| work_base_dir | string | "/home/fengbo/4_Sn/14_free_energy_airflow_test" | should be changed to the dir will this file locates | -| ti_path | string | "t" or "p" | indicate protocol used inthis calculation in TI calculation(along t keep p; along p keep t) | -| conf_lmp | string | "beta.lmp" | structure file name | -| ens | choice:"npt-iso", "npt-aniso", "npt-xy" | 0.002 | the ensemble used in NPT and TI simulation. (solid:npt-aniso; liquid:npt-iso) | -| if_liquid | string | bool | true for liquid, false for other | - ### pb.json example command: diff --git a/dpti/equi.py b/dpti/equi.py index 42e455d2..504d8832 100755 --- a/dpti/equi.py +++ b/dpti/equi.py @@ -131,7 +131,7 @@ def gen_equi_dump_settings(if_dump_avg_posi): return ret -def gen_equi_ensemble_settings(ens, if_dump_avg_posi): +def gen_equi_ensemble_settings(ens, if_dump_avg_posi=False): # ens = equi_settings['ens'] ret = "" if ens == "nvt": diff --git a/dpti/hti.py b/dpti/hti.py index 419cd6fa..2aeb4d30 100755 --- a/dpti/hti.py +++ b/dpti/hti.py @@ -1331,7 +1331,11 @@ def compute_task( print(print_format % (e1, de_err[0], de_err[1])) elif free_energy_type == "gibbs": if npt is not None: - npt_in = json.load(open(os.path.join(npt, "jdata.json"))) + # Try jdata.json first, then equi_settings.json for compatibility + try: + npt_in = json.load(open(os.path.join(npt, "jdata.json"))) + except FileNotFoundError: + npt_in = json.load(open(os.path.join(npt, "equi_settings.json"))) npt_info = json.load(open(os.path.join(npt, "result.json"))) p = npt_in["pres"] v = npt_info["v"] diff --git a/dpti/hti_liq.py b/dpti/hti_liq.py index 2f7889b8..55342d72 100755 --- a/dpti/hti_liq.py +++ b/dpti/hti_liq.py @@ -363,7 +363,7 @@ def make_tasks(iter_name, jdata, if_meam=None): if model: copied_model = os.path.join(os.path.abspath(iter_name), "graph.pb") shutil.copyfile(model, copied_model) - jdata["model"] = copied_model + jdata["model"] = copied_model cwd = os.getcwd() os.chdir(iter_name) diff --git a/dpti/hti_water.py b/dpti/hti_water.py index 8784d388..4f39e17e 100755 --- a/dpti/hti_water.py +++ b/dpti/hti_water.py @@ -35,9 +35,9 @@ def _ff_angle_on(lamb, model, bparam, sparam): alpha_lj = sparam["alpha_lj"] rcut = sparam["rcut"] epsilon = sparam["epsilon"] - sigma_oo = sparam["sigma_oo"] - sigma_oh = sparam["sigma_oh"] - sigma_hh = sparam["sigma_hh"] + sigma_oo = sparam.get("sigma_oo", None) or sparam["sigma_0_0"] + sigma_oh = sparam.get("sigma_oh", None) or sparam["sigma_0_1"] + sigma_hh = sparam.get("sigma_hh", None) or sparam["sigma_1_1"] activation = sparam["activation"] ret = "" ret += f"variable EPSILON equal {epsilon:f}\n" @@ -64,9 +64,9 @@ def _ff_deep_on(lamb, model, bparam, sparam): alpha_lj = sparam["alpha_lj"] rcut = sparam["rcut"] epsilon = sparam["epsilon"] - sigma_oo = sparam["sigma_oo"] - sigma_oh = sparam["sigma_oh"] - sigma_hh = sparam["sigma_hh"] + sigma_oo = sparam.get("sigma_oo", None) or sparam.get("sigma_0_0") + sigma_oh = sparam.get("sigma_oh", None) or sparam.get("sigma_0_1") + sigma_hh = sparam.get("sigma_hh", None) or sparam.get("sigma_1_1") activation = sparam["activation"] ret = "" ret += f"variable EPSILON equal {epsilon:f}\n" @@ -94,9 +94,9 @@ def _ff_bond_angle_off(lamb, model, bparam, sparam): alpha_lj = sparam["alpha_lj"] rcut = sparam["rcut"] epsilon = sparam["epsilon"] - sigma_oo = sparam["sigma_oo"] - sigma_oh = sparam["sigma_oh"] - sigma_hh = sparam["sigma_hh"] + sigma_oo = sparam.get("sigma_oo", None) or sparam["sigma_0_0"] + sigma_oh = sparam.get("sigma_oh", None) or sparam["sigma_0_1"] + sigma_hh = sparam.get("sigma_hh", None) or sparam["sigma_1_1"] activation = sparam["activation"] ret = "" ret += "variable INV_LAMBDA equal 1-${LAMBDA}\n" diff --git a/dpti/ti.py b/dpti/ti.py index c130475f..09949e64 100755 --- a/dpti/ti.py +++ b/dpti/ti.py @@ -108,10 +108,10 @@ def _gen_lammps_input( ret += "compute allmsd all msd\n" if ens == "nvt": ret += "thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*]\n" - ret += "thermo_modify format 4*8 %20.6f\n" + ret += "thermo_modify format float %20.6f\n" elif "npt" in ens: ret += "thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*]\n" - ret += "thermo_modify format 4*8 %20.6f\n" + ret += "thermo_modify format float %20.6f\n" else: raise RuntimeError(f"unknow ensemble {ens}\n") ret += "dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z\n" diff --git a/examples/Sn_High_Pressure/command.sh b/examples/Sn_High_Pressure/command.sh new file mode 100644 index 00000000..bbfd810f --- /dev/null +++ b/examples/Sn_High_Pressure/command.sh @@ -0,0 +1,19 @@ +# NPT +dpti equi gen npt.json -e npt-xy -t 200 -p 20000 -o NPT_sim/ +# cd NPT_sim/new_job/ +dpti equi extract ./ -o npt_avg.lmp + +# NVT +dpti equi gen equi_settings.json --ensemble nvt -t 200 -p 20000 --conf-npt ./NPT_sim/new_job/ -o NVT_sim/ +# cd NVT_sim/new_job/ +dpti equi extract ./ -o nvt_last_dump.lmp + +# HTI +dpti hti gen hti.json -s three-step -o HTI_sim/ +# dpti hti_water gen hti_water.json -o HTI_water/ +# dpti hti_ice gen hti_ice.json -s three-step -o HTI_ice/ +dpti hti compute ./new_job/ -t gibbs --npt ../NPT_sim/new_job/ + +# TI +dpti ti gen ti_settings.json -o TI_sim/ +dpti ti compute ./TI_sim/new_job/ --hti ../HTI_sim/new_job/ diff --git a/examples/Sn_High_Pressure/conf.lmp b/examples/Sn_High_Pressure/conf.lmp new file mode 120000 index 00000000..323add74 --- /dev/null +++ b/examples/Sn_High_Pressure/conf.lmp @@ -0,0 +1 @@ +beta.lmp \ No newline at end of file diff --git a/examples/Sn_High_Pressure/hti.json b/examples/Sn_High_Pressure/hti.json index 2d9724ed..97f389e0 100644 --- a/examples/Sn_High_Pressure/hti.json +++ b/examples/Sn_High_Pressure/hti.json @@ -1,5 +1,5 @@ { - "equi_conf": null, + "equi_conf": "nvt_last_dump.lmp", "ncopies": [ 1, 1, diff --git a/examples/download_models.sh b/examples/download_models.sh new file mode 100755 index 00000000..1d90ff38 --- /dev/null +++ b/examples/download_models.sh @@ -0,0 +1,3 @@ +wget https://huggingface.co/Felix5572/Sn-SCAN-Compressed/resolve/main/graph.pb -O Sn_SCAN_compressed.pb + +wget https://huggingface.co/Felix5572/Water-Ice-SCAN-Phase-Dirgram/resolve/main/graph.pb -O H2O-Phase-Diagram-model_compressed.pb diff --git a/examples/water_SCAN/H2O-Phase-Diagram-model_compressed.pb b/examples/water_SCAN/H2O-Phase-Diagram-model_compressed.pb new file mode 120000 index 00000000..026c89e0 --- /dev/null +++ b/examples/water_SCAN/H2O-Phase-Diagram-model_compressed.pb @@ -0,0 +1 @@ +../H2O-Phase-Diagram-model_compressed.pb \ No newline at end of file diff --git a/examples/water_SCAN/ice04/command.sh b/examples/water_SCAN/ice04/command.sh new file mode 100644 index 00000000..df9edb36 --- /dev/null +++ b/examples/water_SCAN/ice04/command.sh @@ -0,0 +1,37 @@ +# docker pull yfb222333/dpti-lammps-fep:latest +# docker run -it --gpus all dpti-lammps-fep:latest +# all in /opt/ +# all files in /opt/dpti/examples/water_SCAN/ice04/ + +#NPT +dpti equi gen npt.json -o npt/ + +# submit jobs `lmp -i in.lammps` for npt/ + +dpti equi extract ./npt/ -o npt_avg.lmp # extract average + +# NVT +dpti equi gen nvt.json -o nvt/ + +# submit jobs `lmp -i in.lammps` for nvt/ + +dpti equi extract ./nvt/ -o nvt_last_dump.lmp # extract average + +## HTI (hti,hti_liq, hti_water, hti_ice) module +dpti hti_ice gen hti_ice.json -s three-step -o hti/ + +# submit jobs `lmp -i in.lammps` for subdirs like `hti/0*/task*/` + +dpti hti_ice compute ./hti/ -t gibbs --npt ./npt/ # note use NPT simulation usually longer steps, and the P*V value is more accurate + +# result txt in ./hti/result + +## TI (ti, ti_water) module + +dpti ti_water gen path-t.json -o ti_path_t/ + +# submit jobs `lmp -i in.lammps` for subdirs like `ti_path_t/task*/` + + dpti ti_water compute ./ti_path_t/ --hti ./hti/ # HTI simulation (starting point, gibbs free energy value) + +# final result for a ti-line txt in ./ti_path_t/result diff --git a/examples/water_SCAN/ice04/conf.lmp b/examples/water_SCAN/ice04/conf.lmp new file mode 120000 index 00000000..28a2742d --- /dev/null +++ b/examples/water_SCAN/ice04/conf.lmp @@ -0,0 +1 @@ +ice04.lmp \ No newline at end of file diff --git a/examples/water_SCAN/ice04/graph.pb b/examples/water_SCAN/ice04/graph.pb new file mode 120000 index 00000000..026c89e0 --- /dev/null +++ b/examples/water_SCAN/ice04/graph.pb @@ -0,0 +1 @@ +../H2O-Phase-Diagram-model_compressed.pb \ No newline at end of file diff --git a/examples/water_SCAN/ice04/hti_ice.json b/examples/water_SCAN/ice04/hti_ice.json new file mode 100644 index 00000000..6b1fb59e --- /dev/null +++ b/examples/water_SCAN/ice04/hti_ice.json @@ -0,0 +1,52 @@ +{ + "equi_conf": "nvt_last_dump.lmp", + "ncopies": [ + 1, + 1, + 1 + ], + "lambda_lj_on": [ + "0.000:0.100:0.0125", + "0.100:0.200:0.025", + "0.200:1.000:0.2", + "1" + ], + "lambda_deep_on": [ + "0.0:0.1:0.025", + "0.1:1.0:0.1125", + "1" + ], + "lambda_spring_off": [ + "0.000:0.750:0.125", + "0.750:0.875:0.0625", + "0.875:1.000:0.03125", + "1" + ], + "protect_eps": 1e-08, + "model": "graph.pb", + "model_mass_map": [ + 16, + 2 + ], + "spring_k": 0.5, + "soft_param": { + "epsilon": 0.02, + "sigma_oo": 3.15, + "sigma_oh": 0.987, + "sigma_hh": 0.987, + "activation": 0.5, + "n": 1.0, + "alpha_lj": 0.5, + "rcut": 6.0, + "_comment": "that's all" + }, + "crystal": "frenkel", + "langevin": true, + "nsteps": 200000, + "dt": 0.0005, + "stat_freq": 10, + "stat_skip": 10000, + "stat_bsize": 2000, + "temp": 150.000000, + "_comment": "that's all" +} diff --git a/examples/water_SCAN/ice04/ice04.lmp b/examples/water_SCAN/ice04/ice04.lmp new file mode 100644 index 00000000..d749a6f3 --- /dev/null +++ b/examples/water_SCAN/ice04/ice04.lmp @@ -0,0 +1,394 @@ +# LAMMPS data file written by OVITO +384 atoms +2 atom types +0.0 14.3919191 xlo xhi +0.0 13.5760737 ylo yhi +0.0 13.1112938 zlo zhi +5.0103922 5.0029712 3.4473841 xy xz yz + +Atoms # atomic + +1 1 6.8296848 7.3690739 5.0090914 +2 1 4.2902894 6.1186934 3.9980362 +3 1 3.5812118 4.4326911 0.7180506 +4 1 5.7483168 6.4241967 1.6890702 +5 1 9.1977816 5.7698121 2.4388078 +6 1 7.1795545 4.2975373 0.7776736 +7 1 5.3307476 1.1708654 1.550296 +8 1 7.9151674 2.4273603 2.6098299 +9 1 8.6302414 4.1109781 5.8219209 +10 1 6.5502692 2.1699925 4.9606658 +11 1 2.8984624 2.7398725 4.0706711 +12 1 4.9767742 4.2278533 5.8127013 +13 1 1.0548483 0.7336095 0.4857395 +14 1 5.0379095 3.4856229 2.7263575 +15 1 11.1628742 7.7988191 5.9618502 +16 1 7.0823393 4.980473 3.853381 +17 1 9.376113 9.0321941 11.5190411 +18 1 6.7504134 7.8127451 10.5719404 +19 1 6.0673914 6.1444049 7.3126664 +20 1 8.1621037 8.0770302 8.2545366 +21 1 11.7611704 7.5173898 9.0740681 +22 1 9.7143479 6.0721655 7.2898722 +23 1 7.7397022 2.8491696 8.0917807 +24 1 10.5195923 4.2045178 9.1008463 +25 1 11.1860571 5.8152333 12.3572998 +26 1 9.0858536 3.8307092 11.3688755 +27 1 5.4954543 4.3962965 10.6559439 +28 1 7.6075878 5.9263368 12.3292084 +29 1 3.4767313 2.4602041 7.1408625 +30 1 7.5647593 5.2150397 9.2451067 +31 1 13.6558399 9.5033436 12.5460119 +32 1 9.6257839 6.6546703 10.3769884 +33 1 9.4174023 14.1935339 5.0071521 +34 1 6.7354059 12.9214954 3.9700094 +35 1 6.0796394 11.1624165 0.749587 +36 1 8.1967421 13.1872969 1.6440057 +37 1 11.7154951 12.5949497 2.4698069 +38 1 9.7359162 11.1354599 0.7715461 +39 1 7.8758922 7.983098 1.5582817 +40 1 10.4410715 9.1696596 2.5230992 +41 1 11.0608864 10.8771954 5.8971758 +42 1 9.021574 8.8670684 4.8250366 +43 1 5.4134755 9.4595785 4.049799 +44 1 7.4843369 10.9101276 5.7473598 +45 1 3.6049352 7.475492 0.5513278 +46 1 7.5564757 10.347024 2.7628451 +47 1 13.7002001 14.5783654 6.0162177 +48 1 9.6097632 11.8103457 3.855918 +49 1 11.9329988 15.8685304 11.6119499 +50 1 9.2617264 14.5440989 10.5827389 +51 1 8.5694609 12.8469124 7.2379761 +52 1 10.5953923 14.876174 8.2395172 +53 1 14.2949619 14.4052696 9.0752335 +54 1 12.2023754 12.8142529 7.3444767 +55 1 10.31709 9.6457882 8.2272406 +56 1 13.0213499 10.9191562 9.1248846 +57 1 13.5701275 12.6808005 12.40483 +58 1 11.54389 10.5787077 11.3596382 +59 1 7.9604088 11.1593914 10.6136122 +60 1 10.1101151 12.6338473 12.3255711 +61 1 6.0441661 9.2178183 7.1595092 +62 1 10.0772848 12.0783911 9.2835856 +63 1 16.2233372 16.3204041 12.5180311 +64 1 12.1649838 13.5437451 10.3743191 +65 1 14.0260725 7.3540921 5.0075393 +66 1 11.3454018 6.0416546 3.9856184 +67 1 10.859024 4.446527 0.676406 +68 1 12.8520212 6.4630528 1.7503875 +69 1 16.4952526 5.8732204 2.5137377 +70 1 14.3346605 4.3718753 0.8276395 +71 1 12.4934492 1.1732699 1.5015935 +72 1 15.1465168 2.4156444 2.5136807 +73 1 15.7807522 4.1260166 5.9114634 +74 1 13.7014323 2.0735951 4.8087712 +75 1 10.1539249 2.7252138 4.0440078 +76 1 12.219264 4.1585927 5.7684245 +77 1 8.2457647 0.764077 0.565628 +78 1 12.3104372 3.5232785 2.7263191 +79 1 18.3546353 7.8399572 5.987854 +80 1 14.3894415 4.9973212 3.8231035 +81 1 16.4983864 9.1031666 11.4125137 +82 1 13.909461 7.7347532 10.5996943 +83 1 13.2036982 6.0985951 7.2773905 +84 1 15.3593235 8.1136217 8.3129902 +85 1 18.9724198 7.5944314 9.0754337 +86 1 16.8799286 6.103241 7.3405476 +87 1 15.0389538 2.8565674 8.2321453 +88 1 17.7043534 4.1940632 9.1320152 +89 1 18.363224 5.8570762 12.3637781 +90 1 16.2533684 3.7937777 11.4117088 +91 1 12.6954642 4.380826 10.6345606 +92 1 14.8224058 5.8925944 12.3866844 +93 1 10.7616339 2.4551001 7.1362243 +94 1 14.7447958 5.2739802 9.2336893 +95 1 20.8886414 9.4889279 12.5937243 +96 1 16.846491 6.6712551 10.3489971 +97 1 16.516552 14.1475229 4.9843908 +98 1 13.9159394 12.878273 3.9549782 +99 1 13.2735357 11.2240133 0.7245944 +100 1 15.339819 13.1946278 1.6653462 +101 1 18.956648 12.6427441 2.4349616 +102 1 16.8821964 11.1351414 0.8170198 +103 1 15.0392189 7.9665576 1.5761519 +104 1 17.6390057 9.1741505 2.5163071 +105 1 18.2896042 10.9027042 5.8046208 +106 1 16.2060947 8.886405 4.8161607 +107 1 12.5832224 9.4635134 4.0659647 +108 1 14.6583338 10.938921 5.7293554 +109 1 10.7475348 7.5028243 0.5194612 +110 1 14.755517 10.3232727 2.7426975 +111 1 20.8178978 14.6096201 5.9843292 +112 1 16.847725 11.8019228 3.7949195 +113 1 19.0883484 15.8159027 11.4993668 +114 1 16.4900437 14.4978047 10.5893822 +115 1 15.6827889 12.8670512 7.2617779 +116 1 17.8568364 14.9312268 8.2748919 +117 1 21.5352574 14.2630978 9.01616 +118 1 19.3734455 12.8616038 7.3165383 +119 1 17.5264569 9.6841727 8.1279631 +120 1 20.133646 10.9802342 9.1294022 +121 1 20.9032784 12.6522093 12.3912945 +122 1 18.7418938 10.5652161 11.4287014 +123 1 15.1440649 11.3435383 10.6709719 +124 1 17.3171311 12.6607914 12.3863526 +125 1 13.2382546 9.1797581 7.126533 +126 1 17.2885456 12.0798578 9.2476425 +127 1 23.3707276 16.2789211 12.5276366 +128 1 19.3915997 13.4642802 10.3789024 +129 2 6.9875994 5.8761412 4.2867446 +130 2 6.3477149 6.5947614 6.4655552 +131 2 7.6529045 7.9316846 4.9399652 +132 2 6.3056436 8.1426239 4.6541243 +133 2 5.217969 6.3130717 2.5289412 +134 2 4.7235074 4.9254476 5.1432109 +135 2 3.4668224 6.0262642 3.4391446 +136 2 4.1667996 6.7675824 4.7481656 +137 2 4.1294761 4.0762386 1.4739264 +138 2 3.874332 4.859129 -0.1370702 +139 2 7.9759632 6.6632939 12.8950644 +140 2 17.0352135 5.3469057 1.8576616 +141 2 6.6537466 5.0788283 1.1125022 +142 2 6.5535679 7.014214 1.6395691 +143 2 4.4150124 7.0781617 0.9813306 +144 2 7.8759004 5.2765765 3.3227356 +145 2 8.3608856 7.1710553 1.881342 +146 2 10.0045719 5.8719344 3.0198939 +147 2 9.7994089 5.2905774 1.8005452 +148 2 7.4499183 3.6101809 1.4510563 +149 2 11.5608244 6.5409818 12.9333544 +150 2 13.1018715 8.8421756 13.0509634 +151 2 5.2187276 2.0563357 2.0001779 +152 2 10.8743382 5.37747 13.2000313 +153 2 9.0045538 13.774827 1.6087045 +154 2 5.8369022 0.3783193 1.8889384 +155 2 7.415546 2.3331506 3.4703548 +156 2 8.7515507 2.5386362 3.1456285 +157 2 8.1213579 1.3899897 1.3348849 +158 2 8.0466127 4.438817 5.0796943 +159 2 9.3098641 5.3404408 6.7421751 +160 2 8.3060331 3.6516078 6.6482792 +161 2 9.5941973 3.2342754 4.6971259 +162 2 5.9735566 2.9242338 5.2729516 +163 2 5.7409497 1.5837382 4.9782196 +164 2 12.8951112 15.0177603 5.6190229 +165 2 4.2262249 3.2026928 3.2363765 +166 2 8.8725196 14.9601422 4.6688981 +167 2 2.0957267 2.6184705 3.4876814 +168 2 2.3507354 3.2427962 4.7385512 +169 2 5.3855109 4.9461304 6.3748517 +170 2 4.0378776 3.1214588 6.6440144 +171 2 1.6380103 1.3903643 0.0086696 +172 2 7.3997035 13.6069927 1.2108926 +173 2 15.2596874 1.7816576 1.7493159 +174 2 0.301969 0.200986 0.1004017 +175 2 5.7750473 4.0246043 3.1327159 +176 2 10.6094227 7.1391006 6.4692593 +177 2 9.8294277 8.4640475 5.2539253 +178 2 11.2765761 6.7042179 4.7307849 +179 2 11.9167728 8.3004561 6.3849301 +180 2 9.4703036 8.1352568 11.0881929 +181 2 10.188324 9.6116343 11.4593163 +182 2 8.4823742 10.3751021 10.9474402 +183 2 7.6445713 7.9801422 9.1041079 +184 2 7.0657592 7.1187558 11.218421 +185 2 5.9304234 7.7302461 10.006423 +186 2 20.9847432 8.853961 11.827837 +187 2 6.6396313 5.7892351 8.0511751 +188 2 19.5179749 7.0624037 8.4286585 +189 2 8.7340012 7.3383732 7.8991228 +190 2 9.5090685 9.0575752 8.2374754 +191 2 6.8450642 8.7864294 7.5735936 +192 2 10.4323788 6.9805436 9.8848392 +193 2 11.2281475 8.3030005 8.7614966 +194 2 12.573328 7.5995631 9.6508284 +195 2 12.6708603 6.6226664 7.9410424 +196 2 10.0098906 5.3866959 7.9545418 +197 2 7.6734143 3.7456241 8.5287886 +198 2 6.9294152 2.266633 8.147337 +199 2 13.7286463 15.145751 8.7147198 +200 2 9.6148176 3.968622 10.5321093 +201 2 11.334755 4.2705689 9.6754332 +202 2 10.6111689 3.5426269 8.3575335 +203 2 10.2126761 6.3389192 11.1218777 +204 2 12.1372252 4.911325 11.2716971 +205 2 8.1471338 5.1614618 11.9786998 +206 2 12.7441635 16.4453373 11.5208025 +207 2 9.8879672 3.421041 11.8022166 +208 2 6.7798143 4.9044672 9.7802754 +209 2 6.0206461 3.6220842 11.0077524 +210 2 4.6782484 4.320591 10.0854664 +211 2 18.9242344 5.3193917 11.735158 +212 2 9.7988081 15.3145056 7.8244038 +213 2 17.7664299 3.5389583 8.3796959 +214 2 2.7304912 1.943681 6.7221389 +215 2 8.311923 5.7369356 9.6554375 +216 2 12.3403559 10.1731625 11.8070479 +217 2 13.8135138 8.403821 11.3359976 +218 2 14.4124069 10.0259333 12.937808 +219 2 9.4898548 13.2959089 4.5735412 +220 2 8.878746 13.33809 6.4242883 +221 2 7.2646508 13.0177593 3.1276119 +222 2 7.2157149 11.6315518 5.1098714 +223 2 5.9237924 12.8172713 3.3960576 +224 2 20.9347668 13.972024 5.2235308 +225 2 6.9944992 10.6573038 1.9967448 +226 2 6.3928285 11.6259928 -0.0786702 +227 2 5.7175765 10.4267626 0.177987 +228 2 19.5160332 12.0961275 1.8126307 +229 2 9.1680918 11.8924132 1.0934097 +230 2 10.9183484 12.2979288 2.9945338 +231 2 12.5392723 12.7010174 3.0258095 +232 2 12.6992378 11.7293434 1.3678846 +233 2 10.182498 9.890504 1.8808184 +234 2 14.0064421 13.3908634 12.9565926 +235 2 10.293314 11.7879 0.2590714 +236 2 7.7564225 8.867261 2.0088165 +237 2 13.3121023 12.2141018 13.2501793 +238 2 9.9197074 9.0585213 3.3685734 +239 2 11.7771664 9.3529406 3.4854088 +240 2 10.6308136 8.1376667 1.2825805 +241 2 10.1524372 11.4613772 4.6192837 +242 2 11.775692 12.090189 6.8034821 +243 2 10.7894049 10.4277382 6.7476373 +244 2 11.6103182 10.3669787 5.2362661 +245 2 8.4562941 9.6183529 5.1641979 +246 2 6.7489915 10.0126343 3.2477703 +247 2 4.6023522 9.3527117 3.4756406 +248 2 4.858768 9.9876928 4.6919799 +249 2 7.8899312 11.6340523 6.3045173 +250 2 6.5908823 9.8602506 6.6234303 +251 2 9.5414686 11.9861766 12.8316975 +252 2 2.8423084 6.9575038 0.165208 +253 2 17.7754193 8.5266161 1.7672487 +254 2 8.8629742 11.2781286 3.4583624 +255 2 13.1391401 13.9175606 6.5137601 +256 2 10.0133066 1.9303568 6.7316871 +257 2 13.8354979 13.5121784 4.7235437 +258 2 12.0206995 14.989666 11.1440735 +259 2 9.7524233 14.6662789 9.7205963 +260 2 9.7985296 13.3354206 11.6854849 +261 2 8.4626332 14.4380999 9.9917966 +262 2 23.4785958 15.617486 11.7861061 +263 2 9.1371107 12.5575886 8.0080853 +264 2 22.0664272 13.7356301 8.3538637 +265 2 11.1766777 14.1303253 7.9157586 +266 2 12.9715624 13.8699856 9.8823834 +267 2 15.6677885 14.4631415 10.0221977 +268 2 14.7987662 13.8468724 8.4169207 +269 2 12.5026379 12.1194477 7.9972324 +270 2 10.2270804 10.5588551 8.6237345 +271 2 12.4745245 10.7931519 9.951992 +272 2 13.8189183 11.0786085 9.7057972 +273 2 13.1566973 9.833787 7.8779298 +274 2 12.7019034 13.2140055 11.150198 +275 2 14.560688 11.8391924 11.3136234 +276 2 11.0102768 11.3435755 11.7191315 +277 2 9.2829371 11.7335406 9.782672 +278 2 7.1315198 11.0924587 10.0591183 +279 2 21.4325428 12.1069603 11.7419997 +280 2 19.1090946 8.3393889 6.4125419 +281 2 20.2472687 10.3181181 8.3893395 +282 2 10.8294869 12.6063614 9.6765785 +283 2 16.9594936 16.8509312 12.9370956 +284 2 16.3232899 15.6373472 11.7952299 +285 2 14.2530365 5.8820268 4.2677274 +286 2 13.7240105 6.8929434 5.8412658 +287 2 15.3904848 8.3131218 4.8877606 +288 2 13.4965811 8.1282005 4.6620035 +289 2 12.3000822 6.3086763 2.5692477 +290 2 11.664587 5.3538489 4.6368041 +291 2 11.4011288 4.1016922 1.442051 +292 2 11.0911484 4.8876052 -0.1899477 +293 2 15.2137728 6.6460181 12.914116 +294 2 13.3959417 5.6958814 1.4118673 +295 2 14.2173233 7.401578 1.6416252 +296 2 11.541133 7.1107283 0.9836414 +297 2 15.1897783 5.3302155 3.3254655 +298 2 15.959591 6.6433425 2.1688073 +299 2 14.8467732 3.1378982 1.8911828 +300 2 13.9737216 3.6450429 0.2441701 +301 2 14.9204674 5.0024996 0.3195617 +302 2 12.3793001 2.6390319 2.265487 +303 2 12.813263 1.6294575 0.6717671 +304 2 16.1500206 13.7767067 1.6040378 +305 2 13.0265379 0.4002776 1.844082 +306 2 14.2298002 2.1986594 3.9696138 +307 2 15.257246 4.4538617 5.1256785 +308 2 16.1913319 4.864576 6.4452744 +309 2 15.3088341 3.3184176 7.387836 +310 2 12.7614727 3.3958569 5.4173632 +311 2 12.8783504 1.5103895 4.8746172 +312 2 20.0164833 15.0053854 5.5369988 +313 2 10.9672242 3.0261927 3.5470598 +314 2 16.0180759 14.9414692 4.6377354 +315 2 12.5909014 4.8909708 6.3380804 +316 2 11.31637 3.1034043 6.6156755 +317 2 14.2265206 5.2560177 12.8752442 +318 2 9.0407238 0.3270361 0.985193 +319 2 13.0593815 4.0542903 3.1214266 +320 2 17.4362126 6.7583609 6.8302884 +321 2 17.5478058 8.2329254 5.5478535 +322 2 16.6283551 8.1951828 11.0154371 +323 2 17.3357506 9.648861 11.4185553 +324 2 15.6415615 10.5205584 10.94337 +325 2 14.8292771 7.9751144 9.1489735 +326 2 14.2444382 7.0588293 11.2553759 +327 2 13.7908535 5.7844177 8.0227366 +328 2 15.9218626 7.369894 7.9532414 +329 2 16.7190666 9.0990477 8.1968975 +330 2 14.0370789 8.7782374 7.5733691 +331 2 17.649971 7.0201631 9.8676634 +332 2 18.4395352 8.3645697 8.7262602 +333 2 17.1801357 5.40803 7.9928956 +334 2 14.856454 4.3563728 8.8535194 +335 2 14.2143898 2.2919119 8.2482214 +336 2 20.9940148 15.0533533 8.7305832 +337 2 17.1734676 4.0476074 9.9661074 +338 2 17.7911663 6.164155 11.6038742 +339 2 15.7277146 4.5647626 11.7698593 +340 2 19.9012242 16.3965588 11.4666128 +341 2 17.0565491 3.3779132 11.837102 +342 2 13.9683828 4.9355984 9.7644243 +343 2 13.2088966 3.5856955 10.9557344 +344 2 17.0608349 15.3511973 7.840138 +345 2 16.0851803 6.1651096 9.9449912 +346 2 20.084753 9.891963 12.1574612 +347 2 16.7228508 12.686369 4.2434297 +348 2 16.2126885 13.6808558 5.814384 +349 2 14.4401722 12.9947462 3.111999 +350 2 14.386672 11.6485825 5.0800624 +351 2 14.1988459 10.6616144 1.9846456 +352 2 18.7906285 15.3961868 12.3562222 +353 2 12.9127542 10.4679089 0.1794854 +354 2 15.9088336 12.4348412 1.3523814 +355 2 18.1601753 12.3251934 2.948573 +356 2 17.1620522 10.409998 1.4453893 +357 2 16.5126477 10.4086428 0.2385434 +358 2 22.8113747 15.6401844 13.055027 +359 2 14.8627272 9.4326725 2.3018608 +360 2 15.3525057 8.4170704 0.7407537 +361 2 17.1134205 9.0686073 3.3598831 +362 2 17.742014 11.2442045 5.0413885 +363 2 18.9724408 12.1368418 6.7571521 +364 2 18.0104313 10.4569445 6.6545396 +365 2 15.6390295 9.6384011 5.1507344 +366 2 13.3918743 9.7835646 3.5733695 +367 2 15.2989292 12.1445875 6.6875849 +368 2 14.1242752 10.2773419 6.2548013 +369 2 16.7222691 12.0112705 12.858862 +370 2 16.0926933 11.2683106 3.4151967 +371 2 19.9223938 13.5259228 6.8102441 +372 2 19.2760239 14.3605404 10.8059387 +373 2 16.9918004 14.6569147 9.7397204 +374 2 17.0109062 13.340929 11.7210408 +375 2 16.2833519 12.5726357 8.0045042 +376 2 18.4102764 14.1759806 7.9251696 +377 2 20.1962414 13.764123 9.867386 +378 2 19.8544064 11.6713095 8.4634905 +379 2 17.4368973 10.5860148 8.5494595 +380 2 19.2533951 10.7177439 10.5836563 +381 2 20.331974 12.9591132 11.6307554 +382 2 18.2162132 11.3384009 11.7820378 +383 2 16.4878979 11.8049517 9.779047 +384 2 18.0500622 12.5811568 9.6572714 diff --git a/examples/water_SCAN/ice04/npt.json b/examples/water_SCAN/ice04/npt.json new file mode 100644 index 00000000..9bfd4abb --- /dev/null +++ b/examples/water_SCAN/ice04/npt.json @@ -0,0 +1,19 @@ +{ + "equi_conf": "conf.lmp", + "model": "graph.pb", + "model_mass_map": [16, 2], + "nsteps": 1000000, + "dt": 0.0005, + "ens": "npt-tri", + "temp": 150, + "pres": 10000, + "tau_t": 0.1, + "tau_p": 0.5, + + "stat_freq": 10, + "dump_freq": 100000, + "stat_skip": 30000, + "stat_bsize": 10000, + + "_comment": "that's all" +} diff --git a/examples/water_SCAN/ice04/nvt.json b/examples/water_SCAN/ice04/nvt.json new file mode 100644 index 00000000..f04b8c07 --- /dev/null +++ b/examples/water_SCAN/ice04/nvt.json @@ -0,0 +1,19 @@ +{ + "equi_conf": "npt_avg.lmp", + "model": "graph.pb", + "model_mass_map": [16, 2], + "nsteps": 200000, + "dt": 0.0005, + "ens": "nvt", + "temp": 150, + "pres": 10000, + "tau_t": 0.1, + "tau_p": 0.5, + + "stat_freq": 10, + "dump_freq": 1000, + "stat_skip": 10000, + "stat_bsize": 2000, + + "_comment": "that's all" +} diff --git a/examples/water_SCAN/ice04/path-p.json b/examples/water_SCAN/ice04/path-p.json new file mode 100644 index 00000000..f2aaef1f --- /dev/null +++ b/examples/water_SCAN/ice04/path-p.json @@ -0,0 +1,21 @@ +{ + "equi_conf":"conf.lmp", + "copies": [1,1,1], + "model": "graph.pb", + "model_mass_map": [ + 16, + 2 + ], + "nsteps": 100000, + "dt": 0.0005, + "ens": "npt-tri", + "path": "p", + "temps": 150, + "press": ["0:20000:2000", "20000"], + "tau_t": 0.1, + "tau_p": 0.5, + "stat_freq": 10, + "stat_skip": 5000, + "stat_bsize": 1000, + "_comment": "that's all" +} diff --git a/examples/water_SCAN/ice04/path-t.json b/examples/water_SCAN/ice04/path-t.json new file mode 100644 index 00000000..dcd47844 --- /dev/null +++ b/examples/water_SCAN/ice04/path-t.json @@ -0,0 +1,21 @@ +{ + "equi_conf":"conf.lmp", + "copies": [1,1,1], + "model": "graph.pb", + "model_mass_map": [ + 16, + 2 + ], + "nsteps": 100000, + "dt": 0.0005, + "ens": "npt-tri", + "path": "t", + "temps": ["50:400:5", "400"], + "press": 10000, + "tau_t": 0.1, + "tau_p": 0.5, + "stat_freq": 10, + "stat_skip": 5000, + "stat_bsize": 1000, + "_comment": "that's all" +} diff --git a/pyproject.toml b/pyproject.toml index 619dec04..ad97ff6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,13 +20,13 @@ readme = "README.md" requires-python = ">3.6" keywords = ["free energy", "thermodynamics integration", "deepmd-kit"] dependencies = [ - "apache-airflow >= 2.0", + # "apache-airflow >= 2.0", "scipy", "numpy", "pymbar", "dargs", "dpdispatcher >= 0.3", - "sqlalchemy >=1.4.28,<2.0", + "sqlalchemy", ] [project.urls] diff --git a/tests/benchmark_gdi/deepmd/0/in.lammps b/tests/benchmark_gdi/deepmd/0/in.lammps index ff8c29e7..d9d4c48d 100644 --- a/tests/benchmark_gdi/deepmd/0/in.lammps +++ b/tests/benchmark_gdi/deepmd/0/in.lammps @@ -25,7 +25,7 @@ timestep 0.002 thermo ${THERMO_FREQ} compute allmsd all msd thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*] -thermo_modify format 4*8 %20.6f +thermo_modify format float %20.6f dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} iso ${PRES} ${PRES} ${TAU_P} fix mzero all momentum 10 linear 1 1 1 diff --git a/tests/benchmark_ti/path-p/in.lammps b/tests/benchmark_ti/path-p/in.lammps index 008a3483..3bb386f1 100644 --- a/tests/benchmark_ti/path-p/in.lammps +++ b/tests/benchmark_ti/path-p/in.lammps @@ -26,7 +26,7 @@ timestep 0.002 thermo ${THERMO_FREQ} compute allmsd all msd thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*] -thermo_modify 4*8 format %20.6f +thermo_modify float format %20.6f dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} aniso ${PRES} ${PRES} ${TAU_P} couple xy fix mzero all momentum 10 linear 1 1 1 diff --git a/tests/benchmark_ti/path-p/task.000006/in.lammps b/tests/benchmark_ti/path-p/task.000006/in.lammps index c8720fb6..3b9fda1f 100644 --- a/tests/benchmark_ti/path-p/task.000006/in.lammps +++ b/tests/benchmark_ti/path-p/task.000006/in.lammps @@ -26,7 +26,7 @@ timestep 0.002 thermo ${THERMO_FREQ} compute allmsd all msd thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*] -thermo_modify format 4*8 %20.6f +thermo_modify format float %20.6f dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} aniso ${PRES} ${PRES} ${TAU_P} couple xy fix mzero all momentum 10 linear 1 1 1 diff --git a/tests/benchmark_ti/path-t/task.000006/in.lammps b/tests/benchmark_ti/path-t/task.000006/in.lammps index 78d6e681..78086736 100644 --- a/tests/benchmark_ti/path-t/task.000006/in.lammps +++ b/tests/benchmark_ti/path-t/task.000006/in.lammps @@ -25,7 +25,7 @@ timestep 0.002 thermo ${THERMO_FREQ} compute allmsd all msd thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*] -thermo_modify 4*8 format %20.6f +thermo_modify format float %20.6f dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} aniso ${PRES} ${PRES} ${TAU_P} couple xy fix mzero all momentum 10 linear 1 1 1 diff --git a/tests/benchmark_ti_water/new_job/task.000003/in.lammps b/tests/benchmark_ti_water/new_job/task.000003/in.lammps index 731c0ed5..f9bc96cc 100644 --- a/tests/benchmark_ti_water/new_job/task.000003/in.lammps +++ b/tests/benchmark_ti_water/new_job/task.000003/in.lammps @@ -27,7 +27,7 @@ timestep 0.0005 thermo ${THERMO_FREQ} compute allmsd all msd thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*] -thermo_modify format 4*8 %20.6f +thermo_modify format float %20.6f dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} iso ${PRES} ${PRES} ${TAU_P} fix mzero all momentum 10 linear 1 1 1 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..0e826b92 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,15 @@ +import os +import sys + +from _pytest.config import Config # type: ignore + +project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +sys.path.insert(0, project_root) + + +def pytest_configure(config: Config) -> None: + """Print paths information before any test collection starts.""" + print("\n" + "=" * 50) + print(f"Running tests from: {os.path.abspath(__file__)}") + print(f"Project root: {project_root}") + print("=" * 50 + "\n") diff --git a/tests/graph.pb b/tests/graph.pb index 4455db4c..ac261022 100644 --- a/tests/graph.pb +++ b/tests/graph.pb @@ -2,3 +2,8 @@ # origin file Sn SCAN functional label:continue-2/000 by yfb222333@gmail.com; github:felix5572 # model version 1.2: wget https://deepmd-kit.oss-cn-beijing.aliyuncs.com/graph.pb # model version 2.0: wget https://deepmd-kit.oss-cn-beijing.aliyuncs.com/graph_Sn_convert_from_1.2_to_2.0.pb +# compressed model: wget https://huggingface.co/Felix5572/Sn-SCAN-Compressed/resolve/main/graph.pb -O Sn_SCAN_compressed.pb +# +# +# For water compressed model (SCAN, Phase diagram, PRL) +# wget https://huggingface.co/Felix5572/Water-Ice-SCAN-Phase-Dirgram/resolve/main/graph.pb -O H2O-Phase-Diagram-model_compressed.pb diff --git a/tests/test_hti_ff_spring.py b/tests/test_hti_ff_spring.py index 7f8d4a86..095d8682 100644 --- a/tests/test_hti_ff_spring.py +++ b/tests/test_hti_ff_spring.py @@ -50,22 +50,21 @@ def test_spring_multiple_element(self): ret2 = dpti.hti._ff_spring(**input) self.assertEqual(ret1, ret2) - -def test_spring_var_spring_multiple_element(self): - input = {"lamb": 0.20, "m_spring_k": [118.71, 207.2], "var_spring": False} - ret1 = textwrap.dedent( - """\ - group type_1 type 1 - group type_2 type 2 - fix l_spring_1 type_1 spring/self 9.4968000000e+01 - fix_modify l_spring_1 energy yes - fix l_spring_2 type_2 spring/self 1.6576000000e+02 - fix_modify l_spring_2 energy yes - variable l_spring equal f_l_spring_1+f_l_spring_2 - """ - ) - ret2 = dpti.hti._ff_spring(**input) - self.assertEqual(ret1, ret2) + def test_spring_var_spring_multiple_element(self): + input = {"lamb": 0.20, "m_spring_k": [118.71, 207.2], "var_spring": False} + ret1 = textwrap.dedent( + """\ + group type_1 type 1 + group type_2 type 2 + fix l_spring_1 type_1 spring/self 1.1871000000e+02 + fix_modify l_spring_1 energy yes + fix l_spring_2 type_2 spring/self 2.0720000000e+02 + fix_modify l_spring_2 energy yes + variable l_spring equal f_l_spring_1+f_l_spring_2 + """ + ) + ret2 = dpti.hti._ff_spring(**input) + self.assertEqual(ret1, ret2) if __name__ == "__main__": diff --git a/tests/test_ti_gen_lammps_input.py b/tests/test_ti_gen_lammps_input.py index 1c7b05e6..f81087a5 100644 --- a/tests/test_ti_gen_lammps_input.py +++ b/tests/test_ti_gen_lammps_input.py @@ -62,7 +62,7 @@ def test_deepmd(self, patch_random): thermo ${THERMO_FREQ} compute allmsd all msd thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*] - thermo_modify format 4*8 %20.6f + thermo_modify format float %20.6f dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} iso ${PRES} ${PRES} ${TAU_P} fix mzero all momentum 10 linear 1 1 1 @@ -128,7 +128,7 @@ def test_meam(self, patch_random): thermo ${THERMO_FREQ} compute allmsd all msd thermo_style custom step ke pe etotal enthalpy temp press vol c_allmsd[*] - thermo_modify format 4*8 %20.6f + thermo_modify format float %20.6f dump 1 all custom ${DUMP_FREQ} traj.dump id type x y z fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} iso ${PRES} ${PRES} ${TAU_P} fix mzero all momentum 10 linear 1 1 1 diff --git a/workflow/README.md b/workflow/README.md new file mode 100644 index 00000000..a7be4813 --- /dev/null +++ b/workflow/README.md @@ -0,0 +1,266 @@ + + +# Airflow installation document. (deprecated) + +airflow installation document. (deprecated) + + + + +## manually + +```bash + # copy dpti'workflow file + cp /path-to-dpti/workflow/DpFreeEnergy.py ~/airflow/dags/ + + # create a workdir and copy example files + cp /path-to-dpti/examples/*json /path-to-a-work-dir/ + + # start our airflow job + cd /path-to-a-work-dir/ + cat ./airflow.sh + + airflow dags trigger TI_taskflow --conf $(printf "%s" $(cat FreeEnergy.json)) + +``` + + + +## + +## 🕹install postgresql database +Airflow use relation database as backend. And PostgreSQL is widely used in airflow community.
+ + +### install database +airflow's introduction on how to set up database backend: [apache-airflow:set up database](https://airflow.apache.org/docs/apache-airflow/stable/howto/set-up-database.html) +```bash +# install apache-airflow postgresql module +pip install apache-airflow-providers-postgres + +# install postgresql +yum install postgresql + +# enable postgresql service +systemctl start postgresql + +# enter posgresql +psql + +``` + + + +### create database and database user +```sql +CREATE DATABASE airflow_db1; +CREATE USER airflow_user1 WITH PASSWORD 'airflow_user1'; +GRANT ALL PRIVILEGES ON DATABASE airflow_db1 TO airflow_user1; +``` + +### + +### configure airflow configure file to connect database +configure ~/airflow/airflow.cfg
+ +``` +# change the following item with the sql above +# sql_alchemy_conn = sqlite:////home/fengbo/airflow/airflow.db +# sql_alchemy_conn = postgres://airflow:airflow@localhost:5432/airflow +sql_alchemy_conn = postgresql+psycopg2://:@:/ +``` + +### configure apache-airflow +reset db and webserver scheduler +``` +# reset db +airflow db init +# -D flag represent daemonize +airflow webserver # -p 8080 -D +airflow scheduler # -D +``` + +### airflow webserver + +If things work well, we could type the ip and prot in the web Browser and use the web service to monitor and manage the tasks operated by apache-airflow. + +We refer to this doc [apache-airflow webserver guide](https://airflow.apache.org/docs/apache-airflow/stable/security/webserver.html) for further information. + +after login(usually with default username and password:airflow, airflow) + +[![template_webserver.png](https://s11.ax1x.com/2024/02/19/pFYmlWj.png)](https://imgse.com/i/pFYmlWj) + +
+ + + +### ssh to use the webserver + +Sometime, apache-airflow runs on remote machine and user can `ssh` to contect to the cloud server by command like ` ssh -L localhost:8080:localhost:8080 user1@67.xxx.xxx.25`  and visit [http://localhost:8080/](http://localhost:8080/) to monitor the free energy calculation tasks process. + +### apache-airflow: further instruction + +The backend of this software is based on the software `airflow`. The following command can start the calculation. + +
+
The first command is used for calculate the free energy of solid.
The second command is used for calculate the free energy of liquid.
+ +```bash +airflow trigger_dag HTI_taskflow --conf $(printf "%s" $(cat FreeEnergy.json)) +airflow trigger_dag TI_taskflow --conf $(printf "%s" $(cat FreeEnergy.meam.json)) +``` +#### FreeEnergy.json + +We usually want to calculate the free energy of a metal at a specific pressure or temperature. And the crystal structure of the metal can be various. For example, we want to calculate the free energy of metal Sn of bcc structure at 200 K and 50000 bar (5GPa). In order to caculate the per atom free energy of metal Sn. First, We must prepare a configuration file named bcc.lmp and modify the [FreeEnergy.json](#ULX0o) or [FreeEnergyLiquid.json](#WuLBQ) and modify the key-value pair like "structure": "bcc", "target_temp": 200, "target_press" : 50000. And decide whether to integrate along the t(temperature) path or along the p(pressure) path . Modify the "path" key-value pair for this. The key-value pair "ensemble" for lammps MD simulation. Usually the ensemble shoule be consistent with the crystal intrinsic structure. That means we should set "npt-iso" for structure "bcc" to keep the simulation box changes simultaneously in x, y, z directions. + +#### ti-path json +Modify the ti.t.json or ti.p.json, and change the key-value pair "temps" or "press" . For ti.t.json, the tar_temp of FreeEnergy.json must be in the list which the key-value pair "temps" of ti.t.json represents. And similarly for ti.p.json, the tar_press of FreeEnergy.json must be in the list which the key-value pair "temps" of ti.t.json represents. + +#### workflow +1. Use the command `airflow trigger_dag`  mentioned above. This command will start a [airflow dag](https://airflow.apache.org/docs/apache-airflow/stable/concepts.html).This dag is wrote and maintained by the dpti software developer. It is used to make the calculation to be done more autocally . The user could monitor the task state and calculation procedure at [a website](#2aabcbd6). The user can also rerun, restart, delete the whole calculation or some part of the calculations. +2. Wait until the calculation finish. Usually the whole procedure continues for about 6 to 10 hours. The calculations will be done autocally. +3. Find the results in [Results Show](#2aabcbd6) part. The user could use the tables and data of it and plot the curve. + + +## For airflow workflow: + +Sometimes, we need to do **high-throughput** calculations(which means we need to calculate a series of temperature, pressure points for multiple phases). + +It would be a great burden for users to execute these tasks manually and monitor the tasks' execution. + +We provide the workflow tools based on apache-airflow workflow framework. + +>we refer this docs [airflow official docs](https://airflow.apache.org/docs/apache-airflow/stable/index.html) for more instructions. + + +### TI_Workflow +We implement a workflow de +implemented at `workflow/DpFreeEnergy.py` + +example dir and json: +``` +cd examples/ +cat examples/FreeEnergy.json +``` + +Requirement: setup apache-airflow or use the docker version dpti +``` +docker run --name dpti -p 9999:8080 -it deepmodeling/dpti:latest /bin/bash +docker exec -it dpti /bin/bash +``` +Then we provide a basic example for apache-airflow usage + +``` +# pwd at /home/airflow/ +cd dpti/examples/ +airflow dags trigger TI_taskflow --conf $(printf "%s" $(cat FreeEnergy.json)) +``` + + + +**Input:** Lammps structure file. + +**Output:** free energy values at given temperature and pressure. + +**Parameters:** Given temperature(or the range), Given pressure(or therange), force field,Lammps simulation ensemble and etc. + +we implement a workflow called TI_taskflow: +It includes these steps: +1. npt simulation to get lattice constant. +2. nvt simulation. +3. HTI: free energy at given temperature and pressure +4. TI: free energy values at the given range of temperature/pressure. + +### website to manage and monitor these jobs. + + + +## For airflow workflow: + +Sometimes, we need to do **high-throughput** calculations(which means we need to calculate a series of temperature, pressure points for multiple phases). + +It would be a great burden for users to execute these tasks manually and monitor the tasks' execution. + +We provide the workflow tools based on apache-airflow workflow framework. + +>we refer this docs [airflow official docs](https://airflow.apache.org/docs/apache-airflow/stable/index.html) for more instructions. + + +### TI_Workflow +We implement a workflow de +implemented at `workflow/DpFreeEnergy.py` + +example dir and json: +``` +cd examples/ +cat examples/FreeEnergy.json +``` + +Requirement: setup apache-airflow or use the docker version dpti +``` +docker run --name dpti -p 9999:8080 -it deepmodeling/dpti:latest /bin/bash +docker exec -it dpti /bin/bash +``` +Then we provide a basic example for apache-airflow usage + +``` +# pwd at /home/airflow/ +cd dpti/examples/ +airflow dags trigger TI_taskflow --conf $(printf "%s" $(cat FreeEnergy.json)) +``` + + + +**Input:** Lammps structure file. + +**Output:** free energy values at given temperature and pressure. + +**Parameters:** Given temperature(or the range), Given pressure(or therange), force field,Lammps simulation ensemble and etc. + +we implement a workflow called TI_taskflow: +It includes these steps: +1. npt simulation to get lattice constant. +2. nvt simulation. +3. HTI: free energy at given temperature and pressure +4. TI: free energy values at the given range of temperature/pressure. + +website to manage and monitor these jobs. + + + +# 📌Calculation Results and files + +
For each step, the result files are located at the corresponding location.
For example, we start a calculation at `/home/user1/metal_Sn/1_free_energy/400K-0bar-bcc-t`
+
For NPT MD simulation, the result file will locate at `/home/user1/metal_Sn/1_free_energy/400K-0bar-bcc-t/NPT_sim/result`
+
For TI simulation the result will locate at `/home/fengbo/4_Sn/1_free_energy/400K-0bar-bct-t/TI_sim/result`
+
You may want to use the result file and datas of TI_sim/result and plot the free_energy vs T curve for different structure and find the crossing point.
+ +For HTI simulation the result will locate at `/home/fengbo/4_Sn/1_free_energy/400K-0bar-bct-t/HTI_sim/result`, a pure txt file. + +The hti out file at +`new_job/02.spring_off/hti.out` which records the integration node on the path is also helpful. + + +# 💎The procedure of the free energy calculations + +
To calculate out Gibbs (or Helmholtz) free energy of the materials, there are four steps.
+ +1. NPT MD simulation +2. NVT MD simulation +3. Hamiltonian thermodynamic integration +4. thermodynamic integration + + +## FreeEnergy.json + +
FreeEnergy calculation settings for solid + +| Field | Type | Example | Discription | +| --- | --- | --- | --- | +| target_temp | positive integer | 200 | the temperature of HTI | +| target_press | non-negative integer | 50000 | unit :bar.the pressure of HTI | +| work_base_dir | string | "/home/user1/metal_Sn" | see note1. work  directory.  | +| ti_path | "t" or "p" | "t" | thermodynamic integration along temperature or pressure | +| conf_lmp | string | "bct.lmp" | see note1. the materials structure to be calculated | +| ens | string | "npt-iso" | MD simulation ensemble in lammps | +| if_liquid | bool | false | if simulate liquid |