.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/props/plot_ke_frac.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_props_plot_ke_frac.py: Kinetic energy fraction ======================= Plot the kinetic energy fraction for various $\alpha_n$ as a function of $\xi_\text{wall}$ .. GENERATED FROM PYTHON SOURCE LINES 7-50 .. image-sg:: /auto_examples/props/images/sphx_glr_plot_ke_frac_001.png :alt: plot ke frac :srcset: /auto_examples/props/images/sphx_glr_plot_ke_frac_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 0.2754830658241228 Peak: i=0, ke_frac=0.06355062289332492, v_wall=0.8, alpha_n=0.2854830658241228 | .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from examples import utils from pttools.bubble import get_ke_frac from pttools.analysis.bubble_grid import create_bubbles from pttools.models.const_cs import ConstCSModel def main(): # model = ConstCSModel(css2=1/3, csb2=1/3, a_s=100, a_b=50, V_s=1e-8, V_b=0) model = ConstCSModel(css2=1 / 3, csb2=1 / 4, a_s=5, a_b=1, V_s=1, V_b=0) print(model.alpha_n_min) # v_walls = np.linspace(0.05, 0.95, 100) v_walls = np.linspace(0.8, 0.9, 100) # alpha_ns = np.array([model.alpha_n_min, 0.2, 0.25]) alpha_ns = np.array([model.alpha_n_min + 0.01]) bubbles, ke_fracs = create_bubbles( model, v_walls=v_walls, alpha_ns=alpha_ns, func=get_ke_frac, # allow_bubble_failure=True, # bubble_kwargs={"allow_invalid": True} ) i_max = np.nanargmax(ke_fracs[0]) print(f"Peak: i={i_max}, ke_frac={ke_fracs[0, i_max]}, v_wall={v_walls[i_max]}, alpha_n={alpha_ns[0]}") fig: plt.Figure = plt.figure() ax: plt.Axes = fig.add_subplot() for i_alpha_n, alpha_n in enumerate(alpha_ns): ax.plot(v_walls, ke_fracs[i_alpha_n, :], label=rf"$\alpha_n={alpha_n:.2f}$") ax.set_xlabel(r"$\xi_w$") ax.set_ylabel(r"$K$") ax.grid() ax.legend() return fig if __name__ == "__main__": fig = main() utils.save_and_show(fig, "ke_frac.png") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.575 seconds) **Estimated memory usage:** 279 MB .. _sphx_glr_download_auto_examples_props_plot_ke_frac.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ke_frac.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ke_frac.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_ke_frac.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_