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
Updated the IO package with a swift converter. Also fixed an issue with the collision_movie script
  • Loading branch information
daminton committed Sep 9, 2021
1 parent 7d61dd4 commit 57c10ac
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 6 deletions.
10 changes: 5 additions & 5 deletions examples/symba_energy_momentum/collision_movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
ncutoff = 1e20
radscale = 2000

cases = ['supercat_head', 'supercat_off', 'disruption_head', 'disruption_off']
#cases = ['supercat_head']
#cases = ['supercat_head', 'supercat_off', 'disruption_head', 'disruption_off']
cases = ['disruption_off']

def scale_sim(ds, Rcb):
dst0 = ds.isel(time=0)
Expand Down Expand Up @@ -100,8 +100,8 @@ def __init__(self, ds, param):
# Then setup FuncAnimation.
self.ani = animation.FuncAnimation(fig, self.update, interval=1, frames=nframes,
init_func=self.setup_plot, blit=False)
self.ani.save(animfile, fps=60, dpi=300, extra_args=['-vcodec', 'mpeg4'])
#self.ani.save(animfile, fps=60, dpi=300, extra_args=['-vcodec', 'libx264'])
#self.ani.save(animfile, fps=60, dpi=300, extra_args=['-vcodec', 'mpeg4'])
self.ani.save(animfile, fps=60, dpi=300, extra_args=['-vcodec', 'libx264'])
print(f"Finished writing {animfile}")

def plot_pl_circles(self, pl, radmarker):
Expand Down Expand Up @@ -264,7 +264,7 @@ def data_stream(self, frame=0):
origin = d['origin_type'].values

t = self.ds.coords['time'].values[frame]
self.mask = np.logical_not(radius > self.Rcb)
self.mask = np.logical_not(radius == 0.0)

x = np.nan_to_num(x, copy=False)
y = np.nan_to_num(y, copy=False)
Expand Down
51 changes: 50 additions & 1 deletion python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,4 +1503,53 @@ def swiftest2swifter_param(swiftest_param, J2=0.0, J4=0.0):
swifter_param['OUT_STAT'] = "UNKNOWN"
swifter_param['! VERSION'] = "Swifter parameter file converted from Swiftest"

return swifter_param
return swifter_param


def swifter2swift_param(swifter_param, J2=0.0, J4=0.0):
swift_param = {
'! VERSION': f"Swift parameter input file converted from Swifter",
'T0': 0.0,
'TSTOP': 0.0,
'DT': 0.0,
'DTOUT': 0.0,
'DTDUMP': 0.0,
'L1': "F",
'L1': "F",
'L2': "F",
'L3': "F",
'L4': "F",
'L5': "T",
'L6': "F",
'RMIN': -1,
'RMAX': -1,
'RMAXU': -1,
'QMIN': -1,
'LCLOSE': "F",
'BINARY_OUTPUTFILE': "bin.dat",
'STATUS_FLAG_FOR_OPEN_STATEMENTS': "NEW",
}

swift_param['T0'] = swifter_param['T0']
swift_param['TSTOP'] = swifter_param['TSTOP']
swift_param['DT'] = swifter_param['DT']
# Convert the parameter file values
swift_param['DTOUT'] = swifter_param['ISTEP_OUT'] * swifter_param['DT']
swift_param['DTDUMP'] = swifter_param['ISTEP_DUMP'] * swifter_param['DT']
swift_param['BINARY_OUTPUTFILE'] = swifter_param['BIN_OUT']
swift_param['STATUS_FLAG_FOR_OPEN_STATEMENTS'] = swifter_param['OUT_STAT']

if swifter_param['CHK_CLOSE'] == "YES":
swift_param['LCLOSE'] = "T"
else:
swift_param['LCLOSE'] = "F"

swift_param['RMIN'] = swifter_param['CHK_RMIN']
swift_param['RMAX'] = swifter_param['CHK_RMAX']
swift_param['QMIN'] = swifter_param['CHK_QMIN']

if swift_param['RMIN'] > 0 or swift_param['RMAX'] > 0 or swift_param['QMIN'] > 0:
swift_param['L2'] = 'T'


return swift_param

0 comments on commit 57c10ac

Please sign in to comment.