-
Notifications
You must be signed in to change notification settings - Fork 176
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
Changes from 40 commits
12971b9
3b26eb9
729d8bd
e08b479
3d227a9
7d30fc1
7c68fe9
86b9cf2
420df0d
3277c26
09be223
224b62d
8af2b2a
239765a
0bf1473
7b0db3f
15d130a
d1e73c9
361546e
a8ca7f8
2ac1efe
f1ae450
a6048fb
d651e36
1c1b670
68cd1c9
ff23f23
3796cd4
496fa07
36dd23a
0e9669e
961f63f
df2bf1c
43ef866
33271e9
56b1e05
2cfb895
c96345e
e1a603a
9450979
44a167b
efc934e
b478712
cbae769
0d5b7fa
d705948
2901d23
d20723d
2551a69
2dca9e6
1f091e1
fbca550
7631283
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,4 @@ dbconfig.json | |
.idea/* | ||
_build | ||
tests/generator/calypso_test_path | ||
doc/api/ | ||
doc/api/ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -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) | ||
|
@@ -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" | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't be |
||
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" | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
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) | ||
|
||
|
@@ -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 | ||
|
There was a problem hiding this comment.
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