Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Moved the CHK_QMIN_HELIO parameter setting into the distance_range setters and getters. Removed the loop style parameters out of the initiation of the param dictionary
  • Loading branch information
daminton committed Nov 11, 2022
1 parent 152fc89 commit 9b31c06
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def __init__(self,
TU_name: str | None = None,
rmin: float = constants.RSun / constants.AU2M,
rmax: float = 10000.0,
qmin_coord: Literal["HELIO","BARY"] = "HELIO",
close_encounter_check: bool = True,
general_relativity: bool = True,
fragmentation: bool = True,
Expand Down Expand Up @@ -183,6 +184,8 @@ def __init__(self,
Minimum distance of the simulation (CHK_QMIN, CHK_RMIN, CHK_QMIN_RANGE[0])
rmax : float, default value is 10000 AU in the unit system defined by the unit input arguments.
Maximum distance of the simulation (CHK_RMAX, CHK_QMIN_RANGE[1])
qmin_coord : str, {"HELIO", "BARY"}, default "HELIO"
coordinate frame to use for CHK_QMIN
close_encounter_check : bool, default True
Check for close encounters between bodies. If set to True, then the radii of massive bodies must be included
in initial conditions.
Expand Down Expand Up @@ -238,9 +241,6 @@ def __init__(self,
self.ds = xr.Dataset()
self.param = {
'! VERSION': f"Swiftest parameter input",
'CHK_QMIN_COORD': "HELIO",
'INTERACTION_LOOPS': interaction_loops,
'ENCOUNTER_CHECK': encounter_check_loops
}
self.codename = codename
self.verbose = verbose
Expand Down Expand Up @@ -1402,6 +1402,7 @@ def update_param_units(self, MU2KG_old, DU2M_old, TU2S_old):
def set_distance_range(self,
rmin: float | None = None,
rmax: float | None = None,
qmin_coord: Literal["HELIO","BARY"] | None = None,
verbose: bool | None = None,
**kwargs: Any):
"""
Expand All @@ -1413,6 +1414,8 @@ def set_distance_range(self,
Minimum distance of the simulation (CHK_QMIN, CHK_RMIN, CHK_QMIN_RANGE[0])
rmax : float
Maximum distance of the simulation (CHK_RMAX, CHK_QMIN_RANGE[1])
qmin_coord : str, {"HELIO", "BARY"}
coordinate frame to use for CHK_QMIN
**kwargs
A dictionary of additional keyword argument. This allows this method to be called by the more general
set_parameter method, which takes all possible Simulation parameters as arguments, so these are ignored.
Expand Down Expand Up @@ -1440,6 +1443,14 @@ def set_distance_range(self,
self.param['CHK_EJECT'] = rmax
CHK_QMIN_RANGE[1] = rmax
update_list.append("rmax")
if qmin_coord is not None:
valid_qmin_coord = ["HELIO","BARY"]
if qmin_coord.upper() not in valid_qmin_coord:
print(f"qmin_coord = {qmin_coord} is not a valid option. Must be one of",','.join(valid_qmin_coord))
self.param['CHK_QMIN_COORD'] = valid_qmin_coord[0]
else:
self.param['CHK_QMIN_COORD'] = qmin_coord.upper()
update_list.append("qmin_coord")

self.param['CHK_QMIN_RANGE'] = f"{CHK_QMIN_RANGE[0]} {CHK_QMIN_RANGE[1]}"

Expand Down Expand Up @@ -1473,6 +1484,7 @@ def get_distance_range(self, arg_list: str | List[str] | None = None, verbose: b

valid_var = {"rmin": "CHK_RMIN",
"rmax": "CHK_RMAX",
"qmin_coord": "CHK_QMIN_COORD",
"qmin": "CHK_QMIN",
"qminR": "CHK_QMIN_RANGE"
}
Expand Down Expand Up @@ -1503,6 +1515,9 @@ def get_distance_range(self, arg_list: str | List[str] | None = None, verbose: b
if "rmax" in valid_arg:
key = valid_var["rmax"]
print(f"{'rmax':<{self._getter_column_width}} {range_dict[key]} {units['rmax']}")
if "qmin_coord" in valid_arg:
key = valid_var["qmin_coord"]
print(f"{'qmin_coord':<{self._getter_column_width}} {range_dict[key]}")

return range_dict

Expand Down

0 comments on commit 9b31c06

Please sign in to comment.