diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index 009e71470..652321f20 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -313,6 +313,7 @@ def __init__(self,read_param: bool = False, read_old_output: bool = False, simdi self._getter_column_width = self._swiftest_configuration['getter_column_width'] self._shell = Path(self._swiftest_configuration['shell']) self._shell_full = Path(self._swiftest_configuration['shell_full']) + self.verbose = kwargs.pop("verbose",True) self.param = {} self.data = xr.Dataset() @@ -320,19 +321,9 @@ def __init__(self,read_param: bool = False, read_old_output: bool = False, simdi self.encounters = xr.Dataset() self.collisions = xr.Dataset() - self.simdir = Path(simdir) - if self.simdir.exists(): - if not self.simdir.is_dir(): - msg = f"Cannot create the {self.simdir.resolve()} directory: File exists." - msg += "\nDelete the file or change the location of param_file" - raise NotADirectoryError(msg) - else: - if read_old_output or read_param: - raise NotADirectoryError(f"Cannot find directory {self.simdir.resolve()} ") - # Set the location of the parameter input file, choosing the default if it isn't specified. - param_file = kwargs.pop("param_file",Path.cwd() / self.simdir / "param.in") - self.verbose = kwargs.pop("verbose",True) + self.simdir = Path.cwd() / Path(simdir) + param_file = Path(kwargs.pop("param_file", "param.in")) # Parameters are set in reverse priority order. First the defaults, then values from a pre-existing input file, # then using the arguments passed via **kwargs. @@ -794,13 +785,13 @@ def set_parameter(self, verbose: bool = True, **kwargs): "encounter_check_loops": "TRIANGULAR", "ephemeris_date": "MBCL", "restart": False, - "encounter_save" : "NONE" + "encounter_save" : "NONE", + "simdir" : self.simdir } param_file = kwargs.pop("param_file",None) - # Extract the simulation directory and create it if it doesn't exist if param_file is not None: - self.param_file = Path.cwd() / param_file + self.param_file = param_file # If no arguments (other than, possibly, verbose) are requested, use defaults if len(kwargs) == 0: @@ -1245,6 +1236,7 @@ def set_feature(self, raise NotADirectoryError(msg) self.binary_path = self.simdir.resolve() self.driver_executable = self.binary_path / "swiftest_driver" + self.param_file = Path(kwargs.pop("param_file","param.in")) self.param["TIDES"] = False @@ -2587,7 +2579,7 @@ def read_param(self, True if the parameter file exists and is read correctly. False otherwise. """ if param_file is None: - param_file = self.param_file + param_file = self.simdir / self.param_file if read_init_cond is None: read_init_cond = True if codename is None: @@ -2661,7 +2653,7 @@ def write_param(self, verbose = self.verbose if verbose: - print(f"Writing parameter inputs to file {param_file}") + print(f"Writing parameter inputs to file {str(self.simdir / param_file)}") param['! VERSION'] = f"{codename} input file" self.simdir.mkdir(parents=True, exist_ok=True) @@ -2673,9 +2665,9 @@ def write_param(self, param.pop("CB_IN", None) param.pop("PL_IN", None) param.pop("TP_IN", None) - io.write_labeled_param(param, param_file) + io.write_labeled_param(param, self.simdir / param_file) elif codename == "Swift": - io.write_swift_param(param, param_file) + io.write_swift_param(param, self.simdir / param_file) else: warnings.warn('Cannot process unknown code type. Call the read_param method with a valid code name. Valid options are "Swiftest", "Swifter", or "Swift".',stacklevel=2) return diff --git a/src/collision/collision_regime.f90 b/src/collision/collision_regime.f90 index 4de99a844..5a8bd32f8 100644 --- a/src/collision/collision_regime.f90 +++ b/src/collision/collision_regime.f90 @@ -381,7 +381,7 @@ end function calc_b function calc_c_star(Rc1) result(c_star) !! author: David A. Minton !! - !! Calculates c_star as a function of impact equivalent radius. It inteRpolates between 5 for ~1 km sized bodies to + !! Calculates c_star as a function of impact equivalent radius. It interpolates between 5 for ~1 km sized bodies to !! 1.8 for ~10000 km sized bodies. See LS12 Fig. 4 for details. !! implicit none