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
Performed some maintenance on the intial conditions generators and conversion routines to fix issues with the indexing of the central body and when rotation is disabled
  • Loading branch information
daminton committed Aug 27, 2021
1 parent 4d53903 commit 7c035a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
4 changes: 3 additions & 1 deletion python/swiftest/swiftest/init_cond.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def solar_system_horizons(plname, idval, param, ephemerides_start_date, ds):
Ipsun = np.array([0.0, 0.0, planetIpz['Sun']])

cbid = np.array([1])
cvec = np.vstack([GMcb, Rcb, J2RP2, J4RP4, Ipsun[0], Ipsun[1], Ipsun[2], rotcb.x, rotcb.y, rotcb.z ])
cvec = np.vstack([GMcb, Rcb, J2RP2, J4RP4])
if param['ROTATION'] == 'YES':
cvec = np.vstack([cvec, Ipsun[0], Ipsun[1], Ipsun[2], rotcb.x, rotcb.y, rotcb.z])

# Horizons date time internal variables
tstart = datetime.date.fromisoformat(ephemerides_start_date)
Expand Down
23 changes: 12 additions & 11 deletions python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,21 +766,22 @@ def swiftest_xr2infile(ds, param, framenum=-1):
A set of three input files for a Swiftest run
"""
frame = ds.isel(time=framenum)
cb = frame.where(frame.id == 0, drop=True)
pl = frame.where(frame.id > 0, drop=True)
cb = frame.where(frame.id == 1, drop=True)
pl = frame.where(frame.id > 1, drop=True)
pl = pl.where(np.invert(np.isnan(pl['Gmass'])), drop=True).drop_vars(['J_2', 'J_4'])
tp = frame.where(np.isnan(frame['Gmass']), drop=True).drop_vars(['Gmass', 'radius', 'J_2', 'J_4'])

GMSun = np.double(cb['Gmass'])
RSun = np.double(cb['radius'])
J2 = np.double(cb['J_2'])
J4 = np.double(cb['J_4'])
Ip1cb = np.double(cb['Ip1'])
Ip2cb = np.double(cb['Ip2'])
Ip3cb = np.double(cb['Ip3'])
rotxcb = np.double(cb['rotx'])
rotycb = np.double(cb['roty'])
rotzcb = np.double(cb['rotz'])
if param['ROTATION'] == 'YES':
Ip1cb = np.double(cb['Ip1'])
Ip2cb = np.double(cb['Ip2'])
Ip3cb = np.double(cb['Ip3'])
rotxcb = np.double(cb['rotx'])
rotycb = np.double(cb['roty'])
rotzcb = np.double(cb['rotz'])
cbid = int(0)

if param['IN_TYPE'] == 'ASCII':
Expand Down Expand Up @@ -942,8 +943,8 @@ def swifter_xr2infile(ds, param, framenum=-1):
A set of input files for a Swifter run
"""
frame = ds.isel(time=framenum)
cb = frame.where(frame.id == 0, drop=True)
pl = frame.where(frame.id > 0, drop=True)
cb = frame.where(frame.id == 1, drop=True)
pl = frame.where(frame.id > 1, drop=True)
pl = pl.where(np.invert(np.isnan(pl['Gmass'])), drop=True).drop_vars(['J_2', 'J_4'])
tp = frame.where(np.isnan(frame['Gmass']), drop=True).drop_vars(['Gmass', 'radius', 'J_2', 'J_4'])

Expand All @@ -956,7 +957,7 @@ def swifter_xr2infile(ds, param, framenum=-1):
# Swiftest Central body file
plfile = open(param['PL_IN'], 'w')
print(pl.id.count().values + 1, file=plfile)
print(cb.id.values[0], cb['Gmass'].values[0], file=plfile)
print(cb.id.values[0], GMSun, file=plfile)
print('0.0 0.0 0.0', file=plfile)
print('0.0 0.0 0.0', file=plfile)
for i in pl.id:
Expand Down

0 comments on commit 7c035a2

Please sign in to comment.