.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/solvers/plot_xi_kappa_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_xi_kappa_bag.py: Compare kappa(xi) for old and new solvers ========================================= .. GENERATED FROM PYTHON SOURCE LINES 5-46 .. image-sg:: /auto_examples/solvers/images/sphx_glr_plot_xi_kappa_bag_001.png :alt: plot xi kappa bag :srcset: /auto_examples/solvers/images/sphx_glr_plot_xi_kappa_bag_001.png :class: sphx-glr-single-img .. code-block:: Python import logging import time import matplotlib.pyplot as plt import numpy as np from examples import utils from pttools.bubble import quantities from pttools.bubble.bubble import Bubble from pttools.models.bag import BagModel logger = logging.getLogger(__name__) def main() -> plt.Figure: t_start = time.perf_counter() model = BagModel(a_s=1.1, a_b=1, V_s=1) v_walls = np.linspace(0.2, 0.95, 10) alpha_ns = np.array([0.1]) fig: plt.Figure = plt.figure() ax: plt.Axes = fig.add_subplot() for alpha_n in alpha_ns: old = np.zeros_like(v_walls) new = np.zeros_like(v_walls) for i_v, v_wall in enumerate(v_walls): # Old old[i_v], _ = quantities.get_kappa_de_bag(v_wall, alpha_n) # New bubble = Bubble(model, v_wall, alpha_n) new[i_v] = bubble.kappa ax.plot(v_walls, new) logger.info(f"Elapsed time: {time.perf_counter() - t_start}") return fig if __name__ == "__main__": fig = main() utils.save_and_show(fig, "xi_kappa_bag.png") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.350 seconds) **Estimated memory usage:** 265 MB .. _sphx_glr_download_auto_examples_solvers_plot_xi_kappa_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_xi_kappa_bag.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_xi_kappa_bag.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_xi_kappa_bag.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_