Skip to content

Commit

Permalink
create the folder for each system of GO
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhu2017 committed Jul 3, 2024
1 parent c4f5d4f commit 84ce4fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions pyxtal/optimize/GA.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(self,

def full_str(self):
s = str(self)
s += "\n------Vanila Genetic Algorithm------"
s += "\nMethod : Genetic Algorithm"
s += "\nGeneration: {:4d}".format(self.N_gen)
s += "\nPopulation: {:4d}".format(self.N_pop)
s += "\nFraction : {:4.2f} {:4.2f} {:4.2f}".format(*self.fracs)
Expand Down Expand Up @@ -191,7 +191,7 @@ def run(self, ref_pmg=None, ref_eng=None, ref_pxrd=None):
self.block,
self.num_block,
self.atom_info,
self.workdir,
self.workdir + '/' + 'calc',
self.sg,
self.composition,
self.lattice,
Expand Down Expand Up @@ -253,7 +253,7 @@ def run(self, ref_pmg=None, ref_eng=None, ref_pxrd=None):
if xtal.energy < 9999:
if self.verbose:
print("Add qualified structure", id, xtal.energy)
with open(self.cif, 'a+') as f:
with open(self.workdir+'/'+self.cif, 'a+') as f:
label = self.tag + '-g' + str(gen) + '-p' + str(id)
f.writelines(xtal.to_file(header=label))
#else:
Expand Down Expand Up @@ -361,8 +361,9 @@ def _crossover(self, x1, x2):
ncpu = options.ncpu
ffopt = options.ffopt
db_name, name = 'pyxtal/database/test.db', 'ACSALA'
wdir = 'tmp'
wdir = name
os.makedirs(wdir, exist_ok=True)
os.makedirs(wdir+'/calc', exist_ok=True)

db = database(db_name)
row = db.get_row(name)
Expand All @@ -373,8 +374,8 @@ def _crossover(self, x1, x2):
if 'charmm_info' in row.data.keys():
# prepare charmm input
chm_info = row.data['charmm_info']
prm = open(wdir+'/pyxtal.prm', 'w'); prm.write(chm_info['prm']); prm.close()
rtf = open(wdir+'/pyxtal.rtf', 'w'); rtf.write(chm_info['rtf']); rtf.close()
prm = open(wdir+'/calc/pyxtal.prm', 'w'); prm.write(chm_info['prm']); prm.close()
rtf = open(wdir+'/calc/pyxtal.rtf', 'w'); rtf.write(chm_info['rtf']); rtf.close()
else:
# Make sure we generate the initial guess from ambertools
if os.path.exists('parameters.xml'): os.remove('parameters.xml')
Expand Down
6 changes: 3 additions & 3 deletions pyxtal/optimize/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self,
else:
print("No FF parameter file exists, using the default setting", ff_style)
params0 = self.parameters.params_init.copy()
self.parameters.export_parameters(self.ff_parameters, params0)
self.parameters.export_parameters(self.wdir+'/'+self.ff_parameters, params0)

self.prepare_chm_info(params0)

Expand All @@ -152,7 +152,7 @@ def __init__(self,
self.tag = tag
self.cif = cif
if cif is not None:
with open(cif, 'w') as f: f.writelines(str(self))
with open(self.workdir+'/'+cif, 'w') as f: f.writelines(str(self))
#print(self)

def __str__(self):
Expand Down Expand Up @@ -433,7 +433,7 @@ def ff_optimization(self, xtals, N_added, N_min=50, dE=2.5, FMSE=2.5):

return N_added

def prepare_chm_info(self, params0, params1=None, suffix='pyxtal0'):
def prepare_chm_info(self, params0, params1=None, suffix='calc/pyxtal0'):
"""
TODO: A base classs for optimization
prepar_chm_info with the updated params.
Expand Down

0 comments on commit 84ce4fe

Please sign in to comment.