
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "_as_gen/tests_ci/run_mhd_orszag_tang.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_mhd_orszag_tang.py>`
        to download the full example code.

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

.. _sphx_glr__as_gen_tests_ci_run_mhd_orszag_tang.py:


Testing Orszag-Tang vortex (3D thin box) with SPMHD
=====================================================

CI test for the 3D (thin box) Orszag-Tang vortex, following the setup
described in the Phantom code paper (Price et al. 2018, Section 5.7.3):
a uniform density, periodic box with a sinusoidal velocity and magnetic
field perturbation that develops into a system of interacting MHD shocks.

.. GENERATED FROM PYTHON SOURCE LINES 11-25

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


    import os

    import matplotlib.pyplot as plt
    import numpy as np

    import shamrock

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








.. GENERATED FROM PYTHON SOURCE LINES 26-27

Parameters (Price et al. 2018, Sec 5.7.3)

.. GENERATED FROM PYTHON SOURCE LINES 27-123

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


    kernel = "M4"

    C_cour = 0.3
    C_force = 0.25

    nx = 32
    ny = 32
    nz = 3

    xymin = -0.5
    xmin = xymin
    ymin = xymin

    gamma = 5.0 / 3.0
    betazero = 10.0 / 3.0
    machzero = 1.0
    vzero = 1.0
    bzero = 1.0 / np.sqrt(4.0 * np.pi)

    przero = 0.5 * bzero**2 * betazero
    rhozero = gamma * przero * machzero
    gam1 = gamma - 1.0
    uuzero = przero / (gam1 * rhozero)

    t_target = 0.5


    def vel_func(r):
        x, y, z = r
        vx = -vzero * np.sin(2.0 * np.pi * (y - ymin))
        vy = vzero * np.sin(2.0 * np.pi * (x - xmin))
        return (vx, vy, 0.0)


    def mag_func(r):
        x, y, z = r
        Bx = -bzero * np.sin(2.0 * np.pi * (y - ymin)) / rhozero
        By = bzero * np.sin(4.0 * np.pi * (x - xmin)) / rhozero
        return (Bx, By, 0.0)


    def run_orszag_tang(nx, ny, nz=3):
        ctx = shamrock.Context()
        ctx.pdata_layout_new()

        codeu = shamrock.UnitSystem(unit_time=1.0, unit_length=1.0, unit_mass=1.2566370621219e-06)
        ucte = shamrock.Constants(codeu)
        model = shamrock.get_Model_SPH(context=ctx, vector_type="f64_3", sph_kernel=kernel)

        cfg = model.gen_default_config()
        cfg.set_units(codeu)

        cfg.set_artif_viscosity_None()
        cfg.set_IdealMHD(sigma_mhd=1, sigma_u=1)
        cfg.set_boundary_periodic()
        cfg.set_eos_adiabatic(gamma)
        model.set_solver_config(cfg)

        crit_split = int(1e7)
        crit_merge = 1
        model.init_scheduler(crit_split, crit_merge)

        (xs, ys, zs) = model.get_box_dim_fcc_3d(1, nx, ny, nz)
        dr = 1 / xs
        (xs, ys, zs) = model.get_box_dim_fcc_3d(dr, nx, ny, nz)

        model.resize_simulation_box((-xs / 2, -ys / 2, -zs / 2), (xs / 2, ys / 2, zs / 2))
        model.add_cube_fcc_3d(dr, (-xs / 2, -ys / 2, -zs / 2), (xs / 2, ys / 2, zs / 2))
        model.set_value_in_a_box(
            "uint", "f64", uuzero, (-xs / 2, -ys / 2, -zs / 2), (xs / 2, ys / 2, zs / 2)
        )

        model.set_field_value_lambda_f64_3("vxyz", vel_func)
        model.set_field_value_lambda_f64_3("B/rho", mag_func)

        vol_b = xs * ys * zs
        totmass = rhozero * vol_b
        pmass = model.total_mass_to_part_mass(totmass)
        model.set_particle_mass(pmass)

        print(f"[nx={nx}] Total mass :", totmass)
        print(f"[nx={nx}] Current part mass :", pmass)

        model.set_cfl_cour(C_cour)
        model.set_cfl_force(C_force)

        model.timestep()

        return ctx, model, xs, ys, zs, pmass, ucte.mu_0()


    ctx, model, xs, ys, zs, pmass, mu_0 = run_orszag_tang(nx, ny, nz)

    model.evolve_until(t_target)





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

 .. code-block:: none

    [nx=32] Total mass : 0.01435415559948049
    [nx=32] Current part mass : 4.505384682825013e-06
    ---------------- 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.016923076923076926 unconverged cnt = 3186   
    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.01861538461538462 unconverged cnt = 3186   
    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.020476923076923084 unconverged cnt = 3186   
    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.022524615384615393 unconverged cnt = 3186   
    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.024777076923076933 unconverged cnt = 3186   
    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.02725478461538463 unconverged cnt = 3186   
    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.029980263076923093 unconverged cnt = 3178   
    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.0329782893846154 unconverged cnt = 58   
    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 = 3.033731433136635e-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 = 3.033731433136635e-05, dt = 0.001031437962581657 ---------------- 
    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.0010617752769130234, dt = 0.0016976264484685334 ---------------- 
    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.0027594017253815568, dt = 0.0021356366249373863 ---------------- 
    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.004895038350318943, dt = 0.002418806853735241 ---------------- 
    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.007313845204054184, dt = 0.0026700013750796284 ---------------- 
    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.009983846579133813, dt = 0.002773642037475183 ---------------- 
    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.012757488616608996, dt = 0.0028010142809859677 ---------------- 
    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.015558502897594964, dt = 0.0028577746372138112 ---------------- 
    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.018416277534808775, dt = 0.002941129869256174 ---------------- 
    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.02135740740406495, dt = 0.0028564063306287346 ---------------- 
    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.024213813734693685, dt = 0.0028792313183021627 ---------------- 
    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.027093045052995847, dt = 0.002902213759073423 ---------------- 
    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.02999525881206927, dt = 0.0029291361613329285 ---------------- 
    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.0329243949734022, dt = 0.0029625739452987837 ---------------- 
    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.03588696891870099, dt = 0.0030030588818953344 ---------------- 
    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.038890027800596326, dt = 0.003052236188930685 ---------------- 
    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.04194226398952701, dt = 0.002742368941219658 ---------------- 
    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.04468463293074667, dt = 0.0027901580401330723 ---------------- 
    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.04747479097087974, dt = 0.0028326095093300853 ---------------- 
    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.050307400480209825, dt = 0.0028554783210417113 ---------------- 
    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.053162878801251534, dt = 0.002835728348659805 ---------------- 
    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.05599860714991134, dt = 0.0027927986915133934 ---------------- 
    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.05879140584142473, dt = 0.0028486935768232153 ---------------- 
    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.06164009941824795, dt = 0.0025706011675115104 ---------------- 
    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.06421070058575945, dt = 0.0026281393955539935 ---------------- 
    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.06683883998131344, dt = 0.002686366459414145 ---------------- 
    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.06952520644072759, dt = 0.002750488301862423 ---------------- 
    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.07227569474259, dt = 0.00282599512954057 ---------------- 
    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.07510168987213058, dt = 0.002896294785169768 ---------------- 
    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.07799798465730035, dt = 0.0028991343909787227 ---------------- 
    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.08089711904827906, dt = 0.002938456287501252 ---------------- 
    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.08383557533578032, dt = 0.0029913168773705767 ---------------- 
    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.08682689221315089, dt = 0.0029571832280422625 ---------------- 
    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.08978407544119316, dt = 0.0030218771869806042 ---------------- 
    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.09280595262817376, dt = 0.003085624431122113 ---------------- 
    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.09589157705929588, dt = 0.0031441906204539853 ---------------- 
    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.09903576767974986, dt = 0.0032009987795236245 ---------------- 
    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.10223676645927349, dt = 0.003282075102662769 ---------------- 
    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.10551884156193625, dt = 0.0033784125545342812 ---------------- 
    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.10889725411647053, dt = 0.003323999560157249 ---------------- 
    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.11222125367662777, dt = 0.003296141542512871 ---------------- 
    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.11551739521914065, dt = 0.0033018687533237726 ---------------- 
    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.11881926397246442, dt = 0.00328991782363642 ---------------- 
    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.12210918179610085, dt = 0.003242292423378229 ---------------- 
    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.12535147421947906, dt = 0.0032121565900727457 ---------------- 
    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.1285636308095518, dt = 0.0032553347553047 ---------------- 
    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.1318189655648565, dt = 0.0031677212387990193 ---------------- 
    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.13498668680365553, dt = 0.003153877934640941 ---------------- 
    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.13814056473829647, dt = 0.0030214671694061934 ---------------- 
    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.14116203190770266, dt = 0.002971659631602173 ---------------- 
    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.14413369153930483, dt = 0.0029489830329003383 ---------------- 
    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.14708267457220517, dt = 0.0029606050896834606 ---------------- 
    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.15004327966188863, dt = 0.0028421227584198338 ---------------- 
    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.15288540242030846, dt = 0.00284432153159224 ---------------- 
    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.1557297239519007, dt = 0.002831902509442114 ---------------- 
    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.15856162646134284, dt = 0.002832357112130397 ---------------- 
    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.16139398357347323, dt = 0.0027830177962468224 ---------------- 
    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.16417700136972005, dt = 0.0027843453347914057 ---------------- 
    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.16696134670451146, dt = 0.0026955123916991095 ---------------- 
    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.16965685909621056, dt = 0.0026406642458044814 ---------------- 
    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.17229752334201504, dt = 0.002612749455775484 ---------------- 
    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.1749102727977905, dt = 0.00264450642498602 ---------------- 
    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.17755477922277652, dt = 0.0026593957242491114 ---------------- 
    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.18021417494702563, dt = 0.0026873882192648734 ---------------- 
    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.1829015631662905, dt = 0.0026082572489186514 ---------------- 
    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.18550982041520914, dt = 0.0025773743193899133 ---------------- 
    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.18808719473459906, dt = 0.0026127883656065394 ---------------- 
    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.1906999831002056, dt = 0.002658191343635494 ---------------- 
    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.1933581744438411, dt = 0.002671156310461559 ---------------- 
    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.19602933075430265, dt = 0.0025820322522970124 ---------------- 
    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.19861136300659965, dt = 0.0026349938126811467 ---------------- 
    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.2012463568192808, dt = 0.002682325791323772 ---------------- 
    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.20392868261060457, dt = 0.0025133197113263142 ---------------- 
    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.20644200232193088, dt = 0.002541578607633636 ---------------- 
    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.2089835809295645, dt = 0.0025869081186845654 ---------------- 
    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.21157048904824907, dt = 0.0026188534590828854 ---------------- 
    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.21418934250733196, dt = 0.002660852595712909 ---------------- 
    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.21685019510304487, dt = 0.0026038109250228997 ---------------- 
    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.21945400602806778, dt = 0.0026432774343134913 ---------------- 
    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.22209728346238128, dt = 0.002510128157296585 ---------------- 
    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.22460741161967787, dt = 0.0023911730958748826 ---------------- 
    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.22699858471555276, dt = 0.0024156216438691786 ---------------- 
    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.22941420635942195, dt = 0.0023927813338326703 ---------------- 
    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.2318069876932546, dt = 0.0023120878804907758 ---------------- 
    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.2341190755737454, dt = 0.0023313415047011158 ---------------- 
    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.23645041707844652, dt = 0.002365539822237645 ---------------- 
    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.23881595690068416, dt = 0.002336595718729727 ---------------- 
    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.2411525526194139, dt = 0.002416285436429048 ---------------- 
    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.24356883805584295, dt = 0.002358883032914871 ---------------- 
    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.24592772108875782, dt = 0.0023733814629670357 ---------------- 
    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.24830110255172486, dt = 0.002404665516944625 ---------------- 
    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.25070576806866945, dt = 0.0024555495802389194 ---------------- 
    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.25316131764890837, dt = 0.0024377006691237947 ---------------- 
    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.25559901831803217, dt = 0.002538332802226522 ---------------- 
    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.2581373511202587, dt = 0.0025776357362716222 ---------------- 
    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.26071498685653033, dt = 0.0025931183039620102 ---------------- 
    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.26330810516049236, dt = 0.0025805021488309455 ---------------- 
    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.2658886073093233, dt = 0.0024896839895845145 ---------------- 
    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.2683782912989078, dt = 0.0025233634383153404 ---------------- 
    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.2709016547372231, dt = 0.0025797502368433253 ---------------- 
    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.2734814049740664, dt = 0.002623379466377052 ---------------- 
    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.27610478444044345, dt = 0.002688311088951301 ---------------- 
    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.27879309552939474, dt = 0.002704022753635474 ---------------- 
    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.2814971182830302, dt = 0.00271036982186821 ---------------- 
    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.28420748810489843, dt = 0.002660715756450602 ---------------- 
    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.28686820386134904, dt = 0.002707707923686889 ---------------- 
    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.28957591178503594, dt = 0.0026928636680525375 ---------------- 
    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.2922687754530885, dt = 0.0027384484119079735 ---------------- 
    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.29500722386499645, dt = 0.0027880510531527337 ---------------- 
    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.29779527491814917, dt = 0.002844778442487287 ---------------- 
    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.30064005336063643, dt = 0.0027946993649719605 ---------------- 
    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.3034347527256084, dt = 0.0028852857509845974 ---------------- 
    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.306320038476593, dt = 0.002934193447490817 ---------------- 
    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.3092542319240838, dt = 0.002805127096990373 ---------------- 
    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.3120593590210742, dt = 0.0028885768692379532 ---------------- 
    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.3149479358903121, dt = 0.0028438220935711493 ---------------- 
    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.31779175798388326, dt = 0.0027826996416755864 ---------------- 
    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.32057445762555886, dt = 0.002862843765714108 ---------------- 
    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.32343730139127297, dt = 0.0027971870523728825 ---------------- 
    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.32623448844364583, dt = 0.0028555860961777635 ---------------- 
    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.3290900745398236, dt = 0.0027891373559386892 ---------------- 
    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.33187921189576225, dt = 0.0028374530308694157 ---------------- 
    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.33471666492663166, dt = 0.002910277362997476 ---------------- 
    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.33762694228962914, dt = 0.0029080522420572735 ---------------- 
    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.3405349945316864, dt = 0.0026503662647422285 ---------------- 
    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.34318536079642864, dt = 0.0026251733035954406 ---------------- 
    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.3458105341000241, dt = 0.002667145819351389 ---------------- 
    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.3484776799193755, dt = 0.0027274570658869226 ---------------- 
    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.3512051369852624, dt = 0.0028098955514387004 ---------------- 
    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.3540150325367011, dt = 0.0029189913858782114 ---------------- 
    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.3569340239225793, dt = 0.002887284302166794 ---------------- 
    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.35982130822474606, dt = 0.002925846623724978 ---------------- 
    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.36274715484847103, dt = 0.002924587631044734 ---------------- 
    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.3656717424795158, dt = 0.0029985772979750592 ---------------- 
    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.3686703197774908, dt = 0.0030065698663788816 ---------------- 
    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.3716768896438697, dt = 0.002889750802606165 ---------------- 
    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.37456664044647586, dt = 0.0029599366644587383 ---------------- 
    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.3775265771109346, dt = 0.002985873189398533 ---------------- 
    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.38051245030033315, dt = 0.0029973351969724282 ---------------- 
    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.3835097854973056, dt = 0.002960214870350956 ---------------- 
    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.38647000036765655, dt = 0.0029819795510055264 ---------------- 
    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.3894519799186621, dt = 0.003037154163210768 ---------------- 
    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.39248913408187286, dt = 0.003101989741769651 ---------------- 
    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.39559112382364253, dt = 0.0030902577660956963 ---------------- 
    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.3986813815897382, dt = 0.0029923244121638003 ---------------- 
    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.401673706001902, dt = 0.0030563478905641104 ---------------- 
    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.40473005389246614, dt = 0.0031428891716875646 ---------------- 
    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.4078729430641537, dt = 0.0031927419052565718 ---------------- 
    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.4110656849694103, dt = 0.0030678299848718475 ---------------- 
    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.4141335149542822, dt = 0.003098914585759383 ---------------- 
    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.4172324295400416, dt = 0.0031525424609631417 ---------------- 
    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.4203849720010047, dt = 0.003210725851575855 ---------------- 
    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.42359569785258055, dt = 0.0032892657971469 ---------------- 
    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.42688496364972744, dt = 0.003357149761513026 ---------------- 
    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.43024211341124047, dt = 0.003378844428219875 ---------------- 
    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.43362095783946036, dt = 0.0032369895947596773 ---------------- 
    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.43685794743422, dt = 0.003348427072921212 ---------------- 
    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.44020637450714123, dt = 0.003369462124969044 ---------------- 
    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.44357583663211025, dt = 0.003477608970171239 ---------------- 
    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.4470534456022815, dt = 0.003552916803054394 ---------------- 
    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.4506063624053359, dt = 0.0035442874703774836 ---------------- 
    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.4541506498757134, dt = 0.003544946330021918 ---------------- 
    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.4576955962057353, dt = 0.0035783505304329295 ---------------- 
    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.4612739467361682, dt = 0.003617092430427224 ---------------- 
    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.46489103916659547, dt = 0.00370003851308489 ---------------- 
    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.46859107767968033, dt = 0.003774781852861722 ---------------- 
    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.47236585953254207, dt = 0.0037186488750704004 ---------------- 
    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.47608450840761246, dt = 0.003616173015480347 ---------------- 
    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.4797006814230928, dt = 0.003684027487475568 ---------------- 
    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.4833847089105684, dt = 0.0037591441321218663 ---------------- 
    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.48714385304269026, dt = 0.0036814092107613334 ---------------- 
    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.4908252622534516, dt = 0.0037493908910763364 ---------------- 
    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.4945746531445279, dt = 0.0038492532129886367 ---------------- 
    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.49842390635751654, dt = 0.001576093642483456 ---------------- 
    Warning: High interface/patch volume ratio.                                  [InterfaceGen][rank=0]
        This can lead to high mpi overhead, try to increase the patch split crit  

    EvolveUntilResults(reach_target_time=true, reach_niter_max=false, reach_max_walltime=false, iter_count=175)



.. GENERATED FROM PYTHON SOURCE LINES 124-125

Diagnostics

.. GENERATED FROM PYTHON SOURCE LINES 125-299

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


    kinetic_energy = shamrock.model_sph.analysisEnergyKinetic(model=model).get_kinetic_energy()
    total_momentum = shamrock.model_sph.analysisTotalMomentum(model=model).get_total_momentum()

    data = ctx.collect_data()
    hpart = data["hpart"]
    hfact = model.get_hfact()
    rho = pmass * (hfact / hpart) ** 3
    B_on_rho = data["B/rho"]

    magnetic_energy = 0.5 * pmass * np.sum(rho * np.sum(B_on_rho**2, axis=1)) / mu_0

    rho_max = np.max(rho)
    rho_min = np.min(rho)

    momentum_norm = np.sqrt(total_momentum[0] ** 2 + total_momentum[1] ** 2 + total_momentum[2] ** 2)

    print(f"kinetic_energy   = {kinetic_energy}")
    print(f"magnetic_energy  = {magnetic_energy}")
    print(f"momentum_norm    = {momentum_norm}")
    print(f"rho_max          = {rho_max}")
    print(f"rho_min          = {rho_min}")


    plot_extra_resols = []  # 128, 148

    do_plot = False
    dump_folder = "_to_trash"
    if do_plot and shamrock.sys.world_rank() == 0:
        os.makedirs(dump_folder, exist_ok=True)


    def render_density_z0(model, xs, ys, render_res=300, min_normalization=1e-9):
        kwargs = dict(
            center=(0.0, 0.0, 0.0),
            delta_x=(xs, 0.0, 0.0),
            delta_y=(0.0, ys, 0.0),
            nx=render_res,
            ny=render_res,
        )
        raw = np.asarray(model.render_cartesian_slice("rho", "f64", **kwargs))
        unity = np.asarray(model.render_cartesian_slice("unity", "f64", **kwargs))
        return np.where(unity < min_normalization, np.nan, raw / unity)


    def pressure_cut(model, y0, xs, n_pts=400, min_normalization=1e-9):
        x_arr = np.linspace(-xs / 2, xs / 2, n_pts)
        positions = [(x, y0, 0.0) for x in x_arr]

        rho_field = model.compute_field("rho", "f64")
        uint_field = model.compute_field("uint", "f64")

        def compute_pressure(size, rho, uint):
            return (gamma - 1.0) * rho * uint

        P_field = shamrock.map_fields_f64(compute_pressure, rho=rho_field, uint=uint_field)

        P_raw = np.asarray(model.render_slice(P_field, positions))
        unity = np.asarray(model.render_slice("unity", "f64", positions))
        P_cut = np.where(unity < min_normalization, np.nan, P_raw / unity)
        return x_arr, P_cut


    if do_plot:
        y_cuts = [0.3125, 0.4277]

        # snapshot at t=0.5 (already reached above) for the primary resolution
        resols = [(nx, ny)]
        density_t05 = [render_density_z0(model, xs, ys)]
        cuts_t05 = [[pressure_cut(model, y0, xs) for y0 in y_cuts]]

        # continue to t=1 for the Fig. 32 bottom row
        model.evolve_until(1.0)
        density_t10 = [render_density_z0(model, xs, ys)]

        for nx_e, ny_e in plot_extra_resols:
            ctx_e, model_e, xs_e, ys_e, zs_e, pmass_e, mu_0_e = run_orszag_tang(nx_e, ny_e, nz)

            model_e.evolve_until(0.5)
            resols.append((nx_e, ny_e))
            density_t05.append(render_density_z0(model_e, xs_e, ys_e))
            cuts_t05.append([pressure_cut(model_e, y0, xs_e) for y0 in y_cuts])

            model_e.evolve_until(1.0)
            density_t10.append(render_density_z0(model_e, xs_e, ys_e))

        if shamrock.sys.world_rank() == 0:
            # Figure 32: density z=0, rows = t=0.5 / t=1, columns = resolutions
            n_res = len(resols)
            fig32, axs32 = plt.subplots(2, n_res, figsize=(max(4 * n_res, 6), 8), squeeze=False)
            for icol, (nxr, nyr) in enumerate(resols):
                extent = [-xs / 2, xs / 2, -ys / 2, ys / 2]
                axs32[0, icol].imshow(
                    density_t05[icol], origin="lower", extent=extent, cmap="gist_heat"
                )
                axs32[0, icol].set_title(f"nx={nxr}, t=0.5")
                axs32[1, icol].imshow(
                    density_t10[icol], origin="lower", extent=extent, cmap="gist_heat"
                )
                axs32[1, icol].set_title(f"nx={nxr}, t=1")
                for ax in (axs32[0, icol], axs32[1, icol]):
                    ax.set_xlabel("x")
                    ax.set_ylabel("y")
            fig32.suptitle("Orszag-Tang vortex: density in a z=0 cross section")
            fig32.tight_layout()
            fig32.savefig(os.path.join(dump_folder, "mhd_orszag_tang_density_z0.png"), dpi=150)
            plt.close(fig32)

            # Figure 33: horizontal pressure cuts at t=0.5, one panel per y0,
            # one line per resolution
            fig33, axs33 = plt.subplots(len(y_cuts), 1, figsize=(7, 8), squeeze=False)
            axs33 = axs33[:, 0]
            for irow, y0 in enumerate(y_cuts):
                for (nxr, nyr), cuts in zip(resols, cuts_t05):
                    x_arr, P_cut = cuts[irow]
                    axs33[irow].plot(x_arr, P_cut, label=f"nx={nxr}")
                axs33[irow].set_title(f"y={y0}")
                axs33[irow].set_xlabel("x")
                axs33[irow].set_ylabel("P")
                axs33[irow].legend()
            fig33.suptitle("Orszag-Tang vortex: horizontal pressure cuts (z=0, t=0.5)")
            fig33.tight_layout()
            fig33.savefig(os.path.join(dump_folder, "mhd_orszag_tang_pressure_cuts.png"), dpi=150)
            plt.close(fig33)

    test_pass = True
    err_log = ""


    expect_kinetic_energy = 0.0021986783020805675
    expect_magnetic_energy = 0.0029601504573239087
    expect_rho_max = 0.3400457561374047
    expect_rho_min = 0.14169354827263864

    tol = 1e-4  # relative tolerance
    max_momentum_norm = 1e-3


    def float_equal(val1, val2, prec):
        return abs(val1 - val2) < prec


    if not float_equal(kinetic_energy, expect_kinetic_energy, tol * expect_kinetic_energy):
        err_log += "error on the kinetic energy is outside of tolerances:\n"
        err_log += f"  expected error = {expect_kinetic_energy} +- {tol * expect_kinetic_energy}\n"
        err_log += f"  obtained error = {kinetic_energy}\n"
        test_pass = False

    if not float_equal(magnetic_energy, expect_magnetic_energy, tol * expect_magnetic_energy):
        err_log += "error on the magnetic energy is outside of tolerances:\n"
        err_log += f"  expected error = {expect_magnetic_energy} +- {tol * expect_magnetic_energy}\n"
        err_log += f"  obtained error = {magnetic_energy}\n"
        test_pass = False

    if momentum_norm > max_momentum_norm:
        err_log += "total momentum norm is outside of tolerances:\n"
        err_log += f"  expected |p| < {max_momentum_norm}\n"
        err_log += f"  obtained |p| = {momentum_norm}\n"
        test_pass = False

    if not float_equal(rho_max, expect_rho_max, tol * expect_rho_max):
        err_log += "error on rho_max is outside of tolerances:\n"
        err_log += f"  expected error = {expect_rho_max} +- {tol * expect_rho_max}\n"
        err_log += f"  obtained error = {rho_max}\n"
        test_pass = False

    if not float_equal(rho_min, expect_rho_min, tol * expect_rho_min):
        err_log += "error on rho_min is outside of tolerances:\n"
        err_log += f"  expected error = {expect_rho_min} +- {tol * expect_rho_min}\n"
        err_log += f"  obtained error = {rho_min}\n"
        test_pass = False

    if test_pass == False:
        exit("Test did not pass L2 margins : \n" + err_log)




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

 .. code-block:: none

    kinetic_energy   = 0.0021986783020805675
    magnetic_energy  = 0.0029601504573239087
    momentum_norm    = 7.683768519158053e-05
    rho_max          = 0.3400457561374047
    rho_min          = 0.14169354827263864





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

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

**Estimated memory usage:**  162 MB


.. _sphx_glr_download__as_gen_tests_ci_run_mhd_orszag_tang.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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