
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "_as_gen/tests_ci/run_sph_eos_barotropic.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download__as_gen_tests_ci_run_sph_eos_barotropic.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr__as_gen_tests_ci_run_sph_eos_barotropic.py:


CI test: SPH barotropic equation of state
==========================================

The barotropic equation of state

.. math::
    P = c_{s,0}^2 \rho \left[1 + \left(\frac{\rho}{\rho_0}\right)^{\gamma - 1}\right]

is isothermal well below :math:`\rho_0` and a polytrope
:math:`P = K \rho^\gamma` with :math:`K = c_{s,0}^2 \rho_0^{1-\gamma}` well above it.

This test evolves the same small periodic setup (a velocity perturbation in a
uniform box) with

* ``set_eos_barotropic`` with :math:`\rho_0 \gg \rho`, compared to
  ``set_eos_isothermal(cs0)``,
* ``set_eos_barotropic`` with :math:`\rho_0 \ll \rho`, compared to
  ``set_eos_polytropic(K, gamma)``,

and checks that both pairs of runs agree. It also checks that invalid
barotropic parameters are rejected.

.. GENERATED FROM PYTHON SOURCE LINES 24-94

.. code-block:: Python
   :lineno-start: 25


    import numpy as np

    import shamrock

    if not shamrock.sys.is_initialized():
        shamrock.change_loglevel(1)
        shamrock.sys.init("0:0")

    pmass = 1e-3
    dr = 0.05
    bmin = (-0.6, -0.6, -0.6)
    bmax = (0.6, 0.6, 0.6)
    t_end = 0.05

    # HCP neighbours are 2 dr apart, the number density is sqrt(2) / (2 dr)^3
    rho_mean = pmass * np.sqrt(2) / (2 * dr) ** 3


    def run(set_eos):
        ctx = shamrock.Context()
        ctx.pdata_layout_new()

        model = shamrock.get_Model_SPH(context=ctx, vector_type="f64_3", sph_kernel="M4")

        cfg = model.gen_default_config()
        cfg.set_self_gravity_none()
        cfg.set_artif_viscosity_Constant(alpha_u=1.0, alpha_AV=1.0, beta_AV=2.0)
        set_eos(cfg)
        cfg.set_particle_mass(pmass)
        cfg.set_boundary_periodic()
        model.set_solver_config(cfg)

        model.set_cfl_cour(0.1)
        model.set_cfl_force(0.1)

        model.init_scheduler(1000, 1)
        model.resize_simulation_box(bmin, bmax)

        setup = model.get_setup()
        setup.apply_setup(setup.make_generator_lattice_hcp(dr, bmin, bmax))

        L = bmax[0] - bmin[0]

        def vel_func(r):
            x, y, z = r
            return (0.05 * np.sin(2 * np.pi * x / L), 0.0, 0.0)

        model.set_field_value_lambda_f64_3("vxyz", vel_func)
        model.set_value_in_a_box("uint", "f64", 1.0, bmin, bmax)

        model.timestep()
        model.evolve_until(t_end)

        vxyz = np.asarray(ctx.collect_data()["vxyz"])
        # sorted speeds do not depend on the particle ordering
        return np.sort(np.linalg.norm(vxyz, axis=1))


    def compare(name, ref, got, rtol):
        if ref.shape != got.shape:
            raise AssertionError(f"{name}: shape mismatch {ref.shape} vs {got.shape}")
        err = np.max(np.abs(got - ref)) / np.max(np.abs(ref))
        print(f"{name}: max relative speed difference = {err:.3e} (tolerance {rtol:.1e})")
        if not err < rtol:
            raise AssertionError(f"{name}: barotropic run differs from the reference: {err:.3e}")


    gamma = 5.0 / 3.0








.. GENERATED FROM PYTHON SOURCE LINES 95-96

Isothermal limit: rho0 >> rho

.. GENERATED FROM PYTHON SOURCE LINES 96-102

.. code-block:: Python
   :lineno-start: 97


    cs0 = 1.0
    v_iso = run(lambda cfg: cfg.set_eos_isothermal(cs0))
    v_baro_iso = run(lambda cfg: cfg.set_eos_barotropic(cs0=cs0, rho0=1e30, gamma0=gamma))
    compare("isothermal limit", v_iso, v_baro_iso, 1e-10)





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    SPH setup: generating particles ...  
    SPH setup: Nstep = 0 ( 0.0e+00 ) Ntotal = 0 ( 0.0e+00 rank min = 0.0e+00 max = 0.0e+00) rate = 0.000000e+00 N.s^-1  
    SPH setup: Nstep = 70 ( 7.0e+01 ) Ntotal = 70 ( 7.0e+01 rank min = 8.8e+04 max = 7.0e+01) rate = 7.000000e+01 N.s^-1  
    SPH setup: Nstep = 106 ( 1.1e+02 ) Ntotal = 176 ( 1.8e+02 rank min = 1.3e+05 max = 1.8e+02) rate = 1.760000e+02 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 294 ( 2.9e+02 rank min = 1.6e+05 max = 2.9e+02) rate = 2.940000e+02 N.s^-1  
    SPH setup: Nstep = 109 ( 1.1e+02 ) Ntotal = 403 ( 4.0e+02 rank min = 4.8e+05 max = 4.0e+02) rate = 4.030000e+02 N.s^-1  
    SPH setup: Nstep = 110 ( 1.1e+02 ) Ntotal = 513 ( 5.1e+02 rank min = 1.5e+05 max = 5.1e+02) rate = 5.130000e+02 N.s^-1  
    SPH setup: Nstep = 106 ( 1.1e+02 ) Ntotal = 619 ( 6.2e+02 rank min = 8.2e+05 max = 6.2e+02) rate = 6.190000e+02 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 737 ( 7.4e+02 rank min = 8.9e+05 max = 7.4e+02) rate = 7.370000e+02 N.s^-1  
    SPH setup: Nstep = 110 ( 1.1e+02 ) Ntotal = 847 ( 8.5e+02 rank min = 1.4e+05 max = 8.5e+02) rate = 8.470000e+02 N.s^-1  
    SPH setup: Nstep = 109 ( 1.1e+02 ) Ntotal = 956 ( 9.6e+02 rank min = 6.0e+05 max = 9.6e+02) rate = 9.560000e+02 N.s^-1  
    SPH setup: Nstep = 115 ( 1.2e+02 ) Ntotal = 1071 ( 1.1e+03 rank min = 6.0e+05 max = 1.1e+03) rate = 1.071000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1192 ( 1.2e+03 rank min = 5.4e+05 max = 1.2e+03) rate = 1.192000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 1310 ( 1.3e+03 rank min = 1.3e+05 max = 1.3e+03) rate = 1.310000e+03 N.s^-1  
    SPH setup: Nstep = 119 ( 1.2e+02 ) Ntotal = 1429 ( 1.4e+03 rank min = 6.4e+05 max = 1.4e+03) rate = 1.429000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1550 ( 1.6e+03 rank min = 8.5e+05 max = 1.6e+03) rate = 1.550000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1671 ( 1.7e+03 rank min = 8.8e+05 max = 1.7e+03) rate = 1.671000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 1789 ( 1.8e+03 rank min = 6.9e+05 max = 1.8e+03) rate = 1.789000e+03 N.s^-1  
    SPH setup: Nstep = 119 ( 1.2e+02 ) Ntotal = 1908 ( 1.9e+03 rank min = 8.9e+05 max = 1.9e+03) rate = 1.908000e+03 N.s^-1  
    SPH setup: Nstep = 122 ( 1.2e+02 ) Ntotal = 2030 ( 2.0e+03 rank min = 1.2e+05 max = 2.0e+03) rate = 2.030000e+03 N.s^-1  
    SPH setup: Nstep = 120 ( 1.2e+02 ) Ntotal = 2150 ( 2.2e+03 rank min = 8.3e+05 max = 2.2e+03) rate = 2.150000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 2268 ( 2.3e+03 rank min = 9.2e+05 max = 2.3e+03) rate = 2.268000e+03 N.s^-1  
    SPH setup: Nstep = 63 ( 6.3e+01 ) Ntotal = 2331 ( 2.3e+03 rank min = 4.1e+05 max = 2.3e+03) rate = 2.331000e+03 N.s^-1  
    SPH setup: the generation step took : 0.013693024000000002 s  
    SPH setup: final particle count = 2331 beginning injection ...  
    SPH setup: injected         2000 / 2331 =>  85.8% | ranks with patchs = 1 / 1  -> local loop <-  
    SPH setup: injected         2331 / 2331 => 100.0% | ranks with patchs = 1 / 1  <- global loop -> (msg count : 0)  
    SPH setup: the injection step took : 0.032361091 s  
    SPH setup: the setup took : 0.050662324 s  
    ---------------- t = 0, dt = 0 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.09799885899543734 unconverged cnt = 2331   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.10779874489498108 unconverged cnt = 682   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.1185786193844792 unconverged cnt = 36   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0, dt = 9.255285691623669e-05 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 9.255285691623669e-05, dt = 0.0031468192696409913 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.012560635289608792  
    ---------------- t = 0.003239372126557228, dt = 0.002501613489598968 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.005740985616156196, dt = 0.004463790444989298 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.02048626534789981  
    ---------------- t = 0.010204776061145494, dt = 0.0027054239987146797 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.012910200059860173, dt = 0.004251869945085898 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.018840222366621324  
    ---------------- t = 0.01716207000494607, dt = 0.0025114741784108938 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.019673544183356963, dt = 0.003899499114001739 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.014963872969620408  
    ---------------- t = 0.023573043297358702, dt = 0.0023227000126066935 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.025895743309965396, dt = 0.003618392931977634 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.011838616798169554  
    ---------------- t = 0.02951413624194303, dt = 0.0021766395165257243 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.03169077575846876, dt = 0.0034079009815905013 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.03509867674005926, dt = 0.004128805367701994 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.012886214194963963  
    ---------------- t = 0.03922748210776125, dt = 0.002255085418876398 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.04148256752663765, dt = 0.0032938402491943797 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.04477640777583203, dt = 0.003910076306337886 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.04868648408216991, dt = 0.001313515917830091 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    SPH setup: generating particles ...  
    SPH setup: Nstep = 0 ( 0.0e+00 ) Ntotal = 0 ( 0.0e+00 rank min = 0.0e+00 max = 0.0e+00) rate = 0.000000e+00 N.s^-1  
    SPH setup: Nstep = 70 ( 7.0e+01 ) Ntotal = 70 ( 7.0e+01 rank min = 4.2e+05 max = 7.0e+01) rate = 7.000000e+01 N.s^-1  
    SPH setup: Nstep = 106 ( 1.1e+02 ) Ntotal = 176 ( 1.8e+02 rank min = 2.7e+05 max = 1.8e+02) rate = 1.760000e+02 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 294 ( 2.9e+02 rank min = 2.9e+05 max = 2.9e+02) rate = 2.940000e+02 N.s^-1  
    SPH setup: Nstep = 109 ( 1.1e+02 ) Ntotal = 403 ( 4.0e+02 rank min = 9.5e+05 max = 4.0e+02) rate = 4.030000e+02 N.s^-1  
    SPH setup: Nstep = 110 ( 1.1e+02 ) Ntotal = 513 ( 5.1e+02 rank min = 2.8e+05 max = 5.1e+02) rate = 5.130000e+02 N.s^-1  
    SPH setup: Nstep = 106 ( 1.1e+02 ) Ntotal = 619 ( 6.2e+02 rank min = 9.7e+05 max = 6.2e+02) rate = 6.190000e+02 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 737 ( 7.4e+02 rank min = 1.0e+06 max = 7.4e+02) rate = 7.370000e+02 N.s^-1  
    SPH setup: Nstep = 110 ( 1.1e+02 ) Ntotal = 847 ( 8.5e+02 rank min = 2.5e+05 max = 8.5e+02) rate = 8.470000e+02 N.s^-1  
    SPH setup: Nstep = 109 ( 1.1e+02 ) Ntotal = 956 ( 9.6e+02 rank min = 9.5e+05 max = 9.6e+02) rate = 9.560000e+02 N.s^-1  
    SPH setup: Nstep = 115 ( 1.2e+02 ) Ntotal = 1071 ( 1.1e+03 rank min = 1.1e+06 max = 1.1e+03) rate = 1.071000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1192 ( 1.2e+03 rank min = 1.1e+06 max = 1.2e+03) rate = 1.192000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 1310 ( 1.3e+03 rank min = 2.8e+05 max = 1.3e+03) rate = 1.310000e+03 N.s^-1  
    SPH setup: Nstep = 119 ( 1.2e+02 ) Ntotal = 1429 ( 1.4e+03 rank min = 1.1e+06 max = 1.4e+03) rate = 1.429000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1550 ( 1.6e+03 rank min = 1.0e+06 max = 1.6e+03) rate = 1.550000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1671 ( 1.7e+03 rank min = 1.1e+06 max = 1.7e+03) rate = 1.671000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 1789 ( 1.8e+03 rank min = 1.1e+06 max = 1.8e+03) rate = 1.789000e+03 N.s^-1  
    SPH setup: Nstep = 119 ( 1.2e+02 ) Ntotal = 1908 ( 1.9e+03 rank min = 1.1e+06 max = 1.9e+03) rate = 1.908000e+03 N.s^-1  
    SPH setup: Nstep = 122 ( 1.2e+02 ) Ntotal = 2030 ( 2.0e+03 rank min = 2.9e+05 max = 2.0e+03) rate = 2.030000e+03 N.s^-1  
    SPH setup: Nstep = 120 ( 1.2e+02 ) Ntotal = 2150 ( 2.2e+03 rank min = 1.1e+06 max = 2.2e+03) rate = 2.150000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 2268 ( 2.3e+03 rank min = 1.1e+06 max = 2.3e+03) rate = 2.268000e+03 N.s^-1  
    SPH setup: Nstep = 63 ( 6.3e+01 ) Ntotal = 2331 ( 2.3e+03 rank min = 6.1e+05 max = 2.3e+03) rate = 2.331000e+03 N.s^-1  
    SPH setup: the generation step took : 0.008229973 s  
    SPH setup: final particle count = 2331 beginning injection ...  
    SPH setup: injected         2000 / 2331 =>  85.8% | ranks with patchs = 1 / 1  -> local loop <-  
    SPH setup: injected         2331 / 2331 => 100.0% | ranks with patchs = 1 / 1  <- global loop -> (msg count : 0)  
    SPH setup: the injection step took : 0.028814234 s  
    SPH setup: the setup took : 0.041017048 s  
    ---------------- t = 0, dt = 0 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.09799885899543734 unconverged cnt = 2331   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.10779874489498108 unconverged cnt = 682   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.1185786193844792 unconverged cnt = 36   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0, dt = 9.255285691623669e-05 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 9.255285691623669e-05, dt = 0.0031468192696409913 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.012560635289608792  
    ---------------- t = 0.003239372126557228, dt = 0.002501613489598968 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.005740985616156196, dt = 0.004463790444989298 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.02048626534789981  
    ---------------- t = 0.010204776061145494, dt = 0.0027054239987146797 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.012910200059860173, dt = 0.004251869945085898 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.018840222366621324  
    ---------------- t = 0.01716207000494607, dt = 0.0025114741784108938 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.019673544183356963, dt = 0.003899499114001739 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.014963872969620408  
    ---------------- t = 0.023573043297358702, dt = 0.0023227000126066935 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.025895743309965396, dt = 0.003618392931977634 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.011838616798169554  
    ---------------- t = 0.02951413624194303, dt = 0.0021766395165257243 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.03169077575846876, dt = 0.0034079009815905013 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.03509867674005926, dt = 0.004128805367701994 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.012886214194963963  
    ---------------- t = 0.03922748210776125, dt = 0.002255085418876398 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.04148256752663765, dt = 0.0032938402491943797 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.04477640777583203, dt = 0.003910076306337886 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.04868648408216991, dt = 0.001313515917830091 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    isothermal limit: max relative speed difference = 0.000e+00 (tolerance 1.0e-10)




.. GENERATED FROM PYTHON SOURCE LINES 103-106

Adiabatic limit: rho0 << rho, choosing cs0 such that K = 1 (the sound speed stays ~1)

The barotropic pressure differs from the polytrope by a relative (rho0 / rho)^(gamma - 1)

.. GENERATED FROM PYTHON SOURCE LINES 106-115

.. code-block:: Python
   :lineno-start: 107


    K = 1.0
    rho0 = 1e-12 * rho_mean
    cs0_poly = np.sqrt(K * rho0 ** (gamma - 1))

    v_poly = run(lambda cfg: cfg.set_eos_polytropic(K, gamma))
    v_baro_poly = run(lambda cfg: cfg.set_eos_barotropic(cs0=cs0_poly, rho0=rho0, gamma0=gamma))
    compare("adiabatic limit", v_poly, v_baro_poly, 1e-6)





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    SPH setup: generating particles ...  
    SPH setup: Nstep = 0 ( 0.0e+00 ) Ntotal = 0 ( 0.0e+00 rank min = 0.0e+00 max = 0.0e+00) rate = 0.000000e+00 N.s^-1  
    SPH setup: Nstep = 70 ( 7.0e+01 ) Ntotal = 70 ( 7.0e+01 rank min = 7.1e+04 max = 7.0e+01) rate = 7.000000e+01 N.s^-1  
    SPH setup: Nstep = 106 ( 1.1e+02 ) Ntotal = 176 ( 1.8e+02 rank min = 1.3e+05 max = 1.8e+02) rate = 1.760000e+02 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 294 ( 2.9e+02 rank min = 1.5e+05 max = 2.9e+02) rate = 2.940000e+02 N.s^-1  
    SPH setup: Nstep = 109 ( 1.1e+02 ) Ntotal = 403 ( 4.0e+02 rank min = 4.1e+05 max = 4.0e+02) rate = 4.030000e+02 N.s^-1  
    SPH setup: Nstep = 110 ( 1.1e+02 ) Ntotal = 513 ( 5.1e+02 rank min = 1.3e+05 max = 5.1e+02) rate = 5.130000e+02 N.s^-1  
    SPH setup: Nstep = 106 ( 1.1e+02 ) Ntotal = 619 ( 6.2e+02 rank min = 5.6e+05 max = 6.2e+02) rate = 6.190000e+02 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 737 ( 7.4e+02 rank min = 6.8e+05 max = 7.4e+02) rate = 7.370000e+02 N.s^-1  
    SPH setup: Nstep = 110 ( 1.1e+02 ) Ntotal = 847 ( 8.5e+02 rank min = 1.3e+05 max = 8.5e+02) rate = 8.470000e+02 N.s^-1  
    SPH setup: Nstep = 109 ( 1.1e+02 ) Ntotal = 956 ( 9.6e+02 rank min = 7.4e+05 max = 9.6e+02) rate = 9.560000e+02 N.s^-1  
    SPH setup: Nstep = 115 ( 1.2e+02 ) Ntotal = 1071 ( 1.1e+03 rank min = 4.9e+05 max = 1.1e+03) rate = 1.071000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1192 ( 1.2e+03 rank min = 4.6e+05 max = 1.2e+03) rate = 1.192000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 1310 ( 1.3e+03 rank min = 1.3e+05 max = 1.3e+03) rate = 1.310000e+03 N.s^-1  
    SPH setup: Nstep = 119 ( 1.2e+02 ) Ntotal = 1429 ( 1.4e+03 rank min = 7.4e+05 max = 1.4e+03) rate = 1.429000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1550 ( 1.6e+03 rank min = 6.8e+05 max = 1.6e+03) rate = 1.550000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1671 ( 1.7e+03 rank min = 7.6e+05 max = 1.7e+03) rate = 1.671000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 1789 ( 1.8e+03 rank min = 6.3e+05 max = 1.8e+03) rate = 1.789000e+03 N.s^-1  
    SPH setup: Nstep = 119 ( 1.2e+02 ) Ntotal = 1908 ( 1.9e+03 rank min = 7.2e+05 max = 1.9e+03) rate = 1.908000e+03 N.s^-1  
    SPH setup: Nstep = 122 ( 1.2e+02 ) Ntotal = 2030 ( 2.0e+03 rank min = 1.1e+05 max = 2.0e+03) rate = 2.030000e+03 N.s^-1  
    SPH setup: Nstep = 120 ( 1.2e+02 ) Ntotal = 2150 ( 2.2e+03 rank min = 7.4e+05 max = 2.2e+03) rate = 2.150000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 2268 ( 2.3e+03 rank min = 8.6e+05 max = 2.3e+03) rate = 2.268000e+03 N.s^-1  
    SPH setup: Nstep = 63 ( 6.3e+01 ) Ntotal = 2331 ( 2.3e+03 rank min = 3.7e+05 max = 2.3e+03) rate = 2.331000e+03 N.s^-1  
    SPH setup: the generation step took : 0.013420126000000001 s  
    SPH setup: final particle count = 2331 beginning injection ...  
    SPH setup: injected         2000 / 2331 =>  85.8% | ranks with patchs = 1 / 1  -> local loop <-  
    SPH setup: injected         2331 / 2331 => 100.0% | ranks with patchs = 1 / 1  <- global loop -> (msg count : 0)  
    SPH setup: the injection step took : 0.03501319 s  
    SPH setup: the setup took : 0.053025123 s  
    ---------------- t = 0, dt = 0 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.09799885899543734 unconverged cnt = 2331   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.10779874489498108 unconverged cnt = 682   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.1185786193844792 unconverged cnt = 36   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0, dt = 6.277945852849434e-05 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 6.277945852849434e-05, dt = 0.0021345213423489785 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.002197300800877473, dt = 0.0034438413780923834 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.017950048495129278  
    ---------------- t = 0.005641142178969856, dt = 0.0020927070362889103 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.007733849215258767, dt = 0.0032850168036234863 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.015812191142968283  
    ---------------- t = 0.011018866018882252, dt = 0.0019486631377921082 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.01296752915667436, dt = 0.0030290735775780494 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.01270127501075283  
    ---------------- t = 0.015996602734252408, dt = 0.0018127825353165812 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.01780938526956899, dt = 0.00282449510933336 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.010198642068520647  
    ---------------- t = 0.020633880378902347, dt = 0.0016984325167797556 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.0223323128956821, dt = 0.0026578074050630286 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.02499012030074513, dt = 0.003215804002377956 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.011178545544621778  
    ---------------- t = 0.028205924303123086, dt = 0.001760067056772007 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.029965991359895094, dt = 0.002575576618736964 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.03254156797863206, dt = 0.003064109154448612 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.03560567713308067, dt = 0.003342588586698593 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.03894826571977926, dt = 0.0034924013309094535 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.04244066705068871, dt = 0.0035664638904123413 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.04600713094110105, dt = 0.003597945978507056 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.04960507691960811, dt = 0.00039492308039189294 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    SPH setup: generating particles ...  
    SPH setup: Nstep = 0 ( 0.0e+00 ) Ntotal = 0 ( 0.0e+00 rank min = 0.0e+00 max = 0.0e+00) rate = 0.000000e+00 N.s^-1  
    SPH setup: Nstep = 70 ( 7.0e+01 ) Ntotal = 70 ( 7.0e+01 rank min = 4.5e+05 max = 7.0e+01) rate = 7.000000e+01 N.s^-1  
    SPH setup: Nstep = 106 ( 1.1e+02 ) Ntotal = 176 ( 1.8e+02 rank min = 2.2e+05 max = 1.8e+02) rate = 1.760000e+02 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 294 ( 2.9e+02 rank min = 2.5e+05 max = 2.9e+02) rate = 2.940000e+02 N.s^-1  
    SPH setup: Nstep = 109 ( 1.1e+02 ) Ntotal = 403 ( 4.0e+02 rank min = 9.2e+05 max = 4.0e+02) rate = 4.030000e+02 N.s^-1  
    SPH setup: Nstep = 110 ( 1.1e+02 ) Ntotal = 513 ( 5.1e+02 rank min = 2.1e+05 max = 5.1e+02) rate = 5.130000e+02 N.s^-1  
    SPH setup: Nstep = 106 ( 1.1e+02 ) Ntotal = 619 ( 6.2e+02 rank min = 8.4e+05 max = 6.2e+02) rate = 6.190000e+02 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 737 ( 7.4e+02 rank min = 1.1e+06 max = 7.4e+02) rate = 7.370000e+02 N.s^-1  
    SPH setup: Nstep = 110 ( 1.1e+02 ) Ntotal = 847 ( 8.5e+02 rank min = 2.2e+05 max = 8.5e+02) rate = 8.470000e+02 N.s^-1  
    SPH setup: Nstep = 109 ( 1.1e+02 ) Ntotal = 956 ( 9.6e+02 rank min = 9.1e+05 max = 9.6e+02) rate = 9.560000e+02 N.s^-1  
    SPH setup: Nstep = 115 ( 1.2e+02 ) Ntotal = 1071 ( 1.1e+03 rank min = 1.0e+06 max = 1.1e+03) rate = 1.071000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1192 ( 1.2e+03 rank min = 1.1e+06 max = 1.2e+03) rate = 1.192000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 1310 ( 1.3e+03 rank min = 2.4e+05 max = 1.3e+03) rate = 1.310000e+03 N.s^-1  
    SPH setup: Nstep = 119 ( 1.2e+02 ) Ntotal = 1429 ( 1.4e+03 rank min = 1.1e+06 max = 1.4e+03) rate = 1.429000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1550 ( 1.6e+03 rank min = 1.1e+06 max = 1.6e+03) rate = 1.550000e+03 N.s^-1  
    SPH setup: Nstep = 121 ( 1.2e+02 ) Ntotal = 1671 ( 1.7e+03 rank min = 1.1e+06 max = 1.7e+03) rate = 1.671000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 1789 ( 1.8e+03 rank min = 1.2e+06 max = 1.8e+03) rate = 1.789000e+03 N.s^-1  
    SPH setup: Nstep = 119 ( 1.2e+02 ) Ntotal = 1908 ( 1.9e+03 rank min = 1.2e+06 max = 1.9e+03) rate = 1.908000e+03 N.s^-1  
    SPH setup: Nstep = 122 ( 1.2e+02 ) Ntotal = 2030 ( 2.0e+03 rank min = 2.6e+05 max = 2.0e+03) rate = 2.030000e+03 N.s^-1  
    SPH setup: Nstep = 120 ( 1.2e+02 ) Ntotal = 2150 ( 2.2e+03 rank min = 1.2e+06 max = 2.2e+03) rate = 2.150000e+03 N.s^-1  
    SPH setup: Nstep = 118 ( 1.2e+02 ) Ntotal = 2268 ( 2.3e+03 rank min = 1.2e+06 max = 2.3e+03) rate = 2.268000e+03 N.s^-1  
    SPH setup: Nstep = 63 ( 6.3e+01 ) Ntotal = 2331 ( 2.3e+03 rank min = 6.2e+05 max = 2.3e+03) rate = 2.331000e+03 N.s^-1  
    SPH setup: the generation step took : 0.010047348000000001 s  
    SPH setup: final particle count = 2331 beginning injection ...  
    SPH setup: injected         2000 / 2331 =>  85.8% | ranks with patchs = 1 / 1  -> local loop <-  
    SPH setup: injected         2331 / 2331 => 100.0% | ranks with patchs = 1 / 1  <- global loop -> (msg count : 0)  
    SPH setup: the injection step took : 0.032996801 s  
    SPH setup: the setup took : 0.046904673 s  
    ---------------- t = 0, dt = 0 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.09799885899543734 unconverged cnt = 2331   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.10779874489498108 unconverged cnt = 682   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: smoothing length is not converged, rerunning the iterator ...    [Smoothinglength][rank=0]
         largest h = 0.1185786193844792 unconverged cnt = 36   
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0, dt = 6.277945836822782e-05 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 6.277945836822782e-05, dt = 0.0021345213368997667 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.0021973007952679944, dt = 0.003443841368949804 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.017950048591669807  
    ---------------- t = 0.005641142164217798, dt = 0.0020927070304981045 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.007733849194715902, dt = 0.003285016793301358 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.015812191223307306  
    ---------------- t = 0.011018865988017261, dt = 0.0019486631314653822 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.012967529119482643, dt = 0.003029073567584856 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.012701275063256977  
    ---------------- t = 0.0159966026870675, dt = 0.0018127825287304717 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.01780938521579797, dt = 0.002824495098958605 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.010198642099160982  
    ---------------- t = 0.020633880314756575, dt = 0.00169843251046018 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.022332312825216756, dt = 0.0026578073950987505 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.024990120220315507, dt = 0.003215803990197971 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    Warning: the corrector tolerance are broken the step will be re rerunned      [BasicGasSPH][rank=0]
        eps_v = 0.011178545570919938  
    ---------------- t = 0.02820592421051348, dt = 0.0017600670500431477 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.029965991260556626, dt = 0.0025755766088448196 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.03254156786940145, dt = 0.0030641091426134226 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.03560567701201487, dt = 0.0033425885737203894 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.03894826558573526, dt = 0.0034924013172949646 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.04244066690303023, dt = 0.0035664638764735636 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.046007130779503795, dt = 0.003597945964430602 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    ---------------- t = 0.0496050767439344, dt = 0.00039492325606560463 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  
    adiabatic limit: max relative speed difference = 6.654e-09 (tolerance 1.0e-06)




.. GENERATED FROM PYTHON SOURCE LINES 116-117

Invalid parameters must be rejected when the config is set

.. GENERATED FROM PYTHON SOURCE LINES 117-136

.. code-block:: Python
   :lineno-start: 118


    for bad in [
        dict(cs0=-1.0, rho0=1.0, gamma0=gamma),
        dict(cs0=1.0, rho0=0.0, gamma0=gamma),
        dict(cs0=1.0, rho0=1.0, gamma0=1.0),
    ]:
        ctx = shamrock.Context()
        ctx.pdata_layout_new()
        model = shamrock.get_Model_SPH(context=ctx, vector_type="f64_3", sph_kernel="M4")
        cfg = model.gen_default_config()
        cfg.set_eos_barotropic(**bad)
        try:
            model.set_solver_config(cfg)
        except ValueError as e:
            print(f"rejected {bad} as expected: {type(e).__name__}")
        else:
            raise AssertionError(f"invalid barotropic parameters {bad} were accepted")

    print("barotropic EOS test passed")




.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Error: Exception created :                                                      [Exception][rank=0]
    barotropic EOS requires cs0 > 0, rho0 > 0 and gamma0 > 1, got cs0 = -1, rho0 = 1, gamma0 = 1.6666666666666667
    ---- Source Location ----
    /opt/Shamrock_src/src/shammodels/sph/include/shammodels/sph/SolverConfig.hpp:1265:17
    call = void shammodels::sph::SolverConfig<hipsycl::sycl::vec<double, 3>, shammath::M4>::check_config() [Tvec = hipsycl::sycl::vec<double, 3>, SPHKernel = shammath::M4]
    stacktrace :
      -> process identifier: ad7362c1cd7e (world rank: 0, local rank: Unknown)
    Memory usage & performance info:

        World infos :
            World size = 1
            World rank = 0
        Device infos :
            Device name = AdaptiveCpp OpenMP host device
        Allocs :
            max_allocated_byte_host = 5.29 MB
            max_allocated_byte_device = 1.26 GB
            max_allocated_byte_shared = 0.00 B
            allocated_byte_host = 0.00 B
            allocated_byte_device = 331.38 MB
            allocated_byte_shared = 0.00 B
        

    -------------------------

    ---- Source Location ----
    /opt/Shamrock_src/src/shambase/include/shambase/exception.hpp:133:15
    call = void shambase::throw_with_loc(std::string, SourceLocation) [ExcptTypes = std::invalid_argument]
    stacktrace :
      -> process identifier: ad7362c1cd7e (world rank: 0, local rank: Unknown)
    Memory usage & performance info:

        World infos :
            World size = 1
            World rank = 0
        Device infos :
            Device name = AdaptiveCpp OpenMP host device
        Allocs :
            max_allocated_byte_host = 5.29 MB
            max_allocated_byte_device = 1.26 GB
            max_allocated_byte_shared = 0.00 B
            allocated_byte_host = 0.00 B
            allocated_byte_device = 331.38 MB
            allocated_byte_shared = 0.00 B
        

    -------------------------
  
    rejected {'cs0': -1.0, 'rho0': 1.0, 'gamma0': 1.6666666666666667} as expected: ValueError
    Error: Exception created :                                                      [Exception][rank=0]
    barotropic EOS requires cs0 > 0, rho0 > 0 and gamma0 > 1, got cs0 = 1, rho0 = 0, gamma0 = 1.6666666666666667
    ---- Source Location ----
    /opt/Shamrock_src/src/shammodels/sph/include/shammodels/sph/SolverConfig.hpp:1265:17
    call = void shammodels::sph::SolverConfig<hipsycl::sycl::vec<double, 3>, shammath::M4>::check_config() [Tvec = hipsycl::sycl::vec<double, 3>, SPHKernel = shammath::M4]
    stacktrace :
      -> process identifier: ad7362c1cd7e (world rank: 0, local rank: Unknown)
    Memory usage & performance info:

        World infos :
            World size = 1
            World rank = 0
        Device infos :
            Device name = AdaptiveCpp OpenMP host device
        Allocs :
            max_allocated_byte_host = 5.29 MB
            max_allocated_byte_device = 1.26 GB
            max_allocated_byte_shared = 0.00 B
            allocated_byte_host = 0.00 B
            allocated_byte_device = 331.38 MB
            allocated_byte_shared = 0.00 B
        

    -------------------------

    ---- Source Location ----
    /opt/Shamrock_src/src/shambase/include/shambase/exception.hpp:133:15
    call = void shambase::throw_with_loc(std::string, SourceLocation) [ExcptTypes = std::invalid_argument]
    stacktrace :
      -> process identifier: ad7362c1cd7e (world rank: 0, local rank: Unknown)
    Memory usage & performance info:

        World infos :
            World size = 1
            World rank = 0
        Device infos :
            Device name = AdaptiveCpp OpenMP host device
        Allocs :
            max_allocated_byte_host = 5.29 MB
            max_allocated_byte_device = 1.26 GB
            max_allocated_byte_shared = 0.00 B
            allocated_byte_host = 0.00 B
            allocated_byte_device = 331.38 MB
            allocated_byte_shared = 0.00 B
        

    -------------------------
  
    rejected {'cs0': 1.0, 'rho0': 0.0, 'gamma0': 1.6666666666666667} as expected: ValueError
    Error: Exception created :                                                      [Exception][rank=0]
    barotropic EOS requires cs0 > 0, rho0 > 0 and gamma0 > 1, got cs0 = 1, rho0 = 1, gamma0 = 1
    ---- Source Location ----
    /opt/Shamrock_src/src/shammodels/sph/include/shammodels/sph/SolverConfig.hpp:1265:17
    call = void shammodels::sph::SolverConfig<hipsycl::sycl::vec<double, 3>, shammath::M4>::check_config() [Tvec = hipsycl::sycl::vec<double, 3>, SPHKernel = shammath::M4]
    stacktrace :
      -> process identifier: ad7362c1cd7e (world rank: 0, local rank: Unknown)
    Memory usage & performance info:

        World infos :
            World size = 1
            World rank = 0
        Device infos :
            Device name = AdaptiveCpp OpenMP host device
        Allocs :
            max_allocated_byte_host = 5.29 MB
            max_allocated_byte_device = 1.26 GB
            max_allocated_byte_shared = 0.00 B
            allocated_byte_host = 0.00 B
            allocated_byte_device = 331.38 MB
            allocated_byte_shared = 0.00 B
        

    -------------------------

    ---- Source Location ----
    /opt/Shamrock_src/src/shambase/include/shambase/exception.hpp:133:15
    call = void shambase::throw_with_loc(std::string, SourceLocation) [ExcptTypes = std::invalid_argument]
    stacktrace :
      -> process identifier: ad7362c1cd7e (world rank: 0, local rank: Unknown)
    Memory usage & performance info:

        World infos :
            World size = 1
            World rank = 0
        Device infos :
            Device name = AdaptiveCpp OpenMP host device
        Allocs :
            max_allocated_byte_host = 5.29 MB
            max_allocated_byte_device = 1.26 GB
            max_allocated_byte_shared = 0.00 B
            allocated_byte_host = 0.00 B
            allocated_byte_device = 331.38 MB
            allocated_byte_shared = 0.00 B
        

    -------------------------
  
    rejected {'cs0': 1.0, 'rho0': 1.0, 'gamma0': 1.0} as expected: ValueError
    barotropic EOS test passed





.. rst-class:: sphx-glr-timing

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

**Estimated memory usage:**  218 MB


.. _sphx_glr_download__as_gen_tests_ci_run_sph_eos_barotropic.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: run_sph_eos_barotropic.ipynb <run_sph_eos_barotropic.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: run_sph_eos_barotropic.py <run_sph_eos_barotropic.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: run_sph_eos_barotropic.zip <run_sph_eos_barotropic.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
