Uniform box in SPH#

This simple example shows a uniform density box in SPH, it is also used to test that the smoothing length iteration find the correct value

10 import shamrock
11
12 # If we use the shamrock executable to run this script instead of the python interpreter,
13 # we should not initialize the system as the shamrock executable needs to handle specific MPI logic
14 if not shamrock.sys.is_initialized():
15     shamrock.change_loglevel(1)
16     shamrock.sys.init("0:0")

Setup parameters

22 gamma = 5.0 / 3.0
23 rho_g = 1
24
25 bmin = (-0.6, -0.6, -0.6)
26 bmax = (0.6, 0.6, 0.6)
27
28 N_target = 1e4
29 scheduler_split_val = int(2e7)
30 scheduler_merge_val = int(1)

Deduced quantities

34 import numpy as np
35
36 xm, ym, zm = bmin
37 xM, yM, zM = bmax
38 vol_b = (xM - xm) * (yM - ym) * (zM - zm)
39
40 part_vol = vol_b / N_target
41
42 # lattice volume
43 HCP_PACKING_DENSITY = 0.74
44 part_vol_lattice = HCP_PACKING_DENSITY * part_vol
45
46 dr = (part_vol_lattice / ((4.0 / 3.0) * np.pi)) ** (1.0 / 3.0)
47
48 pmass = -1

Setup

 53 ctx = shamrock.Context()
 54 ctx.pdata_layout_new()
 55
 56 model = shamrock.get_Model_SPH(context=ctx, vector_type="f64_3", sph_kernel="M4")
 57
 58 cfg = model.gen_default_config()
 59 cfg.set_artif_viscosity_VaryingCD10(
 60     alpha_min=0.0, alpha_max=1, sigma_decay=0.1, alpha_u=1, beta_AV=2
 61 )
 62 cfg.set_boundary_periodic()
 63 cfg.set_eos_adiabatic(gamma)
 64 cfg.print_status()
 65 model.set_solver_config(cfg)
 66 model.init_scheduler(scheduler_split_val, scheduler_merge_val)
 67
 68
 69 bmin, bmax = model.get_ideal_hcp_box(dr, bmin, bmax)
 70 xm, ym, zm = bmin
 71 xM, yM, zM = bmax
 72
 73 model.resize_simulation_box(bmin, bmax)
 74
 75 setup = model.get_setup()
 76 gen = setup.make_generator_lattice_hcp(dr, bmin, bmax)
 77 setup.apply_setup(gen, insert_step=scheduler_split_val)
 78
 79
 80 xc, yc, zc = model.get_closest_part_to((0, 0, 0))
 81
 82 if shamrock.sys.world_rank() == 0:
 83     print("closest part to (0,0,0) is in :", xc, yc, zc)
 84
 85
 86 vol_b = (xM - xm) * (yM - ym) * (zM - zm)
 87
 88 totmass = rho_g * vol_b
 89
 90 pmass = model.total_mass_to_part_mass(totmass)
 91
 92 model.set_value_in_a_box("uint", "f64", 0, bmin, bmax)
 93
 94 tot_u = pmass * model.get_sum("uint", "f64")
 95 if shamrock.sys.world_rank() == 0:
 96     print("total u :", tot_u)
 97
 98 model.set_particle_mass(pmass)
 99
100 model.set_cfl_cour(0.1)
101 model.set_cfl_force(0.1)
----- SPH Solver configuration -----
[
    {
        "artif_viscosity": {
            "alpha_max": 1.0,
            "alpha_min": 0.0,
            "alpha_u": 1.0,
            "av_type": "varying_cd10",
            "beta_AV": 2.0,
            "sigma_decay": 0.1
        },
        "boundary_config": {
            "bc_type": "periodic"
        },
        "cfl_config": {
            "cfl_cour": 0.0,
            "cfl_force": 0.0,
            "cfl_multiplier_stiffness": 2.0,
            "eta_sink": 0.05
        },
        "combined_dtdiv_divcurlv_compute": false,
        "debug_dump_filename": "",
        "do_debug_dump": false,
        "enable_particle_reordering": false,
        "eos_config": {
            "Tvec": "f64_3",
            "eos_type": "adiabatic",
            "gamma": 1.6666666666666667
        },
        "epsilon_h": 1e-06,
        "ext_force_config": {
            "force_list": []
        },
        "gpart_mass": 0.0,
        "h_iter_per_subcycles": 50,
        "h_max_subcycles_count": 100,
        "htol_up_coarse_cycle": 1.1,
        "htol_up_fine_cycle": 1.1,
        "kernel_id": "M4<f64>",
        "mhd_config": {
            "mhd_type": "none"
        },
        "particle_killing": [],
        "particle_reordering_step_freq": 1000,
        "self_grav_config": {
            "softening_length": 1e-09,
            "softening_mode": "plummer",
            "type": "none"
        },
        "show_neigh_stats": false,
        "smoothing_length_config": {
            "type": "density_based"
        },
        "time_state": {
            "cfl_multiplier": 0.01,
            "dt_sph": 0.0,
            "time": 0.0
        },
        "tree_reduction_level": 3,
        "type_id": "sycl::vec<f64,3>",
        "unit_sys": null,
        "use_two_stage_search": true
    }
]
------------------------------------
Info: pushing data in scheduler, N = 11520                            [DataInserterUtility][rank=0]
Info: reattributing data ...                                          [DataInserterUtility][rank=0]
Info: reattributing data done in  9.44 ms                             [DataInserterUtility][rank=0]
Info: ---------------------------------------------                   [DataInserterUtility][rank=0]
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 12.71 us   (77.2%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 2.05 us    (0.3%)
   patch tree reduce : 611.00 ns  (0.1%)
   gen split merge   : 671.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 1042.00 ns (0.1%)
   LB compute        : 735.03 us  (98.4%)
   LB move op cnt    : 0
   LB apply          : 3.52 us    (0.5%)
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 3.00 us    (66.9%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 1914.00 ns (0.3%)
   patch tree reduce : 350.00 ns  (0.1%)
   gen split merge   : 371.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 260.00 ns  (0.0%)
   LB compute        : 567.00 us  (98.5%)
   LB move op cnt    : 0
   LB apply          : 2.31 us    (0.4%)
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 3.13 us    (67.2%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 1934.00 ns (0.3%)
   patch tree reduce : 340.00 ns  (0.1%)
   gen split merge   : 391.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 291.00 ns  (0.0%)
   LB compute        : 590.24 us  (98.6%)
   LB move op cnt    : 0
   LB apply          : 2.32 us    (0.4%)
Info: ---------------------------------------------                   [DataInserterUtility][rank=0]
Info: Final load balancing step 0 of 3                                          [SPH setup][rank=0]
Info: ---------------------------------------------                   [DataInserterUtility][rank=0]
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 2.88 us    (61.2%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 1382.00 ns (0.2%)
   patch tree reduce : 360.00 ns  (0.1%)
   gen split merge   : 390.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 361.00 ns  (0.1%)
   LB compute        : 623.52 us  (98.7%)
   LB move op cnt    : 0
   LB apply          : 2.31 us    (0.4%)
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 2.75 us    (65.5%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 1493.00 ns (0.3%)
   patch tree reduce : 381.00 ns  (0.1%)
   gen split merge   : 380.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 261.00 ns  (0.0%)
   LB compute        : 525.54 us  (98.5%)
   LB move op cnt    : 0
   LB apply          : 2.30 us    (0.4%)
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 2.80 us    (66.0%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 2.12 us    (0.4%)
   patch tree reduce : 371.00 ns  (0.1%)
   gen split merge   : 391.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 271.00 ns  (0.1%)
   LB compute        : 476.56 us  (98.3%)
   LB move op cnt    : 0
   LB apply          : 2.09 us    (0.4%)
Info: ---------------------------------------------                   [DataInserterUtility][rank=0]
Info: Final load balancing step 1 of 3                                          [SPH setup][rank=0]
Info: ---------------------------------------------                   [DataInserterUtility][rank=0]
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 7.19 us    (82.4%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 1532.00 ns (0.4%)
   patch tree reduce : 371.00 ns  (0.1%)
   gen split merge   : 391.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 240.00 ns  (0.1%)
   LB compute        : 384.44 us  (98.0%)
   LB move op cnt    : 0
   LB apply          : 2.24 us    (0.6%)
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 2.79 us    (68.9%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 1313.00 ns (0.3%)
   patch tree reduce : 401.00 ns  (0.1%)
   gen split merge   : 391.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 230.00 ns  (0.0%)
   LB compute        : 477.08 us  (98.4%)
   LB move op cnt    : 0
   LB apply          : 2.31 us    (0.5%)
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 2.65 us    (71.2%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 1923.00 ns (0.4%)
   patch tree reduce : 401.00 ns  (0.1%)
   gen split merge   : 400.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 250.00 ns  (0.0%)
   LB compute        : 498.42 us  (98.2%)
   LB move op cnt    : 0
   LB apply          : 2.49 us    (0.5%)
Info: ---------------------------------------------                   [DataInserterUtility][rank=0]
Info: Final load balancing step 2 of 3                                          [SPH setup][rank=0]
Info: ---------------------------------------------                   [DataInserterUtility][rank=0]
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 2.73 us    (68.3%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 1483.00 ns (0.5%)
   patch tree reduce : 371.00 ns  (0.1%)
   gen split merge   : 381.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 251.00 ns  (0.1%)
   LB compute        : 314.25 us  (97.6%)
   LB move op cnt    : 0
   LB apply          : 2.16 us    (0.7%)
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 2.67 us    (71.0%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 1322.00 ns (0.3%)
   patch tree reduce : 340.00 ns  (0.1%)
   gen split merge   : 380.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 251.00 ns  (0.0%)
   LB compute        : 505.27 us  (98.5%)
   LB move op cnt    : 0
   LB apply          : 2.34 us    (0.5%)
Info: Compute load ...                                                [DataInserterUtility][rank=0]
Info: run scheduler step ...                                          [DataInserterUtility][rank=0]
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 2.68 us    (66.6%)
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 1873.00 ns (0.4%)
   patch tree reduce : 391.00 ns  (0.1%)
   gen split merge   : 381.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 291.00 ns  (0.1%)
   LB compute        : 510.93 us  (98.4%)
   LB move op cnt    : 0
   LB apply          : 2.25 us    (0.4%)
Info: ---------------------------------------------                   [DataInserterUtility][rank=0]
Info: the setup took : 0.025641537000000002 s                                   [SPH setup][rank=0]
closest part to (0,0,0) is in : 0.0 0.0 0.0
total u : 0.0

Single timestep to iterate the smoothing length

---------------- t = 0, dt = 0 ----------------
Info: summary :                                                               [LoadBalance][rank=0]
Info:  - strategy "psweep" : max = 11520 min = 11520                          [LoadBalance][rank=0]
Info:  - strategy "round robin" : max = 11520 min = 11520                     [LoadBalance][rank=0]
Info: Loadbalance stats :                                                     [LoadBalance][rank=0]
    npatch = 1
    min = 11520
    max = 11520
    avg = 11520
    efficiency = 100.00%
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 23.86 us   (2.5%)
   patch tree reduce : 2.13 us    (0.2%)
   gen split merge   : 481.00 ns  (0.1%)
   split / merge op  : 0/0
   apply split merge : 952.00 ns  (0.1%)
   LB compute        : 875.98 us  (93.2%)
   LB move op cnt    : 0
   LB apply          : 5.27 us    (0.6%)
Info: Scheduler step timings :                                                  [Scheduler][rank=0]
   metadata sync     : 5.59 us    (75.3%)
Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
    This can lead to high mpi overhead, try to increase the patch split crit
    patch 0 high interf/patch volume: 0.39592013888888883
Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
     largest h = 0.03437860905706778 unconverged cnt = 11520
Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
    This can lead to high mpi overhead, try to increase the patch split crit
    patch 0 high interf/patch volume: 0.4238715277777777
Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
     largest h = 0.03781646996277456 unconverged cnt = 11520
Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
    This can lead to high mpi overhead, try to increase the patch split crit
    patch 0 high interf/patch volume: 0.4238715277777777
Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
     largest h = 0.041598116959052016 unconverged cnt = 11520
Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
    This can lead to high mpi overhead, try to increase the patch split crit
    patch 0 high interf/patch volume: 0.4506076388888888
Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
     largest h = 0.045757928654957224 unconverged cnt = 11520
Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
    This can lead to high mpi overhead, try to increase the patch split crit
    patch 0 high interf/patch volume: 0.5162326388888888
Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
     largest h = 0.05033372152045295 unconverged cnt = 11520
Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
    This can lead to high mpi overhead, try to increase the patch split crit
    patch 0 high interf/patch volume: 0.6863715277777777
Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
     largest h = 0.05536709367249825 unconverged cnt = 11520
Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
    This can lead to high mpi overhead, try to increase the patch split crit
    patch 0 high interf/patch volume: 0.6863715277777777
Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
     largest h = 0.06090380303974808 unconverged cnt = 11520
Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
    This can lead to high mpi overhead, try to increase the patch split crit
    patch 0 high interf/patch volume: 0.7886284722222223
Warning: the unit system is not set                                           [sph::Config][rank=0]
Warning: the unit system is not set                                           [sph::Config][rank=0]
Info: conservation infos :                                                     [sph::Model][rank=0]
    sum v = (0,0,0)
    sum a = (0,0,0)
    sum e = 0
    sum de = 0
Info: CFL hydro = 1.7976931348623157e+308 sink sink = inf                             [SPH][rank=0]
Info: cfl dt = 1.7976931348623157e+308 cfl multiplier : 0.01                   [sph::Model][rank=0]
Info: Timestep perf report:                                                    [sph::Model][rank=0]
+======+============+=======+========+===========+======+=============+=============+=============+
| rank | rate (N/s) | Nobj  | Npatch |   tstep   | MPI  | alloc d% h% | mem (max) d | mem (max) h |
+======+============+=======+========+===========+======+=============+=============+=============+
| 0    | 3.8586e+04 | 11520 |      1 | 2.986e-01 | 0.0% |   1.3% 0.0% |   935.14 MB |   450.00 kB |
+------+------------+-------+--------+-----------+------+-------------+-------------+-------------+
Info: estimated rate : 0 (tsim/hr)                                             [sph::Model][rank=0]

<shamrock.model_sph.TimestepLog object at 0x7f4656381b70>

Recover data

Info: collected : 1 patches                                                [PatchScheduler][rank=0]
adding ->  xyz
adding ->  vxyz
adding ->  axyz
adding ->  axyz_ext
adding ->  hpart
adding ->  uint
adding ->  duint
adding ->  alpha_AV
adding ->  divv
adding ->  dtdivv
adding ->  curlv
adding ->  soundspeed

Test h value

113 import numpy as np
114
115 min_hpart = np.min(dat["hpart"])
116 max_hpart = np.max(dat["hpart"])
117 mean_hpart = np.mean(dat["hpart"])
118
119 print(f"hpart min={min_hpart} max={max_hpart} delta={max_hpart-min_hpart}")
120
121 assert np.abs(max_hpart - min_hpart) < 1e-15, "hpart delta is too large"
122
123 expected_h = (0.06688949833400996 + 0.06688949833401027) / 2
124
125 assert np.abs(min_hpart - expected_h) < 1e-15, "hpart is off the expected value"
hpart min=0.06688949833400996 max=0.06688949833401027 delta=3.0531133177191805e-16

Plot particle distrib

129 import matplotlib
130 import matplotlib.pyplot as plt
131 from mpl_toolkits.mplot3d import Axes3D
132
133 fig = plt.figure(dpi=120)
134 ax = fig.add_subplot(111, projection="3d")
135 ax.set_xlim3d(bmin[0], bmax[0])
136 ax.set_ylim3d(bmin[1], bmax[1])
137 ax.set_zlim3d(bmin[2], bmax[2])
138
139 cm = matplotlib.colormaps["viridis"]
140 sc = ax.scatter(
141     dat["xyz"][:, 0],
142     dat["xyz"][:, 1],
143     dat["xyz"][:, 2],
144     s=1,
145     vmin=mean_hpart - 1e-10,
146     vmax=mean_hpart + 1e-10,
147     c=dat["hpart"],
148     cmap=cm,
149 )
150 plt.colorbar(sc)
151 plt.show()
run uniform box

Total running time of the script: (0 minutes 3.921 seconds)

Estimated memory usage: 113 MB

Gallery generated by Sphinx-Gallery