Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support several CALYPSO run in different pressure in one iteration #814

Merged
merged 53 commits into from
Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
12971b9
feature: merge run.py
wangzyphysics Feb 21, 2022
3b26eb9
fix:fix syntax bug
wangzyphysics Feb 22, 2022
729d8bd
fix summary ratio bug
wangzyphysics Feb 22, 2022
e08b479
fix: fix bug of var(calypso_run_opt_path) not defined
wangzyphysics Feb 24, 2022
3d227a9
Merge branch 'deepmodeling:master' into calypso
wangzyphysics Mar 1, 2022
7d30fc1
reorganize code v1
wangzyphysics Mar 3, 2022
7c68fe9
add: add unittest
wangzyphysics Mar 3, 2022
86b9cf2
Merge branch 'calypso' of github.com:wangzyphysics/dpgen into calypso
wangzyphysics Mar 4, 2022
420df0d
add: add some explainations of dp+calypso in README.md
wangzyphysics Mar 4, 2022
3277c26
change a little bit in readme.md
wangzyphysics Mar 4, 2022
09be223
change position of function
wangzyphysics Mar 4, 2022
224b62d
add deepmd-kit>=2.0.1 install_require in setup.py
wangzyphysics Mar 4, 2022
8af2b2a
test failed cause no tensorflow module so add tensorflow in setup.py
wangzyphysics Mar 4, 2022
239765a
calc model devi in command line
wangzyphysics Mar 9, 2022
0bf1473
fix some small bugs of modd and PBS script of cpu
wangzyphysics Mar 9, 2022
7b0db3f
fix unittest
wangzyphysics Mar 9, 2022
15d130a
delete parse_input.dat
wangzyphysics Mar 9, 2022
d1e73c9
fix unittest
wangzyphysics Mar 10, 2022
361546e
first reorganization
wangzyphysics Mar 13, 2022
a8ca7f8
secord reorganization
wangzyphysics Mar 13, 2022
2ac1efe
fix bugs
wangzyphysics Mar 15, 2022
f1ae450
fix: fix bugs in modd_calypso.py write_modd.py and run.py
wangzyphysics Mar 19, 2022
a6048fb
change functions name and fix bugs
wangzyphysics Mar 22, 2022
d651e36
remove modd_calypso.py
wangzyphysics Mar 22, 2022
1c1b670
remove: remove modd_calypso.py
wangzyphysics Mar 22, 2022
68cd1c9
remove some useless outputs
wangzyphysics Mar 22, 2022
ff23f23
restore dispatcher/PBS.py
wangzyphysics Mar 22, 2022
3796cd4
refactor: make some changes in calypso related code
wangzyphysics Mar 23, 2022
496fa07
refactor: move calypso main code(run.py) into run_calypso.py and modi…
wangzyphysics Mar 23, 2022
36dd23a
docs: modify README.md related to CALYPSO
wangzyphysics Mar 23, 2022
0e9669e
delete some useless comments in run.py
wangzyphysics Mar 24, 2022
961f63f
add write_model_devi_out function into make_calypso.py for passing un…
wangzyphysics Mar 24, 2022
df2bf1c
fix a spelling mistake in calypso_run_opt.py (famx -> fmax)
wangzyphysics Mar 26, 2022
43ef866
change runopt script's name from run_opt.py to calypso_run_opt.py and…
wangzyphysics Mar 26, 2022
33271e9
fix unittest
wangzyphysics Mar 31, 2022
56b1e05
make vsc mode work for any situation
wangzyphysics Jul 18, 2022
2cfb895
feat: one iter can run different calypso loop in different pressure
wangzyphysics Jul 21, 2022
c96345e
Merge branch 'calypso' into devel
wangzyphysics Jul 21, 2022
e1a603a
write model_devi_jobs[current_iter] into cur_jobs.json and modify a c…
wangzyphysics Jul 22, 2022
9450979
modify README.md and make_calypso.py
wangzyphysics Jul 22, 2022
44a167b
Merge branch 'deepmodeling:devel' into devel
wangzyphysics Jul 23, 2022
efc934e
Merge branch 'deepmodeling:devel' into devel
wangzyphysics Jul 24, 2022
b478712
fix calypso_run_opt script and check outcar script to support Bohrium
wangzyphysics Aug 1, 2022
cbae769
Support different pressure in vsc mode
wangzyphysics Aug 1, 2022
0d5b7fa
delete some useless comments and modify the assert code in calypso_ru…
wangzyphysics Aug 1, 2022
d705948
change sys.exit() into RuntimeError in run_calypso.py
wangzyphysics Aug 1, 2022
2901d23
compatible with new python interface of calc_model_devi func
wangzyphysics Aug 2, 2022
d20723d
Merge branch 'deepmodeling:devel' into devel
wangzyphysics Aug 2, 2022
2551a69
vsc mode can also have different pressure in one iter and model devia…
wangzyphysics Aug 2, 2022
2dca9e6
add comments to explain the meaning of run_mode
wangzyphysics Aug 2, 2022
1f091e1
change caly_run_opt_path into calypso_run_opt_path
wangzyphysics Aug 3, 2022
fbca550
fix bug when key Volume is not given CALYPSO will not run
wangzyphysics Aug 4, 2022
7631283
fix bug of the number of confs is not correct when different pressure…
wangzyphysics Aug 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ dbconfig.json
_build
tests/generator/calypso_test_path
doc/api/

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,15 +590,15 @@ The bold notation of key (such as **calypso_path**) means that it's a necessary
| **model_devi_jobs["NameOfAtoms"]** | List of string |["Al","Cu"] | Parameter of CALYPSO input file, means the element species of structures to be generated. |
| **model_devi_jobs["NumberOfAtoms"]** | List of int |[1,10] | Parameter of CALYPSO input file, means the number of atoms for each chemical species in one formula unit. |
| **model_devi_jobs["NumberOfFormula"]** | List of int |[1,2] | Parameter of CALYPSO input file, means the range of formula unit per cell. |
| **model_devi_jobs["Volume"]** | List of int |[300] | Parameter of CALYPSO input file, means the colume per formula unit(angstrom^3). |
| **model_devi_jobs["Volume"]** | int | 300 | Parameter of CALYPSO input file, means the colume per formula unit(angstrom^3). |
| **model_devi_jobs["DistanceOfIon"]** | List of float |[[ 1.48,1.44],[ 1.44,1.41]] | Parameter of CALYPSO input file, means minimal distance between atoms of each chemical species. Unit is in angstrom. |
| **model_devi_jobs["PsoRatio"]** | List of float |[0.6] | Parameter of CALYPSO input file, means the proportion of the structures generated by PSO. |
| **model_devi_jobs["PopSize"]** | List of int |[5] | Parameter of CALYPSO input file, means the number of structures to be generated in one step in CALYPSO. |
| **model_devi_jobs["MaxStep"]** | List of int |[3] | Parameter of CALYPSO input file, means the number of max step in CALYPSO.|
| **model_devi_jobs["ICode"]** | List of int |[13] | Parameter of CALYPSO input file, means the chosen of local optimization, 1 is vasp and 13 is ASE with dp. |
| **model_devi_jobs["PsoRatio"]** | float or int | 0.6 | Parameter of CALYPSO input file, means the proportion of the structures generated by PSO. |
| **model_devi_jobs["PopSize"]** | int | 5 | Parameter of CALYPSO input file, means the number of structures to be generated in one step in CALYPSO. |
| **model_devi_jobs["MaxStep"]** | int | 3 | Parameter of CALYPSO input file, means the number of max step in CALYPSO.|
| **model_devi_jobs["ICode"]** | int | 13 | Parameter of CALYPSO input file, means the chosen of local optimization, 1 is vasp and 13 is ASE with dp. |
| **model_devi_jobs["Split"]** | String |"T" | Parameter of CALYPSO input file, means that generating structures and optimizing structures are split into two parts, in dpgen workflow, Split must be T. |
| **model_devi_jobs["PSTRESS"]** | List of float |[0.001] | Same as PSTRESS in INCAR. |
| **model_devi_jobs["fmax"]** | List of float |[0.01] | The convergence criterion is that the force on all individual atoms should be less than *fmax*. |
| **model_devi_jobs["PSTRESS"]** | List of float or int |[0.001] | Same as PSTRESS in INCAR. |
| **model_devi_jobs["fmax"]** | float | 0.01 | The convergence criterion is that the force on all individual atoms should be less than *fmax*. |
| *in machine file*
| **model_devi["deepmdkit_python"]** | String | "/home/zhenyu/soft/deepmd-kit/bin/python" | A python path with deepmd package. |
| **model_devi["calypso_path"]** | string | "/home/zhenyu/workplace/debug" | The absolute path of calypso.x.|
Expand Down
185 changes: 91 additions & 94 deletions dpgen/generator/lib/calypso_check_outcar.py
Original file line number Diff line number Diff line change
@@ -1,107 +1,104 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np
import os,sys,glob,time
from deepmd.calculator import DP
from ase.io import read
import numpy as np
import os,sys,glob,time
from deepmd.calculator import DP
from ase.io import read

'''
check if structure optimization worked well
if not, this script will generate a fake outcar
'''
def Get_Element_Num(elements):

def Get_Element_Num(elements):
'''Using the Atoms.symples to Know Element&Num'''
element = []
ele = {}
element.append(elements[0])
for x in elements:
if x not in element :
element.append(x)
for x in element:
ele[x] = elements.count(x)
return element, ele

def Write_Contcar(element, ele, lat, pos):
'''Write CONTCAR'''
f = open('CONTCAR','w')
f.write('ASE-DPKit-FAILED-nan\n')
f.write('1.0\n')
for i in range(3):
f.write('%15.10f %15.10f %15.10f\n' % tuple(lat[i]))
for x in element:
f.write(x + ' ')
f.write('\n')
for x in element:
f.write(str(ele[x]) + ' ')
f.write('\n')
f.write('Direct\n')
na = sum(ele.values())
dpos = np.dot(pos,np.linalg.inv(lat))
for i in range(na):
f.write('%15.10f %15.10f %15.10f\n' % tuple(dpos[i]))

def Write_Outcar(element, ele, volume, lat, pos, ene, force, stress,pstress):
'''Write OUTCAR'''
f = open('OUTCAR','w')
for x in element:
f.write('VRHFIN =' + str(x) + '\n')
f.write('ions per type =')
for x in element:
f.write('%5d' % ele[x])
#f.write('\nvolume of cell :\n')
element = []
ele = {}
element.append(elements[0])
for x in elements:
if x not in element :
element.append(x)
for x in element:
ele[x] = elements.count(x)
return element, ele

def Write_Contcar(element, ele, lat, pos):
'''Write CONTCAR'''
f = open('CONTCAR','w')
f.write('ASE-DPKit-FAILED-nan\n')
f.write('1.0\n')
for i in range(3):
f.write('%15.10f %15.10f %15.10f\n' % tuple(lat[i]))
for x in element:
f.write(x + ' ')
f.write('\n')
for x in element:
f.write(str(ele[x]) + ' ')
f.write('\n')
f.write('Direct\n')
na = sum(ele.values())
dpos = np.dot(pos,np.linalg.inv(lat))
for i in range(na):
f.write('%15.10f %15.10f %15.10f\n' % tuple(dpos[i]))

def Write_Outcar(element, ele, volume, lat, pos, ene, force, stress,pstress):
'''Write OUTCAR'''
f = open('OUTCAR','w')
for x in element:
f.write('VRHFIN =' + str(x) + '\n')
f.write('ions per type =')
for x in element:
f.write('%5d' % ele[x])
f.write('\nDirection XX YY ZZ XY YZ ZX\n')
f.write('in kB')
f.write('%15.6f' % stress[0])
f.write('%15.6f' % stress[1])
f.write('%15.6f' % stress[2])
f.write('%15.6f' % stress[3])
f.write('%15.6f' % stress[4])
f.write('%15.6f' % stress[5])
f.write('\n')
ext_pressure = np.sum(stress[0] + stress[1] + stress[2])/3.0 - pstress
f.write('in kB')
f.write('%15.6f' % stress[0])
f.write('%15.6f' % stress[1])
f.write('%15.6f' % stress[2])
f.write('%15.6f' % stress[3])
f.write('%15.6f' % stress[4])
f.write('%15.6f' % stress[5])
f.write('\n')
ext_pressure = np.sum(stress[0] + stress[1] + stress[2])/3.0 - pstress
f.write('external pressure = %20.6f kB Pullay stress = %20.6f kB\n'% (ext_pressure, pstress))
f.write('volume of cell : %20.6f\n' % volume)
f.write('direct lattice vectors\n')
for i in range(3):
f.write('%10.6f %10.6f %10.6f\n' % tuple(lat[i]))
f.write('POSITION TOTAL-FORCE(eV/Angst)\n')
f.write('-------------------------------------------------------------------\n')
na = sum(ele.values())
for i in range(na):
f.write('%15.6f %15.6f %15.6f' % tuple(pos[i]))
f.write('%15.6f %15.6f %15.6f\n' % tuple(force[i]))
f.write('-------------------------------------------------------------------\n')
f.write('energy without entropy= %20.6f %20.6f\n' % (ene, ene))
enthalpy = ene + pstress * volume / 1602.17733
f.write('enthalpy is TOTEN = %20.6f %20.6f\n' % (enthalpy, enthalpy))

def check():

from deepmd.calculator import DP
from ase.io import read
model_path = sys.argv[1]
Model_List = glob.glob('%s/graph*pb'%model_path)
calc = DP(model='%s'%(Model_List[0])) # init the model before iteration

to_be_opti = read('POSCAR')
to_be_opti.calc = calc
# ---------------------------------
# for failed outcar
atoms_symbols_f = to_be_opti.get_chemical_symbols()
element_f, ele_f = Get_Element_Num(atoms_symbols_f)
atoms_vol_f = to_be_opti.get_volume()
atoms_stress_f = to_be_opti.get_stress()
atoms_stress_f = atoms_stress_f/(0.01*0.6242)
atoms_lat_f = to_be_opti.cell
atoms_pos_f = to_be_opti.positions
atoms_force_f = to_be_opti.get_forces()
atoms_ene_f = 610612509
# ---------------------------------
Write_Contcar(element_f, ele_f, atoms_lat_f, atoms_pos_f)
f.write('volume of cell : %20.6f\n' % volume)
f.write('direct lattice vectors\n')
for i in range(3):
f.write('%10.6f %10.6f %10.6f\n' % tuple(lat[i]))
f.write('POSITION TOTAL-FORCE(eV/Angst)\n')
f.write('-------------------------------------------------------------------\n')
na = sum(ele.values())
for i in range(na):
f.write('%15.6f %15.6f %15.6f' % tuple(pos[i]))
f.write('%15.6f %15.6f %15.6f\n' % tuple(force[i]))
f.write('-------------------------------------------------------------------\n')
f.write('energy without entropy= %20.6f %20.6f\n' % (ene, ene))
enthalpy = ene + pstress * volume / 1602.17733
f.write('enthalpy is TOTEN = %20.6f %20.6f\n' % (enthalpy, enthalpy))

def check():

from deepmd.calculator import DP
from ase.io import read
calc = DP(model='../graph.000.pb') # init the model before iteration

to_be_opti = read('POSCAR')
to_be_opti.calc = calc
# ---------------------------------
# for failed outcar
atoms_symbols_f = to_be_opti.get_chemical_symbols()
element_f, ele_f = Get_Element_Num(atoms_symbols_f)
atoms_vol_f = to_be_opti.get_volume()
atoms_stress_f = to_be_opti.get_stress()
atoms_stress_f = atoms_stress_f/(0.01*0.6242)
atoms_lat_f = to_be_opti.cell
atoms_pos_f = to_be_opti.positions
atoms_force_f = to_be_opti.get_forces()
atoms_ene_f = 610612509
# ---------------------------------
Write_Contcar(element_f, ele_f, atoms_lat_f, atoms_pos_f)
Write_Outcar(element_f, ele_f, atoms_vol_f, atoms_lat_f, atoms_pos_f,atoms_ene_f, atoms_force_f, atoms_stress_f * -10.0, 0)

cwd = os.getcwd()
if not os.path.exists(os.path.join(cwd,'OUTCAR')):
check()
cwd = os.getcwd()
if not os.path.exists(os.path.join(cwd,'OUTCAR')):
check()
7 changes: 5 additions & 2 deletions dpgen/generator/lib/calypso_run_model_devi.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ def Modd(all_models,type_map):
pdata.to_vasp_poscar(os.path.join(put_poscar,'%s.poscar'%str(index)))
nopbc = pdata.nopbc
coord = pdata.data['coords']
cell = pdata.data['cells']
cell = pdata.data['cells'] if not nopbc else None
atom_types = pdata.data['atom_types']
devi = calc_model_devi(coord,cell,atom_types,graphs,nopbc=nopbc)
try:
devi = calc_model_devi(coord,cell,atom_types,graphs,nopbc=nopbc)
except TypeError:
devi = calc_model_devi(coord,cell,atom_types,graphs)
# ------------------------------------------------------------------------------------
# append min-distance in devi list
dis = pdata.to_ase_structure()[0].get_all_distances(mic=True)
Expand Down
Loading