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

Commit

Permalink
Fixed some unit issues and added some more helpful unit conversion in…
Browse files Browse the repository at this point in the history
…stance variables
  • Loading branch information
daminton committed Jan 9, 2023
1 parent d828020 commit 72f9df2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,8 @@ def set_unit_system(self,
warnings.warn(f"{MU} not a recognized unit system. Using MSun as a default.",stacklevel=2)
self.param['MU2KG'] = constants.MSun
self.MU_name = "MSun"
self.MU2KG = self.param['MU2KG']
self.KG2MU = 1.0 / self.MU2KG

if DU2M is not None or DU is not None:
DU2M_old = self.param.pop('DU2M', None)
Expand All @@ -1786,6 +1788,8 @@ def set_unit_system(self,
warnings.warn(f"{DU} not a recognized unit system. Using AU as a default.",stacklevel=2)
self.param['DU2M'] = constants.AU2M
self.DU_name = "AU"
self.DU2M = self.param['DU2M']
self.M2DU = 1.0 / self.DU2M

if TU2S is not None or TU is not None:
TU2S_old = self.param.pop('TU2S', None)
Expand All @@ -1806,6 +1810,8 @@ def set_unit_system(self,
warnings.warn(f"{TU} not a recognized unit system. Using YR as a default.",stacklevel=2)
self.param['TU2S'] = constants.YR2S
self.TU_name = "y"
self.TU2S = self.param['TU2S']
self.S2TU = 1.0 / self.TU2S

if MU_name is not None:
self.MU_name = MU_name
Expand Down Expand Up @@ -2464,8 +2470,8 @@ def input_to_array_3d(val,n=None):
if mass is not None:
if Gmass is not None:
raise ValueError("Cannot use mass and Gmass inputs simultaneously!")
else:
Gmass = self.param['GU'] * mass
else:
Gmass = self.GU * mass

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, J2=J2, J4=J4, time=time)
Expand Down

0 comments on commit 72f9df2

Please sign in to comment.