Skip to content

Commit

Permalink
mainloop| prioritize start.in
Browse files Browse the repository at this point in the history
  • Loading branch information
Kisung Kang committed Jun 20, 2024
1 parent a9df30d commit 94a7283
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions libs/lib_mainloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,39 @@ def MLMD_main(
# When this initialization starts from scratch,
if MD_index == 0:
# Even when it is very first iterative step,
if inputs.index != 0:
if os.path.exists('start.in'):
single_print(f'[MLMD] Read a configuration from start.in')
# Read the ground state structure with the primitive cell
struc_init = atoms_read('start.in', format='aims')
# Make it supercell
struc_step = make_supercell(struc_init, inputs.supercell_init)
MaxwellBoltzmannDistribution(struc_step, temperature_K=inputs.temperature, force_temp=True)

elif os.path.exists('start.traj'):
single_print(f'[runMD]\tFound the start.traj file. MD starts from this.')
# Read the ground state structure with the primitive cell
struc_init = Trajectory('start.traj')[-1]
struc_step = make_supercell(struc_init, inputs.supercell_init)
del struc_init
try:
struc_step.get_velocities()
except AttributeError:
MaxwellBoltzmannDistribution(struc_step, temperature_K=inputs.temperature, force_temp=True)

elif os.path.exists('start.bundle'):
from ase.io.bundletrajectory import BundleTrajectory
single_print(f'[runMD]\tFound the start.bundle file. MD starts from this.')
file_traj_read = BundleTrajectory(filename='start.bundle', mode='r')
file_traj_read[0]; #ASE bug
struc_init = file_traj_read[-1]
struc_step = make_supercell(struc_init, inputs.supercell_init)
del struc_init
try:
struc_step.get_velocities()
except AttributeError:
MaxwellBoltzmannDistribution(struc_step, temperature_K=inputs.temperature, force_temp=True)

elif inputs.index != 0:
# Name of the pervious uncertainty file
uncert_file = f'UNCERT/uncertainty-{condition}_{inputs.index-1}.txt'

Expand Down Expand Up @@ -143,38 +175,6 @@ def MLMD_main(
# Resume the MD calculation from last configuration in the trajectory file
struc_step = traj_previous[-1]; del traj_previous;

elif os.path.exists('start.in'):
single_print(f'[MLMD] Read a configuration from start.in')
# Read the ground state structure with the primitive cell
struc_init = atoms_read('start.in', format='aims')
# Make it supercell
struc_step = make_supercell(struc_init, inputs.supercell_init)
MaxwellBoltzmannDistribution(struc_step, temperature_K=inputs.temperature, force_temp=True)

elif os.path.exists('start.traj'):
single_print(f'[runMD]\tFound the start.traj file. MD starts from this.')
# Read the ground state structure with the primitive cell
struc_init = Trajectory('start.traj')[-1]
struc_step = make_supercell(struc_init, inputs.supercell_init)
del struc_init
try:
struc_step.get_velocities()
except AttributeError:
MaxwellBoltzmannDistribution(struc_step, temperature_K=inputs.temperature, force_temp=True)

elif os.path.exists('start.bundle'):
from ase.io.bundletrajectory import BundleTrajectory
single_print(f'[runMD]\tFound the start.bundle file. MD starts from this.')
file_traj_read = BundleTrajectory(filename='start.bundle', mode='r')
file_traj_read[0]; #ASE bug
struc_init = file_traj_read[-1]
struc_step = make_supercell(struc_init, inputs.supercell_init)
del struc_init
try:
struc_step.get_velocities()
except AttributeError:
MaxwellBoltzmannDistribution(struc_step, temperature_K=inputs.temperature, force_temp=True)

else:
single_print(f'[MLMD] Read a configuration from trajectory_train.son')
# Read the trajectory file from 'trajectory_train.son'
Expand Down

0 comments on commit 94a7283

Please sign in to comment.