Note
Go to the end to download the full example code.
Basic disc simulation#
This simple example shows how to run a basic disc simulation in SPH
8 import shamrock
9
10 # If we use the shamrock executable to run this script instead of the python interpreter,
11 # we should not initialize the system as the shamrock executable needs to handle specific MPI logic
12 if not shamrock.sys.is_initialized():
13 shamrock.change_loglevel(1)
14 shamrock.sys.init("0:0")
Setup units
19 si = shamrock.UnitSystem()
20 sicte = shamrock.Constants(si)
21 codeu = shamrock.UnitSystem(
22 unit_time=3600 * 24 * 365,
23 unit_length=sicte.au(),
24 unit_mass=sicte.sol_mass(),
25 )
26 ucte = shamrock.Constants(codeu)
27 G = ucte.G()
List parameters
33 # Resolution
34 Npart = 1000000
35
36 # Sink parameters
37 center_mass = 1
38 center_racc = 0.1
39
40 # Disc parameter
41 disc_mass = 0.01 # sol mass
42 rout = 10 # au
43 rin = 1 # au
44 H_r_in = 0.05
45 q = 0.5
46 p = 3.0 / 2.0
47 r0 = 1
48
49 # Viscosity parameter
50 alpha_AV = 1e-3 / 0.08
51 alpha_u = 1
52 beta_AV = 2
53
54 # Integrator parameters
55 C_cour = 0.3
56 C_force = 0.25
57
58
59 # Disc profiles
60 def sigma_profile(r):
61 sigma_0 = 1
62 return sigma_0 * (r / rin) ** (-p)
63
64
65 def kep_profile(r):
66 return (G * center_mass / r) ** 0.5
67
68
69 def omega_k(r):
70 return kep_profile(r) / r
71
72
73 def cs_profile(r):
74 cs_in = (H_r_in * rin) * omega_k(rin)
75 return ((r / rin) ** (-q)) * cs_in
Utility functions and quantities deduced from the base one
81 # Deduced quantities
82 pmass = disc_mass / Npart
83 bmin = (-rout * 2, -rout * 2, -rout * 2)
84 bmax = (rout * 2, rout * 2, rout * 2)
85
86 cs0 = cs_profile(rin)
87
88
89 def rot_profile(r):
90 return ((kep_profile(r) ** 2) - (2 * p + q) * cs_profile(r) ** 2) ** 0.5
91
92
93 def H_profile(r):
94 H = cs_profile(r) / omega_k(r)
95 # fact = (2.**0.5) * 3. # factor taken from phantom, to fasten thermalizing
96 fact = 1
97 return fact * H
Start the context The context holds the data of the code We then init the layout of the field (e.g. the list of fields used by the solver)
105 ctx = shamrock.Context()
106 ctx.pdata_layout_new()
Attach a SPH model to the data and configure it
111 model = shamrock.get_Model_SPH(context=ctx, vector_type="f64_3", sph_kernel="M4")
112
113 # Generate the default config
114 cfg = model.gen_default_config()
115 # Use disc alpha model viscosity
116 cfg.set_artif_viscosity_ConstantDisc(alpha_u=alpha_u, alpha_AV=alpha_AV, beta_AV=beta_AV)
117 # use the Lodato Price 2007 equation of state
118 cfg.set_eos_locally_isothermalLP07(cs0=cs0, q=q, r0=r0)
119 # Use the given code units
120 cfg.set_units(codeu)
121 # Change particle mass
122 cfg.set_particle_mass(pmass)
123 # Set the CFL
124 cfg.set_cfl_cour(C_cour)
125 cfg.set_cfl_force(C_force)
126
127 # Set the solver config to be the one stored in cfg
128 model.set_solver_config(cfg)
129
130 # Print the solver config
131 model.get_current_config().print_status()
132
133 # We want the patches to split above 10^8 part and merge if smaller than 1 part (e.g. disable patch)
134 model.init_scheduler(int(1e8), 1)
135
136 # Set the simulation box size
137 model.resize_simulation_box(bmin, bmax)
----- SPH Solver configuration -----
units :
unit_length : 149597870700
unit_mass : 1.98847e+30
unit_current : 1
unit_temperature : 1
unit_qte : 1
unit_lumint : 1
part mass 1e-08 ( can be changed using .set_part_mass() )
cfl force 0.25
cfl courant 0.3
--- artificial viscosity config
Config Type : constant disc
alpha_AV = 0.0125
alpha_u = 1
beta_AV = 2
--- artificial viscosity config (deduced)
-------------
EOS config f64_3 :
locally isothermal (Lodato Price 2007) :
--- Bondaries config
Config Type : Free boundaries
--- Bondaries config config (deduced)
-------------
------------------------------------
Add the sink particle
142 # null position and velocity
143 model.add_sink(center_mass, (0, 0, 0), (0, 0, 0), center_racc)
Create the setup
148 setup = model.get_setup()
149 gen_disc = setup.make_generator_disc_mc(
150 part_mass=pmass,
151 disc_mass=disc_mass,
152 r_in=rin,
153 r_out=rout,
154 sigma_profile=sigma_profile,
155 H_profile=H_profile,
156 rot_profile=rot_profile,
157 cs_profile=cs_profile,
158 random_seed=666,
159 )
160
161 # Print the dot graph of the setup
162 print(gen_disc.get_dot())
digraph G {
rankdir=LR;
node_0 [label="GeneratorMCDisc"];
node_2 [label="Simulation"];
node_0 -> node_2;
}
Apply the setup
Info: pushing data in scheduler, N = 1000000 [DataInserterUtility][rank=0]
Info: reattributing data ... [DataInserterUtility][rank=0]
Info: reattributing data done in 52.53 ms [DataInserterUtility][rank=0]
Info: run scheduler step ... [DataInserterUtility][rank=0]
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 7.71 us (57.8%)
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 1073.00 ns (0.2%)
patch tree reduce : 992.00 ns (0.2%)
gen split merge : 771.00 ns (0.1%)
split / merge op : 0/0
apply split merge : 1312.00 ns (0.2%)
LB compute : 608.39 us (98.4%)
LB move op cnt : 0
LB apply : 2.29 us (0.4%)
Info: the setup took : 3.163686182 s [SPH setup][rank=0]
Run a single step to init the integrator and smoothing lenght of the particles
Here the htolerance is the maximum factor of evolution of the smoothing lenght in each
Smoothing lenght iterations, increasing it affect the performance negatively but increse the
convergence rate of the smoothing lenght
this is why we increase it temporely to 1.3 before lowering it back to 1.1 (default value)
Note that both change_htolerance
can be removed and it will work the same but would converge
more slowly at the first timestep
177 model.change_htolerance(1.3)
178 model.timestep()
179 model.change_htolerance(1.1)
---------------- t = 0, dt = 0 ----------------
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 28.14 us (2.1%)
patch tree reduce : 2.01 us (0.1%)
gen split merge : 872.00 ns (0.1%)
split / merge op : 0/0
apply split merge : 1082.00 ns (0.1%)
LB compute : 1297.16 us (94.7%)
LB move op cnt : 0
LB apply : 1954.00 ns (0.1%)
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 1983.00 ns (66.2%)
Info: free boundaries skipping geometry update [PositionUpdated][rank=0]
Warning: smoothing length is not converged, rerunning the iterator ... [Smoothinglength][rank=0]
largest h = 0.7251187699241748 unconverged cnt = 999992
Warning: smoothing length is not converged, rerunning the iterator ... [Smoothinglength][rank=0]
largest h = 0.7251187699241738 unconverged cnt = 999954
Warning: smoothing length is not converged, rerunning the iterator ... [Smoothinglength][rank=0]
largest h = 0.7529481567236117 unconverged cnt = 999847
Warning: smoothing length is not converged, rerunning the iterator ... [Smoothinglength][rank=0]
largest h = 0.7529481567236117 unconverged cnt = 999058
Warning: smoothing length is not converged, rerunning the iterator ... [Smoothinglength][rank=0]
largest h = 0.7529481567236117 unconverged cnt = 970419
Warning: smoothing length is not converged, rerunning the iterator ... [Smoothinglength][rank=0]
largest h = 0.7529481567236117 unconverged cnt = 623188
Warning: smoothing length is not converged, rerunning the iterator ... [Smoothinglength][rank=0]
largest h = 0.7529481567236117 unconverged cnt = 38585
Warning: smoothing length is not converged, rerunning the iterator ... [Smoothinglength][rank=0]
largest h = 0.7529481567236117 unconverged cnt = 101
Info: smoothing length iteration converged [Smoothinglength][rank=0]
eps min = 0, max = 8.951768789337238e-07
iterations = 3
Info: conservation infos : [sph::Model][rank=0]
sum v = (9.877002876193511e-06,-3.3153642116852934e-05,0)
sum a = (-3.3203691532368573e-18,1.3145951341386741e-18,4.658681209898652e-21)
sum e = 0.05004044613227274
sum de = 3.3881317890172014e-20
Info: cfl dt = 3.895385803115442e-05 cfl multiplier : 0.01 [sph::Model][rank=0]
Info: processing rate infos : [sph::Model][rank=0]
---------------------------------------------------------------------------------------
| rank | rate (N.s^-1) | Nobj | t compute (s) | interf | alloc | mem (max) |
---------------------------------------------------------------------------------------
| 0 | 3.4700e+04 | 1000000 | 2.882e+01 | 0 % | 0 % | 950.66 MB |
---------------------------------------------------------------------------------------
Info: estimated rate : 0 (tsim/hr) [sph::Model][rank=0]
Manipulating the simulation#
Dump files (path relative to where you have started shamrock)
186 dump_folder = "_to_trash"
187 import os
188
189 os.system("mkdir -p " + dump_folder)
190
191 # VTK dump
192 model.do_vtk_dump(dump_folder + "/init_disc.vtk", True)
193
194 # Shamrock restart dump files
195 model.dump(dump_folder + "/init_disc.sham")
196
197 # Phantom dump
198 dump = model.make_phantom_dump()
199 dump.save_dump(dump_folder + "/init_disc.phdump")
Info: dump to _to_trash/init_disc.vtk [VTK Dump][rank=0]
- took 146.46 ms, bandwidth = 364.66 MB/s
Info: Dumping state to _to_trash/init_disc.sham [SPH][rank=0]
Info: dump to _to_trash/init_disc.sham [Shamrock Dump][rank=0]
- took 128.19 ms, bandwidth = 892.79 MB/s
Single timestep
203 model.evolve_once()
---------------- t = 0, dt = 3.895385803115442e-05 ----------------
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 12.62 us (1.4%)
patch tree reduce : 1603.00 ns (0.2%)
gen split merge : 661.00 ns (0.1%)
split / merge op : 0/0
apply split merge : 1193.00 ns (0.1%)
LB compute : 850.92 us (96.5%)
LB move op cnt : 0
LB apply : 2.29 us (0.3%)
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 3.45 us (78.0%)
Info: free boundaries skipping geometry update [PositionUpdated][rank=0]
Info: smoothing length iteration converged [Smoothinglength][rank=0]
eps min = 9.801209890616902e-15, max = 9.999977929357478e-07
iterations = 1
Info: conservation infos : [sph::Model][rank=0]
sum v = (9.877274458998799e-06,-3.315172351500661e-05,4.5064286673134777e-11)
sum a = (9.639234939753938e-19,-2.7511630126819675e-18,-5.734413052911613e-19)
sum e = 0.05004044727231212
sum de = 1.638590127723689e-07
Info: cfl dt = 0.0013246034089634724 cfl multiplier : 0.34 [sph::Model][rank=0]
Info: processing rate infos : [sph::Model][rank=0]
---------------------------------------------------------------------------------------
| rank | rate (N.s^-1) | Nobj | t compute (s) | interf | alloc | mem (max) |
---------------------------------------------------------------------------------------
| 0 | 1.6785e+05 | 1000000 | 5.958e+00 | 0 % | 0 % | 950.66 MB |
---------------------------------------------------------------------------------------
Info: estimated rate : 0.023538453871035987 (tsim/hr) [sph::Model][rank=0]
Info: iteration since start : 2 [SPH][rank=0]
Info: time since start : 57.451070087000005 (s) [SPH][rank=0]
Evolve until a given time (code units)
207 model.evolve_until(0.001)
---------------- t = 3.895385803115442e-05, dt = 0.0009610461419688457 ----------------
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 16.12 us (1.8%)
patch tree reduce : 1883.00 ns (0.2%)
gen split merge : 712.00 ns (0.1%)
split / merge op : 0/0
apply split merge : 1012.00 ns (0.1%)
LB compute : 793.02 us (90.4%)
LB move op cnt : 0
LB apply : 1854.00 ns (0.2%)
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 2.08 us (65.2%)
Info: free boundaries skipping geometry update [PositionUpdated][rank=0]
Info: smoothing length iteration converged [Smoothinglength][rank=0]
eps min = 5.761597459766956e-14, max = 9.99984119568859e-07
iterations = 2
Info: conservation infos : [sph::Model][rank=0]
sum v = (9.883695796318215e-06,-3.310631048745232e-05,1.1117989573418118e-09)
sum a = (-1.4670610646444482e-18,4.743384504624082e-19,-5.713237229230256e-19)
sum e = 0.050041140179747985
sum de = 4.202179861575134e-06
Info: cfl dt = 0.002188797630762785 cfl multiplier : 0.56 [sph::Model][rank=0]
Info: processing rate infos : [sph::Model][rank=0]
---------------------------------------------------------------------------------------
| rank | rate (N.s^-1) | Nobj | t compute (s) | interf | alloc | mem (max) |
---------------------------------------------------------------------------------------
| 0 | 1.6006e+05 | 1000000 | 6.248e+00 | 0 % | 0 % | 950.66 MB |
---------------------------------------------------------------------------------------
Info: estimated rate : 0.5537775528023824 (tsim/hr) [sph::Model][rank=0]
Info: iteration since start : 3 [SPH][rank=0]
Info: time since start : 63.91565913 (s) [SPH][rank=0]
True
Get the sinks positions
211 print(model.get_sinks())
[{'pos': (-6.9645029304530114e-12, -4.9250231245437725e-11, -1.15686324401464e-12), 'velocity': (-1.374628895941851e-08, -9.842692059825167e-08, -2.3137247314062144e-09), 'sph_acceleration': (-1.3548784354595216e-05, -9.834742672125893e-05, -2.313722832390366e-06), 'ext_acceleration': (0.0, 0.0, 0.0), 'mass': 1.0, 'angular_momentum': (0.0, 0.0, 0.0), 'accretion_radius': 0.1}]
Get the fields as python dictionary of numpy arrays
Warning
Do not do this on a large distributed simulation as this gather all data on MPI rank 0 and will use a lot of memory (and crash if the simulation is too large)
221 print(ctx.collect_data())
adding -> xyz
adding -> vxyz
adding -> axyz
adding -> axyz_ext
adding -> hpart
adding -> uint
adding -> duint
{'xyz': array([[-7.65869663, -6.39642264, -0.95720382],
[-7.55994716, -6.50503632, -1.17167965],
[-7.51908014, -6.42069667, -1.15259445],
...,
[ 7.55443246, 6.37259864, 1.01837507],
[ 7.57542343, 6.28326045, 1.24366222],
[ 7.65988442, 6.31067776, 0.96346951]]), 'vxyz': array([[ 1.26064246e+00, -1.52288302e+00, -5.51013538e-04],
[ 1.28544857e+00, -1.51257386e+00, -6.24111362e-03],
[ 1.28734769e+00, -1.52178147e+00, -3.34366897e-03],
...,
[-1.27700796e+00, 1.52214753e+00, 3.96807363e-03],
[-1.26813654e+00, 1.53456934e+00, 6.37018776e-03],
[-1.25652339e+00, 1.53414415e+00, 4.88137129e-03]]), 'axyz': array([[ -7.62410459, -3.72392315, -0.55169954],
[ -5.34944275, -11.84317988, -6.24085762],
[ -3.35111101, -9.6642787 , -3.34390459],
...,
[ 4.82957121, 1.96547374, 3.96824979],
[ 3.67155219, 0.58009335, 6.36994852],
[ 4.92884225, 2.37259344, 4.88141652]]), 'axyz_ext': array([[ 0.299749 , 0.25034564, 0.03746341],
[ 0.29432289, 0.25325323, 0.04561568],
[ 0.30052408, 0.25662367, 0.04606712],
...,
[-0.3036538 , -0.25614946, -0.04093404],
[-0.30590699, -0.25372751, -0.05022095],
[-0.30459947, -0.25094754, -0.03831289]]), 'hpart': array([0.20772107, 0.24976708, 0.20235783, ..., 0.22745153, 0.30584271,
0.22650431]), 'uint': array([-2.25966937e-05, 1.34453304e-05, -2.26322647e-05, ...,
-6.17869819e-05, -4.00023136e-05, -6.15569252e-05]), 'duint': array([-0.04227789, -0.0562385 , -0.10388435, ..., -0.07490322,
-0.05237283, -0.07313985])}
Performing a timestep loop
225 dt_stop = 0.001
226 for i in range(10):
227 t_target = i * dt_stop
228 # skip if the model is already past the target
229 if model.get_time() > t_target:
230 continue
231
232 model.evolve_until(i * dt_stop)
233
234 # Dump name is "dump_xxxx.sham" where xxxx is the timestep
235 model.dump(dump_folder + f"/dump_{i:04}.sham")
Info: iteration since start : 3 [SPH][rank=0]
Info: time since start : 64.77965679500001 (s) [SPH][rank=0]
Info: Dumping state to _to_trash/dump_0001.sham [SPH][rank=0]
Info: dump to _to_trash/dump_0001.sham [Shamrock Dump][rank=0]
- took 114.13 ms, bandwidth = 1002.81 MB/s
---------------- t = 0.001, dt = 0.001 ----------------
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 6.70 us (0.9%)
patch tree reduce : 1072.00 ns (0.1%)
gen split merge : 841.00 ns (0.1%)
split / merge op : 0/0
apply split merge : 1022.00 ns (0.1%)
LB compute : 705.57 us (96.3%)
LB move op cnt : 0
LB apply : 2.05 us (0.3%)
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 1854.00 ns (67.3%)
Info: free boundaries skipping geometry update [PositionUpdated][rank=0]
Info: smoothing length iteration converged [Smoothinglength][rank=0]
eps min = 1.9971047123763135e-14, max = 9.999648722707607e-07
iterations = 2
Info: conservation infos : [sph::Model][rank=0]
sum v = (9.883777268369466e-06,-3.310446840349008e-05,1.156861416194528e-09)
sum a = (-8.673617379884035e-19,9.486769009248164e-20,3.2610768469290563e-19)
sum e = 0.05004120231976796
sum de = 8.405289991465789e-06
Info: cfl dt = 0.0027765192383187257 cfl multiplier : 0.7066666666666667 [sph::Model][rank=0]
Info: processing rate infos : [sph::Model][rank=0]
---------------------------------------------------------------------------------------
| rank | rate (N.s^-1) | Nobj | t compute (s) | interf | alloc | mem (max) |
---------------------------------------------------------------------------------------
| 0 | 1.6073e+05 | 1000000 | 6.222e+00 | 0 % | 0 % | 950.66 MB |
---------------------------------------------------------------------------------------
Info: estimated rate : 0.5786384313576193 (tsim/hr) [sph::Model][rank=0]
Info: iteration since start : 4 [SPH][rank=0]
Info: time since start : 71.13014448300001 (s) [SPH][rank=0]
Info: Dumping state to _to_trash/dump_0002.sham [SPH][rank=0]
Info: dump to _to_trash/dump_0002.sham [Shamrock Dump][rank=0]
- took 104.17 ms, bandwidth = 1.07 GB/s
---------------- t = 0.002, dt = 0.001 ----------------
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 7.40 us (1.4%)
patch tree reduce : 1102.00 ns (0.2%)
gen split merge : 821.00 ns (0.2%)
split / merge op : 0/0
apply split merge : 1022.00 ns (0.2%)
LB compute : 504.88 us (96.2%)
LB move op cnt : 0
LB apply : 1933.00 ns (0.4%)
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 3.62 us (82.8%)
Info: free boundaries skipping geometry update [PositionUpdated][rank=0]
Info: smoothing length iteration converged [Smoothinglength][rank=0]
eps min = 6.151207595751965e-14, max = 9.999926494822936e-07
iterations = 2
Info: conservation infos : [sph::Model][rank=0]
sum v = (9.883580477933292e-06,-3.310454869572145e-05,1.1568559320233846e-09)
sum a = (-4.777265822514254e-19,2.5343225781848666e-18,-6.441685563868954e-19)
sum e = 0.050041210663350086
sum de = 1.2608707797471775e-05
Info: cfl dt = 0.0031848710647867013 cfl multiplier : 0.8044444444444444 [sph::Model][rank=0]
Info: processing rate infos : [sph::Model][rank=0]
---------------------------------------------------------------------------------------
| rank | rate (N.s^-1) | Nobj | t compute (s) | interf | alloc | mem (max) |
---------------------------------------------------------------------------------------
| 0 | 1.6418e+05 | 1000000 | 6.091e+00 | 0 % | 0 % | 950.66 MB |
---------------------------------------------------------------------------------------
Info: estimated rate : 0.5910453020526846 (tsim/hr) [sph::Model][rank=0]
Info: iteration since start : 5 [SPH][rank=0]
Info: time since start : 77.339965725 (s) [SPH][rank=0]
Info: Dumping state to _to_trash/dump_0003.sham [SPH][rank=0]
Info: dump to _to_trash/dump_0003.sham [Shamrock Dump][rank=0]
- took 126.63 ms, bandwidth = 903.76 MB/s
---------------- t = 0.003, dt = 0.001 ----------------
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 6.46 us (1.4%)
patch tree reduce : 1062.00 ns (0.2%)
gen split merge : 811.00 ns (0.2%)
split / merge op : 0/0
apply split merge : 1232.00 ns (0.3%)
LB compute : 431.24 us (96.1%)
LB move op cnt : 0
LB apply : 1984.00 ns (0.4%)
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 1883.00 ns (67.1%)
Info: free boundaries skipping geometry update [PositionUpdated][rank=0]
Info: smoothing length iteration converged [Smoothinglength][rank=0]
eps min = 4.0130451842052e-14, max = 9.999844335031671e-07
iterations = 2
Info: conservation infos : [sph::Model][rank=0]
sum v = (9.883384418489218e-06,-3.310462979684227e-05,1.156846806790515e-09)
sum a = (5.6022759131399424e-18,1.5856456772600502e-18,-2.625802136488331e-20)
sum e = 0.05004122228128194
sum de = 1.681219206056172e-05
Info: cfl dt = 0.00347680926460198 cfl multiplier : 0.8696296296296296 [sph::Model][rank=0]
Info: processing rate infos : [sph::Model][rank=0]
---------------------------------------------------------------------------------------
| rank | rate (N.s^-1) | Nobj | t compute (s) | interf | alloc | mem (max) |
---------------------------------------------------------------------------------------
| 0 | 1.6365e+05 | 1000000 | 6.111e+00 | 0 % | 0 % | 950.66 MB |
---------------------------------------------------------------------------------------
Info: estimated rate : 0.5891386787901168 (tsim/hr) [sph::Model][rank=0]
Info: iteration since start : 6 [SPH][rank=0]
Info: time since start : 83.59683927100001 (s) [SPH][rank=0]
Info: Dumping state to _to_trash/dump_0004.sham [SPH][rank=0]
Info: dump to _to_trash/dump_0004.sham [Shamrock Dump][rank=0]
- took 120.96 ms, bandwidth = 946.15 MB/s
---------------- t = 0.004, dt = 0.001 ----------------
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 7.24 us (1.2%)
patch tree reduce : 1232.00 ns (0.2%)
gen split merge : 832.00 ns (0.1%)
split / merge op : 0/0
apply split merge : 1002.00 ns (0.2%)
LB compute : 569.75 us (96.9%)
LB move op cnt : 0
LB apply : 1984.00 ns (0.3%)
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 1843.00 ns (71.3%)
Info: free boundaries skipping geometry update [PositionUpdated][rank=0]
Info: smoothing length iteration converged [Smoothinglength][rank=0]
eps min = 4.6709809818100174e-14, max = 9.999956170277897e-07
iterations = 2
Info: conservation infos : [sph::Model][rank=0]
sum v = (9.883189093216266e-06,-3.310471170215324e-05,1.156834046054849e-09)
sum a = (2.2124500582282325e-18,-1.2197274440461925e-19,-1.8592373192231892e-19)
sum e = 0.05004123716236742
sum de = 2.1015717680430067e-05
Info: cfl dt = 0.0036933730598545473 cfl multiplier : 0.9130864197530864 [sph::Model][rank=0]
Info: processing rate infos : [sph::Model][rank=0]
---------------------------------------------------------------------------------------
| rank | rate (N.s^-1) | Nobj | t compute (s) | interf | alloc | mem (max) |
---------------------------------------------------------------------------------------
| 0 | 1.6493e+05 | 1000000 | 6.063e+00 | 0 % | 0 % | 950.66 MB |
---------------------------------------------------------------------------------------
Info: estimated rate : 0.5937419341859063 (tsim/hr) [sph::Model][rank=0]
Info: iteration since start : 7 [SPH][rank=0]
Info: time since start : 89.797277948 (s) [SPH][rank=0]
Info: Dumping state to _to_trash/dump_0005.sham [SPH][rank=0]
Info: dump to _to_trash/dump_0005.sham [Shamrock Dump][rank=0]
- took 115.04 ms, bandwidth = 994.86 MB/s
---------------- t = 0.005, dt = 0.001 ----------------
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 6.50 us (1.4%)
patch tree reduce : 1312.00 ns (0.3%)
gen split merge : 782.00 ns (0.2%)
split / merge op : 0/0
apply split merge : 992.00 ns (0.2%)
LB compute : 452.97 us (96.0%)
LB move op cnt : 0
LB apply : 2.11 us (0.4%)
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 2.12 us (72.6%)
Info: free boundaries skipping geometry update [PositionUpdated][rank=0]
Info: smoothing length iteration converged [Smoothinglength][rank=0]
eps min = 1.8592711866765938e-13, max = 9.999947606502062e-07
iterations = 3
Info: conservation infos : [sph::Model][rank=0]
sum v = (9.882994505261276e-06,-3.3104794406937104e-05,1.1568176487832544e-09)
sum a = (2.537710709973884e-18,4.0657581468206416e-20,-1.4907779871675686e-19)
sum e = 0.05004125532426453
sum de = 2.5219238580460913e-05
Info: cfl dt = 0.003861256985531854 cfl multiplier : 0.9420576131687243 [sph::Model][rank=0]
Info: processing rate infos : [sph::Model][rank=0]
---------------------------------------------------------------------------------------
| rank | rate (N.s^-1) | Nobj | t compute (s) | interf | alloc | mem (max) |
---------------------------------------------------------------------------------------
| 0 | 1.6417e+05 | 1000000 | 6.091e+00 | 0 % | 0 % | 950.66 MB |
---------------------------------------------------------------------------------------
Info: estimated rate : 0.5910250179589847 (tsim/hr) [sph::Model][rank=0]
Info: iteration since start : 8 [SPH][rank=0]
Info: time since start : 96.016915392 (s) [SPH][rank=0]
Info: Dumping state to _to_trash/dump_0006.sham [SPH][rank=0]
Info: dump to _to_trash/dump_0006.sham [Shamrock Dump][rank=0]
- took 123.19 ms, bandwidth = 929.03 MB/s
---------------- t = 0.006, dt = 0.001 ----------------
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 6.80 us (1.6%)
patch tree reduce : 1203.00 ns (0.3%)
gen split merge : 792.00 ns (0.2%)
split / merge op : 0/0
apply split merge : 1423.00 ns (0.3%)
LB compute : 402.60 us (95.7%)
LB move op cnt : 0
LB apply : 1994.00 ns (0.5%)
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 1694.00 ns (67.9%)
Info: free boundaries skipping geometry update [PositionUpdated][rank=0]
Info: smoothing length iteration converged [Smoothinglength][rank=0]
eps min = 2.8407185226364647e-14, max = 9.99983084205644e-07
iterations = 3
Info: conservation infos : [sph::Model][rank=0]
sum v = (9.882800657757216e-06,-3.310487790646313e-05,1.1567976082859543e-09)
sum a = (-1.1011428314305904e-19,-1.0299920638612292e-18,3.2017845406212553e-19)
sum e = 0.05004127679554002
sum de = 2.9422695190993687e-05
Info: cfl dt = 0.003997801820065854 cfl multiplier : 0.9613717421124829 [sph::Model][rank=0]
Info: processing rate infos : [sph::Model][rank=0]
---------------------------------------------------------------------------------------
| rank | rate (N.s^-1) | Nobj | t compute (s) | interf | alloc | mem (max) |
---------------------------------------------------------------------------------------
| 0 | 1.6117e+05 | 1000000 | 6.205e+00 | 0 % | 0 % | 950.66 MB |
---------------------------------------------------------------------------------------
Info: estimated rate : 0.5802105982446669 (tsim/hr) [sph::Model][rank=0]
Info: iteration since start : 9 [SPH][rank=0]
Info: time since start : 102.35794839 (s) [SPH][rank=0]
Info: Dumping state to _to_trash/dump_0007.sham [SPH][rank=0]
Info: dump to _to_trash/dump_0007.sham [Shamrock Dump][rank=0]
- took 122.85 ms, bandwidth = 931.62 MB/s
---------------- t = 0.007, dt = 0.001 ----------------
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 7.48 us (1.4%)
patch tree reduce : 1492.00 ns (0.3%)
gen split merge : 812.00 ns (0.2%)
split / merge op : 0/0
apply split merge : 1223.00 ns (0.2%)
LB compute : 503.31 us (96.1%)
LB move op cnt : 0
LB apply : 2.52 us (0.5%)
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 1913.00 ns (66.7%)
Info: free boundaries skipping geometry update [PositionUpdated][rank=0]
Info: smoothing length iteration converged [Smoothinglength][rank=0]
eps min = 6.671860683196617e-13, max = 9.99998293967359e-07
iterations = 3
Info: conservation infos : [sph::Model][rank=0]
sum v = (9.882607553815906e-06,-3.31049621960066e-05,1.1567739127542622e-09)
sum a = (8.436448154652831e-19,-3.2526065174565133e-19,5.61159327555974e-19)
sum e = 0.050041301612790835
sum de = 3.3626020256162476e-05
Info: cfl dt = 0.004072662849661999 cfl multiplier : 0.9742478280749886 [sph::Model][rank=0]
Info: processing rate infos : [sph::Model][rank=0]
---------------------------------------------------------------------------------------
| rank | rate (N.s^-1) | Nobj | t compute (s) | interf | alloc | mem (max) |
---------------------------------------------------------------------------------------
| 0 | 1.6039e+05 | 1000000 | 6.235e+00 | 0 % | 0 % | 950.66 MB |
---------------------------------------------------------------------------------------
Info: estimated rate : 0.5774172388316674 (tsim/hr) [sph::Model][rank=0]
Info: iteration since start : 10 [SPH][rank=0]
Info: time since start : 108.729121301 (s) [SPH][rank=0]
Info: Dumping state to _to_trash/dump_0008.sham [SPH][rank=0]
Info: dump to _to_trash/dump_0008.sham [Shamrock Dump][rank=0]
- took 120.01 ms, bandwidth = 953.64 MB/s
---------------- t = 0.008, dt = 0.0010000000000000009 ----------------
Info: summary : [LoadBalance][rank=0]
Info: - strategy "psweep" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: - strategy "round robin" : max = 1000000 min = 1000000 [LoadBalance][rank=0]
Info: Loadbalance stats : [LoadBalance][rank=0]
npatch = 1
min = 1000000
max = 1000000
avg = 1000000
efficiency = 100.00%
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 6.73 us (1.5%)
patch tree reduce : 1001.00 ns (0.2%)
gen split merge : 781.00 ns (0.2%)
split / merge op : 0/0
apply split merge : 1122.00 ns (0.2%)
LB compute : 437.29 us (96.1%)
LB move op cnt : 0
LB apply : 1944.00 ns (0.4%)
Info: Scheduler step timings : [Scheduler][rank=0]
metadata sync : 1783.00 ns (66.9%)
Info: free boundaries skipping geometry update [PositionUpdated][rank=0]
Info: smoothing length iteration converged [Smoothinglength][rank=0]
eps min = 6.472671188767377e-13, max = 9.99993968642381e-07
iterations = 3
Info: conservation infos : [sph::Model][rank=0]
sum v = (9.88241519651721e-06,-3.3105047270816766e-05,1.156746546048336e-09)
sum a = (5.077115485842276e-18,9.351243737687476e-19,5.27278009665802e-19)
sum e = 0.050041329818688036
sum de = 3.7829142459172544e-05
Info: cfl dt = 0.0038805384262170063 cfl multiplier : 0.9828318853833258 [sph::Model][rank=0]
Info: processing rate infos : [sph::Model][rank=0]
---------------------------------------------------------------------------------------
| rank | rate (N.s^-1) | Nobj | t compute (s) | interf | alloc | mem (max) |
---------------------------------------------------------------------------------------
| 0 | 1.6321e+05 | 1000000 | 6.127e+00 | 0 % | 0 % | 950.66 MB |
---------------------------------------------------------------------------------------
Info: estimated rate : 0.5875703466128875 (tsim/hr) [sph::Model][rank=0]
Info: iteration since start : 11 [SPH][rank=0]
Info: time since start : 114.99121193500001 (s) [SPH][rank=0]
Info: Dumping state to _to_trash/dump_0009.sham [SPH][rank=0]
Info: dump to _to_trash/dump_0009.sham [Shamrock Dump][rank=0]
- took 121.91 ms, bandwidth = 938.74 MB/s
Plot column integrated density
239 import matplotlib.pyplot as plt
240
241 pixel_x = 1200
242 pixel_y = 1080
243 radius = 5
244 center = (0.0, 0.0, 0.0)
245
246 aspect = pixel_x / pixel_y
247 pic_range = [-radius * aspect, radius * aspect, -radius, radius]
248 delta_x = (radius * 2 * aspect, 0.0, 0.0)
249 delta_y = (0.0, radius * 2, 0.0)
250
251 arr_rho = model.render_cartesian_column_integ(
252 "rho", "f64", center=(0.0, 0.0, 0.0), delta_x=delta_x, delta_y=delta_y, nx=pixel_x, ny=pixel_y
253 )
254
255 import copy
256
257 import matplotlib
258
259 my_cmap = copy.copy(matplotlib.colormaps.get_cmap("gist_heat")) # copy the default cmap
260 my_cmap.set_bad(color="black")
261
262 fig_width = 6
263 fig_height = fig_width / aspect
264 plt.figure(figsize=(fig_width, fig_height))
265 res = plt.imshow(arr_rho, cmap=my_cmap, origin="lower", extent=pic_range, norm="log", vmin=1e-9)
266
267 cbar = plt.colorbar(res, extend="both")
268 cbar.set_label(r"$\int \rho \, \mathrm{d} z$ [code unit]")
269 # or r"$\rho$ [code unit]" for slices
270
271 plt.title("t = {:0.3f} [code unit]".format(model.get_time()))
272 plt.xlabel("x")
273 plt.ylabel("z")
274 plt.show()
![t = 0.009 [code unit]](../_images/sphx_glr_run_sph_basic_disc_001.png)
Info: compute_column_integ field_name: rho, center: (0,0,0), delta_x: (11.11111111111111,0,0), delta_y: (0,10,0), nx: 1200, ny: 1080 [sph::CartesianRender][rank=0]
Info: compute_column_integ took 11.47 s [sph::CartesianRender][rank=0]
Total running time of the script: (1 minutes 49.608 seconds)
Estimated memory usage: 1099 MB