Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 14, 2023
1 parent 6584e12 commit b8a1959
Show file tree
Hide file tree
Showing 71 changed files with 7,368 additions and 5,879 deletions.
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ We could use dpti to calculate out the Press-Volume phase diagram of metals.<br
**dpti** (deep potential thermodynamic integration) is a python package for calculating free energy, doing thermodynamic integration and figuring out pressure-temperature phase diagram for materials with molecular dynamics (MD) simulation methods.


<br />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.
<br />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.
<a name="xuFE2"></a>
# 🦴software introduction
At first, dpti is a collection of python scripts to generate LAMMPS input scripts and to anaylze results from LAMMPS logs.<br />
Expand Down Expand Up @@ -66,19 +66,19 @@ airflow users create \
--lastname Parker \
--role Admin \
--email [email protected]

# you will be requested to enter the password here.


# start airflow's webserver to manage your workflow use "-D" option to daemon it
airflow webserver --port 8080 --hostname 127.0.0.1

# start airflwo scheduler
airflow scheduler

# if ariflow web server start at the personal computer,
# you could go to http://localhost:8080/ to view it
# if airflow runs on remote server
# if airflow runs on remote server
# you could use ssh to conntect to server
# ssh -CqTnN -L localhost:8080:localhost:8080 [email protected]
```
Expand All @@ -89,23 +89,23 @@ airflow users create \


```bash
# copy dpti'workflow file
# 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))

```


<a name="262831afc14feddc64db20cb6be8fd0d"></a>
##
##
<a name="ad87a3d8509a6920e3e849cb1b423f31"></a>
## 🕹install postgresql database
Airflow use relation database as backend. And PostgreSQL is widely used in airflow community.<br />
Expand All @@ -130,14 +130,14 @@ psql


<a name="iFkxm"></a>
### create database and database user
### 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;
```
<a name="Glyxy"></a>
###
###
<a name="gQvK2"></a>
### configure airflow configure file to connect database
configure ~/airflow/airflow.cfg<br />
Expand Down Expand Up @@ -206,7 +206,7 @@ The user can ssh contect to the aliyun cloud server by command like ` ssh -L lo

<br />To calculate out Gibbs (or Helmholtz) free energy of the materials, there are four steps.<br />

1. NPT MD simulation
1. NPT MD simulation
1. NVT MD simulation
1. Hamiltonian thermodynamic integration
4. thermodynamic integration
Expand All @@ -221,7 +221,7 @@ Run a long MD simulation and we will get the lattice constant and the best simul
Run a long MD simulation with the end structure of NPT simulations. We will know whether the box is reasonable enough from the results of this MD simulation.
<a name="14932184266288e8651c16aebdbfbb8e_h2_2"></a>
## Hamiltonian thermodynamic integration (HTI)
We will know the Gibbs (or Helmholtz) free energy at the specific temperature or pressure condition.
We will know the Gibbs (or Helmholtz) free energy at the specific temperature or pressure condition.
<a name="56937698a8d18e2013bea45f6dfe5890_h2_3"></a>
## thermodynamic integration (TI)
Integrating along the isothermal or isobaric path, We will know the free energy at different pressure and temperature.<br />
Expand Down Expand Up @@ -385,7 +385,7 @@ the settings used in thermodynamic integration (TI) for constant pressure and ch
| stat_bsize | integer | 200 | statistic batch size |

<a name="f3b978108de979f9529b07f01b19dc5d"></a>
#
#
<a name="cf0461961f6d77fdee29d68f2bc9982a"></a>
## ti.p.json
the settings used in thermodynamic integration (TI) for constant temperature and changeable pressure
Expand Down Expand Up @@ -432,4 +432,3 @@ The gdi.json is used for gibbs-duham integration. When you know the one point a
# **👀**Troubleshooting
TODO<br />
<br />

4 changes: 2 additions & 2 deletions conda/dpti/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
channel_sources:
channel_sources:
- conda-forge
channel_targets:
channel_targets:
- deepmodeling
46 changes: 23 additions & 23 deletions docs/main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
\usepackage{algpseudocode}
\usepackage{enumitem}
\usepackage{multirow}
\usepackage{epstopdf}
\usepackage{epstopdf}
\usepackage{hyperref}
\usepackage{footnote}
\usepackage[hang,flushmargin]{footmisc}
Expand Down Expand Up @@ -50,7 +50,7 @@ \section{Ideal Einstein crystal with COM constrained}
\frac{1}{N!} N!
\int e^{-\beta\sum_i\frac{p_i^2}{2m_i}} dp
\int e^{-\beta\sum_i \frac 12k(r_i - r_{i0})^2} dr \\
&=
&=
P \int e^{-\beta\sum_i \frac 12k(r_i - r_{i0})^2} dr \\
&=
P \Big( \frac{2\pi k_BT}{k} \Big)^{\frac{3N}2}
Expand All @@ -65,20 +65,20 @@ \section{Ideal Einstein crystal with COM constrained}
Q & =
P \int e^{-\beta\sum_i \frac 12k(r_i - r_{i0})^2} dr \\
& =
P \int e^{-\beta\sum_i \frac 12k(r_i - r_{i0})^2} \delta\big( \epsilon - \frac1N \sum_i (r_i - r_{i0}) \big) dr d\epsilon
P \int e^{-\beta\sum_i \frac 12k(r_i - r_{i0})^2} \delta\big( \epsilon - \frac1N \sum_i (r_i - r_{i0}) \big) dr d\epsilon
\end{align*}
Now consider $\hat r_i = r_i - \epsilon$, we have
\begin{align}\label{eqn:1}
Q & =
P \int e^{-\beta\sum_i \frac 12k(\hat r_i - r_{i0} + \epsilon)^2} \delta\big( \frac1N \sum_i (\hat r_i - r_{i0}) \big) d\hat r d\epsilon
P \int e^{-\beta\sum_i \frac 12k(\hat r_i - r_{i0} + \epsilon)^2} \delta\big( \frac1N \sum_i (\hat r_i - r_{i0}) \big) d\hat r d\epsilon
\end{align}
We have the observation that $ \frac 1N \sum (\hat r_i - r_{i0}) = \frac 1N \sum ( r_i - r_{i0}) - \epsilon = 0$, then
\begin{align*}
\sum_i (\hat r_i - r_{i0} + \epsilon)^2
&=
\sum_i (\hat r_i - r_{i0})^2 + 2\epsilon\sum_i (\hat r_i - r_{i0}) + N\epsilon^2 \\
&=
\sum_i (\hat r_i - r_{i0})^2 + N\epsilon^2
\sum_i (\hat r_i - r_{i0})^2 + N\epsilon^2
\end{align*}
Inserting this relation to \eqref{eqn:1}, we have
\begin{align}\nonumber
Expand All @@ -93,26 +93,26 @@ \section{Ideal Einstein crystal with COM constrained}
Now consider the constrain of the COM, we have the modified partition function
\begin{align*}
Q_\com
&=
&=
{P_\com}
\int e^{-\beta\sum_i \frac 12k(r_i - r_{i0})^2} \delta\big(\frac1N\sum_i (r_i - r_{i0})\big) dr
\int e^{-\beta\sum_i \frac 12k(r_i - r_{i0})^2} \delta\big(\frac1N\sum_i (r_i - r_{i0})\big) dr
\end{align*}
where $P_\com$ is the integration of the COM-constrained momentum part.
% We let $\epsilon = \frac1N \sum_i r_i - r_{i0}$, and consider the transformation $\hat r_i = r_i - \epsilon$.
% It is easily shown that $\sum_i \hat r_i - r_{i0} = 0$.
% We have,
% We have,
% \begin{align*}
% Q_\com
% &=
% &=
% {P_\com}
% \int e^{-\beta\sum_i \frac 12k(r_i - r_{i0})^2}
% \delta\big(\frac1N\sum_i r_i - \frac1N\sum_i r_{i0}\big)
% dr \\
% &=
% &=
% {P_\com}
% \int e^{-\beta\sum_i \frac 12k(\hat r_i - r_{i0} + \epsilon)^2}
% \delta\big(\frac1N\sum_i \hat r_i - \frac1N\sum_i r_{i0} + \epsilon\big)
% J \: d\hat r
% J \: d\hat r
% \end{align*}
% where $J$ is the Jacobian of the transformation.
% We notice that
Expand All @@ -128,7 +128,7 @@ \section{Ideal Einstein crystal with COM constrained}
\end{align}
so
\begin{align}
A - A_\com = -k_BT \ln(P/P_\com) - k_BT \ln \Lambda_k^3 + k_BT \ln N^{3/2}
A - A_\com = -k_BT \ln(P/P_\com) - k_BT \ln \Lambda_k^3 + k_BT \ln N^{3/2}
\end{align}
and
\begin{align}\label{eqn:5}
Expand All @@ -145,7 +145,7 @@ \subsection{Extension to the case of water}
\frac{1}{N_O!N_H!} N_O!N_H!
\int e^{-\beta\sum_i\frac{p_i^2}{2m_i}} dp
\int e^{-\beta\sum_i \frac 12km_i(r_i - r_{i0})^2} dr \\
&=
&=
P \int e^{-\beta\sum_i \frac 12km_i(r_i - r_{i0})^2} dr \\
&=
P
Expand All @@ -164,21 +164,21 @@ \subsection{Extension to the case of water}
P \int e^{-\beta\sum_i \frac 12km_i(r_i - r_{i0})^2} dr \\
& =
P \int e^{-\beta\sum_i \frac 12km_i(r_i - r_{i0})^2}
\delta\big( \epsilon - \frac1M \sum_i m_i (r_i - r_{i0}) \big) dr d\epsilon
\delta\big( \epsilon - \frac1M \sum_i m_i (r_i - r_{i0}) \big) dr d\epsilon
\end{align*}
Now consider the change of variables $\hat r_i = r_i - \epsilon$, we have
\begin{align}\label{eqn:8}
Q & =
P \int e^{-\beta\sum_i \frac 12km_i(\hat r_i - r_{i0} + \epsilon)^2}
\delta\big( \frac1M \sum_im_i(\hat r_i - r_{i0}) \big) d\hat r d\epsilon
\delta\big( \frac1M \sum_im_i(\hat r_i - r_{i0}) \big) d\hat r d\epsilon
\end{align}
We have the observation that $ \frac 1M \sum m_i(\hat r_i - r_{i0}) = \frac 1M \sum m_i( r_i - r_{i0}) - \epsilon = 0$, then
\begin{align*}
\sum_i m_i(\hat r_i - r_{i0} + \epsilon)^2
&=
\sum_i m_i(\hat r_i - r_{i0})^2 + 2\epsilon\sum_im_i (\hat r_i - r_{i0}) + M\epsilon^2 \\
&=
\sum_i m_i(\hat r_i - r_{i0})^2 + M\epsilon^2
\sum_i m_i(\hat r_i - r_{i0})^2 + M\epsilon^2
\end{align*}
Inserting this relation to \eqref{eqn:8}, we have
\begin{align}\nonumber
Expand All @@ -194,17 +194,17 @@ \subsection{Extension to the case of water}
Now consider the constrain of the COM, we have the modified partition function
\begin{align*}
Q_\com
&=
&=
{P_\com}
\int e^{-\beta\sum_i \frac 12km_i(r_i - r_{i0})^2} \delta\big(\frac1M\sum_i m_i(r_i - r_{i0})\big) dr
\int e^{-\beta\sum_i \frac 12km_i(r_i - r_{i0})^2} \delta\big(\frac1M\sum_i m_i(r_i - r_{i0})\big) dr
\end{align*}
Then we have
\begin{align}
\frac{Q}{Q_\com} = \frac{P}{P_\com}\Big( \frac{2\pi k_BT}k \Big)^{\frac32} M^{-\frac32}
\end{align}
so
\begin{align}
A - A_\com = -k_BT \ln(P/P_\com) - k_BT \ln \Lambda_k^3 + k_BT \ln M^{3/2}
A - A_\com = -k_BT \ln(P/P_\com) - k_BT \ln \Lambda_k^3 + k_BT \ln M^{3/2}
\end{align}
and
\begin{align}\label{eqn:10}
Expand Down Expand Up @@ -264,7 +264,7 @@ \section{Translational invariant system with CM constrained}
&=
A^0_\com + (A - A_\com) \\
&=
Nk_BT\ln \Lambda_p^3
Nk_BT\ln \Lambda_p^3
-N_Ok_BT\ln\Lambda_{k,O}^3
-N_Hk_BT\ln\Lambda_{k,H}^3
+ k_BT\ln\Lambda_k^3
Expand Down Expand Up @@ -321,7 +321,7 @@ \section{Ideal gas with springs}
\frac{1}{h^{3N}}\frac{1}{N_O! 2^{N_O}}
(2\pi m k_BT)^{\frac{3N}{2}}
V^{N_O}
% \Big(\frac{\pi k_BT}{k}\Big)^{\frac{3N_H}2}
% \Big(\frac{\pi k_BT}{k}\Big)^{\frac{3N_H}2}
\Big(\int e^{-\beta k(r - r_0)^2 } d\bm r\Big)^{N_H} \\
&=
\frac{1}{N_O! 2^{N_O}}
Expand All @@ -333,7 +333,7 @@ \section{Ideal gas with springs}
To compute
\begin{align*}
V_H = \int e^{-\beta k(r - r_0)^2 } d\bm r
&=
&=
\int_0^\pi\int_0^{2\pi}\int_0^\infty e^{-\beta k(r - r_0)^2 } r^2\sin\phi dr d\theta d\phi\\
&=
4\pi\int e^{-\beta k(r - r_0)^2 } r^2 dr\\
Expand Down Expand Up @@ -371,7 +371,7 @@ \section{Ideal gas with springs}
= \frac{Nk_BT}{V} +
\frac{1}{3V}
\Big\langle
\sum_i \bm r_i\cdot\bm F_i
\sum_i \bm r_i\cdot\bm F_i
\Big\rangle
= \frac{Nk_BT}{V} +
\frac{1}{6V}
Expand Down
12 changes: 4 additions & 8 deletions dpti/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import sys
import os
import sys

NAME = "dpti"
SHORT_CMD = "dpti"
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
import dpti
from . import lib
from . import equi
from . import hti
from . import hti_liq
from . import ti
from . import gdi

from . import equi, gdi, hti, hti_liq, lib, ti
Loading

0 comments on commit b8a1959

Please sign in to comment.