Note
Go to the end to download the full example code.
ConstCSModel 3D
Plot \(\xi, v, w\) in 3D for the constant sound speed model
Bag, a_s=1.100, a_b=1.000, V_s=1.000, V_b=0.000, v_w=0.5, αₙ=0.578: w0/wn=0.2147, Ubarf2=0.2639, K=0.2230, κ=0.6091, ω=0.3948, κ+ω=1.0039, V-avg. trace anomaly=-0.5233
Reference kappa=0.6088, relative error=0.0004525684334633951
Reference ubarf2=0.1672, relative error=0.5777673033370899
Reference ke_frac_bva=0.2230, relative error=-0.00014746303099464023
Bag, a_s=1.100, a_b=1.000, V_s=1.000, V_b=0.000, v_w=0.7, αₙ=0.151: w0/wn=0.8476, Ubarf2=0.0590, K=0.0683, κ=0.5207, ω=0.4858, κ+ω=1.0065, V-avg. trace anomaly=-1.4367
Reference kappa=0.5189, relative error=0.003413342251522283
Reference ubarf2=0.0511, relative error=0.15492304734832926
Reference ke_frac_bva=0.0681, relative error=0.0034083817101040114
Bag, a_s=1.100, a_b=1.000, V_s=1.000, V_b=0.000, v_w=0.77, αₙ=0.091: w0/wn=0.8871, Ubarf2=0.0180, K=0.0220, κ=0.2639, ω=0.7426, κ+ω=1.0065, V-avg. trace anomaly=-1.9122
Reference kappa=0.2639, relative error=7.366479811861195e-05
Reference ubarf2=0.0165, relative error=0.09100003551957797
Reference ke_frac_bva=0.0220, relative error=3.255689989422937e-08
css2=1/3, csb2=0.322, v_w=0.5, αₙ=0.578: w0/wn=0.2103, Ubarf2=0.2663, K=0.2242, κ=0.6105, ω=0.3932, κ+ω=1.0037, V-avg. trace anomaly=-0.5217
css2=1/3, csb2=0.322, v_w=0.7, αₙ=0.151: w0/wn=0.8452, Ubarf2=0.0565, K=0.0651, κ=0.5055, ω=0.5009, κ+ω=1.0064, V-avg. trace anomaly=-1.3639
css2=1/3, csb2=0.322, v_w=0.8, αₙ=0.11: w0/wn=0.8661, Ubarf2=0.0192, K=0.0230, κ=0.2408, ω=0.7636, κ+ω=1.0045, V-avg. trace anomaly=-1.9691
import os.path
import numpy as np
from examples.utils import FIG_DIR
from pttools.analysis.plot_fluid_shell_3d import BubblePlot3D
from pttools.bubble.boundary import SolutionType
from pttools.bubble.bubble import Bubble
from pttools.bubble import quantities
# from pttools.logging import setup_logging
from pttools.models.bag import BagModel
from pttools.models.const_cs import ConstCSModel
# setup_logging()
def main():
bag = BagModel(a_s=1.1, a_b=1, V_s=1)
# css = 1/np.sqrt(3) - 0.05
# csb = 1/np.sqrt(3) - 0.1
# print(f"css={css}, csb={csb}")
csb = 1/np.sqrt(3) - 0.01
const_cs = ConstCSModel(a_s=1.5, a_b=1, css2=1/3, csb2=csb**2, V_s=1)
plot = BubblePlot3D(model=const_cs)
# v_wall and alpha_n values are from Hindmarsh and Hijazi, 2019.
bag_def = Bubble(bag, v_wall=0.5, alpha_n=0.578, sol_type=SolutionType.SUB_DEF)
bag_hybrid = Bubble(bag, v_wall=0.7, alpha_n=0.151, sol_type=SolutionType.HYBRID)
bag_det = Bubble(bag, v_wall=0.77, alpha_n=0.091, sol_type=SolutionType.DETON)
for bubble in [bag_def, bag_hybrid, bag_det]:
plot.add(bubble, color="blue")
print(bubble.info_str())
kappa = quantities.get_kappa_bag(v_wall=bubble.v_wall, alpha_n=bubble.alpha_n)
ubarf2 = quantities.get_ubarf2_new_bag(v_wall=bubble.v_wall, alpha_n=bubble.alpha_n)
ke_frac = quantities.get_ke_frac_bag(v_wall=bubble.v_wall, alpha_n=bubble.alpha_n)
print(f"Reference kappa={kappa:.4f}, relative error={(bubble.kappa - kappa)/kappa}")
print(f"Reference ubarf2={ubarf2:.4f}, relative error={(bubble.ubarf2 - ubarf2)/ubarf2}")
print(f"Reference ke_frac_bva={ke_frac:.4f}, relative error={(bubble.kinetic_energy_fraction - ke_frac) / ke_frac}")
const_cs_def = Bubble(const_cs, v_wall=0.5, alpha_n=0.578, sol_type=SolutionType.SUB_DEF)
const_cs_hybrid = Bubble(const_cs, v_wall=0.7, alpha_n=0.151, sol_type=SolutionType.HYBRID)
# These values had to be modified for a solution to exist
const_cs_det = Bubble(const_cs, v_wall=0.8, alpha_n=0.11, sol_type=SolutionType.DETON)
for bubble in [const_cs_def, const_cs_hybrid, const_cs_det]:
plot.add(bubble, color="red")
print(bubble.info_str())
return plot
plot = main()
plot.save(os.path.join(FIG_DIR, "plot_const_cs_xi_v_w"))
if __name__ == "__main__" and "__file__" in globals():
plot.show()
plot.fig()
Total running time of the script: (0 minutes 10.168 seconds)
Estimated memory usage: 287 MB