Unverified Commit e5fe159c authored by Jan Janssen's avatar Jan Janssen Committed by GitHub
Browse files

Update 00-IntroductionDay2.ipynb

parent 887d8538
%% Cell type:markdown id: tags:
# Day 2 - Parameterization of interatomic potentials
%% Cell type:markdown id: tags:
In this tutorial we will do simple fits for three different interatomic potentials.
* Embedded Atom Method Potential
* Neural Network Potential
* Atomic Cluster Expansion
Some details of these potentials will be summarized in the following.
%% Cell type:markdown id: tags:
## Embedded Atom Method Potential
%% Cell type:markdown id: tags:
* Atomic descriptors: pair functions
$\rho_i = \sum_j \phi(r_{ij})$ (density)
$V_i = \sum_j V(r_{ij})$ (pair repulsion)
* Atomic energy
$E_i = F( \rho_i ) + V_i$
with non-linear embedding function $F$
%% Cell type:markdown id: tags:
## Neural Network Potential
%% Cell type:markdown id: tags:
* Atomic descriptors: pair and three-body symmetry functions
$G_i = \sum_j \phi(r_{ij})$
$G_i = \sum_{jk} \phi(r_{ij},r_{ik}, \cos_{jik})$
* Atomic energy
$E_i = NN(G_i)$
with neural network $NN$. Various different $G_i$ are the inputs to the $NN$.
%% Cell type:markdown id: tags:
## Atomic Cluster Expansion
%% Cell type:markdown id: tags:
* Atomic descriptors: pair, three-body, ... many-body basis functions
$A_i = \sum_j \phi(\pmb{r}_{ij})$ (many different basis functions that depend on direction and length of $r_{ij}$)
$\varphi_i = c_1 A_i + c_2 A_i A_i + c_3 A_i A_i A_i + ...$
* Atomic energy
$E_i = F(\varphi_i)$
with general non-linear function $F$ and several $\varphi_i$. In the tutorial we will use $E_i = \sqrt{\varphi^{(1)}_i} + \varphi^{(2)}_i$ to make contact to the Embedded Atom Method.
%% Cell type:markdown id: tags:
# Reference data
%% Cell type:markdown id: tags:
The potentials are parameterized by fitting to reference data. Here we use DFT data for Cu that we generated with the FHI-aims code. In the following we summarize key properties of the dataset.
%% Cell type:code id: tags:
``` python
%pylab inline
```
%% Output
Populating the interactive namespace from numpy and matplotlib
%% Cell type:code id: tags:
``` python
import pandas as pd
```
%% Cell type:code id: tags:
``` python
from pyiron import Project
```
%% Cell type:code id: tags:
``` python
def proces_df(df):
df["energy_per_atom"] = df["energy"]/df["number_of_atoms"]
df["volume"]=df["atoms"].map(lambda at: at.get_volume())
df["volume_per_atom"] = df["volume"]/df["number_of_atoms"]
```
%% Cell type:code id: tags:
``` python
data_pr = Project("../datasets/import_database/")
data_pr = Project("..")
```
%% Cell type:code id: tags:
``` python
data_pr.job_table()
```
%% Output
id status chemicalformula job \
0 303 finished None df1_A1_A2_A3_EV_elast_phon
1 304 finished None df3_10k
2 305 finished None df2_1k
3 306 finished None df4_2_5eV_25A3_8K
subjob projectpath \
0 /df1_A1_A2_A3_EV_elast_phon /home/yury/PycharmProjects/pyiron-2021/
1 /df3_10k /home/yury/PycharmProjects/pyiron-2021/
2 /df2_1k /home/yury/PycharmProjects/pyiron-2021/
3 /df4_2_5eV_25A3_8K /home/yury/PycharmProjects/pyiron-2021/
project \
0 pyiron_potentialfit/datasets/import_database/Cu_database/
1 pyiron_potentialfit/datasets/import_database/Cu_database/
2 pyiron_potentialfit/datasets/import_database/Cu_database/
3 pyiron_potentialfit/datasets/import_database/Cu_database/
timestart timestop totalcputime computer \
0 2021-02-18 19:49:53.061360 None None zora@cmti001#1
1 2021-02-18 19:49:55.496691 None None zora@cmti001#1
2 2021-02-18 19:49:56.101883 None None zora@cmti001#1
3 2021-02-18 19:49:57.547918 None None zora@cmti001#1
hamilton hamversion parentid masterid
0 TrainingContainer 0.4 None None
1 TrainingContainer 0.4 None None
2 TrainingContainer 0.4 None None
3 TrainingContainer 0.4 None None
%% Cell type:code id: tags:
``` python
df1_job = data_pr.load('df1_A1_A2_A3_EV_elast_phon')
df2_job = data_pr.load('df2_1k')
df3_job = data_pr.load('df3_10k')
df4_job = data_pr.load('df4_2_5eV_25A3_8K')
```
%% Cell type:code id: tags:
``` python
df1 = df1_job.to_pandas()
df2 = df2_job.to_pandas()
df3 = df3_job.to_pandas()
df4 = df4_job.to_pandas()
dfs = [df1,df2,df3,df4]
```
%% Cell type:code id: tags:
``` python
for df in dfs:
proces_df(df)
```
%% Cell type:code id: tags:
``` python
df_size=[len(df) for df in dfs]
df_num_atoms=[int(df["number_of_atoms"].sum()) for df in dfs]
labels=["df1","df2","df3","df4"]
```
%% Cell type:code id: tags:
``` python
df_stats = pd.DataFrame({"Name":labels, "Structures":df_size, "Atoms":df_num_atoms})
df_stats
```
%% Output
Name Structures Atoms
0 df1 105 368
1 df2 1000 11309
2 df3 10000 84133
3 df4 8073 71979
%% Cell type:markdown id: tags:
* Dataset1 (df1): 105 structures: E-V, elastic matrix and phonopy deformations for fcc, bcc, hcp
* Dataset2 (df2): 1k structures: Dataset1+ more prototypes (ideal and distroted), selected within 1eV window above groundstate
* Dataset3 (df3): 10k structures: Dataset2 + long-range E-V curves + 1000 fcc surface structures (stretched, shaked, etc.)
* Dataset4 (df4): 8k structures: all structures within 2.5eV/atom window above ground state and up to 25 A^3/atom volume
%% Cell type:code id: tags:
``` python
xs = np.arange(len(df_size))
width = 0.75
colors=["red","green","blue","orange"]
fig, (ax,ax2) = plt.subplots(1,2,figsize=(6,3), dpi=150)
ax.bar(df_stats.index, df_stats["Structures"], width=width, color=colors)
ax.set_yscale('log')
ax.set_title('Number of structures')
ax.set_xticks(df_stats.index)
ax.set_xticklabels(df_stats["Name"])
ax2.bar(df_stats.index, df_stats["Atoms"], width=width, color=colors)
ax2.set_yscale('log')
ax2.set_title('Number of atoms')
ax2.set_xticks(df_stats.index)
ax2.set_xticklabels(df_stats["Name"])
fig.tight_layout()
```
%% Output
%% Cell type:code id: tags:
``` python
alpha= 0.35
s=25
plt.figure(figsize=(10,5), dpi=150)
plt.scatter(df3["volume_per_atom"], df3["energy_per_atom"], label="df3", s=s, color="blue",ec=None, alpha=alpha)
plt.scatter(df4["volume_per_atom"], df4["energy_per_atom"], label="df4", s=s, color="orange",ec=None, alpha=alpha)
plt.scatter(df2["volume_per_atom"], df2["energy_per_atom"], label="df2", s=s, color="green",ec=None, alpha=alpha)
plt.scatter(df1["volume_per_atom"], df1["energy_per_atom"], label="df1", s=s, color="red",ec=None, alpha=alpha)
plt.xscale('log')
plt.xlabel('V, $\\AA^3$/atom')
plt.ylabel('E, eV/atom')
plt.legend()
```
%% Output
<matplotlib.legend.Legend at 0x7f7f3fef9220>
%% Cell type:code id: tags:
``` python
```
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment