From 3adb448b691a1e47535f34747049dc7f30840d7c Mon Sep 17 00:00:00 2001 From: David Minton Date: Tue, 6 Jul 2021 21:58:57 -0400 Subject: [PATCH 1/6] Improved param file formatting in swiftest.io --- Makefile.Defines | 4 ++-- python/swiftest/swiftest/io.py | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Makefile.Defines b/Makefile.Defines index 07126f842..820ad6d7d 100644 --- a/Makefile.Defines +++ b/Makefile.Defines @@ -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 diff --git a/python/swiftest/swiftest/io.py b/python/swiftest/swiftest/io.py index a9975c400..93d1f2d69 100644 --- a/python/swiftest/swiftest/io.py +++ b/python/swiftest/swiftest/io.py @@ -263,7 +263,36 @@ 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_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 From c228095eb8af2552f715b8616a256ad5c5ca25e7 Mon Sep 17 00:00:00 2001 From: David Minton Date: Tue, 6 Jul 2021 22:24:23 -0400 Subject: [PATCH 2/6] Fixed issues with initial parameter list --- python/swiftest/swiftest/io.py | 4 ++-- python/swiftest/swiftest/simulation_class.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/swiftest/swiftest/io.py b/python/swiftest/swiftest/io.py index 93d1f2d69..16f8ae952 100644 --- a/python/swiftest/swiftest/io.py +++ b/python/swiftest/swiftest/io.py @@ -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 @@ -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}') diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index 3b3aca540..4a34b92ab 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -69,7 +69,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) From 4e5a5fdb0522087465a4dbaa16054290948faca7 Mon Sep 17 00:00:00 2001 From: David Minton Date: Tue, 6 Jul 2021 22:25:20 -0400 Subject: [PATCH 3/6] Removed J2 and J4 from swiftest reader --- python/swiftest/swiftest/io.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/python/swiftest/swiftest/io.py b/python/swiftest/swiftest/io.py index 16f8ae952..9d325552c 100644 --- a/python/swiftest/swiftest/io.py +++ b/python/swiftest/swiftest/io.py @@ -58,8 +58,6 @@ def read_swiftest_param(param_file_name, param): 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']) From 9c3767683538044010ef74ce808de0b1e7630363 Mon Sep 17 00:00:00 2001 From: David Minton Date: Tue, 6 Jul 2021 22:30:55 -0400 Subject: [PATCH 4/6] More fixes to parameter reader --- python/swiftest/swiftest/io.py | 1 + python/swiftest/swiftest/simulation_class.py | 1 + 2 files changed, 2 insertions(+) diff --git a/python/swiftest/swiftest/io.py b/python/swiftest/swiftest/io.py index 9d325552c..03c6506c4 100644 --- a/python/swiftest/swiftest/io.py +++ b/python/swiftest/swiftest/io.py @@ -277,6 +277,7 @@ def write_labeled_param(param, param_file_name): 'BIN_OUT', 'ENC_OUT', 'CHK_QMIN', + 'CHK_RMIN', 'CHK_RMAX', 'CHK_EJECT', 'CHK_QMIN_COORD', diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index 4a34b92ab..bdcb4ea56 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -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", From 215460035e0b801c8384f114ac7d644ab8ab98c0 Mon Sep 17 00:00:00 2001 From: David Minton Date: Tue, 6 Jul 2021 22:32:27 -0400 Subject: [PATCH 5/6] Added missing component of parameter list --- python/swiftest/swiftest/simulation_class.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index bdcb4ea56..41d6c345f 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -46,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) From cce473ddb8ab20f49e45790738f1e7eb2e84e077 Mon Sep 17 00:00:00 2001 From: David Minton Date: Wed, 7 Jul 2021 00:02:53 -0400 Subject: [PATCH 6/6] Adjusted formatting of tool follow emulator to give more sig figs --- python/swiftest/swiftest/tool.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/python/swiftest/swiftest/tool.py b/python/swiftest/swiftest/tool.py index fba725f4e..5922fc667 100644 --- a/python/swiftest/swiftest/tool.py +++ b/python/swiftest/swiftest/tool.py @@ -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) @@ -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 @@ -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")