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

Commit

Permalink
Merge branch 'Simulation_API_improvements' into debug
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Nov 11, 2022
2 parents 27f6c00 + 152fc89 commit 9e40bbe
Show file tree
Hide file tree
Showing 7 changed files with 781 additions and 481 deletions.
9 changes: 0 additions & 9 deletions examples/Basic_Simulation/cb.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
!! Copyright 2022 - David Minton, Carlisle Wishard, Jennifer Pouplin, Jake Elliott, & Dana Singh
!! This file is part of Swiftest.
!! Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
!! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
!! Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
!! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
!! You should have received a copy of the GNU General Public License along with Swiftest.
!! If not, see: https://www.gnu.org/licenses.

Sun
39.476926408897626
0.004650467260962157
Expand Down
36 changes: 12 additions & 24 deletions examples/Basic_Simulation/initial_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,20 @@
from numpy.random import default_rng

# Initialize the simulation object as a variable
sim = swiftest.Simulation(init_cond_file_type="ASCII")

sim = swiftest.Simulation()
sim.set_simulation_time(tstart=0.0, tstop=10.0, dt=0.005, tstep_out=1.0)

# Add parameter attributes to the simulation object
sim.param['GMTINY'] = 1e-6
sim.param['MIN_GMFRAG'] = 1e-9

# Add the modern planets and the Sun using the JPL Horizons Database
sim.add("Sun", idval=0, date="2022-08-08")
sim.add("Mercury", idval=1, date="2022-08-08")
sim.add("Venus", idval=2, date="2022-08-08")
sim.add("Earth", idval=3, date="2022-08-08")
sim.add("Mars", idval=4, date="2022-08-08")
sim.add("Jupiter", idval=5, date="2022-08-08")
sim.add("Saturn", idval=6, date="2022-08-08")
sim.add("Uranus", idval=7, date="2022-08-08")
sim.add("Neptune", idval=8, date="2022-08-08")
sim.add_solar_system_body(["Sun","Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune","Pluto"])

# Add 5 user-defined massive bodies
npl = 5
density_pl = 3000.0 / (sim.param['MU2KG'] / sim.param['DU2M'] ** 3)

id_pl = np.array([9, 10, 11, 12, 13])
name_pl = np.array(["MassiveBody_01", "MassiveBody_02", "MassiveBody_03", "MassiveBody_04", "MassiveBody_05"])
name_pl = ["MassiveBody_01", "MassiveBody_02", "MassiveBody_03", "MassiveBody_04", "MassiveBody_05"]
a_pl = default_rng().uniform(0.3, 1.5, npl)
e_pl = default_rng().uniform(0.0, 0.3, npl)
inc_pl = default_rng().uniform(0.0, 90, npl)
Expand All @@ -64,28 +53,27 @@
GM_pl = (np.array([6e23, 8e23, 1e24, 3e24, 5e24]) / sim.param['MU2KG']) * sim.GU
R_pl = np.full(npl, (3 * (GM_pl / sim.GU) / (4 * np.pi * density_pl)) ** (1.0 / 3.0))
Rh_pl = a_pl * ((GM_pl) / (3 * sim.GU)) ** (1.0 / 3.0)
Ip1_pl = np.array([0.4, 0.4, 0.4, 0.4, 0.4])
Ip2_pl = np.array([0.4, 0.4, 0.4, 0.4, 0.4])
Ip3_pl = np.array([0.4, 0.4, 0.4, 0.4, 0.4])
rotx_pl = np.array([0.0, 0.0, 0.0, 0.0, 0.0])
roty_pl = np.array([0.0, 0.0, 0.0, 0.0, 0.0])
rotz_pl = np.array([0.0, 0.0, 0.0, 0.0, 0.0])
Ip1_pl = [0.4, 0.4, 0.4, 0.4, 0.4]
Ip2_pl = [0.4, 0.4, 0.4, 0.4, 0.4]
Ip3_pl = [0.4, 0.4, 0.4, 0.4, 0.4]
rotx_pl = [0.0, 0.0, 0.0, 0.0, 0.0]
roty_pl = [0.0, 0.0, 0.0, 0.0, 0.0]
rotz_pl = [0.0, 0.0, 0.0, 0.0, 0.0]

sim.addp(id_pl, name_pl, a_pl, e_pl, inc_pl, capom_pl, omega_pl, capm_pl, GMpl=GM_pl, Rpl=R_pl, rhill=Rh_pl, Ip1=Ip1_pl, Ip2=Ip2_pl, Ip3=Ip3_pl, rotx=rotx_pl, roty=roty_pl, rotz=rotz_pl)
sim.add_body(name_pl, a_pl, e_pl, inc_pl, capom_pl, omega_pl, capm_pl, GMpl=GM_pl, Rpl=R_pl, rhill=Rh_pl, Ip1=Ip1_pl, Ip2=Ip2_pl, Ip3=Ip3_pl, rotx=rotx_pl, roty=roty_pl, rotz=rotz_pl)

# Add 10 user-defined test particles
ntp = 10

id_tp = np.array([14, 15, 16, 17, 18, 19, 20, 21, 22, 23])
name_tp = np.array(["TestParticle_01", "TestParticle_02", "TestParticle_03", "TestParticle_04", "TestParticle_05", "TestParticle_06", "TestParticle_07", "TestParticle_08", "TestParticle_09", "TestParticle_10"])
name_tp = ["TestParticle_01", "TestParticle_02", "TestParticle_03", "TestParticle_04", "TestParticle_05", "TestParticle_06", "TestParticle_07", "TestParticle_08", "TestParticle_09", "TestParticle_10"]
a_tp = default_rng().uniform(0.3, 1.5, ntp)
e_tp = default_rng().uniform(0.0, 0.3, ntp)
inc_tp = default_rng().uniform(0.0, 90, ntp)
capom_tp = default_rng().uniform(0.0, 360.0, ntp)
omega_tp = default_rng().uniform(0.0, 360.0, ntp)
capm_tp = default_rng().uniform(0.0, 360.0, ntp)

sim.addp(id_tp, name_tp, a_tp, e_tp, inc_tp, capom_tp, omega_tp, capm_tp)
sim.add_body(name_tp, a_tp, e_tp, inc_tp, capom_tp, omega_tp, capm_tp)

# Save everything to a set of initial conditions files
sim.save('param.in')
37 changes: 37 additions & 0 deletions examples/Basic_Simulation/param.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
! VERSION Swiftest parameter input
T0 0.0
TSTOP 10.0
DT 0.005
ISTEP_OUT 200
ISTEP_DUMP 200
OUT_FORM XVEL
OUT_TYPE NETCDF_DOUBLE
OUT_STAT REPLACE
IN_TYPE NETCDF_DOUBLE
BIN_OUT bin.nc
CHK_QMIN 0.004650467260962157
CHK_RMIN 0.004650467260962157
CHK_RMAX 10000.0
CHK_EJECT 10000.0
CHK_QMIN_COORD HELIO
CHK_QMIN_RANGE 0.004650467260962157 10000.0
MU2KG 1.988409870698051e+30
TU2S 31557600.0
DU2M 149597870700.0
RESTART NO
INTERACTION_LOOPS TRIANGULAR
ENCOUNTER_CHECK TRIANGULAR
CHK_CLOSE YES
GR YES
FRAGMENTATION YES
ROTATION YES
ENERGY NO
EXTRA_FORCE NO
BIG_DISCARD NO
RHILL_PRESENT NO
TIDES NO
IN_FORM EL
NC_IN init_cond.nc
TSTART 0.0
GMTINY 1e-06
MIN_GMFRAG 1e-09
163 changes: 80 additions & 83 deletions examples/Basic_Simulation/pl.in
Original file line number Diff line number Diff line change
@@ -1,88 +1,85 @@
!! Copyright 2022 - David Minton, Carlisle Wishard, Jennifer Pouplin, Jake Elliott, & Dana Singh
!! This file is part of Swiftest.
!! Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
!! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
!! Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
!! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
!! You should have received a copy of the GNU General Public License along with Swiftest.
!! If not, see: https://www.gnu.org/licenses.

13
Mercury 6.553709809565314146e-06 0.0014751262621647182575
1.6306381826061645943e-05
0.38709864823618972407 0.20562513690973019398 7.0036250456070128223
48.30204974520415817 29.18823342267911869 114.9720047697775982
0.0 0.0 0.34599999999999997424
3.5734889863322150192 -18.38008501876561206 34.361513668512199956
Venus 9.6633133995815381836e-05 0.006759085242739840662
4.0453784346544178454e-05
0.72332603580811538624 0.0067486079191121668003 3.394406261149808035
76.61738837179606776 54.777760273590551776 315.37095689555837907
0.0 0.0 0.4000000000000000222
0.17650282045605921225 -3.6612475825356215592 8.702866268072763821
Earth 0.000120026935827952456416 0.010044668314295209318
4.25875607065040958e-05
0.9999943732711822353 0.016707309394717231171 0.0028984767436730000077
174.05498211951208987 289.04709044403989537 213.07530468023790604
0.0 0.0 0.33069999999999999396
5.002093202481912218 0.055213529850334066125 2301.2110537292529557
Mars 1.2739802010675941808e-05 0.007246950762048707243
2.265740805092889601e-05
1.5237812078483019551 0.0935087708803710449 1.8479353068000929916
49.489305419773351957 286.70300191753761965 24.878418068365981242
0.0 0.0 0.3644000000000000017
997.9357048213454125 -909.4072592492943007 1783.4501726537997323
Jupiter 0.03769225108898567778 0.3552222491747608486
0.00046732617030490929307
5.2028063728088866924 0.048395118271449058533 1.3035670146561249005
100.516498130230701236 273.44233262595901124 346.26538105843917492
0.0 0.0 0.27560000000000001164
-80.96619889339111482 -2388.0060524649362916 5008.7314931237953832
Saturn 0.01128589982009127331 0.43757948578866074266
0.00038925687730393611812
9.580020069168169172 0.053193613750490406633 2.4864365613724639381
113.597044717589099605 335.10179422401358806 237.66485199561481068
0.0 0.0 0.22000000000000000111
441.93538182505989814 378.5284220382117538 5135.9110455622733884
Uranus 0.001723658947826773068 0.4705353566089944894
0.00016953449859497231466
19.272143108769419939 0.043779687288749750962 0.7707536154556786645
74.077748995180698444 93.42271392662131291 242.37685081109759722
0.0 0.0 0.23000000000000000999
-677.3000258209181323 -3008.109907190578637 -836.301326618569835
Neptune 0.0020336100526728302882 0.78184929587893868845
0.000164587904124493665
30.305539399096510067 0.014544938874222059638 1.7686697746048700708
131.73604731224671127 249.9779420269553043 332.54824537252648042
0.0 0.0 0.23000000000000000999
1231.1804455066093229 -2178.0887091151860042 2329.6411363603121418
MassiveBody_01 1.1912109366578087428e-05 0.0016092923734511708263
2.425055692051244981e-05
0.3460404950890429432 0.2093906512182220625 0.11109012870384793459
114.31328763688792094 347.82259114762894114 96.0534391561842682
0.4000000000000000222 0.4000000000000000222 0.4000000000000000222
14
Mercury 6.553709809565314e-06
1.6306381826061646e-05
0.3870985843095394 0.2056234010897001 7.003302508001384
48.29611837378607 29.20442403952454 338.3394874682879
0.0 0.0 0.346
3.573018077015318 -18.380317085416586 34.36143850429876
Venus 9.663313399581537e-05
4.0453784346544176e-05
0.7233297579736101 0.006717605698865438 3.394439273342282
76.60235891771119 54.96037946082961 200.4789339550648
0.0 0.0 0.4
0.17650282045605922 -3.6612475825356214 8.702866268072764
Earth 0.00012002693582795245
4.25875607065041e-05
0.9999904874543223 0.01671400376545858 0.003637862608863003
175.025172600231 287.9619628812575 114.3482934042427
0.0 0.0 0.3307
6.157239621449141 0.057224133705898524 2301.2082528350797
Mars 1.2739802010675942e-05
2.2657408050928896e-05
1.523711925589535 0.09344151133508208 1.847441673557901
49.4728572124747 286.7379771285891 209.3396773477138
0.0 0.0 0.3644
997.9224351226384 -909.5549030011778 1783.3823046046184
Jupiter 0.037692251088985676
0.0004673261703049093
5.2027278008516 0.04824497711637968 1.303631134570075
100.5192588433081 273.5898402882514 129.5536700659942
0.0 0.0 0.2756
-80.9864396731672 -2388.0246092955053 5008.722318533006
Saturn 0.011285899820091273
0.00038925687730393614
9.532011952667288 0.05486329870433341 2.487906363280301
113.6305781676206 339.5467356402391 290.8995806568904
0.0 0.0 0.22
441.95954822014636 378.52638822638795 5135.909115928892
Uranus 0.001723658947826773
0.00016953449859497232
19.24498838290236 0.04796174942301296 0.7730102596086205
74.0125809801658 93.59554912280227 262.8658637277515
0.0 0.0 0.23
-677.3000258209181 -3008.1099071905787 -836.3013266185699
Neptune 0.0020336100526728304
0.00016458790412449367
30.03895991152209 0.008955570138096731 1.771119354296142
131.8221159748827 284.4748429674216 308.4513720536233
0.0 0.0 0.23
1232.224106980634 -2177.3040821077648 2329.8227878119233
Pluto 2.924216771029454e-07
7.943294877391593e-06
39.36791814672583 0.2487178537481577 17.1705505990969
110.3314332962701 113.0826635900664 55.11416408345664
0.0 0.0 0.4
-243.59404988903637 261.28663002814227 -38.57352022187049
MassiveBody_01 1.1912109366578089e-05
2.425055692051245e-05
0.7452368716298337 0.0633011418780484 0.11151363780595558
203.01823417718037 284.9353898127118 266.79344592519305
0.4 0.4 0.4
0.0 0.0 0.0
MassiveBody_02 1.5882812488770779849e-05 0.0016802531895603555184
2.6691191565570073646e-05
0.32826188156947710972 0.27866488696288682636 77.21223337306255985
251.99014895640269174 53.772702227560969845 165.6085387284213084
0.4000000000000000222 0.4000000000000000222 0.4000000000000000222
MassiveBody_02 1.5882812488770783e-05
2.6691191565570074e-05
0.7671203280602826 0.10149029388964753 53.46706656938751
61.74738152068808 68.20565593722856 271.3352706902475
0.4 0.4 0.4
0.0 0.0 0.0
MassiveBody_03 1.9853515610963475658e-05 0.004324919007577881884
2.8752214513575297366e-05
0.7843689028022314824 0.06176128116947356833 78.74144231136708072
286.63765100951468412 347.55933571120488068 266.36960496595537506
0.4000000000000000222 0.4000000000000000222 0.4000000000000000222
MassiveBody_03 1.985351561096348e-05
2.8752214513575297e-05
1.4698824276418418 0.13621250684495437 23.635498327264845
38.071905339231236 283.134612455057 250.67457601578352
0.4 0.4 0.4
0.0 0.0 0.0
MassiveBody_04 5.9560546832890430362e-05 0.0056765613035874530265
4.146786902759040254e-05
0.7138176832994267418 0.28016098557400787028 22.725690778108500467
203.41845532080247949 219.74297850728484605 14.730732982803269593
0.4000000000000000222 0.4000000000000000222 0.4000000000000000222
MassiveBody_04 5.9560546832890444e-05
4.14678690275904e-05
0.9741731590760117 0.1519713326893784 20.51335588582416
350.53780805624825 304.05941264938997 142.62713592644738
0.4 0.4 0.4
0.0 0.0 0.0
MassiveBody_05 9.9267578054817388455e-05 0.010382929139161686458
4.916559523190238318e-05
1.101215402063684401 0.076651567404004070094 52.41961577462824806
142.90070862650665617 293.70542448390904156 318.5666754758643151
0.4000000000000000222 0.4000000000000000222 0.4000000000000000222
MassiveBody_05 9.926757805481742e-05
4.916559523190238e-05
0.6633500122731075 0.13550930562584215 10.680323453316653
328.45970148163457 49.93948991697533 316.2109831817007
0.4 0.4 0.4
0.0 0.0 0.0
49 changes: 20 additions & 29 deletions examples/Basic_Simulation/tp.in
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
!! Copyright 2022 - David Minton, Carlisle Wishard, Jennifer Pouplin, Jake Elliott, & Dana Singh
!! This file is part of Swiftest.
!! Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
!! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
!! Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
!! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
!! You should have received a copy of the GNU General Public License along with Swiftest.
!! If not, see: https://www.gnu.org/licenses.

10
TestParticle_01
1.0288790290699558749 0.088535376967516773994 39.679062610233010844
51.107327480220099858 20.90477961082723013 183.92936958121950397
0.5697767200549144 0.11834332057809717 80.87229166892182
222.5373287698991 111.76944690551065 270.3754252090885
TestParticle_02
0.54831541717225318333 0.20048853000030755767 32.784952066779297297
66.59436607119042151 196.2609764918545352 76.40623742948525887
1.0092273242276735 0.05399051523964523 82.35601343884242
117.598050656921 116.26893959032198 208.13367102381633
TestParticle_03
0.9815578696795972391 0.25717438840188583393 38.959194313128776344
158.31201212846775661 93.86793546512863884 126.96040079919036714
0.7590606700221183 0.027936243833100036 88.12926503625694
188.5414923780248 169.44578516513008 282.4333664924941
TestParticle_04
0.70510786000431613374 0.068740260615181125736 39.981235917453354034
26.668314027440779057 12.507089902982141183 53.606668142734086757
0.9972940668463142 0.2569338531459909 22.75744046640894
199.388648818177 152.8772634782716 307.54746324357103
TestParticle_05
1.336737159289705712 0.25044351028750111432 74.189544264066626056
313.1647935522670423 152.39951433565357775 322.52271715518395467
0.341620427452812 0.052524493325270837 18.839916665085173
327.2732232808312 334.4396604858765 359.4553699087638
TestParticle_06
0.64018428687513928566 0.1478972702874425671 73.39555666508663023
74.03379498826825511 124.22185942531125136 106.36095293685497154
1.1670239341669624 0.07778574626824612 22.716135789279228
196.30730270195494 154.1907148406917 159.6860762761786
TestParticle_07
1.2738161048947760356 0.17129911220230967239 78.723790909435408025
111.971184037421835455 315.6294407604535195 108.74538288631850946
1.0954005977667731 0.10128096358705894 9.878980088486013
101.85525076444998 124.8686145955563 254.7757898831765
TestParticle_08
0.5196197141250760154 0.26607581023277782073 79.221465395061358095
240.07768052067768849 177.4793327047061382 189.85775920180086018
0.39125485873865873 0.17327367123519463 22.276414655828646
105.99598258123197 235.2803528505754 348.706620365582
TestParticle_09
0.7160151851892424535 0.29584187625470087513 58.1214116614385361
24.22606869850931588 338.4678256522021229 136.32070882113120547
0.48720268138208256 0.29707768397862033 39.717820434869466
307.9106242922398 221.91704762104942 333.56626647648994
TestParticle_10
1.0782431797945351004 0.11096856177737297877 54.729767236739554903
280.85362091874827684 116.780853088052467115 286.99855363222661708
0.6458552755486036 0.07522818043309405 45.225887389492826
74.40348173261458 92.77221707157337 260.30279498657796
Loading

0 comments on commit 9e40bbe

Please sign in to comment.