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

Update ex_xx_validation.ipynb

parent 03861de1
......@@ -20,8 +20,7 @@
"metadata": {},
"outputs": [],
"source": [
"from pyiron import Project\n",
"import pyiron_gpl"
"from pyiron import Project"
]
},
{
......@@ -1968,7 +1967,7 @@
"metadata": {},
"outputs": [],
"source": [
"pr_import = Project(\"import_database\")\n",
"pr_import = Project(\"../datasets\")\n",
"if len(pr_import.job_table()) == 0:\n",
" pr_import.unpack(\"Cu_training_archive\")"
]
......
%% Cell type:code id:decreased-jumping tags:
``` python
import numpy as np
%matplotlib inline
import matplotlib.pylab as plt
import pandas as pd
```
%% Cell type:code id:monetary-county tags:
``` python
from pyiron import Project
import pyiron_gpl
```
%% Cell type:code id:based-croatia tags:
``` python
pr = Project("validation")
#pr.remove_jobs(recursive=True)
```
%% Cell type:code id:deluxe-fight tags:
``` python
# The list of potentials to iterate over
potential_list = ['2012--Mendelev-M-I--Cu--LAMMPS--ipr1', '2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2', '1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1']
```
%% Cell type:code id:atmospheric-harbor tags:
``` python
# Do Murnaghan, ElasticMatrix job, vac formation energy, binding energy, surface energies, comparison with dataset forces, energies
```
%% Cell type:code id:seasonal-truck tags:
``` python
def clean_project_name(name):
return name.replace("-", "_")
```
%% Cell type:code id:elect-optics tags:
``` python
%%time
for pot in potential_list:
group_name = clean_project_name(pot)
pr_pot = pr.create_group(pot)
job_ref = pr_pot.create_job(pr_pot.job_type.Lammps, "ref_job")
job_ref.structure = pr_pot.create_ase_bulk("Cu")
job_ref.potential = pot
job_ref.calc_minimize()
murn_job = job_ref.create_job(pr_pot.job_type.Murnaghan, "murn_job")
murn_job.run()
murn_job.plot()
```
%%%% Output: stream
The job murn_job was saved and received the ID: 3880
The job strain_0_9 was saved and received the ID: 3881
The job strain_0_92 was saved and received the ID: 3882
The job strain_0_94 was saved and received the ID: 3883
The job strain_0_96 was saved and received the ID: 3884
The job strain_0_98 was saved and received the ID: 3885
The job strain_1_0 was saved and received the ID: 3886
The job strain_1_02 was saved and received the ID: 3887
The job strain_1_04 was saved and received the ID: 3888
The job strain_1_06 was saved and received the ID: 3889
The job strain_1_08 was saved and received the ID: 3890
The job strain_1_1 was saved and received the ID: 3891
job_id: 3881 finished
job_id: 3882 finished
job_id: 3883 finished
job_id: 3884 finished
job_id: 3885 finished
job_id: 3886 finished
job_id: 3887 finished
job_id: 3888 finished
job_id: 3889 finished
job_id: 3890 finished
job_id: 3891 finished
%%%% Output: display_data
%%%% Output: stream
The job murn_job was saved and received the ID: 3892
The job strain_0_9 was saved and received the ID: 3893
The job strain_0_92 was saved and received the ID: 3894
The job strain_0_94 was saved and received the ID: 3895
The job strain_0_96 was saved and received the ID: 3896
The job strain_0_98 was saved and received the ID: 3897
The job strain_1_0 was saved and received the ID: 3898
The job strain_1_02 was saved and received the ID: 3899
The job strain_1_04 was saved and received the ID: 3900
The job strain_1_06 was saved and received the ID: 3901
The job strain_1_08 was saved and received the ID: 3902
The job strain_1_1 was saved and received the ID: 3903
job_id: 3893 finished
job_id: 3894 finished
job_id: 3895 finished
job_id: 3896 finished
job_id: 3897 finished
job_id: 3898 finished
job_id: 3899 finished
job_id: 3900 finished
job_id: 3901 finished
job_id: 3902 finished
job_id: 3903 finished
%%%% Output: display_data
%%%% Output: stream
The job murn_job was saved and received the ID: 3904
The job strain_0_9 was saved and received the ID: 3905
The job strain_0_92 was saved and received the ID: 3906
The job strain_0_94 was saved and received the ID: 3907
The job strain_0_96 was saved and received the ID: 3908
The job strain_0_98 was saved and received the ID: 3909
The job strain_1_0 was saved and received the ID: 3910
The job strain_1_02 was saved and received the ID: 3911
The job strain_1_04 was saved and received the ID: 3912
The job strain_1_06 was saved and received the ID: 3913
The job strain_1_08 was saved and received the ID: 3914
The job strain_1_1 was saved and received the ID: 3915
job_id: 3905 finished
job_id: 3906 finished
job_id: 3907 finished
job_id: 3908 finished
job_id: 3909 finished
job_id: 3910 finished
job_id: 3911 finished
job_id: 3912 finished
job_id: 3913 finished
job_id: 3914 finished
job_id: 3915 finished
%%%% Output: display_data
%%%% Output: stream
CPU times: user 1min 23s, sys: 54 s, total: 2min 17s
Wall time: 2min 30s
%% Cell type:code id:alpha-plant tags:
``` python
murn_job["output/equilibrium_energy"]
```
%%%% Output: execute_result
-3.540132976728019
%% Cell type:code id:prescribed-bacteria tags:
``` python
def get_only_murn(job_table):
return job_table.hamilton == "Murnaghan"
def get_eq_vol(job_path):
return job_path["output/equilibrium_volume"]
def get_eq_lp(job_path):
return np.linalg.norm(job_path["output/structure/cell/cell"][0]) * np.sqrt(2)
def get_eq_bm(job_path):
return job_path["output/equilibrium_bulk_modulus"]
def get_potential(job_path):
return job_path["ref_job/input/potential/Name"]
def get_eq_energy(job_path):
return job_path["output/equilibrium_energy"]
def get_n_atoms(job_path):
return len(job_path["output/structure/positions"])
```
%% Cell type:code id:respiratory-killing tags:
``` python
%%time
table = pr.create_table("table_murn", delete_existing_job=True)
table.db_filter_function = get_only_murn
table.add["potential"] = get_potential
table.add["a"] = get_eq_lp
table.add["eq_vol"] = get_eq_vol
table.add["eq_bm"] = get_eq_bm
table.add["eq_energy"] = get_eq_energy
table.add["n_atoms"] = get_n_atoms
table.run()
data_murn = table.get_dataframe()
data_murn
```
%%%% Output: stream
100%|██████████| 3/3 [00:00<00:00, 405.55it/s]
0%| | 0/3 [00:00<?, ?it/s]
%%%% Output: stream
The job table_murn was saved and received the ID: 3916
%%%% Output: stream
100%|██████████| 3/3 [00:00<00:00, 13.59it/s]
%%%% Output: stream
CPU times: user 359 ms, sys: 266 ms, total: 625 ms
Wall time: 673 ms
%%%% Output: execute_result
job_id potential a eq_vol \
0 3880 Cu_Mendelev_eam 3.637410 12.031420
1 3892 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2 3.614942 11.809844
2 3904 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1 3.614840 11.808844
eq_bm eq_energy n_atoms
0 151.879230 -3.422980 1
1 135.774799 -3.539942 1
2 141.746540 -3.540133 1
%% Cell type:code id:prepared-antenna tags:
``` python
%%time
for pot in data_murn.potential.to_list():
group_name = clean_project_name(pot)
pr_pot = pr.create_group(pot)
job_id = int(data_murn[data_murn.potential==pot].job_id)
job_ref = pr_pot.create_job(pr_pot.job_type.Lammps, "ref_job")
job_ref.structure = pr_pot.inspect(job_id)["output/structure"].to_object()
job_ref.potential = pot
job_ref.calc_minimize()
elastic_job = job_ref.create_job(pr_pot.job_type.ElasticMatrixJob, "elastic_job")
elastic_job.run()
```
%%%% Output: stream
The job elastic_job was saved and received the ID: 3917
The job s_e_0 was saved and received the ID: 3918
The job s_01_e_m0_00500 was saved and received the ID: 3919
The job s_01_e_m0_00250 was saved and received the ID: 3920
The job s_01_e_0_00250 was saved and received the ID: 3921
The job s_01_e_0_00500 was saved and received the ID: 3922
The job s_08_e_m0_00500 was saved and received the ID: 3923
The job s_08_e_m0_00250 was saved and received the ID: 3924
The job s_08_e_0_00250 was saved and received the ID: 3925
The job s_08_e_0_00500 was saved and received the ID: 3926
The job s_23_e_m0_00500 was saved and received the ID: 3927
The job s_23_e_m0_00250 was saved and received the ID: 3928
The job s_23_e_0_00250 was saved and received the ID: 3929
The job s_23_e_0_00500 was saved and received the ID: 3930
The job elastic_job was saved and received the ID: 3931
The job s_e_0 was saved and received the ID: 3932
The job s_01_e_m0_00500 was saved and received the ID: 3933
The job s_01_e_m0_00250 was saved and received the ID: 3934
The job s_01_e_0_00250 was saved and received the ID: 3935
The job s_01_e_0_00500 was saved and received the ID: 3936
The job s_08_e_m0_00500 was saved and received the ID: 3937
The job s_08_e_m0_00250 was saved and received the ID: 3938
The job s_08_e_0_00250 was saved and received the ID: 3939
The job s_08_e_0_00500 was saved and received the ID: 3940
The job s_23_e_m0_00500 was saved and received the ID: 3941
The job s_23_e_m0_00250 was saved and received the ID: 3942
The job s_23_e_0_00250 was saved and received the ID: 3943
The job s_23_e_0_00500 was saved and received the ID: 3944
The job elastic_job was saved and received the ID: 3945
The job s_e_0 was saved and received the ID: 3946
The job s_01_e_m0_00500 was saved and received the ID: 3947
The job s_01_e_m0_00250 was saved and received the ID: 3948
The job s_01_e_0_00250 was saved and received the ID: 3949
The job s_01_e_0_00500 was saved and received the ID: 3950
The job s_08_e_m0_00500 was saved and received the ID: 3951
The job s_08_e_m0_00250 was saved and received the ID: 3952
The job s_08_e_0_00250 was saved and received the ID: 3953
The job s_08_e_0_00500 was saved and received the ID: 3954
The job s_23_e_m0_00500 was saved and received the ID: 3955
The job s_23_e_m0_00250 was saved and received the ID: 3956
The job s_23_e_0_00250 was saved and received the ID: 3957
The job s_23_e_0_00500 was saved and received the ID: 3958
CPU times: user 1min 26s, sys: 59.8 s, total: 2min 25s
Wall time: 2min 15s
%% Cell type:code id:humanitarian-insured tags:
``` python
plt.matshow(elastic_job["output/elasticmatrix"]["C"]);
```
%%%% Output: display_data
%% Cell type:code id:typical-executive tags:
``` python
elastic_job["output/elasticmatrix"]["C"].flatten()
```
%%%% Output: execute_result
array([168.78653632, 123.56991384, 123.56991384, 0. ,
0. , 0. , 123.56991384, 168.78653632,
123.56991384, 0. , 0. , 0. ,
123.56991384, 123.56991384, 168.78653632, 0. ,
0. , 0. , 0. , 0. ,
0. , 76.69333175, 0. , 0. ,
0. , 0. , 0. , 0. ,
76.69333175, 0. , 0. , 0. ,
0. , 0. , 0. , 76.69333175])
%% Cell type:code id:informational-brunei tags:
``` python
def get_elastic_constants(job_path):
return job_path["output/elasticmatrix"]["C"].flatten()
def get_only_elastic(job_table):
return job_table.hamilton == "ElasticMatrixJob"
```
%% Cell type:code id:contrary-lightning tags:
``` python
%%time
table = pr.create_table("table_elastic", delete_existing_job=True)
table.db_filter_function = get_only_elastic
table.add["potential"] = get_potential
table.add["C_list"] = get_elastic_constants
table.run()
data_elastic = table.get_dataframe()
data_elastic
```
%%%% Output: stream
100%|██████████| 3/3 [00:00<00:00, 204.45it/s]
0%| | 0/3 [00:00<?, ?it/s]
%%%% Output: stream
The job table_elastic was saved and received the ID: 3959
%%%% Output: stream
100%|██████████| 3/3 [00:00<00:00, 7.88it/s]
%%%% Output: stream
CPU times: user 531 ms, sys: 172 ms, total: 703 ms
Wall time: 861 ms
%%%% Output: execute_result
job_id potential \
0 3917 Cu_Mendelev_eam
1 3931 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2
2 3945 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1
C_list
0 [175.61911929994824, 127.95837093157049, 127.95837093157049, 0.0, 0.0, 0.0, 127.95837093157049, 175.61911929994824, 127.95837093157049, 0.0, 0.0, 0.0, 127.95837093157049, 127.95837093157049, 175.6...
1 [169.92737971608926, 121.8273484849514, 121.8273484849514, 0.0, 0.0, 0.0, 121.8273484849514, 169.92737971608926, 121.8273484849514, 0.0, 0.0, 0.0, 121.8273484849514, 121.8273484849514, 169.9273797...
2 [168.78653632020246, 123.56991383768599, 123.56991383768599, 0.0, 0.0, 0.0, 123.56991383768599, 168.78653632020246, 123.56991383768599, 0.0, 0.0, 0.0, 123.56991383768599, 123.56991383768599, 168.7...
%% Cell type:code id:rural-claim tags:
``` python
# Maybe too complex and intimidating for new python users
elastic_matrix = data_elastic.C_list.apply(pd.Series, index=["c{}{}".format(i, j) for i in range(1, 7) for j in range(1, 7)])
data_elastic_matrix = pd.concat([elastic_matrix, data_elastic], axis=1)
data_elastic_matrix
```
%%%% Output: execute_result
c11 c12 c13 c14 c15 c16 c21 c22 \
0 175.619119 127.958371 127.958371 0.0 0.0 0.0 127.958371 175.619119
1 169.927380 121.827348 121.827348 0.0 0.0 0.0 121.827348 169.927380
2 168.786536 123.569914 123.569914 0.0 0.0 0.0 123.569914 168.786536
c23 c24 ... c56 c61 c62 c63 c64 c65 c66 job_id \
0 127.958371 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 84.313524 3917
1 121.827348 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 75.880308 3931
2 123.569914 0.0 ... 0.0 0.0 0.0 0.0 0.0 0.0 76.693332 3945
potential \
0 Cu_Mendelev_eam
1 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2
2 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1
C_list
0 [175.61911929994824, 127.95837093157049, 127.95837093157049, 0.0, 0.0, 0.0, 127.95837093157049, 175.61911929994824, 127.95837093157049, 0.0, 0.0, 0.0, 127.95837093157049, 127.95837093157049, 175.6...
1 [169.92737971608926, 121.8273484849514, 121.8273484849514, 0.0, 0.0, 0.0, 121.8273484849514, 169.92737971608926, 121.8273484849514, 0.0, 0.0, 0.0, 121.8273484849514, 121.8273484849514, 169.9273797...
2 [168.78653632020246, 123.56991383768599, 123.56991383768599, 0.0, 0.0, 0.0, 123.56991383768599, 168.78653632020246, 123.56991383768599, 0.0, 0.0, 0.0, 123.56991383768599, 123.56991383768599, 168.7...
[3 rows x 39 columns]
%% Cell type:code id:systematic-decimal tags:
``` python
data_elastic_matrix_short = data_elastic_matrix[['potential', 'c11', 'c12', 'c13', 'c33', 'c44', 'c66']]
data_elastic_matrix_short
```
%%%% Output: execute_result
potential c11 c12 c13 \
0 Cu_Mendelev_eam 175.619119 127.958371 127.958371
1 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2 169.927380 121.827348 121.827348
2 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1 168.786536 123.569914 123.569914
c33 c44 c66
0 175.619119 84.313524 84.313524
1 169.927380 75.880308 75.880308
2 168.786536 76.693332 76.693332
%% Cell type:code id:floppy-holly tags:
``` python
%%time
surface_type_list = ["fcc111", "fcc110", "fcc100"]
for i, pot in enumerate(data_murn.potential.to_list()):
group_name = clean_project_name(pot)
pr_pot = pr.create_group(group_name)
a = data_murn.a.to_list()[i]
for surface_type in surface_type_list:
surface = pr.create_surface("Cu", surface_type=surface_type, size=(8, 8, 8), a=a, orthogonal=True, vacuum=12)
job_lammps = pr_pot.create_job(pr_pot.job_type.Lammps, "surf_{}".format(surface_type))
job_lammps.structure = surface
job_lammps.potential = pot
job_lammps.calc_minimize()
job_lammps.run()
```
%%%% Output: stream
The job surf_fcc111 was saved and received the ID: 3960
The job surf_fcc110 was saved and received the ID: 3961
The job surf_fcc100 was saved and received the ID: 3962
The job surf_fcc111 was saved and received the ID: 3963
The job surf_fcc110 was saved and received the ID: 3964
The job surf_fcc100 was saved and received the ID: 3965
The job surf_fcc111 was saved and received the ID: 3966
The job surf_fcc110 was saved and received the ID: 3967
The job surf_fcc100 was saved and received the ID: 3968
CPU times: user 15.4 s, sys: 12.9 s, total: 28.3 s
Wall time: 21.3 s
%% Cell type:code id:functional-injury tags:
``` python
pr_pot
```
%%%% Output: execute_result
{'groups': [], 'nodes': ['surf_fcc111', 'surf_fcc110', 'surf_fcc100']}
%% Cell type:code id:broke-armenia tags:
``` python
surface.plot3d()
```
%%%% Output: display_data
%%%% Output: display_data
%% Cell type:code id:available-valley tags:
``` python
len(surface) / 8
```
%%%% Output: execute_result
64.0
%% Cell type:code id:grateful-composite tags:
``` python
pr_pot.job_table().job.str.contains("fcc")
```
%%%% Output: execute_result
0 False
1 False
2 False
3 False
4 False
5 False
6 False
7 False
8 False
9 False
10 False
11 False
12 False
13 False
14 False
15 False
16 False
17 False
18 False
19 False
20 False
21 False
22 False
23 False
24 False
25 False
26 True
27 True
28 True
Name: job, dtype: bool
%% Cell type:code id:swedish-seven tags:
``` python
def is_a_surface(job_table):
return (job_table.hamilton == "Lammps") & (job_table.job.str.contains("fcc"))
def get_potential_lammps_job(job_path):
return job_path["input/potential/Name"]
def get_surface_type(job_path):
surf_list = ["fcc111", "fcc110", "fcc100"]
conditions = [val in job_path.job_name for val in surf_list]
return surf_list[np.where(conditions)[0].tolist()[0]]
def get_area(job_path):
cell = job_path["output/structure/cell/cell"]
return np.linalg.norm(np.cross(cell[0], cell[1]))
```
%% Cell type:code id:listed-basis tags:
``` python
get_surface_type(pr_pot.inspect('surf_fcc100'))
```
%%%% Output: execute_result
'fcc100'
%% Cell type:code id:accredited-progressive tags:
``` python
%%time
table = pr.create_table("table_surface", delete_existing_job=True)
table.db_filter_function = is_a_surface
table.add["potential"] = get_potential_lammps_job
table.add["surface_type"] = get_surface_type
table.add["surface_area"] = get_area
table.add.get_total_number_of_atoms
table.add.get_energy_tot
table.run()
data_surf = table.get_dataframe()
data_surf
```
%%%% Output: stream
100%|██████████| 9/9 [00:00<00:00, 246.09it/s]
0%| | 0/9 [00:00<?, ?it/s]
%%%% Output: stream
The job table_surface was saved and received the ID: 3969
%%%% Output: stream
100%|██████████| 9/9 [00:00<00:00, 17.87it/s]
%%%% Output: stream
CPU times: user 562 ms, sys: 375 ms, total: 938 ms
Wall time: 1.04 s
%%%% Output: execute_result
Number_of_atoms job_id energy_tot \
0 512 3960 -1705.746713
1 512 3961 -1657.007374
2 512 3962 -1689.102779
3 512 3963 -1744.607843
4 512 3964 -1683.836637
5 512 3965 -1730.881227
6 512 3966 -1762.988823
7 512 3967 -1714.851372
8 512 3968 -1749.588671
potential surface_type surface_area
0 Cu_Mendelev_eam fcc111 366.661398
1 Cu_Mendelev_eam fcc110 598.755556
2 Cu_Mendelev_eam fcc100 423.384114
3 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2 fcc111 362.145737
4 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2 fcc110 591.381512
5 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2 fcc100 418.169878
6 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1 fcc111 362.125297
7 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1 fcc110 591.348133
8 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1 fcc100 418.146275
%% Cell type:code id:covered-watson tags:
``` python
```
%% Cell type:code id:nervous-bishop tags:
``` python
data_merged = pd.merge(data_surf, data_murn, on="potential")
data_merged
```
%%%% Output: execute_result
Number_of_atoms job_id_x energy_tot \
0 512 3960 -1705.746713
1 512 3961 -1657.007374
2 512 3962 -1689.102779
3 512 3963 -1744.607843
4 512 3964 -1683.836637
5 512 3965 -1730.881227
6 512 3966 -1762.988823
7 512 3967 -1714.851372
8 512 3968 -1749.588671
potential surface_type surface_area \
0 Cu_Mendelev_eam fcc111 366.661398
1 Cu_Mendelev_eam fcc110 598.755556
2 Cu_Mendelev_eam fcc100 423.384114
3 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2 fcc111 362.145737
4 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2 fcc110 591.381512
5 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2 fcc100 418.169878
6 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1 fcc111 362.125297
7 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1 fcc110 591.348133
8 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1 fcc100 418.146275
job_id_y a eq_vol eq_bm eq_energy n_atoms
0 3880 3.637410 12.031420 151.879230 -3.422980 1
1 3880 3.637410 12.031420 151.879230 -3.422980 1
2 3880 3.637410 12.031420 151.879230 -3.422980 1
3 3892 3.614942 11.809844 135.774799 -3.539942 1
4 3892 3.614942 11.809844 135.774799 -3.539942 1
5 3892 3.614942 11.809844 135.774799 -3.539942 1
6 3904 3.614840 11.808844 141.746540 -3.540133 1
7 3904 3.614840 11.808844 141.746540 -3.540133 1
8 3904 3.614840 11.808844 141.746540 -3.540133 1
%% Cell type:code id:special-halloween tags:
``` python
data_merged["surface_energy"] = data_merged.energy_tot - (data_merged.eq_energy * data_merged.Number_of_atoms)
```
%% Cell type:code id:inner-regular tags:
``` python
data_merged["surface_energy_in_mJ_per_sq_m"] = data_merged.surface_energy / data_merged.surface_area / 2 * 16.0219 * 1e3
```
%% Cell type:code id:confidential-aging tags:
``` python
data_merged
```
%%%% Output: execute_result
Number_of_atoms job_id_x energy_tot \
0 512 3960 -1705.746713
1 512 3961 -1657.007374
2 512 3962 -1689.102779
3 512 3963 -1744.607843
4 512 3964 -1683.836637
5 512 3965 -1730.881227
6 512 3966 -1762.988823
7 512 3967 -1714.851372
8 512 3968 -1749.588671
potential surface_type surface_area \
0 Cu_Mendelev_eam fcc111 366.661398
1 Cu_Mendelev_eam fcc110 598.755556
2 Cu_Mendelev_eam fcc100 423.384114
3 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2 fcc111 362.145737
4 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2 fcc110 591.381512
5 2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2 fcc100 418.169878
6 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1 fcc111 362.125297
7 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1 fcc110 591.348133
8 1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1 fcc100 418.146275
job_id_y a eq_vol eq_bm eq_energy n_atoms \
0 3880 3.637410 12.031420 151.879230 -3.422980 1
1 3880 3.637410 12.031420 151.879230 -3.422980 1
2 3880 3.637410 12.031420 151.879230 -3.422980 1
3 3892 3.614942 11.809844 135.774799 -3.539942 1
4 3892 3.614942 11.809844 135.774799 -3.539942 1
5 3892 3.614942 11.809844 135.774799 -3.539942 1
6 3904 3.614840 11.808844 141.746540 -3.540133 1
7 3904 3.614840 11.808844 141.746540 -3.540133 1
8 3904 3.614840 11.808844 141.746540 -3.540133 1
surface_energy surface_energy_in_mJ_per_sq_m
0 46.819056 1022.919566
1 95.558395 1278.507591
2 63.462990 1200.798101
3 67.842469 1500.729057
4 128.613675 1742.221732
5 81.569085 1562.632546
6 49.559261 1096.351910
7 97.696712 1323.490226
8 62.959413 1206.192037
%% Cell type:markdown id:electric-marriage tags:
## Finite temperature thermodynamics (Harmonic approximation)
%% Cell type:code id:green-organization tags:
``` python
%%time
for pot in data_murn.potential.to_list():
group_name = clean_project_name(pot)
pr_pot = pr.create_group(group_name)
job_id = int(data_murn[data_murn.potential==pot].job_id)
job_ref = pr_pot.create_job(pr_pot.job_type.Lammps, "ref_job")
job_ref.structure = pr_pot.inspect(job_id)["output/structure"].to_object()
job_ref.potential = pot
job_ref.calc_static()
phonopy_job = job_ref.create_job(pr_pot.job_type.PhonopyJob, "phonopy_job")
phonopy_job.run()
```
%%%% Output: stream
The job phonopy_job was saved and received the ID: 3970
The job ref_job_0 was saved and received the ID: 3971
The job phonopy_job was saved and received the ID: 3972
The job ref_job_0 was saved and received the ID: 3973
The job phonopy_job was saved and received the ID: 3974
The job ref_job_0 was saved and received the ID: 3975
CPU times: user 20.3 s, sys: 9.33 s, total: 29.6 s
Wall time: 21.7 s
%% Cell type:code id:muslim-letter tags:
``` python
pr
```
%%%% Output: execute_result
{'groups': ['1985--Foiles-S-M--Ni-Cu--LAMMPS--ipr1', '1985__Foiles_S_M__Ni_Cu__LAMMPS__ipr1', '2004--Zhou-X-W--Cu-Ag-Au--LAMMPS--ipr2', '2004__Zhou_X_W__Cu_Ag_Au__LAMMPS__ipr2', 'Cu_Mendelev_eam'], 'nodes': ['table_murn', 'table_elastic', 'table_surface']}
%% Cell type:code id:approximate-medicare tags:
``` python
fig, ax_list = plt.subplots(ncols=len(potential_list), nrows=3, sharey="row", sharex="row")
fig.set_figwidth(20)
fig.set_figheight(12)
for i, pot in enumerate(potential_list):
group_name = clean_project_name(pot)
ax = ax_list[0][i]
ax.set_title(pot)
phonopy_job = pr[group_name+"/phonopy_job"]
thermo = phonopy_job.get_thermal_properties(t_min=0, t_max=800)
ax = ax_list[0][i]
ax.plot(thermo.temperatures, thermo.free_energies)
ax.set_xlabel("Temperatures [K]")
ax.set_ylabel("Free energies [eV]")
ax = ax_list[1][i]
ax.plot(thermo.temperatures, thermo.entropy)
ax.set_xlabel("Temperatures [K]")
ax.set_ylabel("Entropy [eV/K]")
ax = ax_list[2][i]
ax.plot(thermo.temperatures, thermo.cv)
ax.set_xlabel("Temperatures [K]")
ax.set_ylabel("Heat capacity (C$_\mathrm{V}$) [eV/K]")
fig.subplots_adjust(wspace=0.05, hspace=0.3);
```
%%%% Output: display_data
%% Cell type:code id:biological-mongolia tags:
``` python
```
%% Cell type:markdown id:colonial-services tags:
## **Validating against datasets**
%% Cell type:code id:rubber-stuart tags:
``` python
pr_import = Project("import_database")
pr_import = Project("../datasets")
if len(pr_import.job_table()) == 0:
pr_import.unpack("Cu_training_archive")
```
%% Cell type:code id:similar-beijing tags:
``` python
container = pr_import['Cu_database/df1_A1_A2_A3_EV_elast_phon']
```
%% Cell type:code id:intimate-introduction tags:
``` python
training_dataset = container.to_pandas()
```
%% Cell type:code id:independent-electric tags:
``` python
training_dataset
```
%%%% Output: execute_result
name \
0 A1:FHI-aims/PBE/tight:elastic:s_e_0
1 A1:FHI-aims/PBE/tight:murnaghan:strain_1_0
2 A1:FHI-aims/PBE/tight:phonon:supercell_phonon_0
3 A1:FHI-aims/PBE/tight:murnaghan:strain_1_02
4 A1:FHI-aims/PBE/tight:murnaghan:strain_0_98
.. ...
100 A2:FHI-aims/PBE/tight:elastic:s_01_e_0_05000
101 A1:FHI-aims/PBE/tight:elastic:s_01_e_m0_05000
102 A3:FHI-aims/PBE/tight:elastic:s_01_e_m0_05000
103 A2:FHI-aims/PBE/tight:elastic:s_01_e_m0_05000
104 A2:FHI-aims/PBE/tight:elastic:s_23_e_m0_05000
atoms \
0 (Atom('Cu', [0.0, 0.0, 0.0], index=0))
1 (Atom('Cu', [0.0, 0.0, 0.0], index=0))
2 (Atom('Cu', [4.3368086899420173e-19, 0.007070999999999999, 0.007070999999999999], index=0), Atom('Cu', [3.3306690738754696e-16, 1.81563, 1.8156300000000005], index=1), Atom('Cu', [7.262518, 10.893...
3 (Atom('Cu', [0.0, 0.0, 0.0], index=0))
4 (Atom('Cu', [0.0, 0.0, 0.0], index=0))
.. ...
100 (Atom('Cu', [0.0, 0.0, 0.0], index=0))
101 (Atom('Cu', [0.0, 0.0, 0.0], index=0))
102 (Atom('Cu', [1.2150849, 0.70152958, 0.9998186400000001], index=0), Atom('Cu', [0.0, 1.40305917, 2.99945593], index=1))
103 (Atom('Cu', [0.0, 0.0, 0.0], index=0))
104 (Atom('Cu', [0.0, 0.0, 0.0], index=0))
energy \
0 -3.699843
1 -3.699841
2 -236.789603
3 -3.697932
4 -3.697559
.. ...
100 -3.573436
101 -3.546222
102 -7.079448
103 -3.513068
104 -3.494427
forces \
0 [[0.0, 0.0, 0.0]]
1 [[0.0, 0.0, 0.0]]
2 [[-1.13852957740976e-06, -0.0464638907314277, -0.0464636807741622], [-3.86335457040412e-06, 0.0124851330231607, 0.0124792943417333], [-1.94300535086066e-06, 6.63943441884098e-05, 6.92790474109119e...
3 [[0.0, 0.0, 0.0]]
4 [[0.0, 0.0, 0.0]]
.. ...
100 [[0.0, 0.0, 0.0]]
101 [[0.0, 0.0, 0.0]]
102 [[-3.5446112180968e-23, -1.13427558979097e-22, 0.0], [3.5446112180968e-23, 1.13427558979097e-22, 0.0]]
103 [[0.0, 0.0, 0.0]]
104 [[0.0, 0.0, 0.0]]
number_of_atoms
0 1.0
1 1.0
2 64.0
3 1.0
4 1.0
.. ...
100 1.0
101 1.0
102 2.0
103 1.0
104 1.0
[105 rows x 5 columns]
%% Cell type:code id:opponent-assembly tags:
``` python
from pyiron import ase_to_pyiron
```
%% Cell type:code id:handmade-track tags:
``` python
structure_list = training_dataset.atoms.apply(ase_to_pyiron).to_list()
energy_list = training_dataset.energy.to_list()
force_list = training_dataset.forces.to_list()
num_atoms_list = training_dataset.number_of_atoms.to_list()
energy_per_atom_list = np.array(energy_list) / np.array(num_atoms_list)
```
%% Cell type:code id:general-soundtrack tags:
``` python
%%time
energy_pred_dict = dict()
force_pred_dict = dict()
for pot in potential_list:
group_name = clean_project_name(pot)
pr_pot = pr.create_group(pot)
energy_pred_list = list()
force_pred_list = list()
stride = 10
for i, struct in enumerate(structure_list[::stride]):
job = pr_pot.create_job(pr.job_type.Lammps, "lammps_struct_{}".format(i))
job.potential = pot
job.structure = struct
job.calc_static()
job.run()
energy_pred_list.append(job["output/generic/energy_tot"][-1] / len(struct))
force_pred_list.append(job["output/generic/forces"][-1])
job_box = pr_pot.create_job(pr.job_type.Lammps, "lammps_box")
job_box.potential = pot
job_box.structure = pr_pot.create_atoms("Cu", scaled_positions=[[0.5, 0.5, 0.5]], cell=np.eye(3)*10, pbc=True)
job_box.calc_static()
job_box.run()
# correct for energy of isolated atom
energy_pred_list = np.array(energy_pred_list) - job_box["output/generic/energy_tot"][-1]
energy_pred_dict[pot] = energy_pred_list
force_pred_dict[pot] = force_pred_list
```
%%%% Output: stream
The job lammps_struct_0 was saved and received the ID: 3976
The job lammps_struct_1 was saved and received the ID: 3977
The job lammps_struct_2 was saved and received the ID: 3978
The job lammps_struct_3 was saved and received the ID: 3979
The job lammps_struct_4 was saved and received the ID: 3980
The job lammps_struct_5 was saved and received the ID: 3981
The job lammps_struct_6 was saved and received the ID: 3982
The job lammps_struct_7 was saved and received the ID: 3983
The job lammps_struct_8 was saved and received the ID: 3984
The job lammps_struct_9 was saved and received the ID: 3985
The job lammps_struct_10 was saved and received the ID: 3986
The job lammps_box was saved and received the ID: 3987
The job lammps_struct_0 was saved and received the ID: 3988
The job lammps_struct_1 was saved and received the ID: 3989
The job lammps_struct_2 was saved and received the ID: 3990
The job lammps_struct_3 was saved and received the ID: 3991
The job lammps_struct_4 was saved and received the ID: 3992
The job lammps_struct_5 was saved and received the ID: 3993
The job lammps_struct_6 was saved and received the ID: 3994
The job lammps_struct_7 was saved and received the ID: 3995
The job lammps_struct_8 was saved and received the ID: 3996
The job lammps_struct_9 was saved and received the ID: 3997
The job lammps_struct_10 was saved and received the ID: 3998
The job lammps_box was saved and received the ID: 3999
The job lammps_struct_0 was saved and received the ID: 4000
The job lammps_struct_1 was saved and received the ID: 4001
The job lammps_struct_2 was saved and received the ID: 4002
The job lammps_struct_3 was saved and received the ID: 4003
The job lammps_struct_4 was saved and received the ID: 4004
The job lammps_struct_5 was saved and received the ID: 4005
The job lammps_struct_6 was saved and received the ID: 4006
The job lammps_struct_7 was saved and received the ID: 4007
The job lammps_struct_8 was saved and received the ID: 4008
The job lammps_struct_9 was saved and received the ID: 4009
The job lammps_struct_10 was saved and received the ID: 4010
The job lammps_box was saved and received the ID: 4011
CPU times: user 36.5 s, sys: 34.4 s, total: 1min 10s
Wall time: 50.5 s
%% Cell type:code id:private-ethernet tags:
``` python
fig, ax_list = plt.subplots(ncols=len(potential_list), nrows=4, sharey="row", sharex="row")
fig.set_figwidth(20)
fig.set_figheight(12)
for i, (pot, energy_pred) in enumerate(energy_pred_dict.items()):
ax = ax_list[0][i]
ax.plot(energy_per_atom_list[::stride], energy_pred, "x")
ax.plot(energy_per_atom_list[::stride], energy_per_atom_list[::stride])
ax.set_title(pot + " (Energies)")
ax.set_xlabel("Energy DFT [eV]")
ax.set_ylabel("Energy pred [eV]")
ax = ax_list[1][i]
force_x_orig = np.hstack([f[:, 0] for f in force_list[::stride]])
force_x_pred = np.hstack([f[:, 0] for f in force_pred_list])
ax.plot(force_x_orig, force_x_pred, "x")
ax.plot(force_x_orig, force_x_orig)
ax.set_xlabel("Force DFT [eV/$\mathrm{\AA}$]")
ax.set_ylabel("Force pred [eV/$\mathrm{\AA}$]")
ax.set_title(pot + " (Force-x)")
ax = ax_list[2][i]
force_y_orig = np.hstack([f[:, 1] for f in force_list[::stride]])
force_y_pred = np.hstack([f[:, 1] for f in force_pred_list])
ax.plot(force_y_orig, force_y_pred, "x")
ax.plot(force_y_orig, force_y_orig)
ax.set_xlabel("Force DFT [eV/$\mathrm{\AA}$]")
ax.set_ylabel("Force pred [eV/$\mathrm{\AA}$]")
ax.set_title(pot + " (Force-y)")
ax = ax_list[3][i]
force_z_orig = np.hstack([f[:, 2] for f in force_list[::stride]])
force_z_pred = np.hstack([f[:, 2] for f in force_pred_list])
ax.plot(force_z_orig, force_z_pred, "x")
ax.plot(force_z_orig, force_z_orig)
ax.set_xlabel("Force DFT [eV/$\mathrm{\AA}$]")
ax.set_ylabel("Force pred [eV/$\mathrm{\AA}$]")
ax.set_title(pot + " (Force-z)")
fig.subplots_adjust(wspace=0.05, hspace=0.6)
# ax.set_ylim(x_lim)
```
%%%% Output: display_data
%% Cell type:code id:involved-request tags:
``` python
```
%% Cell type:code id:animal-reply tags:
``` python
```
%% Cell type:code id:integrated-complex 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