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
Fixed unit conversion bug and added simulation time parameters to Simulation class argument list
  • Loading branch information
daminton committed Nov 9, 2022
1 parent 41c61b1 commit bd9bfad
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
self.param['BIN_OUT'] = binpath
Copyright 2022 - David Minton, Carlisle Wishard, Jennifer Pouplin, Jake Elliott, & Dana Singh
This file is part of Swiftest.
Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -36,6 +35,13 @@ def __init__(self,
codename: Literal["Swiftest", "Swifter", "Swift"] = "Swiftest",
param_file: os.PathLike | str ="param.in",
read_param: bool = False,
t0: float = 0.0,
tstart: float = 0.0,
tstop: float = 1.0,
dt: float = 0.002,
istep_out: int = 50,
tstep_out: float | None = None,
istep_dump: int = 50,
init_cond_file_type: Literal["NETCDF_DOUBLE", "NETCDF_FLOAT", "ASCII"] = "NETCDF_DOUBLE",
init_cond_file_name: str | os.PathLike | Dict[str, str] | Dict[str, os.PathLike] | None = None,
init_cond_format: Literal["EL", "XV"] = "EL",
Expand Down Expand Up @@ -248,6 +254,16 @@ def __init__(self,
restart=restart,
verbose = False)

self.set_simulation_time(t0=t0,
tstart=tstart,
tstop=tstop,
dt=dt,
tstep_out=tstep_out,
istep_out=istep_out,
istep_dump=istep_dump,
verbose = False
)

# If the parameter file is in a different location than the current working directory, we will need
# to use it to properly open bin files
self.sim_dir = os.path.dirname(os.path.realpath(param_file))
Expand Down Expand Up @@ -1190,12 +1206,12 @@ def update_param_units(self,MU2KG_old,DU2M_old,TU2S_old):
for k in mass_keys:
if k in self.param:
print(f"param['{k}']: {self.param[k]}")
self.param[k] *= self.param['MU2KG'] / MU2KG_old
self.param[k] *= MU2KG_old / self.param['MU2KG']

if DU2M_old is not None:
for k in distance_keys:
if k in self.param:
self.param[k] *= self.param['DU2M'] / DU2M_old
self.param[k] *= DU2M_old / self.param['DU2M']

CHK_QMIN_RANGE = self.param.pop('CHK_QMIN_RANGE', None)
if CHK_QMIN_RANGE is not None:
Expand All @@ -1207,7 +1223,7 @@ def update_param_units(self,MU2KG_old,DU2M_old,TU2S_old):
if TU2S_old is not None:
for k in time_keys:
if k in self.param:
self.param[k] *= self.param['TU2S'] / TU2S_old
self.param[k] *= TU2S_old / self.param['TU2S']

return

Expand Down

0 comments on commit bd9bfad

Please sign in to comment.