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 40 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ dbconfig.json
.idea/*
_build
tests/generator/calypso_test_path
doc/api/
doc/api/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not remove the '\n' at the end of the file

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,15 +591,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
71 changes: 38 additions & 33 deletions dpgen/generator/lib/make_calypso.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
import json
import numpy as np
from dpgen.generator.lib.utils import create_path

def make_calypso_input(nameofatoms,numberofatoms,
numberofformula,volume,
Expand All @@ -24,7 +25,7 @@ def make_calypso_input(nameofatoms,numberofatoms,
assert numberofformula != None or len(numberofformula) == 2 or type(numberofformula) == type([1,2])
ret+= "NumberOfFormula = %s\n"%(' '.join(list(map(str,numberofformula))))
ret+= "# The volume per formula unit. Unit is in angstrom^3.\n"
ret+= "Volume = %s\n"%(volume[0])
ret+= "Volume = %s\n"%(volume)
ret+= "# Minimal distance between atoms of each chemical species. Unit is in angstrom.\n"
assert len(distanceofion) == len(nameofatoms) #"check distance of ions and the number of atoms"
assert len(distanceofion[0]) == len(nameofatoms)
Expand All @@ -37,14 +38,14 @@ def make_calypso_input(nameofatoms,numberofatoms,
ret+= "# Ialgo = 1 for Global PSO\n"
ret+= "# Ialgo = 2 for Local PSO (default value)\n"
ret+= "# The proportion of the structures generated by PSO.\n"
assert (0 <= psoratio[0] <= 1 )
ret+= "PsoRatio = %s\n"%(psoratio[0])
assert (0 <= psoratio <= 1 )
ret+= "PsoRatio = %s\n"%(psoratio)
ret+= "# The population size. Normally, it has a larger number for larger systems.\n"
assert popsize[0] != None or popsize!=None or type(popsize) == type([0,1]) or type(popsize[0]) == type(0)
ret+= "PopSize = %d\n"%(popsize[0])
assert maxstep[0] != None or maxstep!=None or type(maxstep) == type([0,1]) or type(maxstep[0]) == type(0)
assert popsize != None or type(popsize) == type(0)
ret+= "PopSize = %d\n"%(popsize)
assert maxstep != None or type(maxstep) == type(0)
ret+= "# The Max step for iteration\n"
ret+= "MaxStep = %d\n"%(maxstep[0])
ret+= "MaxStep = %d\n"%(maxstep)
ret+= "#It determines which method should be adopted in generation the random structure. \n"
ret+= "GenType= 1 \n"
ret+= "# 1 under symmetric constraints\n"
Expand All @@ -53,8 +54,8 @@ def make_calypso_input(nameofatoms,numberofatoms,
ret+= "# 0 combination of all method\n"
ret+= "# If GenType=3 or 4, it determined the small unit to grow the whole structure\n"
ret+= "# It determines which local optimization method should be interfaced in the simulation.\n"
assert icode != None or type(icode) == type([0,1]) or type(icode[0]) == type(0)
ret+= "ICode= %d\n"%(icode[0])
assert icode != None or type(icode) == type(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be and? If you want all the conditions are satisfied.
I would recommend changing it to assert icode is not None and type(icode) is int

ret+= "ICode= %d\n"%(icode)
ret+= "# ICode= 1 interfaced with VASP\n"
ret+= "# ICode= 2 interfaced with SIESTA\n"
ret+= "# ICode= 3 interfaced with GULP\n"
Expand All @@ -75,18 +76,18 @@ def make_calypso_input(nameofatoms,numberofatoms,
ret+= "NumberOfParallel = 4\n"
assert split != None
ret+= "Split = %s\n"%(split)
assert pstress != None or type(pstress) == type([200])
ret+= "PSTRESS = %f\n"%(pstress[0])
assert fmax != None or type(fmax) == type([200])
ret+= "fmax = %f\n"%(fmax[0])
assert pstress != None or type(pstress) == type(200) or type(pstress) == type(0.001)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar issue

ret+= "PSTRESS = %f\n"%(pstress)
assert fmax != None or type(fmax) == type(0.01)
ret+= "fmax = %f\n"%(fmax)
ret+= "################################ End of The Basic Parameters of CALYPSO #######################\n"
if vsc == 'T':
assert len(ctrlrange) == len(nameofatoms) #'check distance of ions and the number of atoms'
ret+= "##### The Parameters For Variational Stoichiometry ##############\n"
ret+= "## If True, Variational Stoichiometry structure prediction is performed\n"
ret+= "VSC = %s\n"%(vsc)
ret+= "# The Max Number of Atoms in unit cell\n"
ret+= "MaxNumAtom = %s\n"%(maxnumatom[0])
ret+= "MaxNumAtom = %s\n"%(maxnumatom)
ret+= "# The Variation Range for each type atom \n"
ret+= "@CtrlRange\n"
for ttemp in ctrlrange:
Expand All @@ -95,18 +96,19 @@ def make_calypso_input(nameofatoms,numberofatoms,
ret+= "###################End Parameters for VSC ##########################\n"
return ret

def _make_model_devi_buffet(jdata,calypso_run_opt_path):
def _make_model_devi_buffet(jdata,caly_run_opt_path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer the original variable name, which is self-explanatory to the readers. It is not easy to relate caly to calypso...


calypso_input_path = jdata.get('calypso_input_path')
shutil.copyfile(os.path.join(calypso_input_path,'input.dat'),os.path.join(calypso_run_opt_path, 'input.dat'))
shutil.copyfile(os.path.join(calypso_input_path,'input.dat'),os.path.join(caly_run_opt_path[0], 'input.dat'))

def _make_model_devi_native_calypso(iter_index,model_devi_jobs, calypso_run_opt_path):
def _make_model_devi_native_calypso(iter_index,model_devi_jobs, caly_run_opt_path):

for iiidx, jobbs in enumerate(model_devi_jobs):
if iter_index in jobbs.get('times'):
cur_job = model_devi_jobs[iiidx]

work_path = os.path.dirname(calypso_run_opt_path)
work_path = os.path.dirname(caly_run_opt_path[0])
# cur_job.json
with open(os.path.join(work_path, 'cur_job.json'), 'w') as outfile:
json.dump(cur_job, outfile, indent = 4)

Expand All @@ -116,34 +118,37 @@ def _make_model_devi_native_calypso(iter_index,model_devi_jobs, calypso_run_opt_
numberofformula = cur_job.get('NumberOfFormula',[1,1])
volume = cur_job.get('Volume')
distanceofion = cur_job.get('DistanceOfIon')
psoratio = cur_job.get('PsoRatio')
popsize = cur_job.get('PopSize')
maxstep = cur_job.get('MaxStep')
icode = cur_job.get('ICode',[1])
psoratio = cur_job.get('PsoRatio', 0.6)
popsize = cur_job.get('PopSize', 30)
maxstep = cur_job.get('MaxStep', 5)
icode = cur_job.get('ICode',1)
split = cur_job.get('Split','T')
# Cluster

# 2D

# VSC Control
maxnumatom = None
ctrlrange = None
vsc = cur_job.get('VSC','F')
if vsc == 'T':
maxnumatom = cur_job.get('MaxNumAtom')
ctrlrange = cur_job.get('CtrlRange')

# Optimization
fmax = cur_job.get('fmax',0.01)
# pstress is a List which contains the target stress
pstress = cur_job.get('PSTRESS',[0.001])
fmax = cur_job.get('fmax',[0.01])

# Cluster

# 2D

file_c = make_calypso_input(nameofatoms,numberofatoms,
# pressures
for press_idx, temp_caly_run_opt_path in enumerate(caly_run_opt_path):
# cur_press
cur_press = pstress[press_idx]
file_c = make_calypso_input(nameofatoms,numberofatoms,
numberofformula,volume,
distanceofion,psoratio,popsize,
maxstep,icode,split,vsc,
maxnumatom,ctrlrange,pstress,fmax)
with open(os.path.join(calypso_run_opt_path, 'input.dat'), 'w') as cin :
cin.write(file_c)
maxnumatom,ctrlrange,cur_press,fmax)
with open(os.path.join(temp_caly_run_opt_path, 'input.dat'), 'w') as cin :
cin.write(file_c)

def write_model_devi_out(devi, fname):
assert devi.shape[1] == 8
Expand Down
Loading