From f62cdff6932874ac0bee578b19b8519cf7b4b029 Mon Sep 17 00:00:00 2001 From: David Minton Date: Wed, 8 Dec 2021 17:10:21 -0500 Subject: [PATCH 1/5] Put back production flags --- Makefile.Defines | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Makefile.Defines b/Makefile.Defines index 90a2ceb58..fcc43b14a 100644 --- a/Makefile.Defines +++ b/Makefile.Defines @@ -41,20 +41,14 @@ SWIFTEST_HOME = $(ROOT_DIR) USER_MODULES = COLLRESOLVE_HOME = $(ROOT_DIR)/collresolve/ -#NETCDF_FORTRAN_HOME = /home/daminton/local - - # Compiler definitions # DO NOT include in FFLAGS the "-c" option to compile object only # this is done explicitly as needed in the Makefile -ADVIXE_FLAGS = -g -O2 -qopt-report=5 -vecabi=cmdtarget -simd -shared-intel -debug inline-debug-info -DTBB_DEBUG -DTBB_USE_THREADING_TOOLS -xhost -traceback -parallel-source-info=2 -#Be sure to set the environment variable KMP_FORKJOIN_FRAMES=1 for OpenMP debuging in vtune - IDEBUG = -O0 -init=snan,arrays -nogen-interfaces -no-pie -no-ftz -fpe-all=0 -g -traceback -mp1 -qopt-matmul -fp-model strict -fpe0 -debug all -align all -pad -ip -prec-div -prec-sqrt -assume protect-parens -CB -no-wrap-margin STRICTREAL = -fp-model=precise -prec-div -prec-sqrt -assume protect-parens SIMDVEC = -simd -xhost -align all -assume contiguous_assumed_shape -vecabi=cmdtarget -fp-model no-except -fma -PAR = -qopenmp -parallel -parallel-source-info=2 +PAR = -qopenmp -parallel HEAPARR = -heap-arrays 4194304 OPTREPORT = -qopt-report=5 IPRODUCTION = -no-wrap-margin -O3 -qopt-prefetch=0 -qopt-matmul -sox $(PAR) $(SIMDVEC) #$(HEAPARR) @@ -66,13 +60,11 @@ GMEM = -fsanitize-address-use-after-scope -fstack-check -fsanitize=bounds-stri GWARNINGS = -Wall -Warray-bounds -Wimplicit-interface -Wextra -Warray-temporaries GPRODUCTION = -O3 -ffree-line-length-none $(GPAR) -INCLUDES = -I$(SWIFTEST_HOME)/include -I$(NETCDF_FORTRAN_HOME)/include -I$(MKLROOT)/include -LINKS = -L$(MKLROOT)/lib/intel64 -L$(NETCDF_FORTRAN_HOME)/lib -lswiftest -lnetcdf -lnetcdff -qopt-matmul #$(PAR) +INCLUDES = -I$(SWIFTEST_HOME)/include -I$(NETCDF_FORTRAN_HOME)/include -I$(MKLROOT)/include +LINKS = -L$(MKLROOT)/lib/intel64 -L$(NETCDF_FORTRAN_HOME)/lib -lswiftest -lnetcdf -lnetcdff -qopt-matmul $(PAR) -FSTRICTFLAGS = $(IDEBUG) #$(SIMDVEC) $(PAR) $(HEAPARR) -FFLAGS = $(IDEBUG) #$(SIMDVEC) $(PAR) $(HEAPARR) -#FSTRICTFLAGS = $(IPRODUCTION) $(STRICTREAL) -g -traceback -#FFLAGS = $(IPRODUCTION) -fp-model=fast -g -traceback +FSTRICTFLAGS = $(IPRODUCTION) $(STRICTREAL) +FFLAGS = $(IPRODUCTION) -fp-model=fast FORTRAN = ifort AR = xiar From 5f017d15e6ad867da8f499cd46e89f58b5fc5101 Mon Sep 17 00:00:00 2001 From: Carlisle Wishard Date: Tue, 14 Dec 2021 10:50:01 -0500 Subject: [PATCH 2/5] Added one planetesimal and one test particle in Mercury's orbit --- examples/symba_gr_test/init_cond.py | 27 ++++++++++++++++++++++++++- examples/symba_gr_test/pl.swifter.in | 22 +++++++++++++--------- examples/symba_gr_test/pl.swiftest.in | 22 +++++++++++++--------- examples/symba_gr_test/tp.swifter.in | 5 ++++- examples/symba_gr_test/tp.swiftest.in | 5 ++++- 5 files changed, 60 insertions(+), 21 deletions(-) diff --git a/examples/symba_gr_test/init_cond.py b/examples/symba_gr_test/init_cond.py index 2639272e7..a5dbe9118 100755 --- a/examples/symba_gr_test/init_cond.py +++ b/examples/symba_gr_test/init_cond.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 import swiftest +from numpy.random import default_rng +import numpy as np sim = swiftest.Simulation() sim.param['PL_IN'] = "pl.swiftest.in" @@ -43,7 +45,30 @@ for name, id in bodyid.items(): sim.add(name, idval=id, date="2027-04-30") - + +Me_a = sim.ds.isel(id=1)['a'].values +Me_e = sim.ds.sel(id=1)['e'].values +Me_i = sim.ds.sel(id=1)['inc'].values + +capom_pl = default_rng().uniform(0.0, 360.0, 1) +omega_pl = default_rng().uniform(0.0, 360.0, 1) +capm_pl = default_rng().uniform(0.0, 360.0, 1) + +capom_tp = default_rng().uniform(0.0, 360.0, 1) +omega_tp = default_rng().uniform(0.0, 360.0, 1) +capm_tp = default_rng().uniform(0.0, 360.0, 1) + +GMcb = sim.ds.isel(id=0)['Gmass'].values +GU = swiftest.GC / (sim.param['DU2M']**3 / (sim.param['MU2KG'] * sim.param['TU2S']**2)) +dens = 3000.0 / (sim.param['MU2KG'] / sim.param['DU2M']**3) # Assume a bulk density of 3 g/cm^3 +GM_pl = 2e-7 +M_pl = GM_pl / GU +R_pl = (3 * M_pl / (4 * np.pi * dens))**(1.0 / 3.0) +Rh_pl = Me_a * (GM_pl / (3 * GMcb))**(1.0/3.0) + +sim.addp(np.full(1,9), np.full(1,'Planetesimal'), Me_a, Me_e, Me_i, capom_pl, omega_pl, capm_pl, GMpl=np.full(1, GM_pl), Rpl=np.full(1, R_pl), rhill=Rh_pl) +sim.addp(np.full(1,10), np.full(1,'TestParticle'), Me_a, Me_e, Me_i, capom_tp, omega_tp, capm_tp) + sim.save("param.swiftest.in") sim.param['PL_IN'] = "pl.swifter.in" sim.param['TP_IN'] = "tp.swifter.in" diff --git a/examples/symba_gr_test/pl.swifter.in b/examples/symba_gr_test/pl.swifter.in index dffe532c6..869b2fc13 100644 --- a/examples/symba_gr_test/pl.swifter.in +++ b/examples/symba_gr_test/pl.swifter.in @@ -1,36 +1,40 @@ -9 +10 0 39.476926408897626 0.0 0.0 0.0 0.0 0.0 0.0 -1 6.5537098095653139645e-06 0.0014751260185578720416 +1 6.553709809565314146e-06 0.0014751260185578724335 1.6306381826061645943e-05 0.22527006614756858727 0.22185515636479818946 -0.0025292250509892700606 -9.2410583833491193135 7.7546860001024244665 1.481285384055779404 -2 9.663313399581537916e-05 0.006759120024335718617 +2 9.6633133995815381836e-05 0.0067591200243357198168 4.0453784346544178454e-05 0.6401338616632904488 -0.3439628247287493945 -0.041662537354174501714 3.4536908505004217623 6.4771489080253446934 -0.110257596056190005656 -3 0.000120026935827952453094 0.0100446292823340959596 +3 0.000120026935827952456416 0.010044629282334098766 4.25875607065040958e-05 -0.7819504386201725499 -0.6346854491951327004 4.4451463454996458186e-05 3.8578491980751480153 -4.9026737310919641898 0.0002888700847309900442 -4 1.2739802010675941456e-05 0.0072466212625671651507 +4 1.2739802010675941808e-05 0.0072466212625671666944 2.265740805092889601e-05 -1.6500171831673979828 -0.023341429362091121319 0.039964339661466272147 0.2624112744618213919 -4.673688782463607376 -0.10439239110136837694 -5 0.037692251088985676735 0.35521688466465032753 +5 0.03769225108898567778 0.35521688466465040944 0.00046732617030490929307 -4.540785007788180394 2.8642873711036669349 0.08969619001756239107 -1.5037012644183387769 -2.204631616790602934 0.042803317383791750652 -6 0.011285899820091272997 0.43538665458575465117 +6 0.01128589982009127331 0.43538665458575473606 0.00038925687730393611812 8.9010680046292307566 2.902848867584423953 -0.40487415052930197934 -0.7439396408265333407 1.9316851317225221362 -0.004029214768814220126 -7 0.0017236589478267730203 0.46987236554736915505 +7 0.001723658947826773068 0.46987236554736924745 0.00016953449859497231466 8.1785533453299539275 17.594789418581910923 -0.04069518248189726156 -1.3149276792509819067 0.53722869521767089375 0.019051745273498437594 -8 0.0020336100526728302319 0.7749718408665498732 +8 0.0020336100526728302882 0.7749718408665500834 0.000164587904124493665 29.794198627119580891 2.0446309861539178065 -0.7287194786837880578 -0.08754730406665780868 1.1492225523523839664 -0.021678684633280679721 +9 1.9999999999999999095e-07 0.0004609743061784924374 +6.20967433941813041e-06 +nan nan nan +nan nan nan diff --git a/examples/symba_gr_test/pl.swiftest.in b/examples/symba_gr_test/pl.swiftest.in index 37ebc69a0..1c629790f 100644 --- a/examples/symba_gr_test/pl.swiftest.in +++ b/examples/symba_gr_test/pl.swiftest.in @@ -1,33 +1,37 @@ -8 -Mercury 6.5537098095653139645e-06 0.0014751260185578720416 +9 +Mercury 6.553709809565314146e-06 0.0014751260185578724335 1.6306381826061645943e-05 0.38709858430953941744 0.20562340108970009189 7.0033025080013837638 48.296118373786072198 29.20442403952453958 338.33948746828792764 -Venus 9.663313399581537916e-05 0.006759120024335718617 +Venus 9.6633133995815381836e-05 0.0067591200243357198168 4.0453784346544178454e-05 0.72332975797361009906 0.006717605698865438367 3.3944392733422819042 76.60235891771118588 54.960379460829607012 200.47893395506480374 -Earth 0.000120026935827952453094 0.0100446292823340959596 +Earth 0.000120026935827952456416 0.010044629282334098766 4.25875607065040958e-05 0.99999048745432228547 0.016714003765458580048 0.0036378626088630029375 175.0251726002310022 287.96196288125747742 114.34829340424269617 -Mars 1.2739802010675941456e-05 0.0072466212625671651507 +Mars 1.2739802010675941808e-05 0.0072466212625671666944 2.265740805092889601e-05 1.5237119255895350545 0.09344151133508207807 1.8474416735579008986 49.47285721247470036 286.7379771285890797 209.33967734771380265 -Jupiter 0.037692251088985676735 0.35521688466465032753 +Jupiter 0.03769225108898567778 0.35521688466465040944 0.00046732617030490929307 5.202727800851599582 0.048244977116379678117 1.3036311345700750675 100.51925884330809424 273.58984028825142332 129.5536700659941971 -Saturn 0.011285899820091272997 0.43538665458575465117 +Saturn 0.01128589982009127331 0.43538665458575473606 0.00038925687730393611812 9.532011952667287957 0.054863298704333408884 2.4879063632803011252 113.63057816762059815 339.54673564023909194 290.89958065689040723 -Uranus 0.0017236589478267730203 0.46987236554736915505 +Uranus 0.001723658947826773068 0.46987236554736924745 0.00016953449859497231466 19.244988382902359803 0.0479617494230129629 0.7730102596086204647 74.012580980165793676 93.595549122802268016 262.86586372775150267 -Neptune 0.0020336100526728302319 0.7749718408665498732 +Neptune 0.0020336100526728302882 0.7749718408665500834 0.000164587904124493665 30.038959912561129073 0.008955570159296157365 1.7711193542961420899 131.82211597488270627 284.47484279411258967 308.45137222693909962 +Planetesimal 1.9999999999999999095e-07 0.0004609743061784924374 +6.20967433941813041e-06 +0.38709858430953941744 0.20562340108970009189 7.0033025080013837638 +96.63690427760462853 41.241157268984508733 305.79195407738086487 diff --git a/examples/symba_gr_test/tp.swifter.in b/examples/symba_gr_test/tp.swifter.in index 573541ac9..eec5bc877 100644 --- a/examples/symba_gr_test/tp.swifter.in +++ b/examples/symba_gr_test/tp.swifter.in @@ -1 +1,4 @@ -0 +1 +10 +nan nan nan +nan nan nan diff --git a/examples/symba_gr_test/tp.swiftest.in b/examples/symba_gr_test/tp.swiftest.in index 573541ac9..427febb15 100644 --- a/examples/symba_gr_test/tp.swiftest.in +++ b/examples/symba_gr_test/tp.swiftest.in @@ -1 +1,4 @@ -0 +1 +TestParticle +0.38709858430953941744 0.20562340108970009189 7.0033025080013837638 +91.57330105121243946 163.58917166648961938 345.1110833758885974 From d53700d32a9d4cf148eade38430f0ff4e15db601 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Thu, 27 Jan 2022 10:01:08 -0500 Subject: [PATCH 3/5] Restored compiler flags --- Makefile.Defines | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.Defines b/Makefile.Defines index da00e398c..15f8fe262 100644 --- a/Makefile.Defines +++ b/Makefile.Defines @@ -66,8 +66,8 @@ LINKS = -L$(MKLROOT)/lib/intel64 -L$(NETCDF_FORTRAN_HOME)/lib -lswiftest -lnetc FSTRICTFLAGS = $(IPRODUCTION) $(STRICTREAL) FFLAGS = $(IPRODUCTION) -fp-model=fast -# FSTRICTFLAGS = $(ADVIXE_FLAGS) $(PAR) $(SIMDVEC) $(STRICTREAL) -# FFLAGS = $(ADVIXE_FLAGS) $(PAR) $(SIMDVEC) -fp-model=fast +FSTRICTFLAGS = $(ADVIXE_FLAGS) $(PAR) $(SIMDVEC) $(STRICTREAL) +FFLAGS = $(ADVIXE_FLAGS) $(PAR) $(SIMDVEC) -fp-model=fast FORTRAN = ifort AR = xiar CC = icc From e7c6f9a6042e474f02e533000e954d7ae6d2879d Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 25 Feb 2022 17:15:19 -0500 Subject: [PATCH 4/5] Fixed file input readers so they can be either space or tab delimited --- python/swiftest/swiftest/io.py | 37 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/python/swiftest/swiftest/io.py b/python/swiftest/swiftest/io.py index ca0f29374..d0f863fd0 100644 --- a/python/swiftest/swiftest/io.py +++ b/python/swiftest/swiftest/io.py @@ -4,6 +4,7 @@ import xarray as xr import sys import tempfile +import re newfeaturelist = ("FRAGMENTATION", "ROTATION", "TIDES", "ENERGY", "GR", "YARKOVSKY", "YORP", "IN_FORM") @@ -1157,11 +1158,11 @@ def swift2swifter(swift_param, plname="", tpname="", conversion_questions={}): try: with open(swift_param['PL_IN'], 'r') as plold: line = plold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] npl = int(i_list[0]) print(npl, file=plnew) line = plold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] GMcb = real2float(i_list[0]) if swift_param['L1'] == "T": swifter_param['J2'] = real2float(i_list[1]) @@ -1176,7 +1177,7 @@ def swift2swifter(swift_param, plname="", tpname="", conversion_questions={}): line = plold.readline() for n in range(1, npl): # Loop over planets line = plold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] GMpl = real2float(i_list[0]) if isSyMBA: rhill = real2float(i_list[1]) @@ -1192,13 +1193,13 @@ def swift2swifter(swift_param, plname="", tpname="", conversion_questions={}): if swifter_param['CHK_CLOSE'] == 'YES': print(plrad, file=plnew) line = plold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] xh = real2float(i_list[0]) yh = real2float(i_list[1]) zh = real2float(i_list[2]) print(xh, yh, zh, file=plnew) line = plold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] vhx = real2float(i_list[0]) vhy = real2float(i_list[1]) vhz = real2float(i_list[2]) @@ -1225,19 +1226,19 @@ def swift2swifter(swift_param, plname="", tpname="", conversion_questions={}): print(f'Writing out new TP file: {swifter_param["TP_IN"]}') with open(swift_param['TP_IN'], 'r') as tpold: line = tpold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] ntp = int(i_list[0]) print(ntp, file=tpnew) for n in range(0, ntp): # Loop over test particles print(npl + n + 1, file=tpnew) line = tpold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] xh = real2float(i_list[0]) yh = real2float(i_list[1]) zh = real2float(i_list[2]) print(xh, yh, zh, file=tpnew) line = tpold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] vhx = real2float(i_list[0]) vhy = real2float(i_list[1]) vhz = real2float(i_list[2]) @@ -1275,17 +1276,17 @@ def swifter2swiftest(swifter_param, plname="", tpname="", cbname="", conversion_ with open(swifter_param['PL_IN'], 'r') as plold: line = plold.readline() line = line.split("!")[0] # Ignore comments - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] npl = int(i_list[0]) print(npl - 1, file=plnew) line = plold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] GMcb = real2float(i_list[1]) # Store central body GM for later line = plold.readline() # Ignore the two zero vector lines line = plold.readline() for n in range(1, npl): # Loop over planets line = plold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] idnum = int(i_list[0]) GMpl = real2float(i_list[1]) if swifter_param['RHILL_PRESENT'] == 'YES': @@ -1295,17 +1296,17 @@ def swifter2swiftest(swifter_param, plname="", tpname="", cbname="", conversion_ print(idnum, GMpl, file=plnew) if swifter_param['CHK_CLOSE'] == 'YES': line = plold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] plrad = real2float(i_list[0]) print(plrad, file=plnew) line = plold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] xh = real2float(i_list[0]) yh = real2float(i_list[1]) zh = real2float(i_list[2]) print(xh, yh, zh, file=plnew) line = plold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] vhx = real2float(i_list[0]) vhy = real2float(i_list[1]) vhz = real2float(i_list[2]) @@ -1334,22 +1335,22 @@ def swifter2swiftest(swifter_param, plname="", tpname="", cbname="", conversion_ with open(swifter_param['TP_IN'], 'r') as tpold: line = tpold.readline() line = line.split("!")[0] # Ignore comments - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] ntp = int(i_list[0]) print(ntp, file=tpnew) for n in range(0, ntp): # Loop over test particles line = tpold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] name = int(i_list[0]) print(name, file=tpnew) line = tpold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] xh = real2float(i_list[0]) yh = real2float(i_list[1]) zh = real2float(i_list[2]) print(xh, yh, zh, file=tpnew) line = tpold.readline() - i_list = [i for i in line.split(" ") if i.strip()] + i_list = [i for i in re.split(' +|\t',line) if i.strip()] vhx = real2float(i_list[0]) vhy = real2float(i_list[1]) vhz = real2float(i_list[2]) From 0c86301e4ae968ade7469e46e9a858405a7c50f1 Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 25 Feb 2022 17:15:24 -0500 Subject: [PATCH 5/5] Fixed typo --- python/swiftest/swiftest/simulation_class.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index 465ef9c30..846aba347 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -9,7 +9,7 @@ class Simulation: """ - This is a class that define the basic Swift/Swifter/Swiftest simulation object + This is a class that defines the basic Swift/Swifter/Swiftest simulation object """ def __init__(self, codename="Swiftest", param_file="", readbin=True): self.ds = xr.Dataset()