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

Commit

Permalink
Merge branch 'OOPrestructure' into OOPHelio
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Jul 7, 2021
2 parents 56d9ad8 + cce473d commit 5c257cf
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Makefile.Defines
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ GPAR = -fopenmp -ftree-parallelize-loops=4
GMEM = -fsanitize=undefined -fsanitize=address -fsanitize=leak
GWARNINGS = -Wall -Warray-bounds -Wimplicit-interface -Wextra -Warray-temporaries

FFLAGS = $(IDEBUG) $(HEAPARR)
#FFLAGS = -init=snan,arrays -no-wrap-margin -O3 $(STRICTREAL) $(SIMDVEC) $(PAR)
#FFLAGS = $(IDEBUG) $(HEAPARR)
FFLAGS = -init=snan,arrays -no-wrap-margin -O3 $(STRICTREAL) $(SIMDVEC) $(PAR)
FORTRAN = ifort
#AR = xiar

Expand Down
38 changes: 33 additions & 5 deletions python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def real2float(realstr):
"""
return float(realstr.replace('d', 'E').replace('D', 'E'))

def read_swiftest_param(param_file_name):
def read_swiftest_param(param_file_name, param):
"""
Reads in a Swiftest param.in file and saves it as a dictionary
Expand All @@ -36,7 +36,7 @@ def read_swiftest_param(param_file_name):
param : dict
A dictionary containing the entries in the user parameter file
"""
param = {'! VERSION': f"Swiftest parameter input from file {param_file_name}"}
param['! VERSION'] = f"Swiftest parameter input from file {param_file_name}"

# Read param.in file
print(f'Reading Swiftest file {param_file_name}')
Expand All @@ -58,8 +58,6 @@ def read_swiftest_param(param_file_name):
param['T0'] = real2float(param['T0'])
param['TSTOP'] = real2float(param['TSTOP'])
param['DT'] = real2float(param['DT'])
param['J2'] = real2float(param['J2'])
param['J4'] = real2float(param['J4'])
param['CHK_RMIN'] = real2float(param['CHK_RMIN'])
param['CHK_RMAX'] = real2float(param['CHK_RMAX'])
param['CHK_EJECT'] = real2float(param['CHK_EJECT'])
Expand Down Expand Up @@ -263,7 +261,37 @@ def write_swift_param(param, param_file_name):

def write_labeled_param(param, param_file_name):
outfile = open(param_file_name, 'w')
for key, val in sorted(param.items()):
keylist = ['! VERSION',
'T0',
'TSTOP',
'DT',
'ISTEP_OUT',
'ISTEP_DUMP',
'OUT_FORM',
'OUT_TYPE',
'OUT_STAT',
'IN_TYPE',
'PL_IN',
'TP_IN',
'CB_IN',
'BIN_OUT',
'ENC_OUT',
'CHK_QMIN',
'CHK_RMIN',
'CHK_RMAX',
'CHK_EJECT',
'CHK_QMIN_COORD',
'CHK_QMIN_RANGE',
'MU2KG',
'TU2S',
'DU2M' ]
ptmp = param.copy()
# Print the list of key/value pairs in the preferred order
for key in keylist:
val = ptmp.pop(key)
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)
outfile.close()
return
Expand Down
4 changes: 3 additions & 1 deletion python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, codename="Swiftest", param_file=""):
'OUT_STAT': "REPLACE",
'CHK_RMAX': "1000.0",
'CHK_EJECT': "1000.0",
'CHK_RMIN': constants.RSun / constants.AU2M,
'CHK_QMIN': constants.RSun / constants.AU2M,
'CHK_QMIN_COORD': "HELIO",
'CHK_QMIN_RANGE': f"{constants.RSun / constants.AU2M} 1000.0",
Expand All @@ -45,6 +46,7 @@ def __init__(self, codename="Swiftest", param_file=""):
'GR': "NO",
'YARKOVSKY': "NO",
'YORP': "NO",
'MTINY' : "0.0"
}
if param_file != "" :
self.read_param(param_file, codename)
Expand All @@ -69,7 +71,7 @@ def add(self, plname, date=date.today().isoformat()):

def read_param(self, param_file, codename="Swiftest"):
if codename == "Swiftest":
self.param = io.read_swiftest_param(param_file)
self.param = io.read_swiftest_param(param_file, self.param)
self.codename = "Swiftest"
elif codename == "Swifter":
self.param = io.read_swifter_param(param_file)
Expand Down
7 changes: 3 additions & 4 deletions python/swiftest/swiftest/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def follow_swift(ds, ifol=None, nskp=None):
intxt = input('Input the print frequency\n')
nskp = int(intxt)


dr = 180.0 / np.pi
fol['obar'] = fol['capom'] + fol['omega']
fol['obar'] = fol['obar'].fillna(0)
Expand All @@ -61,12 +60,12 @@ def follow_swift(ds, ifol=None, nskp=None):
fol['peri'] = fol['a'] * (1.0 - fol['e'])
fol['apo'] = fol['a'] * (1.0 + fol['e'])

print('1 2 3 4 5 6 7 8 9 10')
print('t,a,e,inc,capom,omega,capm,peri,apo,obar')

tslice = slice(None, None, nskp)
try:
with open('follow.out', 'w') as f:
print('# 1 2 3 4 5 6 7 8 9 10', file=f)
print('# t,a,e,inc,capom,omega,capm,peri,apo,obar', file=f)
for t in fol.isel(time=tslice).time:
a = fol['a'].sel(time=t).values
e = fol['e'].sel(time=t).values
Expand All @@ -77,7 +76,7 @@ def follow_swift(ds, ifol=None, nskp=None):
peri = fol['peri'].sel(time=t).values
apo = fol['apo'].sel(time=t).values
obar = fol['obar'].sel(time=t).values
print(f"{t.values:15.7e} {a:10.4f} {e:7.5f} {inc:9.4f} {capom:9.4f} {omega:9.4f} {capm:9.4f} {peri:10.4f} {apo:10.4f} {obar:9.4f}", file=f)
print(f"{t.values:15.7e} {a:22.16f} {e:22.16f} {inc:22.16f} {capom:22.16f} {omega:22.16f} {capm:22.16f} {peri:22.16f} {apo:10.4f} {obar:22.16f}", file=f)

except IOError:
print(f"Error writing to follow.out")
Expand Down

0 comments on commit 5c257cf

Please sign in to comment.