Skip to content
Snippets Groups Projects

Implement gear's stars skipping

Merged Loic Hausammann requested to merge gear_skip_feedback into master
Files
13
###############################################################################
###############################################################################
# This file is part of SWIFT.
# This file is part of SWIFT.
# Copyright (c) 2018 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
# Copyright (c) 2018 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
#
#
# This program is free software: you can redistribute it and/or modify
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU Lesser General Public License
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
##############################################################################
##############################################################################
# Script used to plot time evolution of gas particle properties. Intended to
# Script used to plot time evolution of gas particle properties. Intended to
# compare result of feedback due to one star placed in centre of uniform box
# compare result of feedback due to one star placed in centre of uniform box
# of gas with output from EAGLE feedback test. Can also use as input output
# of gas with output from EAGLE feedback test. Can also use as input output
# from SWIFT feedback test (tests/testFeedback) with the appropriate change
# from SWIFT feedback test (tests/testFeedback) with the appropriate change
# to filepath.
# to filepath.
import matplotlib
import matplotlib
 
matplotlib.use("Agg")
matplotlib.use("Agg")
from pylab import *
from pylab import *
from scipy import stats
from scipy import stats
@@ -33,31 +34,34 @@ import glob
@@ -33,31 +34,34 @@ import glob
import os.path
import os.path
# Plot parameters
# Plot parameters
params = {'axes.labelsize': 10,
params = {
'axes.titlesize': 10,
"axes.labelsize": 10,
'font.size': 12,
"axes.titlesize": 10,
'legend.fontsize': 12,
"font.size": 12,
'xtick.labelsize': 10,
"legend.fontsize": 12,
'ytick.labelsize': 10,
"xtick.labelsize": 10,
'text.usetex': True,
"ytick.labelsize": 10,
'figure.figsize' : (9.90,6.45),
"text.usetex": True,
'figure.subplot.left' : 0.05,
"figure.figsize": (9.90, 6.45),
'figure.subplot.right' : 0.995,
"figure.subplot.left": 0.05,
'figure.subplot.bottom' : 0.06,
"figure.subplot.right": 0.995,
'figure.subplot.top' : 0.92,
"figure.subplot.bottom": 0.06,
'figure.subplot.wspace' : 0.25,
"figure.subplot.top": 0.92,
'figure.subplot.hspace' : 0.2,
"figure.subplot.wspace": 0.25,
'lines.markersize' : 6,
"figure.subplot.hspace": 0.2,
'lines.linewidth' : 3.,
"lines.markersize": 6,
'text.latex.unicode': True
"lines.linewidth": 3.0,
 
"text.latex.unicode": True,
}
}
rcParams.update(params)
rcParams.update(params)
rc('font',**{'family':'sans-serif','sans-serif':['Times']})
rc("font", **{"family": "sans-serif", "sans-serif": ["Times"]})
# Number of snapshots and elements
# Number of snapshots and elements
newest_snap_name = max(glob.glob('stellar_evolution_*.hdf5'))#, key=os.path.getctime)
newest_snap_name = max(glob.glob("stellar_evolution_*.hdf5")) # , key=os.path.getctime)
n_snapshots = int(newest_snap_name.replace('stellar_evolution_','').replace('.hdf5','')) + 1
n_snapshots = (
 
int(newest_snap_name.replace("stellar_evolution_", "").replace(".hdf5", "")) + 1
 
)
n_elements = 9
n_elements = 9
# Read the simulation data
# Read the simulation data
@@ -72,7 +76,9 @@ git = sim["Code"].attrs["Git Revision"]
@@ -72,7 +76,9 @@ git = sim["Code"].attrs["Git Revision"]
stellar_mass = sim["/PartType4/Masses"][0]
stellar_mass = sim["/PartType4/Masses"][0]
E_SNII_cgs = double(sim["/Parameters"].attrs["EAGLEFeedback:SNII_energy_erg"])
E_SNII_cgs = double(sim["/Parameters"].attrs["EAGLEFeedback:SNII_energy_erg"])
E_SNIa_cgs = double(sim["/Parameters"].attrs["EAGLEFeedback:SNIa_energy_erg"])
E_SNIa_cgs = double(sim["/Parameters"].attrs["EAGLEFeedback:SNIa_energy_erg"])
ejecta_vel_cgs = double(sim["/Parameters"].attrs["EAGLEFeedback:AGB_ejecta_velocity_km_p_s"]) * 1e5
ejecta_vel_cgs = (
 
double(sim["/Parameters"].attrs["EAGLEFeedback:AGB_ejecta_velocity_km_p_s"]) * 1e5
 
)
# Units
# Units
unit_length_in_cgs = sim["/Units"].attrs["Unit length in cgs (U_L)"]
unit_length_in_cgs = sim["/Units"].attrs["Unit length in cgs (U_L)"]
@@ -81,11 +87,11 @@ unit_time_in_cgs = sim["/Units"].attrs["Unit time in cgs (U_t)"]
@@ -81,11 +87,11 @@ unit_time_in_cgs = sim["/Units"].attrs["Unit time in cgs (U_t)"]
unit_temp_in_cgs = sim["/Units"].attrs["Unit temperature in cgs (U_T)"]
unit_temp_in_cgs = sim["/Units"].attrs["Unit temperature in cgs (U_T)"]
unit_vel_in_cgs = unit_length_in_cgs / unit_time_in_cgs
unit_vel_in_cgs = unit_length_in_cgs / unit_time_in_cgs
unit_energy_in_cgs = unit_mass_in_cgs * unit_vel_in_cgs * unit_vel_in_cgs
unit_energy_in_cgs = unit_mass_in_cgs * unit_vel_in_cgs * unit_vel_in_cgs
unit_density_in_cgs = unit_mass_in_cgs*unit_length_in_cgs**-3
unit_density_in_cgs = unit_mass_in_cgs * unit_length_in_cgs ** -3
unit_pressure_in_cgs = unit_mass_in_cgs/unit_length_in_cgs*unit_time_in_cgs**-2
unit_pressure_in_cgs = unit_mass_in_cgs / unit_length_in_cgs * unit_time_in_cgs ** -2
unit_int_energy_in_cgs = unit_energy_in_cgs/unit_mass_in_cgs
unit_int_energy_in_cgs = unit_energy_in_cgs / unit_mass_in_cgs
unit_entropy_in_cgs = unit_energy_in_cgs/unit_temp_in_cgs
unit_entropy_in_cgs = unit_energy_in_cgs / unit_temp_in_cgs
Gyr_in_cgs = 1e9 * 365. * 24 * 3600.
Gyr_in_cgs = 1e9 * 365.0 * 24 * 3600.0
Msun_in_cgs = 1.98848e33
Msun_in_cgs = 1.98848e33
# Declare arrays to store SWIFT data
# Declare arrays to store SWIFT data
@@ -98,148 +104,247 @@ swift_box_gas_metal_mass = zeros(n_snapshots)
@@ -98,148 +104,247 @@ swift_box_gas_metal_mass = zeros(n_snapshots)
swift_box_gas_metal_mass_AGB = zeros(n_snapshots)
swift_box_gas_metal_mass_AGB = zeros(n_snapshots)
swift_box_gas_metal_mass_SNII = zeros(n_snapshots)
swift_box_gas_metal_mass_SNII = zeros(n_snapshots)
swift_box_gas_metal_mass_SNIa = zeros(n_snapshots)
swift_box_gas_metal_mass_SNIa = zeros(n_snapshots)
swift_element_mass = zeros((n_snapshots,n_elements))
swift_element_mass = zeros((n_snapshots, n_elements))
swift_internal_energy = zeros(n_snapshots)
swift_internal_energy = zeros(n_snapshots)
swift_kinetic_energy = zeros(n_snapshots)
swift_kinetic_energy = zeros(n_snapshots)
swift_total_energy = zeros(n_snapshots)
swift_total_energy = zeros(n_snapshots)
swift_mean_u_start = 0.
swift_mean_u_start = 0.0
t = zeros(n_snapshots)
t = zeros(n_snapshots)
# Read data from snapshots
# Read data from snapshots
for i in range(n_snapshots):
for i in range(n_snapshots):
#print("reading snapshot "+str(i))
# print("reading snapshot "+str(i))
sim = h5py.File("stellar_evolution_%04d.hdf5"%i, "r")
sim = h5py.File("stellar_evolution_%04d.hdf5" % i, "r")
t[i] = sim["/Header"].attrs["Time"][0]
t[i] = sim["/Header"].attrs["Time"][0]
 
 
masses = sim["/PartType0/Masses"][:]
 
swift_box_gas_mass[i] = np.sum(masses)
masses = sim["/PartType0/Masses"][:]
AGB_mass = sim["/PartType0/MassesFromAGB"][:]
swift_box_gas_mass[i] = np.sum(masses)
SNII_mass = sim["/PartType0/MassesFromSNII"][:]
 
SNIa_mass = sim["/PartType0/MassesFromSNIa"][:]
AGB_mass = sim["/PartType0/MassesFromAGB"][:]
swift_box_gas_mass_AGB[i] = np.sum(AGB_mass)
SNII_mass = sim["/PartType0/MassesFromSNII"][:]
swift_box_gas_mass_SNII[i] = np.sum(SNII_mass)
SNIa_mass = sim["/PartType0/MassesFromSNIa"][:]
swift_box_gas_mass_SNIa[i] = np.sum(SNIa_mass)
swift_box_gas_mass_AGB[i] = np.sum(AGB_mass)
Z_star = sim["/PartType4/MetalMassFractions"][0]
swift_box_gas_mass_SNII[i] = np.sum(SNII_mass)
star_masses = sim["/PartType4/Masses"][:]
swift_box_gas_mass_SNIa[i] = np.sum(SNIa_mass)
swift_box_star_mass[i] = np.sum(star_masses)
Z_star = sim["/PartType4/MetalMassFractions"][0]
metallicities = sim["/PartType0/MetalMassFractions"][:]
star_masses = sim["/PartType4/Masses"][:]
swift_box_gas_metal_mass[i] = np.sum(metallicities * masses)
swift_box_star_mass[i] = np.sum(star_masses)
metallicities = sim["/PartType0/MetalMassFractions"][:]
AGB_Z_frac = sim["/PartType0/MetalMassFractionsFromAGB"][:]
swift_box_gas_metal_mass[i] = np.sum(metallicities * masses)
SNII_Z_frac = sim["/PartType0/MetalMassFractionsFromSNII"][:]
 
SNIa_Z_frac = sim["/PartType0/MetalMassFractionsFromSNIa"][:]
AGB_Z_frac = sim["/PartType0/MetalMassFractionsFromAGB"][:]
swift_box_gas_metal_mass_AGB[i] = np.sum(AGB_Z_frac * masses)
SNII_Z_frac = sim["/PartType0/MetalMassFractionsFromSNII"][:]
swift_box_gas_metal_mass_SNII[i] = np.sum(SNII_Z_frac * masses)
SNIa_Z_frac = sim["/PartType0/MetalMassFractionsFromSNIa"][:]
swift_box_gas_metal_mass_SNIa[i] = np.sum(SNIa_Z_frac * masses)
swift_box_gas_metal_mass_AGB[i] = np.sum(AGB_Z_frac * masses)
element_abundances = sim["/PartType0/ElementMassFractions"][:][:]
swift_box_gas_metal_mass_SNII[i] = np.sum(SNII_Z_frac * masses)
for j in range(n_elements):
swift_box_gas_metal_mass_SNIa[i] = np.sum(SNIa_Z_frac * masses)
swift_element_mass[i, j] = np.sum(element_abundances[:, j] * masses)
element_abundances = sim["/PartType0/ElementMassFractions"][:][:]
v = sim["/PartType0/Velocities"][:, :]
for j in range(n_elements):
v2 = v[:, 0] ** 2 + v[:, 1] ** 2 + v[:, 2] ** 2
swift_element_mass[i,j] = np.sum(element_abundances[:,j] * masses)
u = sim["/PartType0/InternalEnergies"][:]
 
swift_internal_energy[i] = np.sum(masses * u)
 
swift_kinetic_energy[i] = np.sum(0.5 * masses * v2)
 
swift_total_energy[i] = swift_kinetic_energy[i] + swift_internal_energy[i]
v = sim["/PartType0/Velocities"][:,:]
if i == 0:
v2 = v[:,0]**2 + v[:,1]**2 + v[:,2]**2
swift_mean_u_start = np.mean(u)
u = sim["/PartType0/InternalEnergies"][:]
swift_internal_energy[i] = np.sum(masses * u)
swift_kinetic_energy[i] = np.sum(0.5 * masses * v2)
swift_total_energy[i] = swift_kinetic_energy[i] + swift_internal_energy[i]
if i == 0:
sim.close()
swift_mean_u_start = np.mean(u)
sim.close()
# Read expected yields from EAGLE. Choose which file to use based on metallicity used when
# Read expected yields from EAGLE. Choose which file to use based on metallicity used when
# running SWIFT (can be specified in yml file)
# running SWIFT (can be specified in yml file)
filename = "./StellarEvolutionSolution/Z_%.4f/StellarEvolutionTotal.txt"%Z_star
filename = "./StellarEvolutionSolution/Z_%.4f/StellarEvolutionTotal.txt" % Z_star
# Read EAGLE test output
# Read EAGLE test output
data = loadtxt(filename)
data = loadtxt(filename)
eagle_time_Gyr = data[:,0]
eagle_time_Gyr = data[:, 0]
eagle_total_mass = data[:,1] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_mass = data[:, 1] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_metal_mass = data[:,2] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_metal_mass = data[:, 2] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_element_mass = data[:, 3:3+n_elements] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_element_mass = (
data[:, 3 : 3 + n_elements] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_energy_from_mass_cgs = eagle_total_mass * Msun_in_cgs * swift_mean_u_start * unit_int_energy_in_cgs
)
eagle_energy_ejecta_cgs = 0.5 * (eagle_total_mass * Msun_in_cgs) * ejecta_vel_cgs**2
 
eagle_energy_from_mass_cgs = (
 
eagle_total_mass * Msun_in_cgs * swift_mean_u_start * unit_int_energy_in_cgs
 
)
 
eagle_energy_ejecta_cgs = 0.5 * (eagle_total_mass * Msun_in_cgs) * ejecta_vel_cgs ** 2
# Read the mass per channel
# Read the mass per channel
filename = "./StellarEvolutionSolution/Z_%.4f/StellarEvolutionAGB.txt"%Z_star
filename = "./StellarEvolutionSolution/Z_%.4f/StellarEvolutionAGB.txt" % Z_star
data = loadtxt(filename)
data = loadtxt(filename)
eagle_total_mass_AGB = data[:,1] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_mass_AGB = data[:, 1] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_metal_mass_AGB = data[:,2] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_metal_mass_AGB = data[:, 2] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
filename = "./StellarEvolutionSolution/Z_%.4f/StellarEvolutionII.txt"%Z_star
filename = "./StellarEvolutionSolution/Z_%.4f/StellarEvolutionII.txt" % Z_star
data = loadtxt(filename)
data = loadtxt(filename)
eagle_total_mass_SNII = data[:,1] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_mass_SNII = data[:, 1] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_metal_mass_SNII = data[:,2] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_metal_mass_SNII = data[:, 2] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
filename = "./StellarEvolutionSolution/Z_%.4f/StellarEvolutionIa.txt"%Z_star
filename = "./StellarEvolutionSolution/Z_%.4f/StellarEvolutionIa.txt" % Z_star
data = loadtxt(filename)
data = loadtxt(filename)
eagle_total_mass_SNIa = data[:,1] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_mass_SNIa = data[:, 1] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_metal_mass_SNIa = data[:,2] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
eagle_total_metal_mass_SNIa = data[:, 2] * stellar_mass / Msun_in_cgs * unit_mass_in_cgs
# Plot the interesting quantities
# Plot the interesting quantities
figure()
figure()
suptitle("Star metallicity Z = %.4f"%Z_star)
suptitle("Star metallicity Z = %.4f" % Z_star)
# Box gas mass --------------------------------
# Box gas mass --------------------------------
subplot(221)
subplot(221)
plot(t[1:] * unit_time_in_cgs / Gyr_in_cgs, (swift_box_gas_mass[1:] - swift_box_gas_mass[0])* unit_mass_in_cgs / Msun_in_cgs, linewidth=0.5, color='k', label='Total')
plot(
plot(t * unit_time_in_cgs / Gyr_in_cgs, swift_box_gas_mass_AGB * unit_mass_in_cgs / Msun_in_cgs, linewidth=0.5, color='C0', label='AGB')
t[1:] * unit_time_in_cgs / Gyr_in_cgs,
plot(t * unit_time_in_cgs / Gyr_in_cgs, swift_box_gas_mass_SNII * unit_mass_in_cgs / Msun_in_cgs, linewidth=0.5, color='C1', label='SNII')
(swift_box_gas_mass[1:] - swift_box_gas_mass[0]) * unit_mass_in_cgs / Msun_in_cgs,
plot(t * unit_time_in_cgs / Gyr_in_cgs, swift_box_gas_mass_SNIa * unit_mass_in_cgs / Msun_in_cgs, linewidth=0.5, color='C2', label='SNIa')
linewidth=0.5,
plot(eagle_time_Gyr[1:],eagle_total_mass[:-1],linewidth=0.5, color='k', ls='--')
color="k",
plot(eagle_time_Gyr[1:],eagle_total_mass_AGB[:-1],linewidth=0.5, color='C0', ls='--')
label="Total",
plot(eagle_time_Gyr[1:],eagle_total_mass_SNII[:-1],linewidth=0.5, color='C1', ls='--')
)
plot(eagle_time_Gyr[1:],eagle_total_mass_SNIa[:-1],linewidth=0.5, color='C2', ls='--')
plot(
 
t * unit_time_in_cgs / Gyr_in_cgs,
 
swift_box_gas_mass_AGB * unit_mass_in_cgs / Msun_in_cgs,
 
linewidth=0.5,
 
color="C0",
 
label="AGB",
 
)
 
plot(
 
t * unit_time_in_cgs / Gyr_in_cgs,
 
swift_box_gas_mass_SNII * unit_mass_in_cgs / Msun_in_cgs,
 
linewidth=0.5,
 
color="C1",
 
label="SNII",
 
)
 
plot(
 
t * unit_time_in_cgs / Gyr_in_cgs,
 
swift_box_gas_mass_SNIa * unit_mass_in_cgs / Msun_in_cgs,
 
linewidth=0.5,
 
color="C2",
 
label="SNIa",
 
)
 
plot(eagle_time_Gyr[1:], eagle_total_mass[:-1], linewidth=0.5, color="k", ls="--")
 
plot(eagle_time_Gyr[1:], eagle_total_mass_AGB[:-1], linewidth=0.5, color="C0", ls="--")
 
plot(eagle_time_Gyr[1:], eagle_total_mass_SNII[:-1], linewidth=0.5, color="C1", ls="--")
 
plot(eagle_time_Gyr[1:], eagle_total_mass_SNIa[:-1], linewidth=0.5, color="C2", ls="--")
legend(loc="lower right", ncol=2, fontsize=8)
legend(loc="lower right", ncol=2, fontsize=8)
xlabel("${\\rm Time~[Gyr]}$", labelpad=0)
xlabel("${\\rm Time~[Gyr]}$", labelpad=0)
ylabel("Change in total gas particle mass ${[\\rm M_\\odot]}$", labelpad=2)
ylabel("Change in total gas particle mass ${[\\rm M_\\odot]}$", labelpad=2)
ticklabel_format(style='sci', axis='y', scilimits=(0,0))
ticklabel_format(style="sci", axis="y", scilimits=(0, 0))
# Box star mass --------------------------------
# Box star mass --------------------------------
subplot(222)
subplot(222)
plot(t * unit_time_in_cgs / Gyr_in_cgs, (swift_box_star_mass)* unit_mass_in_cgs / Msun_in_cgs, linewidth=0.5, color='k', label='SWIFT')
plot(
plot(eagle_time_Gyr[1:], swift_box_star_mass[0] * unit_mass_in_cgs / Msun_in_cgs - eagle_total_mass[:-1],linewidth=0.5,color='k',label='EAGLE test', ls='--')
t * unit_time_in_cgs / Gyr_in_cgs,
 
(swift_box_star_mass) * unit_mass_in_cgs / Msun_in_cgs,
 
linewidth=0.5,
 
color="k",
 
label="SWIFT",
 
)
 
plot(
 
eagle_time_Gyr[1:],
 
swift_box_star_mass[0] * unit_mass_in_cgs / Msun_in_cgs - eagle_total_mass[:-1],
 
linewidth=0.5,
 
color="k",
 
label="EAGLE test",
 
ls="--",
 
)
xlabel("${\\rm Time~[Gyr]}$", labelpad=0)
xlabel("${\\rm Time~[Gyr]}$", labelpad=0)
ylabel("Change in total star particle mass ${[\\rm M_\\odot]}$", labelpad=2)
ylabel("Change in total star particle mass ${[\\rm M_\\odot]}$", labelpad=2)
ticklabel_format(style='sci', axis='y', scilimits=(0,0))
ticklabel_format(style="sci", axis="y", scilimits=(0, 0))
legend()
legend()
# Box gas element mass --------------------------------
# Box gas element mass --------------------------------
colours = ['k','r','g','b','c','y','m','skyblue','plum']
colours = ["k", "r", "g", "b", "c", "y", "m", "skyblue", "plum"]
element_names = ['H','He','C','N','O','Ne','Mg','Si','Fe']
element_names = ["H", "He", "C", "N", "O", "Ne", "Mg", "Si", "Fe"]
subplot(223)
subplot(223)
for j in range(n_elements):
for j in range(n_elements):
plot(t[1:] * unit_time_in_cgs / Gyr_in_cgs, (swift_element_mass[1:,j] - swift_element_mass[0,j]) * unit_mass_in_cgs / Msun_in_cgs, linewidth=0.5, color=colours[j], ms=0.5, label=element_names[j])
plot(
plot(eagle_time_Gyr[1:],eagle_total_element_mass[:-1,j],linewidth=1,color=colours[j],linestyle='--')
t[1:] * unit_time_in_cgs / Gyr_in_cgs,
 
(swift_element_mass[1:, j] - swift_element_mass[0, j])
 
* unit_mass_in_cgs
 
/ Msun_in_cgs,
 
linewidth=0.5,
 
color=colours[j],
 
ms=0.5,
 
label=element_names[j],
 
)
 
plot(
 
eagle_time_Gyr[1:],
 
eagle_total_element_mass[:-1, j],
 
linewidth=1,
 
color=colours[j],
 
linestyle="--",
 
)
xlabel("${\\rm Time~[Gyr]}$", labelpad=0)
xlabel("${\\rm Time~[Gyr]}$", labelpad=0)
ylabel("Change in element mass of gas particles ${[\\rm M_\\odot]}$", labelpad=2)
ylabel("Change in element mass of gas particles ${[\\rm M_\\odot]}$", labelpad=2)
xscale("log")
xscale("log")
yscale("log")
yscale("log")
legend(bbox_to_anchor=(1.005, 1.), ncol=1, fontsize=8, handlelength=1)
legend(bbox_to_anchor=(1.005, 1.0), ncol=1, fontsize=8, handlelength=1)
# Box gas metal mass --------------------------------
# Box gas metal mass --------------------------------
subplot(224)
subplot(224)
plot(t[1:] * unit_time_in_cgs / Gyr_in_cgs, (swift_box_gas_metal_mass[1:] - swift_box_gas_metal_mass[0])* unit_mass_in_cgs / Msun_in_cgs, linewidth=0.5, color='k', label='Total')
plot(
plot(t * unit_time_in_cgs / Gyr_in_cgs, swift_box_gas_metal_mass_AGB * unit_mass_in_cgs / Msun_in_cgs, linewidth=0.5, color='C0', label='AGB')
t[1:] * unit_time_in_cgs / Gyr_in_cgs,
plot(t * unit_time_in_cgs / Gyr_in_cgs, swift_box_gas_metal_mass_SNII * unit_mass_in_cgs / Msun_in_cgs, linewidth=0.5, color='C1', label='SNII')
(swift_box_gas_metal_mass[1:] - swift_box_gas_metal_mass[0])
plot(t * unit_time_in_cgs / Gyr_in_cgs, swift_box_gas_metal_mass_SNIa * unit_mass_in_cgs / Msun_in_cgs, linewidth=0.5, color='C2', label='SNIa')
* unit_mass_in_cgs
plot(eagle_time_Gyr[1:],eagle_total_metal_mass[:-1],linewidth=0.5,color='k', ls='--')
/ Msun_in_cgs,
plot(eagle_time_Gyr[1:],eagle_total_metal_mass_AGB[:-1],linewidth=0.5, color='C0', ls='--')
linewidth=0.5,
plot(eagle_time_Gyr[1:],eagle_total_metal_mass_SNII[:-1],linewidth=0.5, color='C1', ls='--')
color="k",
plot(eagle_time_Gyr[1:],eagle_total_metal_mass_SNIa[:-1],linewidth=0.5, color='C2', ls='--')
label="Total",
 
)
 
plot(
 
t * unit_time_in_cgs / Gyr_in_cgs,
 
swift_box_gas_metal_mass_AGB * unit_mass_in_cgs / Msun_in_cgs,
 
linewidth=0.5,
 
color="C0",
 
label="AGB",
 
)
 
plot(
 
t * unit_time_in_cgs / Gyr_in_cgs,
 
swift_box_gas_metal_mass_SNII * unit_mass_in_cgs / Msun_in_cgs,
 
linewidth=0.5,
 
color="C1",
 
label="SNII",
 
)
 
plot(
 
t * unit_time_in_cgs / Gyr_in_cgs,
 
swift_box_gas_metal_mass_SNIa * unit_mass_in_cgs / Msun_in_cgs,
 
linewidth=0.5,
 
color="C2",
 
label="SNIa",
 
)
 
plot(eagle_time_Gyr[1:], eagle_total_metal_mass[:-1], linewidth=0.5, color="k", ls="--")
 
plot(
 
eagle_time_Gyr[1:],
 
eagle_total_metal_mass_AGB[:-1],
 
linewidth=0.5,
 
color="C0",
 
ls="--",
 
)
 
plot(
 
eagle_time_Gyr[1:],
 
eagle_total_metal_mass_SNII[:-1],
 
linewidth=0.5,
 
color="C1",
 
ls="--",
 
)
 
plot(
 
eagle_time_Gyr[1:],
 
eagle_total_metal_mass_SNIa[:-1],
 
linewidth=0.5,
 
color="C2",
 
ls="--",
 
)
legend(loc="center right", ncol=2, fontsize=8)
legend(loc="center right", ncol=2, fontsize=8)
xlabel("${\\rm Time~[Gyr]}$", labelpad=0)
xlabel("${\\rm Time~[Gyr]}$", labelpad=0)
ylabel("Change in total metal mass of gas particles ${[\\rm M_\\odot]}$", labelpad=2)
ylabel("Change in total metal mass of gas particles ${[\\rm M_\\odot]}$", labelpad=2)
ticklabel_format(style='sci', axis='y', scilimits=(0,0))
ticklabel_format(style="sci", axis="y", scilimits=(0, 0))
savefig("box_evolution_Z_%.4f.png"%(Z_star), dpi=200)
 
savefig("box_evolution_Z_%.4f.png" % (Z_star), dpi=200)
Loading