From cba1f772843ccf3e18581b636c4fe533657e22ee Mon Sep 17 00:00:00 2001 From: David Minton Date: Mon, 26 Feb 2024 11:21:50 -0500 Subject: [PATCH] Fixed problem with unit conversion for the CHK_QMIN_RANGE value. Also set it so that the default rmin value is the central body radius, rather than the solar radius --- swiftest/simulation_class.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/swiftest/simulation_class.py b/swiftest/simulation_class.py index 61f54d64a..d4e3a4e0f 100644 --- a/swiftest/simulation_class.py +++ b/swiftest/simulation_class.py @@ -238,7 +238,7 @@ def __init__(self,read_param: bool = False, The name of the time unit. When setting one of the standard units via `TU` a name will be automatically set for the unit, so this argument will override the automatic name. Parameter input file equivalent is None - rmin : float, default value is the radius of the Sun in the unit system defined by the unit input arguments. + rmin : float, default value is the radius of the central body in the unit system defined by the unit input arguments. Minimum distance of the simulation Parameter input file equivalent are `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. @@ -776,7 +776,7 @@ def set_parameter(self, "MU_name": None, "DU_name": None, "TU_name": None, - "rmin": constants.RSun / constants.AU2M, + "rmin": None, "rmax": 10000.0, "qmin_coord": "HELIO", "gmtiny": 0.0, @@ -2008,7 +2008,8 @@ def _update_param_units(self, MU2KG_old, DU2M_old, TU2S_old): if CHK_QMIN_RANGE is not None: CHK_QMIN_RANGE = CHK_QMIN_RANGE.split(" ") for i, v in enumerate(CHK_QMIN_RANGE): - CHK_QMIN_RANGE[i] = float(CHK_QMIN_RANGE[i]) * self.param['DU2M'] / DU2M_old + if float(v) > 0.0: + CHK_QMIN_RANGE[i] = float(v) * DU2M_old / self.param['DU2M'] self.param['CHK_QMIN_RANGE'] = f"{CHK_QMIN_RANGE[0]} {CHK_QMIN_RANGE[1]}" if TU2S_old is not None: @@ -3255,5 +3256,8 @@ def set_central_body(self, if align_to_central_body_rotation and 'rot' in cbda: self.data = tool.rotate_to_vector(self.data,cbda.rot.isel(time=0).values[()]) - + + if self.param['CHK_CLOSE']: + if 'CHK_RMIN' not in self.param: + self.param['CHK_RMIN'] = cbda.radius.values.item() return \ No newline at end of file