From c01f007842a37743722f4a79db1e6fa13c24e449 Mon Sep 17 00:00:00 2001 From: David Minton Date: Tue, 27 Feb 2024 16:06:41 -0500 Subject: [PATCH] Fixed issues related to central body initial conditions. Now it explicitly sets rh, vh, and orbital elements if it detects a central body is being passed --- swiftest/init_cond.py | 10 ++++++++++ swiftest/simulation_class.py | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/swiftest/init_cond.py b/swiftest/init_cond.py index a8770328a..889780a03 100644 --- a/swiftest/init_cond.py +++ b/swiftest/init_cond.py @@ -363,6 +363,16 @@ def solar_system_horizons(name: str, if param['ROTATION']: Ip = Ipsun rot = rotcb + if param['IN_FORM'] == 'XV': + rh = np.array([0.0, 0.0, 0.0]) + vh = np.array([0.0, 0.0, 0.0]) + elif param['IN_FORM'] == 'EL': + a = np.nan + e = np.nan + inc = np.nan + capom = np.nan + omega = np.nan + capm = np.nan else: # Fetch solar system ephemerides from Horizons if ephemeris_id is None: ephemeris_id = name diff --git a/swiftest/simulation_class.py b/swiftest/simulation_class.py index 2317ea87a..90e96b969 100644 --- a/swiftest/simulation_class.py +++ b/swiftest/simulation_class.py @@ -2635,6 +2635,19 @@ def input_to_clm_array(val, n): if is_central_body: if a is not None or e is not None or inc is not None or capom is not None or omega is not None or capm is not None: raise ValueError("Orbital elements cannot be passed for a central body.") + if nbodies > 1: + raise ValueError("Only one central body may be passed.") + if rh is None: + rh = np.zeros((1,3)) + if vh is None: + vh = np.zeros((1,3)) + a = np.nan + e = np.nan + inc = np.nan + capom = np.nan + omega = np.nan + capm = np.nan + dsnew = init_cond.vec2xr(self.param, name=name, a=a, e=e, inc=inc, capom=capom, omega=omega, capm=capm, id=id, Gmass=Gmass, radius=radius, rhill=rhill, Ip=Ip, rh=rh, vh=vh,rot=rot, j2rp2=J2, j4rp4=J4, c_lm=c_lm, rotphase=rotphase, time=time)