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

Commit

Permalink
Fixed issue with encounter data not being saved
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 5, 2022
1 parent 67b3a77 commit efdd8e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/Fragmentation/Fragmentation_Movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,6 @@ def data_stream(self, frame=0):
minimum_fragment_gmass = 0.2 * body_Gmass[style][1] # Make the minimum fragment mass a fraction of the smallest body
gmtiny = 0.99 * body_Gmass[style][1] # Make GMTINY just smaller than the smallest original body. This will prevent runaway collisional cascades
sim.set_parameter(fragmentation = True, gmtiny=gmtiny, minimum_fragment_gmass=minimum_fragment_gmass, verbose=False)
sim.run(dt=1e-4, tstop=1.0e-2, tstep_out=1e-2, dump_cadence=0)
sim.run(dt=1e-3, tstop=1.0e-2, tstep_out=1e-2, dump_cadence=0)

anim = AnimatedScatter(sim,movie_filename,movie_titles[style],nskip=1)
anim = AnimatedScatter(sim,movie_filename,movie_titles[style],nskip=10)
15 changes: 13 additions & 2 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def __init__(self,read_param: bool = False, read_old_output_file: bool = False,
self.param = {}
self.data = xr.Dataset()
self.ic = xr.Dataset()

self.enc = xr.Dataset()

self.simdir = Path(simdir)
if self.simdir.exists():
Expand Down Expand Up @@ -2670,17 +2670,28 @@ def read_output_file(self,read_init_cond : bool = True):
# Make a temporary copy of the parameter dictionary so we can supply the absolute path of the binary file
# This is done to handle cases where the method is called from a different working directory than the simulation
# results

# EXPERIMENTAL
read_encounter = True
param_tmp = self.param.copy()
param_tmp['BIN_OUT'] = os.path.join(self.simdir, self.param['BIN_OUT'])
if self.codename == "Swiftest":
self.data = io.swiftest2xr(param_tmp, verbose=self.verbose)
if self.verbose: print('Swiftest simulation data stored as xarray DataSet .data')
if read_init_cond:
if self.verbose:
print("Reading initial conditions file as .ic")
if "NETCDF" in self.param['IN_TYPE']:
param_tmp['BIN_OUT'] = os.path.join(self.simdir, self.param['NC_IN'])
param_tmp['BIN_OUT'] = self.simdir / self.param['NC_IN']

self.ic = io.swiftest2xr(param_tmp, verbose=self.verbose)
else:
self.ic = self.data.isel(time=0)
if read_encounter:
param_tmp['BIN_OUT'] = self.simdir / "encounter.nc"
if self.verbose:
print("Reading encounter history file as .enc")
self.enc = io.swiftest2xr(param_tmp, verbose=self.verbose)

elif self.codename == "Swifter":
self.data = io.swifter2xr(param_tmp, verbose=self.verbose)
Expand Down

0 comments on commit efdd8e6

Please sign in to comment.