Skip to content

Commit

Permalink
Keep multiple message file outputs.
Browse files Browse the repository at this point in the history
Disambiguate them with cluster job id prefixes.
  • Loading branch information
joaander committed Oct 24, 2023
1 parent 4e27707 commit 61d503c
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 18 deletions.
4 changes: 2 additions & 2 deletions hoomd_validation/alj_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def alj_2d_create_initial_state(*jobs):

device = hoomd.device.CPU(
communicator=communicator,
message_filename=job.fn('create_initial_state.log'))
message_filename=util.get_message_filename(job, 'create_initial_state.log'))

num_particles = job.statepoint['num_particles']
density = job.statepoint['density']
Expand Down Expand Up @@ -322,7 +322,7 @@ def alj_2d_nve_md_job(*jobs):

device = device_cls(
communicator=communicator,
message_filename=job.fn(f'{sim_mode}_{device_name}.log'))
message_filename=util.get_message_filename(job, f'{sim_mode}_{device_name}.log'))
run_nve_md_sim(job,
device,
complete_filename=f'{sim_mode}_{device_name}_complete')
Expand Down
4 changes: 2 additions & 2 deletions hoomd_validation/hard_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def hard_disk_create_initial_state(*jobs):
# create snapshot
device = hoomd.device.CPU(
communicator=communicator,
message_filename=job.fn('create_initial_state.log'))
message_filename=util.get_message_filename(job, 'create_initial_state.log'))
snap = hoomd.Snapshot(communicator)

if communicator.rank == 0:
Expand Down Expand Up @@ -566,7 +566,7 @@ def sampling_operation(*jobs):

device = device_cls(
communicator=communicator,
message_filename=job.fn(f'{mode}_{device_name}.log'))
message_filename=util.get_message_filename(job, f'{mode}_{device_name}.log'))

globals().get(f'run_{mode}_sim')(
job, device, complete_filename=f'{mode}_{device_name}_complete')
Expand Down
4 changes: 2 additions & 2 deletions hoomd_validation/hard_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def hard_sphere_create_initial_state(*jobs):
# create snapshot
device = hoomd.device.CPU(
communicator=communicator,
message_filename=job.fn('create_initial_state.log'))
message_filename=util.get_message_filename(job, 'create_initial_state.log'))
snap = hoomd.Snapshot(device.communicator)

if device.communicator.rank == 0:
Expand Down Expand Up @@ -445,7 +445,7 @@ def sampling_operation(*jobs):

device = device_cls(
communicator=communicator,
message_filename=job.fn(f'run_{mode}_{device_name}.log'))
message_filename=util.get_message_filename(job, f'run_{mode}_{device_name}.log'))

globals().get(f'run_{mode}_sim')(
job, device, complete_filename=f'{mode}_{device_name}_complete')
Expand Down
8 changes: 4 additions & 4 deletions hoomd_validation/lj_fluid.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def lj_fluid_create_initial_state(*jobs):
sp = job.sp
device = hoomd.device.CPU(
communicator=communicator,
message_filename=job.fn('create_initial_state.log'))
message_filename=util.get_message_filename(job, 'create_initial_state.log'))

box_volume = sp["num_particles"] / sp["density"]
L = box_volume**(1 / 3.)
Expand Down Expand Up @@ -409,7 +409,7 @@ def md_sampling_operation(*jobs):

device = device_cls(
communicator=communicator,
message_filename=job.fn(f'{sim_mode}_{device_name}.log'))
message_filename=util.get_message_filename(job, f'{sim_mode}_{device_name}.log'))

run_md_sim(job,
device,
Expand Down Expand Up @@ -808,7 +808,7 @@ def sampling_operation(*jobs):

device = device_cls(
communicator=communicator,
message_filename=job.fn(f'{mode}_mc_{device_name}.log'))
message_filename=util.get_message_filename(job, f'{mode}_mc_{device_name}.log'))

globals().get(f'run_{mode}_mc_sim')(
job, device, complete_filename=f'{mode}_mc_{device_name}_complete')
Expand Down Expand Up @@ -1338,7 +1338,7 @@ def lj_fluid_nve_md_job(*jobs):

device = device_cls(
communicator=communicator,
message_filename=job.fn(f'{sim_mode}_{device_name}.log'))
message_filename=util.get_message_filename(job, f'{sim_mode}_{device_name}.log'))
run_nve_md_sim(job,
device,
run_length=run_length,
Expand Down
8 changes: 4 additions & 4 deletions hoomd_validation/lj_union.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def lj_union_create_initial_state(*jobs):
sp = job.sp
device = hoomd.device.CPU(
communicator=communicator,
message_filename=job.fn('create_initial_state.log'))
message_filename=util.get_message_filename(job, 'create_initial_state.log'))

box_volume = sp["num_particles"] / sp["density"]
L = box_volume**(1 / 3.)
Expand Down Expand Up @@ -439,7 +439,7 @@ def md_sampling_operation(*jobs):

device = device_cls(
communicator=communicator,
message_filename=job.fn(f'{sim_mode}_{device_name}.log'))
message_filename=util.get_message_filename(job, f'{sim_mode}_{device_name}.log'))

run_md_sim(job,
device,
Expand Down Expand Up @@ -866,7 +866,7 @@ def sampling_operation(*jobs):

device = device_cls(
communicator=communicator,
message_filename=job.fn(f'{mode}_mc_{device_name}.log'))
message_filename=util.get_message_filename(job, f'{mode}_mc_{device_name}.log'))

globals().get(f'run_{mode}_mc_sim')(
job, device, complete_filename=f'{mode}_mc_{device_name}_complete')
Expand Down Expand Up @@ -1420,7 +1420,7 @@ def lj_union_nve_md_job(*jobs):

device = device_cls(
communicator=communicator,
message_filename=job.fn(f'{sim_mode}_{device_name}.log'))
message_filename=util.get_message_filename(job, f'{sim_mode}_{device_name}.log'))
run_nve_md_sim(job,
device,
run_length=run_length,
Expand Down
4 changes: 2 additions & 2 deletions hoomd_validation/patchy_particle_pressure.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def patchy_particle_pressure_create_initial_state(*jobs):
# create snapshot
device = hoomd.device.CPU(
communicator=communicator,
message_filename=job.fn('create_initial_state.log'))
message_filename=util.get_message_filename(job, 'create_initial_state.log'))
snap = hoomd.Snapshot(communicator)

if communicator.rank == 0:
Expand Down Expand Up @@ -602,7 +602,7 @@ def sampling_operation(*jobs):

device = device_cls(
communicator=communicator,
message_filename=job.fn(f'{mode}_{device_name}.log'))
message_filename=util.get_message_filename(job, f'{mode}_{device_name}.log'))

globals().get(f'run_{mode}_sim')(
job, device, complete_filename=f'{mode}_{device_name}_complete')
Expand Down
4 changes: 2 additions & 2 deletions hoomd_validation/simple_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def simple_polygon_create_initial_state(*jobs):
# create snapshot
device = hoomd.device.CPU(
communicator=communicator,
message_filename=job.fn('create_initial_state.log'))
message_filename=util.get_message_filename(job, 'create_initial_state.log'))
snap = hoomd.Snapshot(communicator)

if communicator.rank == 0:
Expand Down Expand Up @@ -488,7 +488,7 @@ def sampling_operation(*jobs):

device = device_cls(
communicator=communicator,
message_filename=job.fn(f'{mode}_{device_name}.log'))
message_filename=util.get_message_filename(job, f'{mode}_{device_name}.log'))

globals().get(f'run_{mode}_sim')(
job, device, complete_filename=f'{mode}_{device_name}_complete')
Expand Down
10 changes: 10 additions & 0 deletions hoomd_validation/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import numpy
import signac
import os


def true_all(*jobs, key):
Expand All @@ -28,6 +29,15 @@ def get_job_filename(sim_mode, device, name, type):
return f"{sim_mode}_{suffix}_{name}.{type}"


def get_message_filename(job, filename):
"""Get a cluster job unique message filename.
"""
cluster_id = os.environ.get('SLURM_JOB_ID', None)
if cluster_id is not None:
return job.fn(f'{cluster_id}-{filename}')
else:
return job.fn(filename)

def run_up_to_walltime(sim, end_step, steps, walltime_stop):
"""Run a simulation, stopping early if a walltime limit is reached.
Expand Down

0 comments on commit 61d503c

Please sign in to comment.