.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/solvers/plot_bag.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_solvers_plot_bag.py: Bag model ========= Simple plots for the bag model .. GENERATED FROM PYTHON SOURCE LINES 7-77 .. image-sg:: /auto_examples/solvers/images/sphx_glr_plot_bag_001.png :alt: plot bag :srcset: /auto_examples/solvers/images/sphx_glr_plot_bag_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Solving with old solver Solving with new solver SolutionType.DETON vp=0.0, vm=0.10223411759573522, vp_tilde=0.85, vm_tilde=0.8189300880938022, wp=1.0, wm=1.2318885193421116 Kappa: 0.10129327966348803 Omega: 0.9046661932578712 | .. code-block:: Python import os.path import matplotlib.pyplot as plt from examples import utils from pttools.logging import setup_logging from pttools.bubble.fluid_bag import sound_shell_bag from pttools.bubble.fluid_reference import ref from pttools.models.bag import BagModel from pttools.models.const_cs import ConstCSModel from pttools.bubble import props from pttools.bubble.bubble import Bubble from pttools.bubble.boundary import SolutionType setup_logging() model = BagModel(g_s=123, g_b=120, V_s=0.9) # model = BagModel(a_s=13.488, a_b=13.159, V_s=0.900, V_b=0.000) # model = ConstCSModel(css2=0.323, csb2=0.322, g_s=123, g_b=120, V_s=0.9) v_wall = 0.85 alpha_n = 0.05 print("Solving with old solver") v, w, xi = sound_shell_bag(v_wall, alpha_n) # print(v, w, xi) print("Solving with new solver") bubble = Bubble(model, v_wall=v_wall, alpha_n=alpha_n) print(bubble.sol_type) ref_data = ref().get(v_wall, alpha_n, bubble.sol_type) print( f"vp={ref_data[0]}, vm={ref_data[1]}, " f"vp_tilde={ref_data[2]}, vm_tilde={ref_data[3]}, " f"wp={ref_data[4]}, wm={ref_data[5]}" ) fig: plt.Figure = plt.figure() ax1, ax2, ax3, ax4 = fig.subplots(4, 1, sharex=True) phase = props.find_phase(bubble.xi, bubble.v_wall) theta = model.theta(bubble.w, phase) ax1.plot(bubble.xi, bubble.v, label="new") ax1.plot(xi, v, label="old", ls=":") ax1.set_ylabel("v") ax1.legend() ax2.plot(bubble.xi, bubble.w, label="new") ax2.plot(xi, w * bubble.wn, label="old", ls=":") ax2.set_ylabel("$w$") ax2.legend() ax3.plot(bubble.xi, phase) ax3.set_ylabel(r"$\phi$") ax4.plot(bubble.xi, theta - theta[-1]) ax4.set_ylabel(r"$\theta - \theta_n$") print("Kappa:", bubble.kappa) print("Omega:", bubble.omega) for ax in [ax1, ax2, ax3, ax4]: ax.set_xlabel(r"$\xi$") ax.set_xlim(0, 1) ax1.set_ylim(0, 1) fig.tight_layout() utils.save_and_show(fig, "bag.png") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.074 seconds) **Estimated memory usage:** 264 MB .. _sphx_glr_download_auto_examples_solvers_plot_bag.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_bag.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_bag.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_bag.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_