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

Commit

Permalink
Fixed bugs in swifter output file generator
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Jul 7, 2021
1 parent 3afb39f commit 006401b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
12 changes: 1 addition & 11 deletions examples/helio_swifter_comparison/param.swifter.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ ISTEP_OUT 1
ISTEP_DUMP 1
OUT_FORM EL
OUT_TYPE REAL8
OUT_STAT REPLACE
OUT_STAT UNKNOWN
IN_TYPE ASCII
PL_IN pl.swifter.in
TP_IN tp.swifter.in
CB_IN None
BIN_OUT bin.dat
ENC_OUT enc.dat
CHK_QMIN 0.004650467260962157
Expand All @@ -19,18 +18,9 @@ CHK_RMAX 1000.0
CHK_EJECT 1000.0
CHK_QMIN_COORD HELIO
CHK_QMIN_RANGE 0.004650467260962157 1000.0
MU2KG None
TU2S None
DU2M None
EXTRA_FORCE NO
BIG_DISCARD NO
CHK_CLOSE YES
FRAGMENTATION NO
ROTATION NO
TIDES NO
ENERGY NO
YARKOVSKY NO
YORP NO
J2 4.7535806948127355e-12
J4 -2.2473967953572827e-18
RHILL_PRESENT YES
14 changes: 10 additions & 4 deletions python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import sys
import tempfile

newfeaturelist = ("FRAGMENTATION", "ROTATION", "TIDES", "ENERGY", "GR", "YARKOVSKY", "YORP" )

def real2float(realstr):
"""
Converts a Fortran-generated ASCII string of a real value into a numpy float type. Handles cases where double precision
Expand Down Expand Up @@ -289,7 +291,7 @@ def write_labeled_param(param, param_file_name):
# Print the list of key/value pairs in the preferred order
for key in keylist:
val = ptmp.pop(key, None)
print(f"{key:<16} {val}", file=outfile)
if val is not None: print(f"{key:<16} {val}", file=outfile)
# Print the remaining key/value pairs in whatever order
for key, val in ptmp.items():
print(f"{key:<16} {val}", file=outfile)
Expand Down Expand Up @@ -984,8 +986,8 @@ def swift2swifter(swift_param, plname="", tpname="", conversion_questions={}):
def swifter2swiftest(swifter_param, plname="", tpname="", cbname="", conversion_questions={}):
swiftest_param = swifter_param.copy()
# Pull additional feature status from the conversion_questions dictionary
featurelist = ("FRAGMENTATION", "ROTATION", "TIDES", "ENERGY", "GR", "YARKOVSKY", "YORP" )
for key in featurelist:

for key in newfeaturelist:
swiftest_param[key] = conversion_questions.get(key, "NO")
# Convert the PL file
if plname == '':
Expand Down Expand Up @@ -1218,7 +1220,7 @@ def swift2swiftest(swift_param, plname="", tpname="", cbname="", conversion_ques
return swiftest_param

def swiftest2swifter_param(swiftest_param, J2=0.0, J4=0.0):
swifter_param = swiftest_param.copy()
swifter_param = swiftest_param
CBIN = swifter_param.pop("CB_IN", None)
MTINY = swifter_param.pop("MTINY", None)
MU2KG = swifter_param.pop("MU2KG", 1.0)
Expand All @@ -1228,10 +1230,14 @@ def swiftest2swifter_param(swiftest_param, J2=0.0, J4=0.0):
if GR is not None:
if GR == 'YES':
swifter_param['C'] = swiftest.einsteinC * np.longdouble(TU2S) / np.longdouble(DU2M)
for key in newfeaturelist:
tmp = swifter_param.pop(key, None)
swifter_param['J2'] = J2
swifter_param['J4'] = J4
swifter_param['RHILL_PRESENT'] = "YES"
swifter_param['CHK_CLOSE'] = "YES"
if swifter_param['OUT_STAT'] == "REPLACE":
swifter_param['OUT_STAT'] = "UNKNOWN"
swifter_param['! VERSION'] = "Swifter parameter file converted from Swiftest"

return swifter_param

0 comments on commit 006401b

Please sign in to comment.