From 57b140fe80080308922ba89f1f55c6e6f98ef30f Mon Sep 17 00:00:00 2001 From: David A Minton Date: Tue, 29 Nov 2022 17:04:20 -0500 Subject: [PATCH 1/2] Set it so that if you set read_old_output_file to True, it also reads the param file --- python/swiftest/swiftest/simulation_class.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index 7669c774f..6a38fb23d 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -320,9 +320,9 @@ def __init__(self,read_param: bool = False, **kwargs: Any): # Higher Priority: Values from a file (if requested and it exists) #----------------------------------------------------------------- - # If the user asks to read in an old parameter file, override any default parameters with values from the file + # If the user asks to read in an old parameter file or output file, override any default parameters with values from the file # If the file doesn't exist, flag it for now so we know to create it - if read_param: + if read_param or read_old_output_file: #good_param is self.read_param() if self.read_param(): # We will add the parameter file to the kwarg list. This will keep the set_parameter method from From 1603e3e93aaeca55a83c5217e85bf6d955fab8b1 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Tue, 29 Nov 2022 17:08:06 -0500 Subject: [PATCH 2/2] Fixed problem with argument read_old_output_file when it is not supplied --- python/swiftest/swiftest/simulation_class.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index 6a38fb23d..aeedc8ac6 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -41,7 +41,7 @@ class Simulation: This is a class that defines the basic Swift/Swifter/Swiftest simulation object """ - def __init__(self,read_param: bool = False, **kwargs: Any): + def __init__(self,read_param: bool = False, read_old_output_file: bool = False, **kwargs: Any): """ Parameters @@ -64,6 +64,10 @@ def __init__(self,read_param: bool = False, **kwargs: Any): - The argument has an equivalent parameter or set of parameters in the parameter input file. 3. Default values (see below) + read_old_output_file : bool, default False + If true, read in a pre-existing binary input file given by the argument `output_file_name` if it exists. + Parameter input file equivalent: None + **kwargs : See list of valid parameters and their defaults below codename : {"Swiftest", "Swifter", "Swift"}, default "Swiftest" @@ -140,9 +144,6 @@ def __init__(self,read_param: bool = False, **kwargs: Any): Specifies the format for the data saved to the output file. If "XV" then cartesian position and velocity vectors for all bodies are stored. If "XVEL" then the orbital elements are also stored. Parameter input file equivalent: `OUT_FORM` - read_old_output_file : bool, default False - If true, read in a pre-existing binary input file given by the argument `output_file_name` if it exists. - Parameter input file equivalent: None MU : str, default "MSUN" The mass unit system to use. Case-insensitive valid options are: * "Msun" : Solar mass @@ -344,7 +345,6 @@ def __init__(self,read_param: bool = False, **kwargs: Any): self.write_param() # Read in an old simulation file if requested - read_old_output_file = kwargs.pop("read_old_output_file",False) if read_old_output_file: binpath = os.path.join(self.sim_dir, self.param['BIN_OUT']) if os.path.exists(binpath):