Skip to content

Commit

Permalink
finalise minimal mode
Browse files Browse the repository at this point in the history
  • Loading branch information
srmnitc committed Sep 7, 2023
1 parent 2828249 commit 3c2b5b9
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 23 deletions.
20 changes: 20 additions & 0 deletions calphy/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def __init__(self):
self._lattice_constant = 0
self._repeat = [1, 1, 1]
self._script_mode = False
self._lammps_executable = None
self._mpi_executable = None
self._npt = True
self._n_equilibration_steps = 25000
self._n_switching_steps = 50000
Expand Down Expand Up @@ -542,6 +544,22 @@ def script_mode(self, val):
self._script_mode = val
else:
raise TypeError("script mode should be either True/False")

@property
def lammps_executable(self):
return self._lammps_executable

@lammps_executable.setter
def lammps_executable(self, val):
self._lammps_executable = val

@property
def mpi_executable(self):
return self._mpi_executable

@mpi_executable.setter
def mpi_executable(self, val):
self._mpi_executable = val

@property
def n_equilibration_steps(self):
Expand Down Expand Up @@ -718,6 +736,8 @@ def generate(cls, indata):
calc.element = indata["element"]
calc.mass = indata["mass"]
calc.script_mode = indata["script_mode"]
calc.lammps_executable = indata["lammps_executable"]
calc.mpi_executable = indata["mpi_executable"]

if "md" in indata.keys():
calc.md.add_from_dict(indata["md"])
Expand Down
101 changes: 78 additions & 23 deletions calphy/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,84 @@ def run_jobs(inputfile):
calculations = read_inputfile(inputfile)
print("Total number of %d calculations found" % len(calculations))

for count, calc in enumerate(calculations):

identistring = calc.create_identifier()
scriptpath = os.path.join(os.getcwd(), ".".join([identistring, "sub"]))
errfile = os.path.join(os.getcwd(), ".".join([identistring, "err"]))

#the below part assigns the schedulers
#now we have to write the submission scripts for the job
#parse Queue and import module
if calc.queue.scheduler == "local":
scheduler = pq.Local(calc.queue.__dict__, cores=calc.queue.cores)
elif calc.queue.scheduler == "slurm":
scheduler = pq.SLURM(calc.queue.__dict__, cores=calc.queue.cores)
elif calc.queue.scheduler == "sge":
scheduler = pq.SGE(calc.queue.__dict__, cores=calc.queue.cores)
else:
raise ValueError("Unknown scheduler")

#for lattice just provide the number of position
scheduler.maincommand = "calphy_kernel -i %s -k %d"%(inputfile,
count)
scheduler.write_script(scriptpath)
_ = scheduler.submit()
if calculations[0].script_mode:
for count, calc in enumerate(calculations):
identistring = calc.create_identifier()
scriptpath = os.path.join(os.getcwd(), ".".join([identistring, "sub"]))
errfile = os.path.join(os.getcwd(), ".".join([identistring, "err"]))
if calc.queue.scheduler == "local":
scheduler = pq.Local(calc.queue.__dict__, cores=calc.queue.cores)
elif calc.queue.scheduler == "slurm":
scheduler = pq.SLURM(calc.queue.__dict__, cores=calc.queue.cores)
elif calc.queue.scheduler == "sge":
scheduler = pq.SGE(calc.queue.__dict__, cores=calc.queue.cores)
else:
raise ValueError("Unknown scheduler")

#add run commands
command = f'calphy_run_averaging -i {inputfile} -k {count}'
scheduler.queueoptions['commands'].append(command)

command = f'cp input.yaml {os.path.join(os.getcwd(), identistring)}'
scheduler.queueoptions['commands'].append(command)

command = f'cd {os.path.join(os.getcwd(), identistring)}'
scheduler.queueoptions['commands'].append(command)
if calc.queue.cores > 1:
#here turn on mpi
command = f'{calc.mpi_executable} -np {calc.queue.cores} {calc.lammps_executable} -in averaging.lmp'
else:
command = f'{calc.lammps_executable} -in averaging.lmp'
scheduler.queueoptions['commands'].append(command)
scheduler.queueoptions['commands'].append('cd ..')

command = f'calphy_process_averaging -i {inputfile} -k {count}'
scheduler.queueoptions['commands'].append(command)

command = f'calphy_run_integration -i {inputfile} -k {count}'
scheduler.queueoptions['commands'].append(command)

command = f'cd {os.path.join(os.getcwd(), identistring)}'
scheduler.queueoptions['commands'].append(command)
if calc.queue.cores > 1:
#here turn on mpi
command = f'{calc.mpi_executable} -np {calc.queue.cores} {calc.lammps_executable} -in integration.lmp'
else:
command = f'{calc.lammps_executable} -in integration.lmp'
scheduler.queueoptions['commands'].append(command)
scheduler.queueoptions['commands'].append('cd ..')

command = f'calphy_process_integration -i {inputfile} -k {count}'
scheduler.maincommand = command
scheduler.write_script(scriptpath)
#_ = scheduler.submit()



else:
for count, calc in enumerate(calculations):

identistring = calc.create_identifier()
scriptpath = os.path.join(os.getcwd(), ".".join([identistring, "sub"]))
errfile = os.path.join(os.getcwd(), ".".join([identistring, "err"]))

#the below part assigns the schedulers
#now we have to write the submission scripts for the job
#parse Queue and import module
if calc.queue.scheduler == "local":
scheduler = pq.Local(calc.queue.__dict__, cores=calc.queue.cores)
elif calc.queue.scheduler == "slurm":
scheduler = pq.SLURM(calc.queue.__dict__, cores=calc.queue.cores)
elif calc.queue.scheduler == "sge":
scheduler = pq.SGE(calc.queue.__dict__, cores=calc.queue.cores)
else:
raise ValueError("Unknown scheduler")

#for lattice just provide the number of position
scheduler.maincommand = "calphy_kernel -i %s -k %d"%(inputfile,
count)
scheduler.write_script(scriptpath)
_ = scheduler.submit()



Expand Down

0 comments on commit 3c2b5b9

Please sign in to comment.