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
Cleaned up more methods to make ready to run a simulationj
  • Loading branch information
daminton committed Nov 14, 2022
1 parent 37230e0 commit 18dd938
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
20 changes: 10 additions & 10 deletions examples/Basic_Simulation/param.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
! VERSION Swiftest parameter input
T0 0.0
TSTART 0.0
TSTOP 10.0
DT 0.005
ISTEP_OUT 200
ISTEP_DUMP 200
NC_IN init_cond.nc
IN_TYPE NETCDF_DOUBLE
IN_FORM EL
BIN_OUT bin.nc
OUT_FORM XVEL
OUT_TYPE NETCDF_DOUBLE
OUT_STAT REPLACE
IN_TYPE NETCDF_DOUBLE
BIN_OUT bin.nc
CHK_QMIN 0.004650467260962157
CHK_RMIN 0.004650467260962157
CHK_RMAX 10000.0
Expand All @@ -18,9 +21,10 @@ CHK_QMIN_RANGE 0.004650467260962157 10000.0
MU2KG 1.988409870698051e+30
TU2S 31557600.0
DU2M 149597870700.0
GMTINY 9.869231602224408e-07
MIN_GMFRAG 9.869231602224408e-10
RESTART NO
INTERACTION_LOOPS TRIANGULAR
ENCOUNTER_CHECK TRIANGULAR
TIDES NO
CHK_CLOSE YES
GR YES
FRAGMENTATION YES
Expand All @@ -29,9 +33,5 @@ ENERGY NO
EXTRA_FORCE NO
BIG_DISCARD NO
RHILL_PRESENT NO
TIDES NO
IN_FORM EL
NC_IN init_cond.nc
TSTART 0.0
GMTINY 1e-06
MIN_GMFRAG 1e-09
INTERACTION_LOOPS TRIANGULAR
ENCOUNTER_CHECK TRIANGULAR
13 changes: 9 additions & 4 deletions python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,18 +404,21 @@ def write_labeled_param(param, param_file_name):
outfile = open(param_file_name, 'w')
keylist = ['! VERSION',
'T0',
'TSTART',
'TSTOP',
'DT',
'ISTEP_OUT',
'ISTEP_DUMP',
'OUT_FORM',
'OUT_TYPE',
'OUT_STAT',
'IN_TYPE',
'NC_IN',
'PL_IN',
'TP_IN',
'CB_IN',
'IN_TYPE',
'IN_FORM',
'BIN_OUT',
'OUT_FORM',
'OUT_TYPE',
'OUT_STAT',
'CHK_QMIN',
'CHK_RMIN',
'CHK_RMAX',
Expand All @@ -425,6 +428,8 @@ def write_labeled_param(param, param_file_name):
'MU2KG',
'TU2S',
'DU2M',
'GMTINY',
'MIN_GMFRAG',
'RESTART']
ptmp = param.copy()
# Print the list of key/value pairs in the preferred order
Expand Down
9 changes: 6 additions & 3 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def run(self,**kwargs):
print(f"Running an integration is not yet supported for {self.codename}")
return

print(f"Running a simulation from tstart={self.param['TSTART']} {self.TU_name} to tstop={self.param['TSTOP']} {self.TU_name}")
print(f"Running a {self.codename} {self.integrator} run from tstart={self.param['TSTART']} {self.TU_name} to tstop={self.param['TSTOP']} {self.TU_name}")

#term_output = subprocess.run([self.driver_executable, self.integrator, self.param_file], capture_output=True)

Expand Down Expand Up @@ -436,6 +436,9 @@ def set_simulation_time(self,
A dictionary containing the requested parameters
"""
if t0 is None and tstart is None and dt is None and istep_out is None and \
tstep_out is None and istep_dump is None:
return {}

update_list = []

Expand Down Expand Up @@ -2289,6 +2292,7 @@ def write_param(self,
param_file = self.param_file
if param is None:
param = self.param
print(f"Writing parameter inputs to file {param_file}")

# Check to see if the parameter type matches the output type. If not, we need to convert
if codename == "Swifter" or codename == "Swiftest":
Expand All @@ -2302,8 +2306,7 @@ def write_param(self,
elif codename == "Swift":
io.write_swift_param(param, param_file)
else:
print(
'Cannot process unknown code type. Call the read_param method with a valid code name. Valid options are "Swiftest", "Swifter", or "Swift".')
print( 'Cannot process unknown code type. Call the read_param method with a valid code name. Valid options are "Swiftest", "Swifter", or "Swift".')
return

def convert(self, param_file, newcodename="Swiftest", plname="pl.swiftest.in", tpname="tp.swiftest.in",
Expand Down

0 comments on commit 18dd938

Please sign in to comment.