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
Fixed initial conditions generator
  • Loading branch information
daminton committed Sep 13, 2021
1 parent d2b3a2e commit 3f61053
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 166 deletions.
4 changes: 2 additions & 2 deletions examples/symba_swifter_comparison/8pl_16tp_encounters/cb.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
0
0.00029591220819207774
Sun
0.0002959122081920778
0.004650467260962157
4.7535806948127355e-12
-2.2473967953572827e-18
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
0
0.00029591220819207774
Sun
0.0002959122081920778
0.004650467260962157
4.7535806948127355e-12
-2.2473967953572827e-18
20 changes: 14 additions & 6 deletions examples/symba_swifter_comparison/8pl_16tp_encounters/init_cond.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@

swifter_input = "param.swifter.in"
swifter_pl = "pl.swifter.in"
swifter_tp = "tp.swifter.in"
swifter_bin = "bin.swifter.dat"
swifter_enc = "enc.swifter.dat"

swiftest_input = "param.swiftest.in"
swiftest_pl = "pl.swiftest.in"
swiftest_tp = "tp.swiftest.in"
swiftest_cb = "cb.swiftest.in"
swiftest_bin = "bin.swiftest.dat"
swiftest_enc = "enc.swiftest.dat"
Expand All @@ -34,12 +36,12 @@
sim.param['CHK_RMIN'] = swiftest.RSun / swiftest.AU2M
sim.param['CHK_RMAX'] = 1000.0
sim.param['CHK_EJECT'] = 1000.0
sim.param['OUT_FORM'] = "XV"
sim.param['OUT_STAT'] = "UNKNOWN"
sim.param['GR'] = 'NO'
sim.param['CHK_CLOSE'] = 'YES'
sim.param['RHILL_PRESENT'] = 'YES'
sim.param['GMTINY'] = 1.0e-12
sim.param['IN_FORM'] = 'XV'

sim.param['MU2KG'] = swiftest.MSun
sim.param['TU2S'] = swiftest.JD2S
Expand Down Expand Up @@ -69,10 +71,14 @@
dims = ['time', 'id', 'vec']
tp = []
t = np.array([0.0])
sim.param['OUT_FORM'] = "XV"
clab, plab, tlab = swio.make_swiftest_labels(sim.param)

# For each planet, we will initialize a pair of test particles. One on its way in, and one on its way out. We will also initialize two additional particles that don't encounter anything
tpnames = np.arange(101, 101 + ntp)
tpidlist = np.arange(9,9+ntp)
tpnames = []
for i in tpidlist:
tpnames.append(f"SmallBody{i+1:0.4g}")
tpxv1 = np.empty((6))
tpxv2 = np.empty((6))

Expand All @@ -86,7 +92,7 @@
for i in pl.id:
pli = pl.sel(id=i)
rstart = 2 * np.double(pli['radius']) # Start the test particles at a multiple of the planet radius away
vstart = 1.5 * np.sqrt(2 * np.double(pli['Mass']) / rstart) # Start the test particle velocities at a multiple of the escape speed
vstart = 1.5 * np.sqrt(2 * np.double(pli['Gmass']) / rstart) # Start the test particle velocities at a multiple of the escape speed
xvstart = np.array([rstart / np.sqrt(2.0), rstart / np.sqrt(2.0), 0.0, vstart, 0.0, 0.0])
# The positions and velocities of each pair of test particles will be in reference to a planet
plvec = np.array([np.double(pli['xhx']),
Expand All @@ -110,9 +116,11 @@
p6.append(tpxv1[5])
p6.append(tpxv2[5])


tvec = np.vstack([p1, p2, p3, p4, p5, p6])
tpframe = np.expand_dims(tvec.T, axis=0)
tpxr = xr.DataArray(tpframe, dims = dims, coords = {'time' : t, 'id' : tpnames, 'vec' : tlab})
tpxr = xr.DataArray(tpframe, dims = dims, coords = {'time' : t, 'id' : tpidlist, 'vec' : tlab})
tpxr = tpxr.assign_coords(name=('id', tpnames))

tp = [tpxr]
tpda = xr.concat(tp,dim='time')
Expand All @@ -122,15 +130,15 @@
swio.swiftest_xr2infile(sim.ds, sim.param)

sim.param['PL_IN'] = swiftest_pl
sim.param['TP_IN'] = tpin
sim.param['TP_IN'] = swiftest_tp
sim.param['CB_IN'] = swiftest_cb
sim.param['BIN_OUT'] = swiftest_bin
sim.param['ENC_OUT'] = swiftest_enc
sim.param['DISCARD_OUT'] = swiftest_dis
sim.save(swiftest_input)

sim.param['PL_IN'] = swifter_pl
sim.param['TP_IN'] = tpin
sim.param['TP_IN'] = swifter_tp
sim.param['BIN_OUT'] = swifter_bin
sim.param['ENC_OUT'] = swifter_enc
sim.save(swifter_input, codename="Swifter")
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ DT 1.0
ISTEP_OUT 11
ISTEP_DUMP 1
OUT_FORM XV
OUT_TYPE REAL8
OUT_TYPE NETCDF_DOUBLE
OUT_STAT UNKNOWN
IN_TYPE ASCII
PL_IN pl.swifter.in
TP_IN tp.in
TP_IN tp.swifter.in
BIN_OUT bin.swifter.dat
ENC_OUT enc.swifter.dat
CHK_QMIN 0.004650467260962157
CHK_RMIN 0.004650467260962157
CHK_RMAX 1000.0
CHK_EJECT 1000.0
CHK_QMIN_COORD HELIO
CHK_QMIN_RANGE 0.004650467260962157 1000.0
ENC_OUT enc.swifter.dat
EXTRA_FORCE NO
BIG_DISCARD NO
CHK_CLOSE YES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ DT 1.0
ISTEP_OUT 11
ISTEP_DUMP 1
OUT_FORM XV
OUT_TYPE REAL8
OUT_TYPE NETCDF_DOUBLE
OUT_STAT UNKNOWN
IN_TYPE ASCII
PL_IN pl.swiftest.in
TP_IN tp.in
TP_IN tp.swiftest.in
CB_IN cb.swiftest.in
BIN_OUT bin.swiftest.dat
ENC_OUT enc.swiftest.dat
DISCARD_OUT discard.swiftest.dat
CHK_QMIN 0.004650467260962157
CHK_RMIN 0.004650467260962157
CHK_RMAX 1000.0
Expand All @@ -23,7 +21,10 @@ CHK_QMIN_RANGE 0.004650467260962157 1000.0
MU2KG 1.988409870698051e+30
TU2S 86400
DU2M 149597870700.0
IN_FORM XV
ENC_OUT enc.swiftest.dat
EXTRA_FORCE NO
DISCARD_OUT discard.swiftest.dat
BIG_DISCARD NO
CHK_CLOSE YES
RHILL_PRESENT YES
Expand Down
48 changes: 24 additions & 24 deletions examples/symba_swifter_comparison/8pl_16tp_encounters/pl.in
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
8
1 4.9125474498983623693e-11 0.001475124456355905224
Mercury 4.9125474498983625056e-11 0.0014751323154597007903
1.6306381826061645943e-05
-0.30949970210807342674 0.1619004125820537876 0.041620272188990829754
-0.018820805516945871005 -0.023743802865467341506 -0.00021385162925667799668
2 7.243452483873646905e-10 0.006759069616556246028
0.053584775529809842987 -0.4548355025417368247 -0.04208301187261995896
0.022298358665237189014 0.0047355207618514265702 -0.0016584224113858070382
Venus 7.243452483873647106e-10 0.0067590814914530454873
4.0453784346544178454e-05
-0.5567137338251560985 -0.46074173273652380134 0.02580196630219121906
0.012753121506668980284 -0.015678149412530151263 -0.0009510907726656827677
3 8.9970113821660187435e-10 0.010044908171483009529
0.12681182092868958922 -0.7161485778943049718 -0.017146261752773749032
0.01978070713081106144 0.0034557070729633850362 -0.00109402215681010293
Earth 8.997011382166018993e-10 0.010044922299157372164
4.25875607065040958e-05
0.6978790186886838498 -0.73607603319120218366 3.261671020506711323e-05
0.012205130808798069983 0.0117727888369263504476 -6.0385404652521189453e-07
4 9.549535102761465607e-11 0.0072466797341124641736
0.9913796310092216624 -0.17236385208280941006 4.574442303609438109e-06
0.0026673818939059660942 0.016885702625202340249 -8.2074388361713082097e-07
Mars 9.549535102761465872e-11 0.007246507286611460043
2.265740805092889601e-05
-1.617661473167097963 0.38314370807747849534 0.04771055403546069218
-0.0027036789764029569086 -0.012421968497550240837 -0.00019400613558421780209
5 2.825345908631354893e-07 0.35527079166215922855
-1.6436878725691590475 -0.09931688681832298582 0.038237939117251117105
0.0013642455487206960919 -0.0127728951275482699446 -0.00030115173687901287654
Jupiter 2.8253459086313549713e-07 0.3552710784524730732
0.00046732617030490929307
4.1527454588897487753 -2.8347492039446908763 -0.081136554176388195336
0.0041683967523185880624 0.0065946899141205552256 -0.00012065009272080269359
6 8.459715183006415395e-08 0.43765832419088212185
4.304060110247122317 -2.579516473452256875 -0.08558202993848706974
0.003792902202341501966 0.0068350794283332117623 -0.00011324814038141340017
Saturn 8.45971518300641563e-08 0.4376659135625219704
0.00038925687730393611812
6.39471595410062843 -7.621162747287802297 -0.121992225877669294154
0.0039680130835247464163 0.0035798698934692090544 -0.00022010758050265331019
7 1.2920249163736673626e-08 0.46960112247450473807
6.54409134618183419 -7.483470470167333133 -0.1303290586096018111
0.003893524262024787054 0.0036668581511023591937 -0.00021865564058601801348
Uranus 1.2920249163736673984e-08 0.46971473227488383167
0.00016953449859497231466
14.793135356927480828 13.074218343364380601 -0.14311846037737518955
-0.0026297294662822792016 0.0027702756265410048361 4.4212949669357180555e-05
8 1.5243589003230834323e-08 0.78136567314580814177
14.692788408572690528 13.179130291284799625 -0.14143429698462339772
-0.0026516826407085368304 0.0027513763836455209892 4.4427867883713361775e-05
Neptune 1.5243589003230834746e-08 0.78149679568494038567
0.000164587904124493665
29.568629894896030663 -4.5543028991960081697 -0.58771107137394917874
0.00046181040300440859715 0.0031288137434451902125 -7.498349850432879627e-05
29.58593540166936009 -4.435365846939811618 -0.5905556302070252839
0.0004489890080502080224 0.003131021601122137201 -7.4728898269552307757e-05
50 changes: 25 additions & 25 deletions examples/symba_swifter_comparison/8pl_16tp_encounters/pl.swifter.in
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
9
0 0.00029591220819207775568
0 0.0002959122081920778
0.0 0.0 0.0
0.0 0.0 0.0
1 4.9125474498983623693e-11 0.001475124456355905224
1 4.9125474498983625056e-11 0.0014751323154597007903
1.6306381826061645943e-05
-0.30949970210807342674 0.1619004125820537876 0.041620272188990829754
-0.018820805516945871005 -0.023743802865467341506 -0.00021385162925667799668
2 7.243452483873646905e-10 0.006759069616556246028
0.053584775529809842987 -0.4548355025417368247 -0.04208301187261995896
0.022298358665237189014 0.0047355207618514265702 -0.0016584224113858070382
2 7.243452483873647106e-10 0.0067590814914530454873
4.0453784346544178454e-05
-0.5567137338251560985 -0.46074173273652380134 0.02580196630219121906
0.012753121506668980284 -0.015678149412530151263 -0.0009510907726656827677
3 8.9970113821660187435e-10 0.010044908171483009529
0.12681182092868958922 -0.7161485778943049718 -0.017146261752773749032
0.01978070713081106144 0.0034557070729633850362 -0.00109402215681010293
3 8.997011382166018993e-10 0.010044922299157372164
4.25875607065040958e-05
0.6978790186886838498 -0.73607603319120218366 3.261671020506711323e-05
0.012205130808798069983 0.0117727888369263504476 -6.0385404652521189453e-07
4 9.549535102761465607e-11 0.0072466797341124641736
0.9913796310092216624 -0.17236385208280941006 4.574442303609438109e-06
0.0026673818939059660942 0.016885702625202340249 -8.2074388361713082097e-07
4 9.549535102761465872e-11 0.007246507286611460043
2.265740805092889601e-05
-1.617661473167097963 0.38314370807747849534 0.04771055403546069218
-0.0027036789764029569086 -0.012421968497550240837 -0.00019400613558421780209
5 2.825345908631354893e-07 0.35527079166215922855
-1.6436878725691590475 -0.09931688681832298582 0.038237939117251117105
0.0013642455487206960919 -0.0127728951275482699446 -0.00030115173687901287654
5 2.8253459086313549713e-07 0.3552710784524730732
0.00046732617030490929307
4.1527454588897487753 -2.8347492039446908763 -0.081136554176388195336
0.0041683967523185880624 0.0065946899141205552256 -0.00012065009272080269359
6 8.459715183006415395e-08 0.43765832419088212185
4.304060110247122317 -2.579516473452256875 -0.08558202993848706974
0.003792902202341501966 0.0068350794283332117623 -0.00011324814038141340017
6 8.45971518300641563e-08 0.4376659135625219704
0.00038925687730393611812
6.39471595410062843 -7.621162747287802297 -0.121992225877669294154
0.0039680130835247464163 0.0035798698934692090544 -0.00022010758050265331019
7 1.2920249163736673626e-08 0.46960112247450473807
6.54409134618183419 -7.483470470167333133 -0.1303290586096018111
0.003893524262024787054 0.0036668581511023591937 -0.00021865564058601801348
7 1.2920249163736673984e-08 0.46971473227488383167
0.00016953449859497231466
14.793135356927480828 13.074218343364380601 -0.14311846037737518955
-0.0026297294662822792016 0.0027702756265410048361 4.4212949669357180555e-05
8 1.5243589003230834323e-08 0.78136567314580814177
14.692788408572690528 13.179130291284799625 -0.14143429698462339772
-0.0026516826407085368304 0.0027513763836455209892 4.4427867883713361775e-05
8 1.5243589003230834746e-08 0.78149679568494038567
0.000164587904124493665
29.568629894896030663 -4.5543028991960081697 -0.58771107137394917874
0.00046181040300440859715 0.0031288137434451902125 -7.498349850432879627e-05
29.58593540166936009 -4.435365846939811618 -0.5905556302070252839
0.0004489890080502080224 0.003131021601122137201 -7.4728898269552307757e-05
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
8
1 4.9125474498983623693e-11 0.001475124456355905224
Mercury 4.9125474498983625056e-11 0.0014751323154597007903
1.6306381826061645943e-05
-0.30949970210807342674 0.1619004125820537876 0.041620272188990829754
-0.018820805516945871005 -0.023743802865467341506 -0.00021385162925667799668
2 7.243452483873646905e-10 0.006759069616556246028
0.053584775529809842987 -0.4548355025417368247 -0.04208301187261995896
0.022298358665237189014 0.0047355207618514265702 -0.0016584224113858070382
Venus 7.243452483873647106e-10 0.0067590814914530454873
4.0453784346544178454e-05
-0.5567137338251560985 -0.46074173273652380134 0.02580196630219121906
0.012753121506668980284 -0.015678149412530151263 -0.0009510907726656827677
3 8.9970113821660187435e-10 0.010044908171483009529
0.12681182092868958922 -0.7161485778943049718 -0.017146261752773749032
0.01978070713081106144 0.0034557070729633850362 -0.00109402215681010293
Earth 8.997011382166018993e-10 0.010044922299157372164
4.25875607065040958e-05
0.6978790186886838498 -0.73607603319120218366 3.261671020506711323e-05
0.012205130808798069983 0.0117727888369263504476 -6.0385404652521189453e-07
4 9.549535102761465607e-11 0.0072466797341124641736
0.9913796310092216624 -0.17236385208280941006 4.574442303609438109e-06
0.0026673818939059660942 0.016885702625202340249 -8.2074388361713082097e-07
Mars 9.549535102761465872e-11 0.007246507286611460043
2.265740805092889601e-05
-1.617661473167097963 0.38314370807747849534 0.04771055403546069218
-0.0027036789764029569086 -0.012421968497550240837 -0.00019400613558421780209
5 2.825345908631354893e-07 0.35527079166215922855
-1.6436878725691590475 -0.09931688681832298582 0.038237939117251117105
0.0013642455487206960919 -0.0127728951275482699446 -0.00030115173687901287654
Jupiter 2.8253459086313549713e-07 0.3552710784524730732
0.00046732617030490929307
4.1527454588897487753 -2.8347492039446908763 -0.081136554176388195336
0.0041683967523185880624 0.0065946899141205552256 -0.00012065009272080269359
6 8.459715183006415395e-08 0.43765832419088212185
4.304060110247122317 -2.579516473452256875 -0.08558202993848706974
0.003792902202341501966 0.0068350794283332117623 -0.00011324814038141340017
Saturn 8.45971518300641563e-08 0.4376659135625219704
0.00038925687730393611812
6.39471595410062843 -7.621162747287802297 -0.121992225877669294154
0.0039680130835247464163 0.0035798698934692090544 -0.00022010758050265331019
7 1.2920249163736673626e-08 0.46960112247450473807
6.54409134618183419 -7.483470470167333133 -0.1303290586096018111
0.003893524262024787054 0.0036668581511023591937 -0.00021865564058601801348
Uranus 1.2920249163736673984e-08 0.46971473227488383167
0.00016953449859497231466
14.793135356927480828 13.074218343364380601 -0.14311846037737518955
-0.0026297294662822792016 0.0027702756265410048361 4.4212949669357180555e-05
8 1.5243589003230834323e-08 0.78136567314580814177
14.692788408572690528 13.179130291284799625 -0.14143429698462339772
-0.0026516826407085368304 0.0027513763836455209892 4.4427867883713361775e-05
Neptune 1.5243589003230834746e-08 0.78149679568494038567
0.000164587904124493665
29.568629894896030663 -4.5543028991960081697 -0.58771107137394917874
0.00046181040300440859715 0.0031288137434451902125 -7.498349850432879627e-05
29.58593540166936009 -4.435365846939811618 -0.5905556302070252839
0.0004489890080502080224 0.003131021601122137201 -7.4728898269552307757e-05
Loading

0 comments on commit 3f61053

Please sign in to comment.