Compare commits

..

11 commits

2 changed files with 52 additions and 13 deletions

View file

@ -47,6 +47,15 @@ def register_arguments_card(parser:ArgumentParser):
parser.add_argument("--OutputFCsDensity", type=str, default=None, help="Output FCs density file.")
parser.add_argument("--OutputFCsSnapshot", type=str, default=None, help="Output FCs snapshot file.")
parser.add_argument("--OutputRngStateLPT", type=str, default=None, help="Output RNG state file.")
## Tests with phiBCs and density
parser.add_argument("--WriteGravPot", type=bool, default=False, help="Write gravitational potential.")
parser.add_argument("--OutputGravitationalPotentialBase", type=str, default=None, help="Output gravitational potential base.")
parser.add_argument("--MeshGravPot", type=int, default=None, help="Mesh for gravitational potential.")
parser.add_argument("--WriteDensity", type=bool, default=False, help="Write density.")
parser.add_argument("--OutputDensityBase", type=str, default=None, help="Output density base.")
parser.add_argument("--MeshDensity", type=int, default=None, help="Mesh for density.")
parser.add_argument("--LoadPhiBCs", type=bool, default=False, help="Load phiBCs.")
parser.add_argument("--InputPhiBCsBase", type=str, default=None, help="Input phiBCs file base.")
def register_arguments_card_for_ICs(parser:ArgumentParser):
@ -118,6 +127,16 @@ def parse_arguments_card(parsed_args):
OutputFCsDensity=parsed_args.OutputFCsDensity,
OutputFCsSnapshot=parsed_args.OutputFCsSnapshot,
OutputRngStateLPT=parsed_args.OutputRngStateLPT,
## Tests with phiBCs and density
WriteGravPot=parsed_args.WriteGravPot,
OutputGravitationalPotentialBase=parsed_args.OutputGravitationalPotentialBase,
MeshGravPot=parsed_args.MeshGravPot,
WriteDensity=parsed_args.WriteDensity,
OutputDensityBase=parsed_args.OutputDensityBase,
MeshDensity=parsed_args.MeshDensity,
LoadPhiBCs=parsed_args.LoadPhiBCs,
InputPhiBCsBase=parsed_args.InputPhiBCsBase,
## Cosmological parameters
h=cosmo_dict["h"],
Omega_m=cosmo_dict["Omega_m"],
Omega_b=cosmo_dict["Omega_b"],
@ -203,6 +222,17 @@ def parse_arguments_card(parsed_args):
card_dict["OutputFCsSnapshot"] = main_dict["resultdir"]+"final_particles_"+main_dict["simname"]+".gadget3"
if card_dict["OutputRngStateLPT"] is None:
card_dict["OutputRngStateLPT"] = main_dict["workdir"]+"rng_state.h5"
## Tests with phiBCs and density
if card_dict["OutputGravitationalPotentialBase"] is None:
card_dict["OutputGravitationalPotentialBase"] = main_dict["workdir"]+"gravpot_"+main_dict["simname"]
if card_dict["MeshGravPot"] is None:
card_dict["MeshGravPot"] = card_dict["N_PM_mesh"]
if card_dict["OutputDensityBase"] is None:
card_dict["OutputDensityBase"] = main_dict["workdir"]+"density_"+main_dict["simname"]
if card_dict["MeshDensity"] is None:
card_dict["MeshDensity"] = card_dict["N_PM_mesh"]
if card_dict["InputPhiBCsBase"] is None:
card_dict["InputPhiBCsBase"] = main_dict["workdir"]+"gravpot_tCOLA"
return card_dict
@ -321,6 +351,16 @@ def create_parameter_card_dict(
OutputFCsDensity:str = 'fcs_density.h5',
OutputFCsSnapshot:str = 'fcs_particles.gadget3',
## Tests with phiBCs and density
WriteGravPot:bool = True,
OutputGravitationalPotentialBase:str = 'gravitational_potential.h5',
MeshGravPot:int = 128,
WriteDensity:bool = False,
OutputDensityBase:str = 'density.h5',
MeshDensity:int = 128,
LoadPhiBCs:bool = False,
InputPhiBCsBase:str = 'gravitational_potential.h5',
## Cosmological parameters
h:float = 0.6732,
Omega_m:float = 0.302,
@ -381,6 +421,17 @@ def create_parameter_card_dict(
OutputLPTPotential1=OutputLPTPotential1,
OutputLPTPotential2=OutputLPTPotential2,
OutputTilesBase=OutputTilesBase,
# Tests with phiBCs and density
WriteGravPot=int(WriteGravPot),
OutputGravitationalPotentialBase=OutputGravitationalPotentialBase,
MeshGravPot=MeshGravPot,
WriteDensity=int(WriteDensity),
OutputDensityBase=OutputDensityBase,
MeshDensity=MeshDensity,
LoadPhiBCs=int(LoadPhiBCs),
InputPhiBCsBase=InputPhiBCsBase,
h=h,
Omega_m=Omega_m,
Omega_b=Omega_b,

View file

@ -1,5 +1,3 @@
limit_slurm_arrays = 512
def main_scola(parsed_args):
from args_main import parse_arguments_main
from low_level import print_starting_module, print_message, print_ending_module, progress_bar_from_logfile, wait_until_file_exists
@ -54,14 +52,12 @@ def main_scola(parsed_args):
elif parsed_args.execution == "slurm":
from slurm_submission import create_slurm_script, parse_arguments_slurm
from args_main import parse_arguments_main
from parameters_card import parse_arguments_card
import os
print_message("Running scola in slurm mode.", 1, "scola", verbose=parsed_args.verbose)
slurm_dict=parse_arguments_slurm(parsed_args)
main_dict=parse_arguments_main(parsed_args)
card_dict=parse_arguments_card(parsed_args)
if (have_no_tiles(parsed_args) or parsed_args.force) and card_dict["N_tiles"]**3 < limit_slurm_arrays :
if have_no_tiles(parsed_args) or parsed_args.force:
## Submit all boxes
print_message("Submitting all boxes.", 2, "scola", verbose=parsed_args.verbose)
slurm_script = slurm_dict["scripts"]+"scola_"+main_dict["simname"]+".sh"
@ -97,7 +93,6 @@ def main_scola(parsed_args):
else:
## Submit missing boxes
from time import sleep
missing_tiles_arrays = get_missing_tiles_arrays(parsed_args)
print_message(f"Submitting missing boxes: {missing_tiles_arrays}.", 2, "scola", verbose=parsed_args.verbose)
@ -132,7 +127,6 @@ def main_scola(parsed_args):
subprocess.run(command_args)
print_message("sCOLA job submitted.", 2, "scola", verbose=parsed_args.verbose)
sleep(len(missing_tiles)*0.2) # Sleep for a bit to avoid overloading the scheduler
os.remove(slurm_script) # Remove the script after submission (because it is specific to the missing tiles)
@ -235,17 +229,11 @@ def get_missing_tiles_arrays(parsed_args):
nboxes_tot = int(parsed_args.N_tiles**3)
missing_tiles_arrays = []
in_sequence_of_missing = False
len_sequence_of_missing = 0
for b in range(1,nboxes_tot+1):
if not isfile(card_dict["OutputTilesBase"]+str(b)+".h5"):
len_sequence_of_missing += 1
if not in_sequence_of_missing:
missing_tiles_arrays.append([b])
in_sequence_of_missing = True
len_sequence_of_missing = 1
if len_sequence_of_missing > limit_slurm_arrays:
missing_tiles_arrays[-1].append(b)
in_sequence_of_missing = False
elif in_sequence_of_missing:
missing_tiles_arrays[-1].append(b-1)
in_sequence_of_missing = False