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

Commit

Permalink
Fixed bugs that prevented reading an old param file
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Nov 19, 2022
1 parent 947ff81 commit e959465
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion python/swiftest/swiftest/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import astropy.constants as const

# Constants in SI units
GC = const.G.value
GC = const.G.value[()]
AU2M = const.au.value
GMSun = const.GM_sun.value
MSun = const.M_sun.value
Expand Down
3 changes: 2 additions & 1 deletion python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def read_swiftest_param(param_file_name, param, verbose=True):
for f in float_param:
if f in param and type(f) is str:
param[f] = real2float(param[f])

for b in bool_param:
if b in param:
param[b] = str2bool(param[b])
Expand Down Expand Up @@ -427,7 +428,7 @@ def write_labeled_param(param, param_file_name):
'TU2S',
'DU2M',
'GMTINY',
'FRAGMENTATION'
'FRAGMENTATION',
'MIN_GMFRAG',
'RESTART']
ptmp = param.copy()
Expand Down
10 changes: 5 additions & 5 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self,read_param: bool = True, **kwargs: Any):
1. Arguments to Simulation()
2. The parameter input file given by `param_file` under the following conditions:
- `read_param` is set to True (default behavior).
- The file given by `param_file` exists. The default file is `param.in` located in the `.swiftest` directory
- The file given by `param_file` exists. The default file is `param.in` located in the `simdata` directory
inside the current working directory, which can be changed by passing `param_file` as an argument.
- The argument has an equivalent parameter or set of parameters in the parameter input file.
3. Default values (see below)
Expand Down Expand Up @@ -314,7 +314,6 @@ def __init__(self,read_param: bool = True, **kwargs: Any):

# Set the location of the parameter input file
param_file = kwargs.pop("param_file",self.param_file)
read_param = kwargs.pop("read_param",False)
self.set_parameter(verbose=False,param_file=param_file)

#-----------------------------------------------------------------
Expand All @@ -329,6 +328,7 @@ def __init__(self,read_param: bool = True, **kwargs: Any):
# We will add the parameter file to the kwarg list. This will keep the set_parameter method from
# overriding everything with defaults when there are no arguments passed to Simulation()
kwargs['param_file'] = self.param_file
param_file_found = True
else:
param_file_found = False

Expand Down Expand Up @@ -665,7 +665,7 @@ def set_parameter(self, verbose: bool = True, **kwargs):
default_arguments = {
"codename" : "Swiftest",
"integrator": "symba",
"param_file": Path.cwd() / ".swiftest" / "param.in",
"param_file": Path.cwd() / "simdata" / "param.in",
"t0": 0.0,
"tstart": 0.0,
"tstop": None,
Expand Down Expand Up @@ -2412,7 +2412,7 @@ def read_param(self,
if param_file is None:
param_file = self.param_file

if coename is None:
if codename is None:
codename = self.codename

if verbose is None:
Expand All @@ -2422,7 +2422,7 @@ def read_param(self,
return False

if codename == "Swiftest":
self.param = io.read_swiftest_param(param_file, param, verbose=verbose)
self.param = io.read_swiftest_param(param_file, self.param, verbose=verbose)
elif codename == "Swifter":
self.param = io.read_swifter_param(param_file, verbose=verbose)
elif codename == "Swift":
Expand Down

0 comments on commit e959465

Please sign in to comment.