From a160178fe3d80117dee4bba700bfcfb524b549fb Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Thu, 21 Sep 2023 21:25:21 +0000 Subject: [PATCH] build based on 4b84f2a --- previews/PR264/index.html | 22 +++++++++++----------- previews/PR264/search/index.html | 2 +- previews/PR264/search_index.js | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/previews/PR264/index.html b/previews/PR264/index.html index 46b1dff..cddcfc2 100644 --- a/previews/PR264/index.html +++ b/previews/PR264/index.html @@ -1,10 +1,10 @@ -Chamber.jl · Chamber.jl

Chamber.jl

This is the API documentation for Chamber.jl. See the package's README for instructions about general usage.

Functions

Chamber.IC_FinderMethod
IC_Finder(composition::Mafic, M_h2o::Float64, M_co2::Float64, M_tot::Float64, P::Float64, T::Float64, V::Float64, rho_m::Float64, param_IC::ParamICFinder{Float64})::NamedTuple{(:eps_g0, :X_co20, :mco2_diss, :phase),NTuple{4,Float64}}

An iterative function that uses thermodynamic modeling to determine the gas phase composition of a mafic magma chamber.

Arguments

  • composition: Mafic()
  • M_h2o: total mass of water in magma (kg)
  • M_co2: total mass of CO2 in magma (kg)
  • M_tot: total mass of magma (kg)
  • P: Pressure (Pa)
  • T: Temperature (K)
  • V: chamber volume (m³)
  • rho_m: density of the melt (kg/m³)
  • param_IC: An instance of the ParamICFinder composite type containing the parameters for IC_Finder

Returns

A NamedTuple with the following fields:

  • eps_g0: Initial gas fraction of the magma chamber
  • X_co20: Initial mole fraction of CO2 in the gas phase
  • mco2_diss: Total mass of CO2 dissolved in the melt (kg)
  • phase: Integer representing the state of the magma

Details

The function uses a thermodynamic model to find the initial gas fraction (eps_g0) and initial mole fraction of CO2 in the gas phase (X_co20) for a mafic magma chamber. The model assumes that the chamber contains two phases: a liquid melt and a gas phase. The model calculates the saturation state of the magma with respect to CO2, and determines whether the gas phase contains only CO2 or a mixture of CO2 and H2O. If the chamber is in two-phase state, the model returns eps_g0 = 0.0, X_co20 = 0.0, mco2_diss = Total mass of CO2 dissolved in the melt, and phase = 2. If the chamber is in gas or liquid state, the function iteratively solves for eps_g0 and X_co20 using the solve_X_co2 and get_eps_g helper functions until the relative difference between eps_g0 and X_co20 in two consecutive iterations is less than the tolerance Tol, or until the maximum number of iterations max_count is reached.

source
Chamber.IC_FinderMethod
IC_Finder(composition::Silicic, M_h2o::Float64, M_co2::Float64, M_tot::Float64, P::Float64, T::Float64, V::Float64, rho_m::Float64, param_IC::ParamICFinder{Float64})::NamedTuple{(:eps_g0, :X_co20, :mco2_diss, :phase),NTuple{4,Float64}}

An iterative function that uses thermodynamic modeling to determine the gas phase composition of a silicic magma chamber.

Arguments

  • composition: Silicic()
  • M_h2o: total mass of water in magma (kg)
  • M_co2: total mass of CO2 in magma (kg)
  • M_tot: total mass of magma (kg)
  • P: Pressure (Pa)
  • T: Temperature (K)
  • V: chamber volume (m³)
  • rho_m: density of the melt (kg/m³)
  • param_IC: An instance of the ParamICFinder composite type containing the parameters for IC_Finder

Returns

A NamedTuple with the following fields:

  • eps_g0: Initial gas fraction of the magma chamber
  • X_co20: Initial mole fraction of CO2 in the gas phase
  • mco2_diss: Total mass of CO2 dissolved in the melt (kg)
  • phase: Integer representing the state of the magma

Details

The function uses a thermodynamic model to find the initial gas fraction (eps_g0) and initial mole fraction of CO2 in the gas phase (X_co20) for a silicic magma chamber. The model assumes that the chamber contains two phases: a liquid melt and a gas phase. The model calculates the saturation state of the magma with respect to CO2, and determines whether the gas phase contains only CO2 or a mixture of CO2 and H2O. If the chamber is in two-phase state, the model returns eps_g0 = 0.0, X_co20 = 0.0, mco2_diss = Total mass of CO2 dissolved in the melt, and phase = 2. If the chamber is in gas or liquid state, the function iteratively solves for eps_g0 and X_co20 using the solve_X_co2 and get_eps_g helper functions until the relative difference between eps_g0 and X_co20 in two consecutive iterations is less than the tolerance Tol, or until the maximum number of iterations max_count is reached.

source
Chamber.a1x_fMethod

This is for a11 and a12 a11: rho, drhodP, V, dVdP a12: rho, drhodT, V, dVdT

source
Chamber.affect!Method
affect!(int, idx, sw::SW{Int8}, param::Param{Float64}, param_saved_var::ParamSaved{Float64}, param_IC_Finder::ParamICFinder{Float64})

Re-initialize the condition when the event happens. This function modifies the current state of the integrator (int.u) when a particular event occurs during the simulation. The function adjusts various parameters based on the current state of the integrator and the custom parameters that were passed in.

Arguments

  • int: The current state of the integrator. It's format is from the DifferentialEquations.jl package
  • idx: The index of the event that caused the function to be called.
  • sw: A custom parameter used to control simulation behavior.
  • param: A custom parameter containing physical constants and other model parameters.
  • param_saved_var: A custom parameter used to store values from the previous time step.
  • param_IC_Finder: A custom parameter used to control the behavior of the IC_Finder function.

The arguments int and idx are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.

source
Chamber.boundary_conditions_newMethod
boundary_conditions_new(P::Float64, T::Float64, V::Float64, rho_m::Float64, rho_x::Float64, c::Float64, sw::SW{Int8}, T_in::Float64, M_h2o::Float64, M_co2::Float64, total_Mass::Float64, param::Param{Float64}, param_saved_var::ParamSaved{Float64})

Arguments

  • P: Pressure (Pa)
  • T: Temperature (K)
  • V: chamber volume (m³)
  • rho_m: density of melt
  • rho_x: density of crystal of magma
  • c: heat of magma
  • sw: eruption/coolingmodule/viscousrelaxation control
  • T_in: Temperature
  • M_h2o: total mess of H2O in the magma
  • M_co2: total mess of CO2 in the magma
  • total_Mass: total mess of magma chamber
source
Chamber.build_co2Method
build_co2(Pw::T, Pc::T, Temp::T, dPwdP::T, dPcdP::T, dPwdXco2::T, dPcdXco2::T)::NamedTuple{(:C_co2, :dC_co2dT, :dC_co2dP, :dC_co2dXco2),NTuple{4,T}} where {T<:Float64}
  • This function is used within the exsolve function.

Returns

A NamedTuple with the following fields:

  • C_co2
  • dC_co2dT
  • dC_co2dP
  • dC_co2dXco2
source
Chamber.build_mdot_inMethod
build_mdot_in(fluxing::Bool, rho_m0::Float64, log_vfr::Float64, P_0::Float64, T_in::Float64)::Float64
  • This function is used within the chamber function.

Returns

  • mdot_in: mass inflow rate
source
Chamber.build_meqMethod
build_meq(composition::Mafic, P::T, Temp::T, X_co2::T)::NamedTuple{(:meq, :dmeqdT, :dmeqdP, :dmeqdXco2),NTuple{4,T}} where {T<:Float64}
  • This function is used within the exsolve function.

Returns

A NamedTuple with the following fields:

  • meq
  • dmeqdT
  • dmeqdP
  • dmeqdXco2
source
Chamber.build_meqMethod
build_meq(composition::Silicic, Pw::T, Pc::T, Temp::T, dPwdP::T, dPcdP::T, dPwdXco2::T, dPcdXco2::T)::NamedTuple{(:meq, :dmeqdT, :dmeqdP, :dmeqdXco2),NTuple{4,T}} where {T<:Float64}
  • This function is used within the exsolve function.

Returns

A NamedTuple with the following fields:

  • meq
  • dmeqdT
  • dmeqdP
  • dmeqdXco2
source
Chamber.build_rho_rcMethod
build_rho_rc(eps_m::T, eps_g::T, eps_x::T, rho_m::T, rho_g::T, rho_x::T, drho_m_dP::T, drho_g_dP::T, drho_x_dP::T, drho_m_dT::T, drho_g_dT::T, drho_x_dT::T, c_x::T, c_m::T, c_g::T, deps_x_dP::T, deps_x_dT::T)::Vector{T} where {T<:Float64}
  • This function is used within the odeChamber function.

Returns

[rho, drho_dP, drho_dT, drho_deps_g, rc, drc_dP, drc_dT]

source
Chamber.chamberFunction
chamber(composition::Union{Silicic,Mafic}, end_time::Float64, log_volume_km3_vector::Union{Float64,Vector{Float64}}, InitialConc_H2O_vector::Union{Float64,Vector{Float64}}, InitialConc_CO2_vector::Union{Float64,Vector{Float64}}, log_vfr_vector::Union{Float64,Vector{Float64}}, depth_vector::Union{Float64,Vector{Float64}}, output_dirname::String; kwargs...)

Simulate the eruption of a volcano using a model for the frequency of eruptions of upper crustal magma chambers based on Degruyter and Huber (2014).

Arguments

  • composition: The magma composition. Use Silicic() for rhyolite composition (arc magma) or Mafic() for basalt composition (rift).
  • end_time: Maximum magma chamber evolution duration in seconds.
  • log_volume_km3: The initial volume of the chamber in logarithmic scale. The actual initial chamber volume is calculated as 10^(log_volume_km3) in km³.
  • InitialConc_H2O: The initial weight fraction of water in the magma (exsolved + dissolved).
  • InitialConc_CO2: The initial weight fraction of CO₂ in the magma (exsolved + dissolved).
  • log_vfr: Magma recharge rate in km³/yr calculated as 10^(log_vfr).
  • depth: Depth of the magma chamber in meters.
  • output_dirname(optional): Name of the output directory. Defaults to current timestamp.

Keyword Arguments

  • plotfig(optional): (default: true). Generate and plot figures for each result if true.

Returns

A DataFrame containing the solution with columns:

  • time: Simulation timestamps in seconds.
  • P+dP: Pressure in Pa.
  • T: Temperature in K.
  • eps_g: Gas volume fraction.
  • V: Volume of the magma chamber in m³.
  • rho_m: Density of the melt in kg/m³.
  • rho_x: Density of magma crystal in kg/m³.
  • X_CO2: Mole fraction of CO2 in the gas.
  • total_mass: Total mass of magma chamber in kg.
  • total_mass_H2O: Total mass of water in the magma in kg.
  • total_mass_CO2: Total mass of CO₂ in the magma in kg.
  • eps_x: Crystal volume fraction.

Outputs

A directory named after output_dirname or the default value, containing the following files:

  • out.csv: a CSV file containing the solution columns listed above.
  • eruptions.csv, A CSV file containing the datas of eruptions with the following columns: timeoferuption (sec), durationoferuption (sec), masserupted (kg) and volumeerupted (km³).
  • Figures for P+dP(t), T(t), epsg(t), V(t), XCO2(t), total_mass(t).

References

  • W. Degruyter and C. Huber (2014). A model for eruption frequency of upper crustal silicic magma chambers. Earth Planet. Sci. Lett. https://doi.org/10.1016/j.epsl.2014.06.047

Examples

# Run a simulation with silicic magma chamber
+Chamber.jl · Chamber.jl

Chamber.jl

This is the API documentation for Chamber.jl. See the package's README for instructions about general usage.

Functions

Chamber.IC_FinderMethod
IC_Finder(composition::Mafic, M_h2o::Float64, M_co2::Float64, M_tot::Float64, P::Float64, T::Float64, V::Float64, rho_m::Float64, param_IC::ParamICFinder{Float64})::NamedTuple{(:eps_g0, :X_co20, :mco2_diss, :phase),NTuple{4,Float64}}

An iterative function that uses thermodynamic modeling to determine the gas phase composition of a mafic magma chamber.

Arguments

  • composition: Mafic()
  • M_h2o: total mass of water in magma (kg)
  • M_co2: total mass of CO2 in magma (kg)
  • M_tot: total mass of magma (kg)
  • P: Pressure (Pa)
  • T: Temperature (K)
  • V: chamber volume (m³)
  • rho_m: density of the melt (kg/m³)
  • param_IC: An instance of the ParamICFinder composite type containing the parameters for IC_Finder

Returns

A NamedTuple with the following fields:

  • eps_g0: Initial gas fraction of the magma chamber
  • X_co20: Initial mole fraction of CO2 in the gas phase
  • mco2_diss: Total mass of CO2 dissolved in the melt (kg)
  • phase: Integer representing the state of the magma

Details

The function uses a thermodynamic model to find the initial gas fraction (eps_g0) and initial mole fraction of CO2 in the gas phase (X_co20) for a mafic magma chamber. The model assumes that the chamber contains two phases: a liquid melt and a gas phase. The model calculates the saturation state of the magma with respect to CO2, and determines whether the gas phase contains only CO2 or a mixture of CO2 and H2O. If the chamber is in two-phase state, the model returns eps_g0 = 0.0, X_co20 = 0.0, mco2_diss = Total mass of CO2 dissolved in the melt, and phase = 2. If the chamber is in gas or liquid state, the function iteratively solves for eps_g0 and X_co20 using the solve_X_co2 and get_eps_g helper functions until the relative difference between eps_g0 and X_co20 in two consecutive iterations is less than the tolerance Tol, or until the maximum number of iterations max_count is reached.

source
Chamber.IC_FinderMethod
IC_Finder(composition::Silicic, M_h2o::Float64, M_co2::Float64, M_tot::Float64, P::Float64, T::Float64, V::Float64, rho_m::Float64, param_IC::ParamICFinder{Float64})::NamedTuple{(:eps_g0, :X_co20, :mco2_diss, :phase),NTuple{4,Float64}}

An iterative function that uses thermodynamic modeling to determine the gas phase composition of a silicic magma chamber.

Arguments

  • composition: Silicic()
  • M_h2o: total mass of water in magma (kg)
  • M_co2: total mass of CO2 in magma (kg)
  • M_tot: total mass of magma (kg)
  • P: Pressure (Pa)
  • T: Temperature (K)
  • V: chamber volume (m³)
  • rho_m: density of the melt (kg/m³)
  • param_IC: An instance of the ParamICFinder composite type containing the parameters for IC_Finder

Returns

A NamedTuple with the following fields:

  • eps_g0: Initial gas fraction of the magma chamber
  • X_co20: Initial mole fraction of CO2 in the gas phase
  • mco2_diss: Total mass of CO2 dissolved in the melt (kg)
  • phase: Integer representing the state of the magma

Details

The function uses a thermodynamic model to find the initial gas fraction (eps_g0) and initial mole fraction of CO2 in the gas phase (X_co20) for a silicic magma chamber. The model assumes that the chamber contains two phases: a liquid melt and a gas phase. The model calculates the saturation state of the magma with respect to CO2, and determines whether the gas phase contains only CO2 or a mixture of CO2 and H2O. If the chamber is in two-phase state, the model returns eps_g0 = 0.0, X_co20 = 0.0, mco2_diss = Total mass of CO2 dissolved in the melt, and phase = 2. If the chamber is in gas or liquid state, the function iteratively solves for eps_g0 and X_co20 using the solve_X_co2 and get_eps_g helper functions until the relative difference between eps_g0 and X_co20 in two consecutive iterations is less than the tolerance Tol, or until the maximum number of iterations max_count is reached.

source
Chamber.a1x_fMethod

This is for a11 and a12 a11: rho, drhodP, V, dVdP a12: rho, drhodT, V, dVdT

source
Chamber.affect!Method
affect!(int, idx, sw::SW{Int8}, param::Param{Float64}, param_saved_var::ParamSaved{Float64}, param_IC_Finder::ParamICFinder{Float64})

Re-initialize the condition when the event happens. This function modifies the current state of the integrator (int.u) when a particular event occurs during the simulation. The function adjusts various parameters based on the current state of the integrator and the custom parameters that were passed in.

Arguments

  • int: The current state of the integrator. It's format is from the DifferentialEquations.jl package
  • idx: The index of the event that caused the function to be called.
  • sw: A custom parameter used to control simulation behavior.
  • param: A custom parameter containing physical constants and other model parameters.
  • param_saved_var: A custom parameter used to store values from the previous time step.
  • param_IC_Finder: A custom parameter used to control the behavior of the IC_Finder function.

The arguments int and idx are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.

source
Chamber.boundary_conditions_newMethod
boundary_conditions_new(P::Float64, T::Float64, V::Float64, rho_m::Float64, rho_x::Float64, c::Float64, sw::SW{Int8}, T_in::Float64, M_h2o::Float64, M_co2::Float64, total_Mass::Float64, param::Param{Float64}, param_saved_var::ParamSaved{Float64})

Arguments

  • P: Pressure (Pa)
  • T: Temperature (K)
  • V: chamber volume (m³)
  • rho_m: density of melt
  • rho_x: density of crystal of magma
  • c: heat of magma
  • sw: eruption/coolingmodule/viscousrelaxation control
  • T_in: Temperature
  • M_h2o: total mess of H2O in the magma
  • M_co2: total mess of CO2 in the magma
  • total_Mass: total mess of magma chamber
source
Chamber.build_co2Method
build_co2(Pw::T, Pc::T, Temp::T, dPwdP::T, dPcdP::T, dPwdXco2::T, dPcdXco2::T)::NamedTuple{(:C_co2, :dC_co2dT, :dC_co2dP, :dC_co2dXco2),NTuple{4,T}} where {T<:Float64}
  • This function is used within the exsolve function.

Returns

A NamedTuple with the following fields:

  • C_co2
  • dC_co2dT
  • dC_co2dP
  • dC_co2dXco2
source
Chamber.build_mdot_inMethod
build_mdot_in(fluxing::Bool, rho_m0::Float64, log_vfr::Float64, P_0::Float64, T_in::Float64)::Float64
  • This function is used within the chamber function.

Returns

  • mdot_in: mass inflow rate
source
Chamber.build_meqMethod
build_meq(composition::Mafic, P::T, Temp::T, X_co2::T)::NamedTuple{(:meq, :dmeqdT, :dmeqdP, :dmeqdXco2),NTuple{4,T}} where {T<:Float64}
  • This function is used within the exsolve function.

Returns

A NamedTuple with the following fields:

  • meq
  • dmeqdT
  • dmeqdP
  • dmeqdXco2
source
Chamber.build_meqMethod
build_meq(composition::Silicic, Pw::T, Pc::T, Temp::T, dPwdP::T, dPcdP::T, dPwdXco2::T, dPcdXco2::T)::NamedTuple{(:meq, :dmeqdT, :dmeqdP, :dmeqdXco2),NTuple{4,T}} where {T<:Float64}
  • This function is used within the exsolve function.

Returns

A NamedTuple with the following fields:

  • meq
  • dmeqdT
  • dmeqdP
  • dmeqdXco2
source
Chamber.build_rho_rcMethod
build_rho_rc(eps_m::T, eps_g::T, eps_x::T, rho_m::T, rho_g::T, rho_x::T, drho_m_dP::T, drho_g_dP::T, drho_x_dP::T, drho_m_dT::T, drho_g_dT::T, drho_x_dT::T, c_x::T, c_m::T, c_g::T, deps_x_dP::T, deps_x_dT::T)::Vector{T} where {T<:Float64}
  • This function is used within the odeChamber function.

Returns

[rho, drho_dP, drho_dT, drho_deps_g, rc, drc_dP, drc_dT]

source
Chamber.chamberFunction
chamber(composition::Union{Silicic,Mafic}, end_time::Float64, log_volume_km3::Float64, InitialConc_H2O::Float64, InitialConc_CO2::Float64, log_vfr::Float64, depth::Float64, output_dirname::String; kwargs...)

Simulate the eruption of a volcano using a model for the frequency of eruptions of upper crustal magma chambers based on Degruyter and Huber (2014).

Arguments

  • composition: The magma composition. Use Silicic() for rhyolite composition (arc magma) or Mafic() for basalt composition (rift).
  • end_time: Maximum magma chamber evolution duration in seconds.
  • log_volume_km3: The initial volume of the chamber in logarithmic scale. The actual initial chamber volume is calculated as 10^(log_volume_km3) in km³.
  • InitialConc_H2O: The initial weight fraction of water in the magma (exsolved + dissolved).
  • InitialConc_CO2: The initial weight fraction of CO₂ in the magma (exsolved + dissolved).
  • log_vfr: Magma recharge rate in km³/yr calculated as 10^(log_vfr).
  • depth: Depth of the magma chamber in meters.
  • output_dirname(optional): Name of the output directory. Defaults to current timestamp.

Keyword Arguments

  • plotfig(optional): (default: true). Generate and plot figures for each result if true.

Returns

A DataFrame containing the solution with columns:

  • time: Simulation timestamps in seconds.
  • P+dP: Pressure in Pa.
  • T: Temperature in K.
  • eps_g: Gas volume fraction.
  • V: Volume of the magma chamber in m³.
  • rho_m: Density of the melt in kg/m³.
  • rho_x: Density of magma crystal in kg/m³.
  • X_CO2: Mole fraction of CO2 in the gas.
  • total_mass: Total mass of magma chamber in kg.
  • total_mass_H2O: Total mass of water in the magma in kg.
  • total_mass_CO2: Total mass of CO₂ in the magma in kg.
  • eps_x: Crystal volume fraction.

Outputs

A directory named after output_dirname or the default value, containing the following files:

  • out.csv: a CSV file containing the solution columns listed above.
  • eruptions.csv, A CSV file containing the datas of eruptions with the following columns: timeoferuption (sec), durationoferuption (sec), masserupted (kg) and volumeerupted (km³).
  • Figures for P+dP(t), T(t), epsg(t), V(t), XCO2(t), total_mass(t).

References

  • W. Degruyter and C. Huber (2014). A model for eruption frequency of upper crustal silicic magma chambers. Earth Planet. Sci. Lett. https://doi.org/10.1016/j.epsl.2014.06.047

Examples

# Run a simulation with silicic magma chamber
 julia> composition = Silicic()
 julia> end_time = 3e9
 julia> log_volume_km3 = 0.2
-julia> InitialConc_H2O = [0.04, 0.045]
-julia> InitialConc_CO2 = [0.001, 0.0012]
+julia> InitialConc_H2O = 0.04
+julia> InitialConc_CO2 = 0.001
 julia> log_vfr = -3.3
 julia> depth = 8e3
 
@@ -14,18 +14,18 @@
 julia> composition = Mafic()
 julia> end_time = 3e9
 julia> log_volume_km3 = 0.2
-julia> InitialConc_H2O = [0.01, 0.012]
+julia> InitialConc_H2O = 0.01
 julia> InitialConc_CO2 = 0.001
 julia> log_vfr = -3.3
-julia> depth = [7e3, 8e3]
+julia> depth = 8e3
 julia> output_dirname = "MyDirname"
 
-julia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth, output_dirname)
source
Chamber.chamberFunction
chamber(composition::Union{Silicic,Mafic}, end_time::Float64, log_volume_km3::Float64, InitialConc_H2O::Float64, InitialConc_CO2::Float64, log_vfr::Float64, depth::Float64, output_dirname::String; kwargs...)

Simulate the eruption of a volcano using a model for the frequency of eruptions of upper crustal magma chambers based on Degruyter and Huber (2014).

Arguments

  • composition: The magma composition. Use Silicic() for rhyolite composition (arc magma) or Mafic() for basalt composition (rift).
  • end_time: Maximum magma chamber evolution duration in seconds.
  • log_volume_km3: The initial volume of the chamber in logarithmic scale. The actual initial chamber volume is calculated as 10^(log_volume_km3) in km³.
  • InitialConc_H2O: The initial weight fraction of water in the magma (exsolved + dissolved).
  • InitialConc_CO2: The initial weight fraction of CO₂ in the magma (exsolved + dissolved).
  • log_vfr: Magma recharge rate in km³/yr calculated as 10^(log_vfr).
  • depth: Depth of the magma chamber in meters.
  • output_dirname(optional): Name of the output directory. Defaults to current timestamp.

Keyword Arguments

  • plotfig(optional): (default: true). Generate and plot figures for each result if true.

Returns

A DataFrame containing the solution with columns:

  • time: Simulation timestamps in seconds.
  • P+dP: Pressure in Pa.
  • T: Temperature in K.
  • eps_g: Gas volume fraction.
  • V: Volume of the magma chamber in m³.
  • rho_m: Density of the melt in kg/m³.
  • rho_x: Density of magma crystal in kg/m³.
  • X_CO2: Mole fraction of CO2 in the gas.
  • total_mass: Total mass of magma chamber in kg.
  • total_mass_H2O: Total mass of water in the magma in kg.
  • total_mass_CO2: Total mass of CO₂ in the magma in kg.
  • eps_x: Crystal volume fraction.

Outputs

A directory named after output_dirname or the default value, containing the following files:

  • out.csv: a CSV file containing the solution columns listed above.
  • eruptions.csv, A CSV file containing the datas of eruptions with the following columns: timeoferuption (sec), durationoferuption (sec), masserupted (kg) and volumeerupted (km³).
  • Figures for P+dP(t), T(t), epsg(t), V(t), XCO2(t), total_mass(t).

References

  • W. Degruyter and C. Huber (2014). A model for eruption frequency of upper crustal silicic magma chambers. Earth Planet. Sci. Lett. https://doi.org/10.1016/j.epsl.2014.06.047

Examples

# Run a simulation with silicic magma chamber
+julia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth, output_dirname)
source
Chamber.chamberFunction
chamber(composition::Union{Silicic,Mafic}, end_time::Float64, log_volume_km3_vector::Union{Float64,Vector{Float64}}, InitialConc_H2O_vector::Union{Float64,Vector{Float64}}, InitialConc_CO2_vector::Union{Float64,Vector{Float64}}, log_vfr_vector::Union{Float64,Vector{Float64}}, depth_vector::Union{Float64,Vector{Float64}}, output_dirname::String; kwargs...)

Simulate the eruption of a volcano using a model for the frequency of eruptions of upper crustal magma chambers based on Degruyter and Huber (2014).

Arguments

  • composition: The magma composition. Use Silicic() for rhyolite composition (arc magma) or Mafic() for basalt composition (rift).
  • end_time: Maximum magma chamber evolution duration in seconds.
  • log_volume_km3: The initial volume of the chamber in logarithmic scale. The actual initial chamber volume is calculated as 10^(log_volume_km3) in km³.
  • InitialConc_H2O: The initial weight fraction of water in the magma (exsolved + dissolved).
  • InitialConc_CO2: The initial weight fraction of CO₂ in the magma (exsolved + dissolved).
  • log_vfr: Magma recharge rate in km³/yr calculated as 10^(log_vfr).
  • depth: Depth of the magma chamber in meters.
  • output_dirname(optional): Name of the output directory. Defaults to current timestamp.

Keyword Arguments

  • plotfig(optional): (default: true). Generate and plot figures for each result if true.

Returns

A DataFrame containing the solution with columns:

  • time: Simulation timestamps in seconds.
  • P+dP: Pressure in Pa.
  • T: Temperature in K.
  • eps_g: Gas volume fraction.
  • V: Volume of the magma chamber in m³.
  • rho_m: Density of the melt in kg/m³.
  • rho_x: Density of magma crystal in kg/m³.
  • X_CO2: Mole fraction of CO2 in the gas.
  • total_mass: Total mass of magma chamber in kg.
  • total_mass_H2O: Total mass of water in the magma in kg.
  • total_mass_CO2: Total mass of CO₂ in the magma in kg.
  • eps_x: Crystal volume fraction.

Outputs

A directory named after output_dirname or the default value, containing the following files:

  • out.csv: a CSV file containing the solution columns listed above.
  • eruptions.csv, A CSV file containing the datas of eruptions with the following columns: timeoferuption (sec), durationoferuption (sec), masserupted (kg) and volumeerupted (km³).
  • Figures for P+dP(t), T(t), epsg(t), V(t), XCO2(t), total_mass(t).

References

  • W. Degruyter and C. Huber (2014). A model for eruption frequency of upper crustal silicic magma chambers. Earth Planet. Sci. Lett. https://doi.org/10.1016/j.epsl.2014.06.047

Examples

# Run a simulation with silicic magma chamber
 julia> composition = Silicic()
 julia> end_time = 3e9
 julia> log_volume_km3 = 0.2
-julia> InitialConc_H2O = 0.04
-julia> InitialConc_CO2 = 0.001
+julia> InitialConc_H2O = [0.04, 0.045]
+julia> InitialConc_CO2 = [0.001, 0.0012]
 julia> log_vfr = -3.3
 julia> depth = 8e3
 
@@ -35,10 +35,10 @@
 julia> composition = Mafic()
 julia> end_time = 3e9
 julia> log_volume_km3 = 0.2
-julia> InitialConc_H2O = 0.01
+julia> InitialConc_H2O = [0.01, 0.012]
 julia> InitialConc_CO2 = 0.001
 julia> log_vfr = -3.3
-julia> depth = 8e3
+julia> depth = [7e3, 8e3]
 julia> output_dirname = "MyDirname"
 
-julia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth, output_dirname)
source
Chamber.check_for_duplicatesMethod
check_for_duplicates(log_volume_km3_vector::Union{Float64,Vector{Float64}}, InitialConc_H2O_vector::Union{Float64,Vector{Float64}}, InitialConc_CO2_vector::Union{Float64,Vector{Float64}}, log_vfr_vector::Union{Float64,Vector{Float64}}, depth_vector::Union{Float64,Vector{Float64}})::Nothing

This function checks if any of the input arrays contain duplicate elements. If duplicates are found, it raises an error indicating which arguments have duplicates.

  • This function is used within the chamber function
source
Chamber.compute_dXdP_dXdTMethod
compute_dXdP_dXdT(u::Float64, param::Param, var::String)::Tuple{Float64,Float64,Float64}
  • This function is used within the odeChamber function.
source
Chamber.crystal_fractionMethod
crystal_fraction(composition::Mafic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::NamedTuple{(:eps_x, :deps_x_dP, :deps_x_dT, :deps_x_deps_g, :deps_x_dmco2_t, :deps_x_dmh2o_t), NTuple{6, Float64}}

Calculate crystal volume fraction and its derivatives in magma at given temperature, pressure, and water and CO2 contents.

Arguments

  • composition: Mafic()
  • T: Temperature (K)
  • P: Pressure (Pa)
  • mH2O: Weight fration of the H2O in magma.
  • mCO2: Weight fration of the CO2 in magma.

Returns

A NamedTuple with the following fields:

  • eps_x: Crystal volume fraction.
  • deps_x_dP: Derivative of eps_x with respect to pressure.
  • deps_x_dT: Derivative of eps_x with respect to temperature.
  • deps_x_deps_g: Derivative of eps_x with respect to gas volume fraction.
  • deps_x_dmco2_t: Derivative of eps_x with respect to CO2 content.
  • deps_x_dmh2o_t: Derivative of eps_x with respect to H2O content.
source
Chamber.crystal_fractionMethod
crystal_fraction(composition::Silicic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::NamedTuple{(:eps_x, :deps_x_dP, :deps_x_dT, :deps_x_deps_g, :deps_x_dmco2_t, :deps_x_dmh2o_t), NTuple{6, Float64}}

Calculate crystal volume fraction and its derivatives in magma at given temperature, pressure, and water and CO2 contents.

Arguments

  • composition: Silicic()
  • T: Temperature (K)
  • P: Pressure (Pa)
  • mH2O: Weight fration of the H2O in magma.
  • mCO2: Weight fration of the CO2 in magma.

Returns

A NamedTuple with the following fields:

  • eps_x: Crystal volume fraction.
  • deps_x_dP: Derivative of eps_x with respect to pressure.
  • deps_x_dT: Derivative of eps_x with respect to temperature.
  • deps_x_deps_g: Derivative of eps_x with respect to gas volume fraction.
  • deps_x_dmco2_t: Derivative of eps_x with respect to CO2 content.
  • deps_x_dmh2o_t: Derivative of eps_x with respect to H2O content.
source
Chamber.crystal_fraction_eps_xMethod
crystal_fraction_eps_x(composition::Mafic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::Float64
  • Calculates crystal volume fraction at given temperature, pressure, and water and CO2 contents.
  • Spetialized version of crystal_fractionthat computeseps_x` only.

Returns

  • eps_x: Crystal volume fraction.
source
Chamber.crystal_fraction_eps_xMethod
crystal_fraction_eps_x(composition::Silicic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::Float64
  • Calculates crystal volume fraction at given temperature, pressure, and water and CO2 contents.
  • Spetialized version of crystal_fraction that computes eps_x only.

Returns

  • eps_x: Crystal volume fraction.
source
Chamber.dM_X_t_dt_fMethod
dM_X_t_dt_f(rho, V, Mdot_v_in, Mdot_v_out, m_h2o, Mdot_in, Mdot_out)

For dM_h2o_t_dt & dM_co2_t_dt

  • MdotXin: Mdot_v_in or Mdot_c_in
  • MdotXout: Mdot_v_out or Mdot_c_out
  • mX: `mh2oorm_co2`
source
Chamber.dX_dxdydzMethod
dX_dxdydz(composition::Union{Silicic,Mafic}, s::String, x::T, y::T, z::T)::NamedTuple{(:X, :dXdx, :dXdy, :dXdz),NTuple{4,T}} where {T<:Float64}
  • This function is used within the parameters_melting_curve function.
  • Calculate value from different parameter sets (# of parameter sets: Silicic: 3, Mafic: 2)

Arguments

  • composition: Silicic() or Mafic()
  • s: String that represents the parameter set to use. For Silicic, s can be "a", "b", or "c". For Mafic, s can be "a" or "b".
  • x: Water (H2O)
  • y: Gas (CO2)
  • z: Pressure (P)

Returns

A NamedTuple with the following fields:

  • X: the calculated value for the given parameter set
  • dXdx: the derivative of X with respect to x
  • dXdy: the derivative of X with respect to y
  • dXdz: the derivative of X with respect to z
source
Chamber.drc_dX_fMethod
drc_dX_f(;eps_x::T, c_x::T, drho_x_dX::T, eps_g::T, c_g::T, drho_g_dX::T, eps_m::T, c_m::T, drho_m_dX::T, rho_x::T, rho_m::T, deps_x_dX::T)::T where {T<:Float64}

Computing the derivatives of the product of density and specific heat for the mixture

  • X: represent P or T
  • This function is used within the build_rho_rc function.

Returns

  • drc_dX: represent drc_dP or drc_dT
source
Chamber.drho_dX_fMethod
drho_dX_f(;eps_m::T, eps_g::T, eps_x::T, drho_m_dX::T, drho_g_dX::T, drho_x_dX::T, rho_x::T, rho_m::T, deps_x_dX::T)::T where {T<:Float64}
  • X: represent P or T
  • This function is used within the build_rho_rc function.

Returns

  • drho_dX: represent drho_dP or drho_dT
source
Chamber.dwater_dxMethod
dwater_dx(composition::Mafic, p::T, t::T, x::T)::T where {T<:Float64}
  • Derivative of Water Partitioning Function with respect to X_CO2
  • This function is used within the exsolve3 function.

Arguments

  • p: pressure (Pa)
  • t: temperature (K)
  • x: The previous mole fraction of CO2 (X_CO2)
source
Chamber.dwater_dxMethod
dwater_dx(composition::Silicic, p::T, t::T, x::T)::T where {T<:Float64}
  • Function for the derivative of water with reference to X_CO2
  • This function is used within the exsolve3 function.

Arguments

  • p: pressure (Pa)
  • t: temperature (K)
  • x: The previous mole fraction of CO2 (X_CO2)
source
Chamber.eos_gMethod
eos_g(P::Float64, T::Float64)::EosG{Float64}

parametrization of redlich kwong taken from Huber et al. 2010

Arguments

  • P: Pressure (Pa)
  • T: Temperature (K)

Returns

An instance of the EosG struct, containing the following fields:

  • rho_g: density of the gas (kg/m³).
  • drho_g_dP: partial derivative of the density with respect to pressure (kg/m³/Pa).
  • drho_g_dT: partial derivative of the density with respect to temperature (kg/m³/K).
source
Chamber.eos_g_rho_gMethod
eos_g_rho_g(P::Float64, T::Float64)::Float64

Spetialized version of eos_g that computes rho_g only.

Arguments

  • P: Pressure (Pa)
  • T: Temperature (K)

Returns

  • rho_g: density of the gas in kg/m³.
source
Chamber.exsolveMethod
exsolve(composition::Mafic, P::Float64, T::Float64, X_co2::Float64)::NamedTuple{(:meq, :dmeqdP, :dmeqdT, :dmeqdXco2, :C_co2, :dC_co2dP, :dC_co2dT, :dC_co2dXco2), NTuple{8, Float64}}

This script uses Liu et al. (2006) to calculate the solubility of water

Arguments

  • composition: Mafic()
  • P: Pressure (Pa)
  • T: Temperature (K)
  • X_co2: mole fraction of CO2 in gas.
source
Chamber.exsolveMethod
exsolve(composition::Silicic, P::Float64, T::Float64, X_co2::Float64)::NamedTuple{(:meq, :dmeqdP, :dmeqdT, :dmeqdXco2, :C_co2, :dC_co2dP, :dC_co2dT, :dC_co2dXco2), NTuple{8, Float64}}

This script uses Liu et al. (2006) to calculate the solubility of water

Arguments

  • composition: Silicic()
  • P: Pressure (Pa)
  • T: Temperature (K)
  • X_co2: mole fraction of CO2 in gas.
source
Chamber.exsolve3Method
exsolve3(composition::Mafic, P::Float64, T::Float64, m_eq::Float64)::NamedTuple{(:C_co2, :X_co2), NTuple{2, Float64}}

Takes pressure, temperature, and amount of water to solve for the concentration of CO2 and X_CO2 using a Newton Raphson scheme

Arguments

  • composition: Mafic()
  • P: pressure (Pa)
  • T: temperature (K)
  • m_eq: amount of water

Returns

A NamedTuple with the following fields:

  • C_co2: The concentration of CO2 in the melt.
  • X_co2: The mole fraction of CO2 in the gas.
source
Chamber.exsolve3Method
exsolve3(composition::Silicic, P::Float64, T::Float64, m_eq::Float64)::NamedTuple{(:C_co2, :X_co2), NTuple{2, Float64}}

Takes pressure, temperature, and amount of water to solve for the concentration of CO2 and X_CO2 using a Newton Raphson scheme

Arguments

  • composition: Silicic()
  • P: pressure (Pa)
  • T: temperature (K)
  • m_eq: amount of water

Returns

A NamedTuple with the following fields:

  • C_co2: The concentration of CO2 in the melt.
  • X_co2: The mole fraction of CO2 in the gas.
source
Chamber.exsolve_meqMethod
exsolve_meq(composition::Mafic, P::Float64, T::Float64, X_co2::Float64)::Float64

Spetialized version of exsolve that computes meq only.

Arguments

  • composition: Mafic()
  • P: Pressure (Pa)
  • T: Temperature (K)
  • X_co2: mole fraction of CO2 in gas.

Returns

  • meq: amount of water
source
Chamber.exsolve_meqMethod
exsolve_meq(composition::Silicic, P::Float64, T::Float64, X_co2::Float64)::Float64

Spetialized version of exsolve that computes meq only.

Arguments

  • composition: Silicic()
  • P: Pressure (Pa)
  • T: Temperature (K)
  • X_co2: mole fraction of CO2 in gas.

Returns

  • meq: amount of water
source
Chamber.find_liqMethod
find_liq(composition::Mafic, water::Float64, co2::Float64, P::Float64, ini_eps_x::Float64)::Float64

Given the weight fractions of H2O and CO2 in magma, and the pressure, finds the temperature at which the magma will crystallize and reach the desired volume fraction of crystals. The function uses the parameters of the melting curve and an error function to estimate the liquidus temperature.

Arguments

  • composition: Mafic()
  • water: Weight fration of the H2O in magma.
  • co2: Weight fration of the CO2 in magma.
  • P: Pressure (Pa)
  • ini_eps_x: The starting volumn fraction of crystal.

Returns

  • Tl: the estimated liquidus temperature (K).
source
Chamber.find_liqMethod
find_liq(composition::Silicic, water::Float64, co2::Float64, P::Float64, ini_eps_x::Float64)::Float64

Given the weight fractions of H2O and CO2 in magma, and the pressure, finds the temperature at which the magma will crystallize and reach the desired volume fraction of crystals. The function uses the parameters of the melting curve and an error function to estimate the liquidus temperature.

Arguments

  • composition: Silicic()
  • water: Weight fration of the H2O in magma.
  • co2: Weight fration of the CO2 in magma.
  • P: Pressure (Pa)
  • ini_eps_x: The starting volumn fraction of crystal.

Returns

  • Tl: the estimated liquidus temperature (K).
source
Chamber.funMethod
fun(x::Float64, P::Float64, T::Float64, eps_g0::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, mm_co2::Float64, mm_h2o::Float64, M_co2::Float64)::Float64
  • This function is used within the solve_X_co2 function to solve X_co20.
source
Chamber.get_eps_gMethod
get_eps_g(composition::Union{Silicic,Mafic}, eps_g_prev::Float64, X_co20::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_h2o::Float64, M_co2::Float64)::NamedTuple{(:eps_g0, :mco2_diss),NTuple{2,Float64}}
  • This function is used within the IC_Finder function to get epsg0 and mco2diss.

Returns

A NamedTuple with the following fields:

  • eps_g0
  • mco2_diss
source
Chamber.get_phaseMethod
get_phase(composition::Union{Silicic,Mafic}, P::Float64, T::Float64, V::Float64, rho_m::Float64, M_h2o::Float64, M_co2::Float64, eps_x0::Float64)::NamedTuple{(:phase, :m_co2_melt),NTuple{2,Float64}}
  • This function is used within the IC_Finder function to determine the initial phase.

Returns

A NamedTuple with the following fields:

  • phase: 2 or 3
  • m_co2_melt
source
Chamber.heat_conduction_chamberCHMethod
heat_conduction_chamberCH(maxn::Int64, a::Float64, c::Float64, dr::Float64, kappa::Float64, rho::Float64, cp::Float64, Tb::Float64, param_sv::ParamSaved{Float64})::Float64

The function calculates the heat conduction within a magma chamber by solving the heat equation in cylindrical coordinates.

Arguments

  • maxn: number of terms
  • a: radius of magma chamber (m)
  • c: radius of outer shell (m)
  • dr: grid spacing for calculating the heat transfer
  • kappa: thermal diffusivity of host rocks (m^2/s)
  • rho: density of the magma (kg/m³)
  • cp: specific heat of magma (J/(kg K))
  • Tb: boundary temperature of the outer shell (K)
  • param_sv: a struct ParamSaved stores the previous results of the function

Returns

  • Q: heat flow rate through the magma chamber (J/s)
source
Chamber.heat_conduction_chamber_profileCHMethod
heat_conduction_chamber_profileCH(maxn::Int64, a::Float64, c::Float64, r::Float64, kappa::Float64, Tb::Float64, param_sv::ParamSaved{Float64})::Float64

Calculates the heat transfer in a magma chamber based on the thermal diffusivity of the host rocks and the temperature profile of the outer shell.

Arguments

  • maxn: number of terms
  • a: radius of magma chamber (m)
  • c: radius of outer shell (m)
  • r: grid spacing of calculate the heat transfer
  • kappa: thermal diffusivity of host rocks
  • Tb: boundary temperature of the outer shell (K)
  • param_sv: a struct ParamSaved stores the previous results of the function

Returns

  • Trt
source
Chamber.ic_phase_conversionMethod
ic_phase_conversion(phase_here::T, composition::Union{Silicic,Mafic}, M_h2o::T, M_co2::T, M_tot::T, P::T, Temp::T, V::T, rho_m::T, param_IC::ParamICFinder{T})::NamedTuple{(:eps_g_temp, :X_co2_temp, :C_co2_temp, :phase),NTuple{4,T}} where {T<:Float64}

This function is used to handle phase conversion by iteratively modifying the max_count or Tol parameters of function IC_Finder until the correct phase is obtained.

  • This function is used within the affect! function.
source
Chamber.mco2_dissolved_satMethod
mco2_dissolved_sat(X::Float64, P::Float64, T::Float64)::Float64
  • This function is used within the solve_X_co2 function

Arguments

  • X: mole fraction of CO2 in gas
  • P: Pressure (Pa)
  • T: Temperature (K)
source
Chamber.meq_waterMethod
meq_water(composition::Mafic, X::Float64, P::Float64, T::Float64)::Float64
  • This function is used within the get_eps_g function

Arguments

  • X: mole fration of H2O in gas
  • P: Pressure (Pa)
  • T: Temperature (K)
source
Chamber.meq_waterMethod
meq_water(composition::Silicic, X::Float64, P::Float64, T::Float64)::Float64
  • This function is used within the get_eps_g function

Arguments

  • X: mole fration of H2O in gas
  • P: Pressure (Pa)
  • T: Temperature (K)
source
Chamber.odeChamberMethod
odeChamber(du::Vector{Float64}, u::Vector{Float64}, params::Tuple{Param{Float64}, ParamSaved{Float64}, SW{Int8}}, t::Float64)
  • Define the ODE equation.
  • Solve the model for eruption frequency of upper crustal magma chambers using an ODE solver.

Arguments

  • du: An array that stores the output of the ODE solver, i.e., the values of the derivatives of the solution u with respect to time t.
  • u: An array that stores the values of the solution at each time step t.
  • p: A tuple that stores the model parameters and some saved variables, which are described in more detail below.
  • t: The time points corresponding to the saved values of the ODE solution.

The arguments du, u, p, and t are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.

Parameters

  • param: A custom parameter containing physical constants and other model parameters.
  • param_saved_var: A custom parameter used to store values from the previous time step.
  • sw: A custom parameter used to control simulation behavior.

Returns

The function modifies du in place to store the values of the derivatives of the solution u with respect to time t.

source
Chamber.parameters_melting_curveMethod
parameters_melting_curve(composition::Mafic, mH2O::Float64, mCO2::Float64, P::Float64)::NamedTuple{(:a, :dadx, :dady, :dadz, :b, :dbdx, :dbdy, :dbdz), NTuple{8, Float64}}
  • This function is used within the find_liq, crystal_fraction, crystal_fraction_eps_x function.

Arguments

  • composition: Mafic()
  • mH2O: Weight fration of the H2O in magma.
  • mCO2: Weight fration of the CO2 in magma.
  • P: Pressure (Pa)
source
Chamber.parameters_melting_curveMethod
parameters_melting_curve(composition::Silicic, mH2O::Float64, mCO2::Float64, P::Float64)::NamedTuple{(:a, :dadx, :dady, :dadz, :b, :dbdx, :dbdy, :dbdz, :c, :dcdx, :dcdy, :dcdz), NTuple{12, Float64}}
  • This function is used within the find_liq, crystal_fraction, crystal_fraction_eps_x function.

Arguments

  • composition: Silicic()
  • mH2O: Weight fration of the H2O in magma.
  • mCO2: Weight fration of the CO2 in magma.
  • P: Pressure (Pa)
source
Chamber.rc_fMethod
rc_f(;rho_x::T, eps_x::T, c_x::T, rho_m::T, eps_m::T, c_m::T, rho_g::T, eps_g::T, c_g::T)::T where {T<:Float64}

Computing the product of density and specific heat

  • This function is used within the build_rho_rc function.

Returns

  • rc: the product of density and specific heat
source
Chamber.record_erupt_endMethod
record_erupt_end(time::T, erupt_saved::EruptSaved{T}, param::Param{T}) where {T<:Float64}

Record duration, mass and volume of eruptions to EruptSaved

  • This function is used within the affect! function.
source
Chamber.record_erupt_startMethod
record_erupt_start(time::T, eps_g::T, eps_x::T, rho_m::T, rho_x::T, rho_g::T, erupt_saved::EruptSaved{T}) where {T<:Float64}

Record time, density of eruptions to EruptSaved

  • This function is used within the affect! function.
source
Chamber.rho_0_fMethod
rho_0_f(eps_g0::Float64, eps_x0::Float64, rho_g0::Float64, rho_m0::Float64, rho_x0::Float64)::Float64
  • This function is used within the chamber function.

Returns

  • rho_0: initial bulk density (kg/m³)
source
Chamber.rho_fMethod
rho_f(;eps_m::T, eps_g::T, eps_x::T, rho_m::T, rho_g::T, rho_x::T)::T where {T<:Float64}
  • This function is used within the build_rho_rc function.

Returns

  • rho: bulk density (kg/m³)
source
Chamber.solve_NRMethod
solve_NR(f, f_prime, errorTol::T, count_max::T, Xc_initial::T)::T where {T<:Float64}
  • Finding mole fraction of CO2 in gas (X_CO2).
  • This function is used within the exsolve3 function.

Arguments

  • f: Water Paritioning Function
  • f_prime: Function for the derivative of water with reference to X_CO2
  • errorTol: error tolerance, the default value is 1e-10
  • count_max: Maximum loop count, the default value is 1e2
  • Xc_initial: initial guess of X_CO2, the dedault value is 1e-2

Returns

  • X_CO2: mole fraction of CO2 in gas
source
Chamber.solve_X_co2Method
solve_X_co2(composition::Mafic, eps_g0::Float64, X_co2_prev::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_co2::Float64, Tol::Float64)::Float64
  • This function is used within the IC_Finder function to solve X_co20.

Returns

  • X_co20
source
Chamber.solve_X_co2Method
solve_X_co2(composition::Silicic, eps_g0::Float64, X_co2_prev::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_co2::Float64, Tol::Float64)::Float64
  • This function is used within the IC_Finder function to solve X_co20.

Returns

  • X_co20
source
Chamber.stopChamber_MTMethod
stopChamber_MT(out, u::Vector{Float64}, t::Float64, int, sw::SW{Int8}, param::Param{Float64})

Define the stopping criteria for an ODE solver that simulates a magma chamber.

Arguments

  • out: An array where the function should save the condition value at the right index. The maximum index of out should be specified in the len property of callback, which allows for a chain of len events, triggering the ith event when out[i] = 0. The function returns the value of out[8] as the last condition. Checking Event Handling and Callback Functions page of DifferentialEquations.jl for more details.
  • u: A vector containing the state of the system at time t.
  • t: The current time of the ODE solver.
  • int: The current state of the integrator. It's format is from the DifferentialEquations.jl package
  • sw: A custom parameter used to control simulation behavior.
  • param: A custom parameter containing physical constants and other model parameters.

The arguments out, u, t, and int are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.

Returns

The out array is modified in-place to contain the condition values at the current state of the system. The function computes several quantities based on the current state of the system and the model parameters, such as the crystal fraction, the maximum amount of exsolved fluid, and the amount of CO2 in the melt. It then uses these values to calculate the condition values to be stored in the out array, as follows:

  • out[1]: the crystal fraction.
  • out[2]: the ratio of crystal fraction to liquid fraction, minus 0.8.
  • out[3]: if an eruption is not occurring, the pressure difference between the lithostatic pressure and the current pressure, minus the critical pressure difference. Otherwise, negative the critical pressure difference.
  • out[4]: if an eruption is occurring, the lithostatic pressure minus the current pressure. Otherwise, negative the critical pressure difference.
  • out[5]: the crystal fraction minus 0.5.
  • out[6]: the difference between the amount of water in the melt and the maximum amount of exsolved fluid.
  • out[7]: negative the difference between the initial lithostatic pressure and the current pressure plus the critical pressure difference.
  • out[8]: the difference between the amount of CO2 in the melt and the saturation concentration.

Note that the out and u arguments are in the format expected by the DifferentialEquations.jl package, and the function is intended to be used as a condition for a callback function.

source
Chamber.waterMethod
water(composition::Silicic, p::T, t::T, x::T, c::T)::T where {T<:Float64}
  • Water Paritioning Function
  • This function is used within the exsolve3 function.

Arguments

  • p: pressure (Pa)
  • t: temperature (K)
  • x: The previous mole fraction of CO2 (X_CO2)
  • c: amount of water
source
Chamber.waterMethod
water(composition::Silicic, p::T, t::T, x::T, c::T)::T where {T<:Float64}
  • Water Paritioning Function
  • This function is used within the exsolve3 function.

Arguments

  • p: pressure (Pa)
  • t: temperature (K)
  • x: The previous mole fraction of CO2 (X_CO2)
  • c: amount of water
source

Index

+julia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth, output_dirname)
source
Chamber.check_for_duplicatesMethod
check_for_duplicates(log_volume_km3_vector::Union{Float64,Vector{Float64}}, InitialConc_H2O_vector::Union{Float64,Vector{Float64}}, InitialConc_CO2_vector::Union{Float64,Vector{Float64}}, log_vfr_vector::Union{Float64,Vector{Float64}}, depth_vector::Union{Float64,Vector{Float64}})::Nothing

This function checks if any of the input arrays contain duplicate elements. If duplicates are found, it raises an error indicating which arguments have duplicates.

  • This function is used within the chamber function
source
Chamber.compute_dXdP_dXdTMethod
compute_dXdP_dXdT(u::Float64, param::Param, var::String)::Tuple{Float64,Float64,Float64}
  • This function is used within the odeChamber function.
source
Chamber.crystal_fractionMethod
crystal_fraction(composition::Mafic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::NamedTuple{(:eps_x, :deps_x_dP, :deps_x_dT, :deps_x_deps_g, :deps_x_dmco2_t, :deps_x_dmh2o_t), NTuple{6, Float64}}

Calculate crystal volume fraction and its derivatives in magma at given temperature, pressure, and water and CO2 contents.

Arguments

  • composition: Mafic()
  • T: Temperature (K)
  • P: Pressure (Pa)
  • mH2O: Weight fration of the H2O in magma.
  • mCO2: Weight fration of the CO2 in magma.

Returns

A NamedTuple with the following fields:

  • eps_x: Crystal volume fraction.
  • deps_x_dP: Derivative of eps_x with respect to pressure.
  • deps_x_dT: Derivative of eps_x with respect to temperature.
  • deps_x_deps_g: Derivative of eps_x with respect to gas volume fraction.
  • deps_x_dmco2_t: Derivative of eps_x with respect to CO2 content.
  • deps_x_dmh2o_t: Derivative of eps_x with respect to H2O content.
source
Chamber.crystal_fractionMethod
crystal_fraction(composition::Silicic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::NamedTuple{(:eps_x, :deps_x_dP, :deps_x_dT, :deps_x_deps_g, :deps_x_dmco2_t, :deps_x_dmh2o_t), NTuple{6, Float64}}

Calculate crystal volume fraction and its derivatives in magma at given temperature, pressure, and water and CO2 contents.

Arguments

  • composition: Silicic()
  • T: Temperature (K)
  • P: Pressure (Pa)
  • mH2O: Weight fration of the H2O in magma.
  • mCO2: Weight fration of the CO2 in magma.

Returns

A NamedTuple with the following fields:

  • eps_x: Crystal volume fraction.
  • deps_x_dP: Derivative of eps_x with respect to pressure.
  • deps_x_dT: Derivative of eps_x with respect to temperature.
  • deps_x_deps_g: Derivative of eps_x with respect to gas volume fraction.
  • deps_x_dmco2_t: Derivative of eps_x with respect to CO2 content.
  • deps_x_dmh2o_t: Derivative of eps_x with respect to H2O content.
source
Chamber.crystal_fraction_eps_xMethod
crystal_fraction_eps_x(composition::Mafic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::Float64
  • Calculates crystal volume fraction at given temperature, pressure, and water and CO2 contents.
  • Spetialized version of crystal_fractionthat computeseps_x` only.

Returns

  • eps_x: Crystal volume fraction.
source
Chamber.crystal_fraction_eps_xMethod
crystal_fraction_eps_x(composition::Silicic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::Float64
  • Calculates crystal volume fraction at given temperature, pressure, and water and CO2 contents.
  • Spetialized version of crystal_fraction that computes eps_x only.

Returns

  • eps_x: Crystal volume fraction.
source
Chamber.dM_X_t_dt_fMethod
dM_X_t_dt_f(rho, V, Mdot_v_in, Mdot_v_out, m_h2o, Mdot_in, Mdot_out)

For dM_h2o_t_dt & dM_co2_t_dt

  • MdotXin: Mdot_v_in or Mdot_c_in
  • MdotXout: Mdot_v_out or Mdot_c_out
  • mX: `mh2oorm_co2`
source
Chamber.dX_dxdydzMethod
dX_dxdydz(composition::Union{Silicic,Mafic}, s::String, x::T, y::T, z::T)::NamedTuple{(:X, :dXdx, :dXdy, :dXdz),NTuple{4,T}} where {T<:Float64}
  • This function is used within the parameters_melting_curve function.
  • Calculate value from different parameter sets (# of parameter sets: Silicic: 3, Mafic: 2)

Arguments

  • composition: Silicic() or Mafic()
  • s: String that represents the parameter set to use. For Silicic, s can be "a", "b", or "c". For Mafic, s can be "a" or "b".
  • x: Water (H2O)
  • y: Gas (CO2)
  • z: Pressure (P)

Returns

A NamedTuple with the following fields:

  • X: the calculated value for the given parameter set
  • dXdx: the derivative of X with respect to x
  • dXdy: the derivative of X with respect to y
  • dXdz: the derivative of X with respect to z
source
Chamber.drc_dX_fMethod
drc_dX_f(;eps_x::T, c_x::T, drho_x_dX::T, eps_g::T, c_g::T, drho_g_dX::T, eps_m::T, c_m::T, drho_m_dX::T, rho_x::T, rho_m::T, deps_x_dX::T)::T where {T<:Float64}

Computing the derivatives of the product of density and specific heat for the mixture

  • X: represent P or T
  • This function is used within the build_rho_rc function.

Returns

  • drc_dX: represent drc_dP or drc_dT
source
Chamber.drho_dX_fMethod
drho_dX_f(;eps_m::T, eps_g::T, eps_x::T, drho_m_dX::T, drho_g_dX::T, drho_x_dX::T, rho_x::T, rho_m::T, deps_x_dX::T)::T where {T<:Float64}
  • X: represent P or T
  • This function is used within the build_rho_rc function.

Returns

  • drho_dX: represent drho_dP or drho_dT
source
Chamber.dwater_dxMethod
dwater_dx(composition::Mafic, p::T, t::T, x::T)::T where {T<:Float64}
  • Derivative of Water Partitioning Function with respect to X_CO2
  • This function is used within the exsolve3 function.

Arguments

  • p: pressure (Pa)
  • t: temperature (K)
  • x: The previous mole fraction of CO2 (X_CO2)
source
Chamber.dwater_dxMethod
dwater_dx(composition::Silicic, p::T, t::T, x::T)::T where {T<:Float64}
  • Function for the derivative of water with reference to X_CO2
  • This function is used within the exsolve3 function.

Arguments

  • p: pressure (Pa)
  • t: temperature (K)
  • x: The previous mole fraction of CO2 (X_CO2)
source
Chamber.eos_gMethod
eos_g(P::Float64, T::Float64)::EosG{Float64}

parametrization of redlich kwong taken from Huber et al. 2010

Arguments

  • P: Pressure (Pa)
  • T: Temperature (K)

Returns

An instance of the EosG struct, containing the following fields:

  • rho_g: density of the gas (kg/m³).
  • drho_g_dP: partial derivative of the density with respect to pressure (kg/m³/Pa).
  • drho_g_dT: partial derivative of the density with respect to temperature (kg/m³/K).
source
Chamber.eos_g_rho_gMethod
eos_g_rho_g(P::Float64, T::Float64)::Float64

Spetialized version of eos_g that computes rho_g only.

Arguments

  • P: Pressure (Pa)
  • T: Temperature (K)

Returns

  • rho_g: density of the gas in kg/m³.
source
Chamber.exsolveMethod
exsolve(composition::Mafic, P::Float64, T::Float64, X_co2::Float64)::NamedTuple{(:meq, :dmeqdP, :dmeqdT, :dmeqdXco2, :C_co2, :dC_co2dP, :dC_co2dT, :dC_co2dXco2), NTuple{8, Float64}}

This script uses Liu et al. (2006) to calculate the solubility of water

Arguments

  • composition: Mafic()
  • P: Pressure (Pa)
  • T: Temperature (K)
  • X_co2: mole fraction of CO2 in gas.
source
Chamber.exsolveMethod
exsolve(composition::Silicic, P::Float64, T::Float64, X_co2::Float64)::NamedTuple{(:meq, :dmeqdP, :dmeqdT, :dmeqdXco2, :C_co2, :dC_co2dP, :dC_co2dT, :dC_co2dXco2), NTuple{8, Float64}}

This script uses Liu et al. (2006) to calculate the solubility of water

Arguments

  • composition: Silicic()
  • P: Pressure (Pa)
  • T: Temperature (K)
  • X_co2: mole fraction of CO2 in gas.
source
Chamber.exsolve3Method
exsolve3(composition::Mafic, P::Float64, T::Float64, m_eq::Float64)::NamedTuple{(:C_co2, :X_co2), NTuple{2, Float64}}

Takes pressure, temperature, and amount of water to solve for the concentration of CO2 and X_CO2 using a Newton Raphson scheme

Arguments

  • composition: Mafic()
  • P: pressure (Pa)
  • T: temperature (K)
  • m_eq: amount of water

Returns

A NamedTuple with the following fields:

  • C_co2: The concentration of CO2 in the melt.
  • X_co2: The mole fraction of CO2 in the gas.
source
Chamber.exsolve3Method
exsolve3(composition::Silicic, P::Float64, T::Float64, m_eq::Float64)::NamedTuple{(:C_co2, :X_co2), NTuple{2, Float64}}

Takes pressure, temperature, and amount of water to solve for the concentration of CO2 and X_CO2 using a Newton Raphson scheme

Arguments

  • composition: Silicic()
  • P: pressure (Pa)
  • T: temperature (K)
  • m_eq: amount of water

Returns

A NamedTuple with the following fields:

  • C_co2: The concentration of CO2 in the melt.
  • X_co2: The mole fraction of CO2 in the gas.
source
Chamber.exsolve_meqMethod
exsolve_meq(composition::Mafic, P::Float64, T::Float64, X_co2::Float64)::Float64

Spetialized version of exsolve that computes meq only.

Arguments

  • composition: Mafic()
  • P: Pressure (Pa)
  • T: Temperature (K)
  • X_co2: mole fraction of CO2 in gas.

Returns

  • meq: amount of water
source
Chamber.exsolve_meqMethod
exsolve_meq(composition::Silicic, P::Float64, T::Float64, X_co2::Float64)::Float64

Spetialized version of exsolve that computes meq only.

Arguments

  • composition: Silicic()
  • P: Pressure (Pa)
  • T: Temperature (K)
  • X_co2: mole fraction of CO2 in gas.

Returns

  • meq: amount of water
source
Chamber.find_liqMethod
find_liq(composition::Mafic, water::Float64, co2::Float64, P::Float64, ini_eps_x::Float64)::Float64

Given the weight fractions of H2O and CO2 in magma, and the pressure, finds the temperature at which the magma will crystallize and reach the desired volume fraction of crystals. The function uses the parameters of the melting curve and an error function to estimate the liquidus temperature.

Arguments

  • composition: Mafic()
  • water: Weight fration of the H2O in magma.
  • co2: Weight fration of the CO2 in magma.
  • P: Pressure (Pa)
  • ini_eps_x: The starting volumn fraction of crystal.

Returns

  • Tl: the estimated liquidus temperature (K).
source
Chamber.find_liqMethod
find_liq(composition::Silicic, water::Float64, co2::Float64, P::Float64, ini_eps_x::Float64)::Float64

Given the weight fractions of H2O and CO2 in magma, and the pressure, finds the temperature at which the magma will crystallize and reach the desired volume fraction of crystals. The function uses the parameters of the melting curve and an error function to estimate the liquidus temperature.

Arguments

  • composition: Silicic()
  • water: Weight fration of the H2O in magma.
  • co2: Weight fration of the CO2 in magma.
  • P: Pressure (Pa)
  • ini_eps_x: The starting volumn fraction of crystal.

Returns

  • Tl: the estimated liquidus temperature (K).
source
Chamber.funMethod
fun(x::Float64, P::Float64, T::Float64, eps_g0::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, mm_co2::Float64, mm_h2o::Float64, M_co2::Float64)::Float64
  • This function is used within the solve_X_co2 function to solve X_co20.
source
Chamber.get_eps_gMethod
get_eps_g(composition::Union{Silicic,Mafic}, eps_g_prev::Float64, X_co20::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_h2o::Float64, M_co2::Float64)::NamedTuple{(:eps_g0, :mco2_diss),NTuple{2,Float64}}
  • This function is used within the IC_Finder function to get epsg0 and mco2diss.

Returns

A NamedTuple with the following fields:

  • eps_g0
  • mco2_diss
source
Chamber.get_phaseMethod
get_phase(composition::Union{Silicic,Mafic}, P::Float64, T::Float64, V::Float64, rho_m::Float64, M_h2o::Float64, M_co2::Float64, eps_x0::Float64)::NamedTuple{(:phase, :m_co2_melt),NTuple{2,Float64}}
  • This function is used within the IC_Finder function to determine the initial phase.

Returns

A NamedTuple with the following fields:

  • phase: 2 or 3
  • m_co2_melt
source
Chamber.heat_conduction_chamberCHMethod
heat_conduction_chamberCH(maxn::Int64, a::Float64, c::Float64, dr::Float64, kappa::Float64, rho::Float64, cp::Float64, Tb::Float64, param_sv::ParamSaved{Float64})::Float64

The function calculates the heat conduction within a magma chamber by solving the heat equation in cylindrical coordinates.

Arguments

  • maxn: number of terms
  • a: radius of magma chamber (m)
  • c: radius of outer shell (m)
  • dr: grid spacing for calculating the heat transfer
  • kappa: thermal diffusivity of host rocks (m^2/s)
  • rho: density of the magma (kg/m³)
  • cp: specific heat of magma (J/(kg K))
  • Tb: boundary temperature of the outer shell (K)
  • param_sv: a struct ParamSaved stores the previous results of the function

Returns

  • Q: heat flow rate through the magma chamber (J/s)
source
Chamber.heat_conduction_chamber_profileCHMethod
heat_conduction_chamber_profileCH(maxn::Int64, a::Float64, c::Float64, r::Float64, kappa::Float64, Tb::Float64, param_sv::ParamSaved{Float64})::Float64

Calculates the heat transfer in a magma chamber based on the thermal diffusivity of the host rocks and the temperature profile of the outer shell.

Arguments

  • maxn: number of terms
  • a: radius of magma chamber (m)
  • c: radius of outer shell (m)
  • r: grid spacing of calculate the heat transfer
  • kappa: thermal diffusivity of host rocks
  • Tb: boundary temperature of the outer shell (K)
  • param_sv: a struct ParamSaved stores the previous results of the function

Returns

  • Trt
source
Chamber.ic_phase_conversionMethod
ic_phase_conversion(phase_here::T, composition::Union{Silicic,Mafic}, M_h2o::T, M_co2::T, M_tot::T, P::T, Temp::T, V::T, rho_m::T, param_IC::ParamICFinder{T})::NamedTuple{(:eps_g_temp, :X_co2_temp, :C_co2_temp, :phase),NTuple{4,T}} where {T<:Float64}

This function is used to handle phase conversion by iteratively modifying the max_count or Tol parameters of function IC_Finder until the correct phase is obtained.

  • This function is used within the affect! function.
source
Chamber.mco2_dissolved_satMethod
mco2_dissolved_sat(X::Float64, P::Float64, T::Float64)::Float64
  • This function is used within the solve_X_co2 function

Arguments

  • X: mole fraction of CO2 in gas
  • P: Pressure (Pa)
  • T: Temperature (K)
source
Chamber.meq_waterMethod
meq_water(composition::Mafic, X::Float64, P::Float64, T::Float64)::Float64
  • This function is used within the get_eps_g function

Arguments

  • X: mole fration of H2O in gas
  • P: Pressure (Pa)
  • T: Temperature (K)
source
Chamber.meq_waterMethod
meq_water(composition::Silicic, X::Float64, P::Float64, T::Float64)::Float64
  • This function is used within the get_eps_g function

Arguments

  • X: mole fration of H2O in gas
  • P: Pressure (Pa)
  • T: Temperature (K)
source
Chamber.odeChamberMethod
odeChamber(du::Vector{Float64}, u::Vector{Float64}, params::Tuple{Param{Float64}, ParamSaved{Float64}, SW{Int8}}, t::Float64)
  • Define the ODE equation.
  • Solve the model for eruption frequency of upper crustal magma chambers using an ODE solver.

Arguments

  • du: An array that stores the output of the ODE solver, i.e., the values of the derivatives of the solution u with respect to time t.
  • u: An array that stores the values of the solution at each time step t.
  • p: A tuple that stores the model parameters and some saved variables, which are described in more detail below.
  • t: The time points corresponding to the saved values of the ODE solution.

The arguments du, u, p, and t are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.

Parameters

  • param: A custom parameter containing physical constants and other model parameters.
  • param_saved_var: A custom parameter used to store values from the previous time step.
  • sw: A custom parameter used to control simulation behavior.

Returns

The function modifies du in place to store the values of the derivatives of the solution u with respect to time t.

source
Chamber.parameters_melting_curveMethod
parameters_melting_curve(composition::Mafic, mH2O::Float64, mCO2::Float64, P::Float64)::NamedTuple{(:a, :dadx, :dady, :dadz, :b, :dbdx, :dbdy, :dbdz), NTuple{8, Float64}}
  • This function is used within the find_liq, crystal_fraction, crystal_fraction_eps_x function.

Arguments

  • composition: Mafic()
  • mH2O: Weight fration of the H2O in magma.
  • mCO2: Weight fration of the CO2 in magma.
  • P: Pressure (Pa)
source
Chamber.parameters_melting_curveMethod
parameters_melting_curve(composition::Silicic, mH2O::Float64, mCO2::Float64, P::Float64)::NamedTuple{(:a, :dadx, :dady, :dadz, :b, :dbdx, :dbdy, :dbdz, :c, :dcdx, :dcdy, :dcdz), NTuple{12, Float64}}
  • This function is used within the find_liq, crystal_fraction, crystal_fraction_eps_x function.

Arguments

  • composition: Silicic()
  • mH2O: Weight fration of the H2O in magma.
  • mCO2: Weight fration of the CO2 in magma.
  • P: Pressure (Pa)
source
Chamber.rc_fMethod
rc_f(;rho_x::T, eps_x::T, c_x::T, rho_m::T, eps_m::T, c_m::T, rho_g::T, eps_g::T, c_g::T)::T where {T<:Float64}

Computing the product of density and specific heat

  • This function is used within the build_rho_rc function.

Returns

  • rc: the product of density and specific heat
source
Chamber.record_erupt_endMethod
record_erupt_end(time::T, erupt_saved::EruptSaved{T}, param::Param{T}) where {T<:Float64}

Record duration, mass and volume of eruptions to EruptSaved

  • This function is used within the affect! function.
source
Chamber.record_erupt_startMethod
record_erupt_start(time::T, eps_g::T, eps_x::T, rho_m::T, rho_x::T, rho_g::T, erupt_saved::EruptSaved{T}) where {T<:Float64}

Record time, density of eruptions to EruptSaved

  • This function is used within the affect! function.
source
Chamber.rho_0_fMethod
rho_0_f(eps_g0::Float64, eps_x0::Float64, rho_g0::Float64, rho_m0::Float64, rho_x0::Float64)::Float64
  • This function is used within the chamber function.

Returns

  • rho_0: initial bulk density (kg/m³)
source
Chamber.rho_fMethod
rho_f(;eps_m::T, eps_g::T, eps_x::T, rho_m::T, rho_g::T, rho_x::T)::T where {T<:Float64}
  • This function is used within the build_rho_rc function.

Returns

  • rho: bulk density (kg/m³)
source
Chamber.solve_NRMethod
solve_NR(f, f_prime, errorTol::T, count_max::T, Xc_initial::T)::T where {T<:Float64}
  • Finding mole fraction of CO2 in gas (X_CO2).
  • This function is used within the exsolve3 function.

Arguments

  • f: Water Paritioning Function
  • f_prime: Function for the derivative of water with reference to X_CO2
  • errorTol: error tolerance, the default value is 1e-10
  • count_max: Maximum loop count, the default value is 1e2
  • Xc_initial: initial guess of X_CO2, the dedault value is 1e-2

Returns

  • X_CO2: mole fraction of CO2 in gas
source
Chamber.solve_X_co2Method
solve_X_co2(composition::Mafic, eps_g0::Float64, X_co2_prev::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_co2::Float64, Tol::Float64)::Float64
  • This function is used within the IC_Finder function to solve X_co20.

Returns

  • X_co20
source
Chamber.solve_X_co2Method
solve_X_co2(composition::Silicic, eps_g0::Float64, X_co2_prev::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_co2::Float64, Tol::Float64)::Float64
  • This function is used within the IC_Finder function to solve X_co20.

Returns

  • X_co20
source
Chamber.stopChamber_MTMethod
stopChamber_MT(out, u::Vector{Float64}, t::Float64, int, sw::SW{Int8}, param::Param{Float64})

Define the stopping criteria for an ODE solver that simulates a magma chamber.

Arguments

  • out: An array where the function should save the condition value at the right index. The maximum index of out should be specified in the len property of callback, which allows for a chain of len events, triggering the ith event when out[i] = 0. The function returns the value of out[8] as the last condition. Checking Event Handling and Callback Functions page of DifferentialEquations.jl for more details.
  • u: A vector containing the state of the system at time t.
  • t: The current time of the ODE solver.
  • int: The current state of the integrator. It's format is from the DifferentialEquations.jl package
  • sw: A custom parameter used to control simulation behavior.
  • param: A custom parameter containing physical constants and other model parameters.

The arguments out, u, t, and int are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.

Returns

The out array is modified in-place to contain the condition values at the current state of the system. The function computes several quantities based on the current state of the system and the model parameters, such as the crystal fraction, the maximum amount of exsolved fluid, and the amount of CO2 in the melt. It then uses these values to calculate the condition values to be stored in the out array, as follows:

  • out[1]: the crystal fraction.
  • out[2]: the ratio of crystal fraction to liquid fraction, minus 0.8.
  • out[3]: if an eruption is not occurring, the pressure difference between the lithostatic pressure and the current pressure, minus the critical pressure difference. Otherwise, negative the critical pressure difference.
  • out[4]: if an eruption is occurring, the lithostatic pressure minus the current pressure. Otherwise, negative the critical pressure difference.
  • out[5]: the crystal fraction minus 0.5.
  • out[6]: the difference between the amount of water in the melt and the maximum amount of exsolved fluid.
  • out[7]: negative the difference between the initial lithostatic pressure and the current pressure plus the critical pressure difference.
  • out[8]: the difference between the amount of CO2 in the melt and the saturation concentration.

Note that the out and u arguments are in the format expected by the DifferentialEquations.jl package, and the function is intended to be used as a condition for a callback function.

source
Chamber.waterMethod
water(composition::Silicic, p::T, t::T, x::T, c::T)::T where {T<:Float64}
  • Water Paritioning Function
  • This function is used within the exsolve3 function.

Arguments

  • p: pressure (Pa)
  • t: temperature (K)
  • x: The previous mole fraction of CO2 (X_CO2)
  • c: amount of water
source
Chamber.waterMethod
water(composition::Silicic, p::T, t::T, x::T, c::T)::T where {T<:Float64}
  • Water Paritioning Function
  • This function is used within the exsolve3 function.

Arguments

  • p: pressure (Pa)
  • t: temperature (K)
  • x: The previous mole fraction of CO2 (X_CO2)
  • c: amount of water
source

Index

diff --git a/previews/PR264/search/index.html b/previews/PR264/search/index.html index bc819fe..eff2812 100644 --- a/previews/PR264/search/index.html +++ b/previews/PR264/search/index.html @@ -1,2 +1,2 @@ -Search · Chamber.jl

Loading search...

    +Search · Chamber.jl

    Loading search...

      diff --git a/previews/PR264/search_index.js b/previews/PR264/search_index.js index 6bdd55a..10d0355 100644 --- a/previews/PR264/search_index.js +++ b/previews/PR264/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"#Chamber.jl","page":"Chamber.jl","title":"Chamber.jl","text":"","category":"section"},{"location":"","page":"Chamber.jl","title":"Chamber.jl","text":"This is the API documentation for Chamber.jl. See the package's README for instructions about general usage.","category":"page"},{"location":"#Functions","page":"Chamber.jl","title":"Functions","text":"","category":"section"},{"location":"","page":"Chamber.jl","title":"Chamber.jl","text":"Modules = [Chamber]\nOrder = [:function, :macro, :type]","category":"page"},{"location":"#Chamber.IC_Finder-Union{Tuple{T}, Tuple{Mafic, T, T, T, T, T, T, T, ParamICFinder{T}}} where T<:Float64","page":"Chamber.jl","title":"Chamber.IC_Finder","text":"IC_Finder(composition::Mafic, M_h2o::Float64, M_co2::Float64, M_tot::Float64, P::Float64, T::Float64, V::Float64, rho_m::Float64, param_IC::ParamICFinder{Float64})::NamedTuple{(:eps_g0, :X_co20, :mco2_diss, :phase),NTuple{4,Float64}}\n\nAn iterative function that uses thermodynamic modeling to determine the gas phase composition of a mafic magma chamber.\n\nArguments\n\ncomposition: Mafic()\nM_h2o: total mass of water in magma (kg)\nM_co2: total mass of CO2 in magma (kg)\nM_tot: total mass of magma (kg)\nP: Pressure (Pa)\nT: Temperature (K)\nV: chamber volume (m³)\nrho_m: density of the melt (kg/m³)\nparam_IC: An instance of the ParamICFinder composite type containing the parameters for IC_Finder\n\nReturns\n\nA NamedTuple with the following fields:\n\neps_g0: Initial gas fraction of the magma chamber\nX_co20: Initial mole fraction of CO2 in the gas phase\nmco2_diss: Total mass of CO2 dissolved in the melt (kg)\nphase: Integer representing the state of the magma\n\nDetails\n\nThe function uses a thermodynamic model to find the initial gas fraction (eps_g0) and initial mole fraction of CO2 in the gas phase (X_co20) for a mafic magma chamber. The model assumes that the chamber contains two phases: a liquid melt and a gas phase. The model calculates the saturation state of the magma with respect to CO2, and determines whether the gas phase contains only CO2 or a mixture of CO2 and H2O. If the chamber is in two-phase state, the model returns eps_g0 = 0.0, X_co20 = 0.0, mco2_diss = Total mass of CO2 dissolved in the melt, and phase = 2. If the chamber is in gas or liquid state, the function iteratively solves for eps_g0 and X_co20 using the solve_X_co2 and get_eps_g helper functions until the relative difference between eps_g0 and X_co20 in two consecutive iterations is less than the tolerance Tol, or until the maximum number of iterations max_count is reached. \n\n\n\n\n\n","category":"method"},{"location":"#Chamber.IC_Finder-Union{Tuple{T}, Tuple{Silicic, T, T, T, T, T, T, T, ParamICFinder{T}}} where T<:Float64","page":"Chamber.jl","title":"Chamber.IC_Finder","text":"IC_Finder(composition::Silicic, M_h2o::Float64, M_co2::Float64, M_tot::Float64, P::Float64, T::Float64, V::Float64, rho_m::Float64, param_IC::ParamICFinder{Float64})::NamedTuple{(:eps_g0, :X_co20, :mco2_diss, :phase),NTuple{4,Float64}}\n\nAn iterative function that uses thermodynamic modeling to determine the gas phase composition of a silicic magma chamber.\n\nArguments\n\ncomposition: Silicic()\nM_h2o: total mass of water in magma (kg)\nM_co2: total mass of CO2 in magma (kg)\nM_tot: total mass of magma (kg)\nP: Pressure (Pa)\nT: Temperature (K)\nV: chamber volume (m³)\nrho_m: density of the melt (kg/m³)\nparam_IC: An instance of the ParamICFinder composite type containing the parameters for IC_Finder\n\nReturns\n\nA NamedTuple with the following fields:\n\neps_g0: Initial gas fraction of the magma chamber\nX_co20: Initial mole fraction of CO2 in the gas phase\nmco2_diss: Total mass of CO2 dissolved in the melt (kg)\nphase: Integer representing the state of the magma\n\nDetails\n\nThe function uses a thermodynamic model to find the initial gas fraction (eps_g0) and initial mole fraction of CO2 in the gas phase (X_co20) for a silicic magma chamber. The model assumes that the chamber contains two phases: a liquid melt and a gas phase. The model calculates the saturation state of the magma with respect to CO2, and determines whether the gas phase contains only CO2 or a mixture of CO2 and H2O. If the chamber is in two-phase state, the model returns eps_g0 = 0.0, X_co20 = 0.0, mco2_diss = Total mass of CO2 dissolved in the melt, and phase = 2. If the chamber is in gas or liquid state, the function iteratively solves for eps_g0 and X_co20 using the solve_X_co2 and get_eps_g helper functions until the relative difference between eps_g0 and X_co20 in two consecutive iterations is less than the tolerance Tol, or until the maximum number of iterations max_count is reached. \n\n\n\n\n\n","category":"method"},{"location":"#Chamber.a1x_f-Union{Tuple{T}, NTuple{4, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.a1x_f","text":"This is for a11 and a12 a11: rho, drhodP, V, dVdP a12: rho, drhodT, V, dVdT\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.affect!-Tuple{Any, Any, SW{Int8}, Param{Float64}, ParamSaved{Float64}, ParamICFinder{Float64}, EruptSaved{Float64}}","page":"Chamber.jl","title":"Chamber.affect!","text":"affect!(int, idx, sw::SW{Int8}, param::Param{Float64}, param_saved_var::ParamSaved{Float64}, param_IC_Finder::ParamICFinder{Float64})\n\nRe-initialize the condition when the event happens. This function modifies the current state of the integrator (int.u) when a particular event occurs during the simulation. The function adjusts various parameters based on the current state of the integrator and the custom parameters that were passed in.\n\nArguments\n\nint: The current state of the integrator. It's format is from the DifferentialEquations.jl package\nidx: The index of the event that caused the function to be called.\nsw: A custom parameter used to control simulation behavior.\nparam: A custom parameter containing physical constants and other model parameters.\nparam_saved_var: A custom parameter used to store values from the previous time step.\nparam_IC_Finder: A custom parameter used to control the behavior of the IC_Finder function.\n\nThe arguments int and idx are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.boundary_conditions_new-Tuple{Float64, Float64, Float64, Float64, Float64, Float64, SW{Int8}, Float64, Float64, Float64, Float64, Param{Float64}, ParamSaved{Float64}}","page":"Chamber.jl","title":"Chamber.boundary_conditions_new","text":"boundary_conditions_new(P::Float64, T::Float64, V::Float64, rho_m::Float64, rho_x::Float64, c::Float64, sw::SW{Int8}, T_in::Float64, M_h2o::Float64, M_co2::Float64, total_Mass::Float64, param::Param{Float64}, param_saved_var::ParamSaved{Float64})\n\nArguments\n\nP: Pressure (Pa)\nT: Temperature (K)\nV: chamber volume (m³)\nrho_m: density of melt\nrho_x: density of crystal of magma\nc: heat of magma\nsw: eruption/coolingmodule/viscousrelaxation control\nT_in: Temperature\nM_h2o: total mess of H2O in the magma\nM_co2: total mess of CO2 in the magma\ntotal_Mass: total mess of magma chamber\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.build_co2-Union{Tuple{T}, NTuple{7, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.build_co2","text":"build_co2(Pw::T, Pc::T, Temp::T, dPwdP::T, dPcdP::T, dPwdXco2::T, dPcdXco2::T)::NamedTuple{(:C_co2, :dC_co2dT, :dC_co2dP, :dC_co2dXco2),NTuple{4,T}} where {T<:Float64}\n\nThis function is used within the exsolve function.\n\nReturns\n\nA NamedTuple with the following fields:\n\nC_co2\ndC_co2dT\ndC_co2dP\ndC_co2dXco2\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.build_mdot_in-Tuple{Bool, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.build_mdot_in","text":"build_mdot_in(fluxing::Bool, rho_m0::Float64, log_vfr::Float64, P_0::Float64, T_in::Float64)::Float64\n\nThis function is used within the chamber function.\n\nReturns\n\nmdot_in: mass inflow rate\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.build_meq-Union{Tuple{T}, Tuple{Mafic, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.build_meq","text":"build_meq(composition::Mafic, P::T, Temp::T, X_co2::T)::NamedTuple{(:meq, :dmeqdT, :dmeqdP, :dmeqdXco2),NTuple{4,T}} where {T<:Float64}\n\nThis function is used within the exsolve function.\n\nReturns\n\nA NamedTuple with the following fields:\n\nmeq\ndmeqdT\ndmeqdP\ndmeqdXco2\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.build_meq-Union{Tuple{T}, Tuple{Silicic, T, T, T, T, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.build_meq","text":"build_meq(composition::Silicic, Pw::T, Pc::T, Temp::T, dPwdP::T, dPcdP::T, dPwdXco2::T, dPcdXco2::T)::NamedTuple{(:meq, :dmeqdT, :dmeqdP, :dmeqdXco2),NTuple{4,T}} where {T<:Float64}\n\nThis function is used within the exsolve function.\n\nReturns\n\nA NamedTuple with the following fields:\n\nmeq\ndmeqdT\ndmeqdP\ndmeqdXco2\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.build_rho_rc-Union{Tuple{T}, NTuple{17, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.build_rho_rc","text":"build_rho_rc(eps_m::T, eps_g::T, eps_x::T, rho_m::T, rho_g::T, rho_x::T, drho_m_dP::T, drho_g_dP::T, drho_x_dP::T, drho_m_dT::T, drho_g_dT::T, drho_x_dT::T, c_x::T, c_m::T, c_g::T, deps_x_dP::T, deps_x_dT::T)::Vector{T} where {T<:Float64}\n\nThis function is used within the odeChamber function.\n\nReturns\n\n[rho, drho_dP, drho_dT, drho_deps_g, rc, drc_dP, drc_dT]\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.chamber","page":"Chamber.jl","title":"Chamber.chamber","text":"chamber(composition::Union{Silicic,Mafic}, end_time::Float64, log_volume_km3_vector::Union{Float64,Vector{Float64}}, InitialConc_H2O_vector::Union{Float64,Vector{Float64}}, InitialConc_CO2_vector::Union{Float64,Vector{Float64}}, log_vfr_vector::Union{Float64,Vector{Float64}}, depth_vector::Union{Float64,Vector{Float64}}, output_dirname::String; kwargs...)\n\nSimulate the eruption of a volcano using a model for the frequency of eruptions of upper crustal magma chambers based on Degruyter and Huber (2014).\n\nArguments\n\ncomposition: The magma composition. Use Silicic() for rhyolite composition (arc magma) or Mafic() for basalt composition (rift).\nend_time: Maximum magma chamber evolution duration in seconds.\nlog_volume_km3: The initial volume of the chamber in logarithmic scale. The actual initial chamber volume is calculated as 10^(log_volume_km3) in km³.\nInitialConc_H2O: The initial weight fraction of water in the magma (exsolved + dissolved).\nInitialConc_CO2: The initial weight fraction of CO₂ in the magma (exsolved + dissolved).\nlog_vfr: Magma recharge rate in km³/yr calculated as 10^(log_vfr).\ndepth: Depth of the magma chamber in meters.\noutput_dirname(optional): Name of the output directory. Defaults to current timestamp.\n\nKeyword Arguments\n\nplotfig(optional): (default: true). Generate and plot figures for each result if true.\n\nReturns\n\nA DataFrame containing the solution with columns:\n\ntime: Simulation timestamps in seconds.\nP+dP: Pressure in Pa.\nT: Temperature in K.\neps_g: Gas volume fraction.\nV: Volume of the magma chamber in m³.\nrho_m: Density of the melt in kg/m³.\nrho_x: Density of magma crystal in kg/m³.\nX_CO2: Mole fraction of CO2 in the gas.\ntotal_mass: Total mass of magma chamber in kg.\ntotal_mass_H2O: Total mass of water in the magma in kg.\ntotal_mass_CO2: Total mass of CO₂ in the magma in kg.\neps_x: Crystal volume fraction.\n\nOutputs\n\nA directory named after output_dirname or the default value, containing the following files:\n\nout.csv: a CSV file containing the solution columns listed above.\neruptions.csv, A CSV file containing the datas of eruptions with the following columns: timeoferuption (sec), durationoferuption (sec), masserupted (kg) and volumeerupted (km³).\nFigures for P+dP(t), T(t), epsg(t), V(t), XCO2(t), total_mass(t).\n\nReferences\n\nW. Degruyter and C. Huber (2014). A model for eruption frequency of upper crustal silicic magma chambers. Earth Planet. Sci. Lett. https://doi.org/10.1016/j.epsl.2014.06.047\n\nExamples\n\n# Run a simulation with silicic magma chamber\njulia> composition = Silicic()\njulia> end_time = 3e9\njulia> log_volume_km3 = 0.2\njulia> InitialConc_H2O = [0.04, 0.045]\njulia> InitialConc_CO2 = [0.001, 0.0012]\njulia> log_vfr = -3.3\njulia> depth = 8e3\n\njulia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth)\n\n# Run a simulation with mafic magma chamber, with custom directory name \"MyDirname\"\njulia> composition = Mafic()\njulia> end_time = 3e9\njulia> log_volume_km3 = 0.2\njulia> InitialConc_H2O = [0.01, 0.012]\njulia> InitialConc_CO2 = 0.001\njulia> log_vfr = -3.3\njulia> depth = [7e3, 8e3]\njulia> output_dirname = \"MyDirname\"\n\njulia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth, output_dirname)\n\n\n\n\n\n","category":"function"},{"location":"#Chamber.chamber-2","page":"Chamber.jl","title":"Chamber.chamber","text":"chamber(composition::Union{Silicic,Mafic}, end_time::Float64, log_volume_km3::Float64, InitialConc_H2O::Float64, InitialConc_CO2::Float64, log_vfr::Float64, depth::Float64, output_dirname::String; kwargs...)\n\nSimulate the eruption of a volcano using a model for the frequency of eruptions of upper crustal magma chambers based on Degruyter and Huber (2014).\n\nArguments\n\ncomposition: The magma composition. Use Silicic() for rhyolite composition (arc magma) or Mafic() for basalt composition (rift).\nend_time: Maximum magma chamber evolution duration in seconds.\nlog_volume_km3: The initial volume of the chamber in logarithmic scale. The actual initial chamber volume is calculated as 10^(log_volume_km3) in km³.\nInitialConc_H2O: The initial weight fraction of water in the magma (exsolved + dissolved).\nInitialConc_CO2: The initial weight fraction of CO₂ in the magma (exsolved + dissolved).\nlog_vfr: Magma recharge rate in km³/yr calculated as 10^(log_vfr).\ndepth: Depth of the magma chamber in meters.\noutput_dirname(optional): Name of the output directory. Defaults to current timestamp.\n\nKeyword Arguments\n\nplotfig(optional): (default: true). Generate and plot figures for each result if true.\n\nReturns\n\nA DataFrame containing the solution with columns:\n\ntime: Simulation timestamps in seconds.\nP+dP: Pressure in Pa.\nT: Temperature in K.\neps_g: Gas volume fraction.\nV: Volume of the magma chamber in m³.\nrho_m: Density of the melt in kg/m³.\nrho_x: Density of magma crystal in kg/m³.\nX_CO2: Mole fraction of CO2 in the gas.\ntotal_mass: Total mass of magma chamber in kg.\ntotal_mass_H2O: Total mass of water in the magma in kg.\ntotal_mass_CO2: Total mass of CO₂ in the magma in kg.\neps_x: Crystal volume fraction.\n\nOutputs\n\nA directory named after output_dirname or the default value, containing the following files:\n\nout.csv: a CSV file containing the solution columns listed above.\neruptions.csv, A CSV file containing the datas of eruptions with the following columns: timeoferuption (sec), durationoferuption (sec), masserupted (kg) and volumeerupted (km³).\nFigures for P+dP(t), T(t), epsg(t), V(t), XCO2(t), total_mass(t).\n\nReferences\n\nW. Degruyter and C. Huber (2014). A model for eruption frequency of upper crustal silicic magma chambers. Earth Planet. Sci. Lett. https://doi.org/10.1016/j.epsl.2014.06.047\n\nExamples\n\n# Run a simulation with silicic magma chamber\njulia> composition = Silicic()\njulia> end_time = 3e9\njulia> log_volume_km3 = 0.2\njulia> InitialConc_H2O = 0.04\njulia> InitialConc_CO2 = 0.001\njulia> log_vfr = -3.3\njulia> depth = 8e3\n\njulia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth)\n\n# Run a simulation with mafic magma chamber, with custom directory name \"MyDirname\"\njulia> composition = Mafic()\njulia> end_time = 3e9\njulia> log_volume_km3 = 0.2\njulia> InitialConc_H2O = 0.01\njulia> InitialConc_CO2 = 0.001\njulia> log_vfr = -3.3\njulia> depth = 8e3\njulia> output_dirname = \"MyDirname\"\n\njulia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth, output_dirname)\n\n\n\n\n\n","category":"function"},{"location":"#Chamber.check_for_duplicates-NTuple{5, Union{Float64, Vector{Float64}}}","page":"Chamber.jl","title":"Chamber.check_for_duplicates","text":"check_for_duplicates(log_volume_km3_vector::Union{Float64,Vector{Float64}}, InitialConc_H2O_vector::Union{Float64,Vector{Float64}}, InitialConc_CO2_vector::Union{Float64,Vector{Float64}}, log_vfr_vector::Union{Float64,Vector{Float64}}, depth_vector::Union{Float64,Vector{Float64}})::Nothing\n\nThis function checks if any of the input arrays contain duplicate elements. If duplicates are found, it raises an error indicating which arguments have duplicates.\n\nThis function is used within the chamber function\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.compute_dXdP_dXdT-Tuple{Float64, Param, String}","page":"Chamber.jl","title":"Chamber.compute_dXdP_dXdT","text":"compute_dXdP_dXdT(u::Float64, param::Param, var::String)::Tuple{Float64,Float64,Float64}\n\nThis function is used within the odeChamber function.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.crystal_fraction-Tuple{Mafic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.crystal_fraction","text":"crystal_fraction(composition::Mafic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::NamedTuple{(:eps_x, :deps_x_dP, :deps_x_dT, :deps_x_deps_g, :deps_x_dmco2_t, :deps_x_dmh2o_t), NTuple{6, Float64}}\n\nCalculate crystal volume fraction and its derivatives in magma at given temperature, pressure, and water and CO2 contents.\n\nArguments\n\ncomposition: Mafic()\nT: Temperature (K)\nP: Pressure (Pa)\nmH2O: Weight fration of the H2O in magma.\nmCO2: Weight fration of the CO2 in magma.\n\nReturns\n\nA NamedTuple with the following fields:\n\neps_x: Crystal volume fraction.\ndeps_x_dP: Derivative of eps_x with respect to pressure.\ndeps_x_dT: Derivative of eps_x with respect to temperature.\ndeps_x_deps_g: Derivative of eps_x with respect to gas volume fraction.\ndeps_x_dmco2_t: Derivative of eps_x with respect to CO2 content.\ndeps_x_dmh2o_t: Derivative of eps_x with respect to H2O content.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.crystal_fraction-Tuple{Silicic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.crystal_fraction","text":"crystal_fraction(composition::Silicic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::NamedTuple{(:eps_x, :deps_x_dP, :deps_x_dT, :deps_x_deps_g, :deps_x_dmco2_t, :deps_x_dmh2o_t), NTuple{6, Float64}}\n\nCalculate crystal volume fraction and its derivatives in magma at given temperature, pressure, and water and CO2 contents.\n\nArguments\n\ncomposition: Silicic()\nT: Temperature (K)\nP: Pressure (Pa)\nmH2O: Weight fration of the H2O in magma.\nmCO2: Weight fration of the CO2 in magma.\n\nReturns\n\nA NamedTuple with the following fields:\n\neps_x: Crystal volume fraction.\ndeps_x_dP: Derivative of eps_x with respect to pressure.\ndeps_x_dT: Derivative of eps_x with respect to temperature.\ndeps_x_deps_g: Derivative of eps_x with respect to gas volume fraction.\ndeps_x_dmco2_t: Derivative of eps_x with respect to CO2 content.\ndeps_x_dmh2o_t: Derivative of eps_x with respect to H2O content.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.crystal_fraction_eps_x-Tuple{Mafic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.crystal_fraction_eps_x","text":"crystal_fraction_eps_x(composition::Mafic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::Float64\n\nCalculates crystal volume fraction at given temperature, pressure, and water and CO2 contents.\nSpetialized version of crystal_fractionthat computeseps_x` only.\n\nReturns\n\neps_x: Crystal volume fraction.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.crystal_fraction_eps_x-Tuple{Silicic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.crystal_fraction_eps_x","text":"crystal_fraction_eps_x(composition::Silicic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::Float64\n\nCalculates crystal volume fraction at given temperature, pressure, and water and CO2 contents.\nSpetialized version of crystal_fraction that computes eps_x only.\n\nReturns\n\neps_x: Crystal volume fraction.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.dM_X_t_dt_f-Union{Tuple{T}, NTuple{7, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.dM_X_t_dt_f","text":"dM_X_t_dt_f(rho, V, Mdot_v_in, Mdot_v_out, m_h2o, Mdot_in, Mdot_out)\n\nFor dM_h2o_t_dt & dM_co2_t_dt\n\nMdotXin: Mdot_v_in or Mdot_c_in\nMdotXout: Mdot_v_out or Mdot_c_out\nmX: `mh2oorm_co2`\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.dX_dxdydz-Union{Tuple{T}, Tuple{Union{Mafic, Silicic}, String, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.dX_dxdydz","text":"dX_dxdydz(composition::Union{Silicic,Mafic}, s::String, x::T, y::T, z::T)::NamedTuple{(:X, :dXdx, :dXdy, :dXdz),NTuple{4,T}} where {T<:Float64}\n\nThis function is used within the parameters_melting_curve function.\nCalculate value from different parameter sets (# of parameter sets: Silicic: 3, Mafic: 2)\n\nArguments\n\ncomposition: Silicic() or Mafic()\ns: String that represents the parameter set to use. For Silicic, s can be \"a\", \"b\", or \"c\". For Mafic, s can be \"a\" or \"b\".\nx: Water (H2O)\ny: Gas (CO2)\nz: Pressure (P)\n\nReturns\n\nA NamedTuple with the following fields:\n\nX: the calculated value for the given parameter set\ndXdx: the derivative of X with respect to x\ndXdy: the derivative of X with respect to y\ndXdz: the derivative of X with respect to z\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.drc_dX_f-Union{Tuple{}, Tuple{T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.drc_dX_f","text":"drc_dX_f(;eps_x::T, c_x::T, drho_x_dX::T, eps_g::T, c_g::T, drho_g_dX::T, eps_m::T, c_m::T, drho_m_dX::T, rho_x::T, rho_m::T, deps_x_dX::T)::T where {T<:Float64}\n\nComputing the derivatives of the product of density and specific heat for the mixture\n\nX: represent P or T\nThis function is used within the build_rho_rc function.\n\nReturns\n\ndrc_dX: represent drc_dP or drc_dT\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.drho_dX_f-Union{Tuple{}, Tuple{T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.drho_dX_f","text":"drho_dX_f(;eps_m::T, eps_g::T, eps_x::T, drho_m_dX::T, drho_g_dX::T, drho_x_dX::T, rho_x::T, rho_m::T, deps_x_dX::T)::T where {T<:Float64}\n\nX: represent P or T\nThis function is used within the build_rho_rc function.\n\nReturns\n\ndrho_dX: represent drho_dP or drho_dT\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.dwater_dx-Union{Tuple{T}, Tuple{Mafic, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.dwater_dx","text":"dwater_dx(composition::Mafic, p::T, t::T, x::T)::T where {T<:Float64}\n\nDerivative of Water Partitioning Function with respect to X_CO2\nThis function is used within the exsolve3 function.\n\nArguments\n\np: pressure (Pa)\nt: temperature (K)\nx: The previous mole fraction of CO2 (X_CO2)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.dwater_dx-Union{Tuple{T}, Tuple{Silicic, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.dwater_dx","text":"dwater_dx(composition::Silicic, p::T, t::T, x::T)::T where {T<:Float64}\n\nFunction for the derivative of water with reference to X_CO2\nThis function is used within the exsolve3 function.\n\nArguments\n\np: pressure (Pa)\nt: temperature (K)\nx: The previous mole fraction of CO2 (X_CO2)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.eos_g-Tuple{Float64, Float64}","page":"Chamber.jl","title":"Chamber.eos_g","text":"eos_g(P::Float64, T::Float64)::EosG{Float64}\n\nparametrization of redlich kwong taken from Huber et al. 2010\n\nArguments\n\nP: Pressure (Pa)\nT: Temperature (K)\n\nReturns\n\nAn instance of the EosG struct, containing the following fields:\n\nrho_g: density of the gas (kg/m³).\ndrho_g_dP: partial derivative of the density with respect to pressure (kg/m³/Pa).\ndrho_g_dT: partial derivative of the density with respect to temperature (kg/m³/K).\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.eos_g_rho_g-Tuple{Float64, Float64}","page":"Chamber.jl","title":"Chamber.eos_g_rho_g","text":"eos_g_rho_g(P::Float64, T::Float64)::Float64\n\nSpetialized version of eos_g that computes rho_g only.\n\nArguments\n\nP: Pressure (Pa)\nT: Temperature (K)\n\nReturns\n\nrho_g: density of the gas in kg/m³.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve-Tuple{Mafic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve","text":"exsolve(composition::Mafic, P::Float64, T::Float64, X_co2::Float64)::NamedTuple{(:meq, :dmeqdP, :dmeqdT, :dmeqdXco2, :C_co2, :dC_co2dP, :dC_co2dT, :dC_co2dXco2), NTuple{8, Float64}}\n\nThis script uses Liu et al. (2006) to calculate the solubility of water\n\nArguments\n\ncomposition: Mafic()\nP: Pressure (Pa)\nT: Temperature (K)\nX_co2: mole fraction of CO2 in gas.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve-Tuple{Silicic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve","text":"exsolve(composition::Silicic, P::Float64, T::Float64, X_co2::Float64)::NamedTuple{(:meq, :dmeqdP, :dmeqdT, :dmeqdXco2, :C_co2, :dC_co2dP, :dC_co2dT, :dC_co2dXco2), NTuple{8, Float64}}\n\nThis script uses Liu et al. (2006) to calculate the solubility of water\n\nArguments\n\ncomposition: Silicic()\nP: Pressure (Pa)\nT: Temperature (K)\nX_co2: mole fraction of CO2 in gas.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve3-Tuple{Mafic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve3","text":"exsolve3(composition::Mafic, P::Float64, T::Float64, m_eq::Float64)::NamedTuple{(:C_co2, :X_co2), NTuple{2, Float64}}\n\nTakes pressure, temperature, and amount of water to solve for the concentration of CO2 and X_CO2 using a Newton Raphson scheme\n\nArguments\n\ncomposition: Mafic()\nP: pressure (Pa)\nT: temperature (K)\nm_eq: amount of water\n\nReturns\n\nA NamedTuple with the following fields:\n\nC_co2: The concentration of CO2 in the melt.\nX_co2: The mole fraction of CO2 in the gas.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve3-Tuple{Silicic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve3","text":"exsolve3(composition::Silicic, P::Float64, T::Float64, m_eq::Float64)::NamedTuple{(:C_co2, :X_co2), NTuple{2, Float64}}\n\nTakes pressure, temperature, and amount of water to solve for the concentration of CO2 and X_CO2 using a Newton Raphson scheme\n\nArguments\n\ncomposition: Silicic()\nP: pressure (Pa)\nT: temperature (K)\nm_eq: amount of water\n\nReturns\n\nA NamedTuple with the following fields:\n\nC_co2: The concentration of CO2 in the melt.\nX_co2: The mole fraction of CO2 in the gas.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve_meq-Tuple{Mafic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve_meq","text":"exsolve_meq(composition::Mafic, P::Float64, T::Float64, X_co2::Float64)::Float64\n\nSpetialized version of exsolve that computes meq only.\n\nArguments\n\ncomposition: Mafic()\nP: Pressure (Pa)\nT: Temperature (K)\nX_co2: mole fraction of CO2 in gas.\n\nReturns\n\nmeq: amount of water\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve_meq-Tuple{Silicic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve_meq","text":"exsolve_meq(composition::Silicic, P::Float64, T::Float64, X_co2::Float64)::Float64\n\nSpetialized version of exsolve that computes meq only.\n\nArguments\n\ncomposition: Silicic()\nP: Pressure (Pa)\nT: Temperature (K)\nX_co2: mole fraction of CO2 in gas.\n\nReturns\n\nmeq: amount of water\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.find_liq-Tuple{Mafic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.find_liq","text":"find_liq(composition::Mafic, water::Float64, co2::Float64, P::Float64, ini_eps_x::Float64)::Float64\n\nGiven the weight fractions of H2O and CO2 in magma, and the pressure, finds the temperature at which the magma will crystallize and reach the desired volume fraction of crystals. The function uses the parameters of the melting curve and an error function to estimate the liquidus temperature.\n\nArguments\n\ncomposition: Mafic()\nwater: Weight fration of the H2O in magma.\nco2: Weight fration of the CO2 in magma.\nP: Pressure (Pa)\nini_eps_x: The starting volumn fraction of crystal.\n\nReturns\n\nTl: the estimated liquidus temperature (K).\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.find_liq-Tuple{Silicic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.find_liq","text":"find_liq(composition::Silicic, water::Float64, co2::Float64, P::Float64, ini_eps_x::Float64)::Float64\n\nGiven the weight fractions of H2O and CO2 in magma, and the pressure, finds the temperature at which the magma will crystallize and reach the desired volume fraction of crystals. The function uses the parameters of the melting curve and an error function to estimate the liquidus temperature.\n\nArguments\n\ncomposition: Silicic()\nwater: Weight fration of the H2O in magma.\nco2: Weight fration of the CO2 in magma.\nP: Pressure (Pa)\nini_eps_x: The starting volumn fraction of crystal.\n\nReturns\n\nTl: the estimated liquidus temperature (K).\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.fun-NTuple{11, Float64}","page":"Chamber.jl","title":"Chamber.fun","text":"fun(x::Float64, P::Float64, T::Float64, eps_g0::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, mm_co2::Float64, mm_h2o::Float64, M_co2::Float64)::Float64\n\nThis function is used within the solve_X_co2 function to solve X_co20.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.gas_heat_capacity-Tuple{Float64}","page":"Chamber.jl","title":"Chamber.gas_heat_capacity","text":"gas_heat_capacity(X_co2::Float64)\n\nArguments\n\nX_co2: mole fraction of CO2 in the gas.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.get_eps_g-Tuple{Union{Mafic, Silicic}, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.get_eps_g","text":"get_eps_g(composition::Union{Silicic,Mafic}, eps_g_prev::Float64, X_co20::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_h2o::Float64, M_co2::Float64)::NamedTuple{(:eps_g0, :mco2_diss),NTuple{2,Float64}}\n\nThis function is used within the IC_Finder function to get epsg0 and mco2diss.\n\nReturns\n\nA NamedTuple with the following fields:\n\neps_g0\nmco2_diss\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.get_phase-Tuple{Union{Mafic, Silicic}, Float64, Float64, Float64, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.get_phase","text":"get_phase(composition::Union{Silicic,Mafic}, P::Float64, T::Float64, V::Float64, rho_m::Float64, M_h2o::Float64, M_co2::Float64, eps_x0::Float64)::NamedTuple{(:phase, :m_co2_melt),NTuple{2,Float64}}\n\nThis function is used within the IC_Finder function to determine the initial phase.\n\nReturns\n\nA NamedTuple with the following fields:\n\nphase: 2 or 3\nm_co2_melt\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.heat_conduction_chamberCH-Tuple{Int64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, ParamSaved{Float64}}","page":"Chamber.jl","title":"Chamber.heat_conduction_chamberCH","text":"heat_conduction_chamberCH(maxn::Int64, a::Float64, c::Float64, dr::Float64, kappa::Float64, rho::Float64, cp::Float64, Tb::Float64, param_sv::ParamSaved{Float64})::Float64\n\nThe function calculates the heat conduction within a magma chamber by solving the heat equation in cylindrical coordinates.\n\nArguments\n\nmaxn: number of terms\na: radius of magma chamber (m)\nc: radius of outer shell (m)\ndr: grid spacing for calculating the heat transfer\nkappa: thermal diffusivity of host rocks (m^2/s)\nrho: density of the magma (kg/m³)\ncp: specific heat of magma (J/(kg K))\nTb: boundary temperature of the outer shell (K)\nparam_sv: a struct ParamSaved stores the previous results of the function\n\nReturns\n\nQ: heat flow rate through the magma chamber (J/s)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.heat_conduction_chamber_profileCH-Tuple{Int64, Float64, Float64, Vector{Float64}, Float64, Float64, ParamSaved{Float64}}","page":"Chamber.jl","title":"Chamber.heat_conduction_chamber_profileCH","text":"heat_conduction_chamber_profileCH(maxn::Int64, a::Float64, c::Float64, r::Float64, kappa::Float64, Tb::Float64, param_sv::ParamSaved{Float64})::Float64\n\nCalculates the heat transfer in a magma chamber based on the thermal diffusivity of the host rocks and the temperature profile of the outer shell.\n\nArguments\n\nmaxn: number of terms\na: radius of magma chamber (m)\nc: radius of outer shell (m)\nr: grid spacing of calculate the heat transfer\nkappa: thermal diffusivity of host rocks\nTb: boundary temperature of the outer shell (K)\nparam_sv: a struct ParamSaved stores the previous results of the function\n\nReturns\n\nTrt\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.ic_phase_conversion-Union{Tuple{T}, Tuple{T, Union{Mafic, Silicic}, T, T, T, T, T, T, T, ParamICFinder{T}}} where T<:Float64","page":"Chamber.jl","title":"Chamber.ic_phase_conversion","text":"ic_phase_conversion(phase_here::T, composition::Union{Silicic,Mafic}, M_h2o::T, M_co2::T, M_tot::T, P::T, Temp::T, V::T, rho_m::T, param_IC::ParamICFinder{T})::NamedTuple{(:eps_g_temp, :X_co2_temp, :C_co2_temp, :phase),NTuple{4,T}} where {T<:Float64}\n\nThis function is used to handle phase conversion by iteratively modifying the max_count or Tol parameters of function IC_Finder until the correct phase is obtained.\n\nThis function is used within the affect! function.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.mco2_dissolved_sat-Tuple{Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.mco2_dissolved_sat","text":"mco2_dissolved_sat(X::Float64, P::Float64, T::Float64)::Float64\n\nThis function is used within the solve_X_co2 function\n\nArguments\n\nX: mole fraction of CO2 in gas\nP: Pressure (Pa)\nT: Temperature (K)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.meq_water-Tuple{Mafic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.meq_water","text":"meq_water(composition::Mafic, X::Float64, P::Float64, T::Float64)::Float64\n\nThis function is used within the get_eps_g function\n\nArguments\n\nX: mole fration of H2O in gas\nP: Pressure (Pa)\nT: Temperature (K)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.meq_water-Tuple{Silicic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.meq_water","text":"meq_water(composition::Silicic, X::Float64, P::Float64, T::Float64)::Float64\n\nThis function is used within the get_eps_g function\n\nArguments\n\nX: mole fration of H2O in gas\nP: Pressure (Pa)\nT: Temperature (K)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.odeChamber-Tuple{Vector{Float64}, Vector{Float64}, Tuple{Param{Float64}, ParamSaved{Float64}, SW{Int8}}, Float64}","page":"Chamber.jl","title":"Chamber.odeChamber","text":"odeChamber(du::Vector{Float64}, u::Vector{Float64}, params::Tuple{Param{Float64}, ParamSaved{Float64}, SW{Int8}}, t::Float64)\n\nDefine the ODE equation.\nSolve the model for eruption frequency of upper crustal magma chambers using an ODE solver.\n\nArguments\n\ndu: An array that stores the output of the ODE solver, i.e., the values of the derivatives of the solution u with respect to time t.\nu: An array that stores the values of the solution at each time step t.\np: A tuple that stores the model parameters and some saved variables, which are described in more detail below.\nt: The time points corresponding to the saved values of the ODE solution.\n\nThe arguments du, u, p, and t are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.\n\nParameters\n\nparam: A custom parameter containing physical constants and other model parameters.\nparam_saved_var: A custom parameter used to store values from the previous time step.\nsw: A custom parameter used to control simulation behavior.\n\nReturns\n\nThe function modifies du in place to store the values of the derivatives of the solution u with respect to time t.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.parameters_melting_curve-Tuple{Mafic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.parameters_melting_curve","text":"parameters_melting_curve(composition::Mafic, mH2O::Float64, mCO2::Float64, P::Float64)::NamedTuple{(:a, :dadx, :dady, :dadz, :b, :dbdx, :dbdy, :dbdz), NTuple{8, Float64}}\n\nThis function is used within the find_liq, crystal_fraction, crystal_fraction_eps_x function.\n\nArguments\n\ncomposition: Mafic()\nmH2O: Weight fration of the H2O in magma.\nmCO2: Weight fration of the CO2 in magma.\nP: Pressure (Pa)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.parameters_melting_curve-Tuple{Silicic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.parameters_melting_curve","text":"parameters_melting_curve(composition::Silicic, mH2O::Float64, mCO2::Float64, P::Float64)::NamedTuple{(:a, :dadx, :dady, :dadz, :b, :dbdx, :dbdy, :dbdz, :c, :dcdx, :dcdy, :dcdz), NTuple{12, Float64}}\n\nThis function is used within the find_liq, crystal_fraction, crystal_fraction_eps_x function.\n\nArguments\n\ncomposition: Silicic()\nmH2O: Weight fration of the H2O in magma.\nmCO2: Weight fration of the CO2 in magma.\nP: Pressure (Pa)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.rc_f-Union{Tuple{}, Tuple{T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.rc_f","text":"rc_f(;rho_x::T, eps_x::T, c_x::T, rho_m::T, eps_m::T, c_m::T, rho_g::T, eps_g::T, c_g::T)::T where {T<:Float64}\n\nComputing the product of density and specific heat \n\nThis function is used within the build_rho_rc function.\n\nReturns\n\nrc: the product of density and specific heat\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.record_erupt_end-Union{Tuple{T}, Tuple{T, EruptSaved{T}, Param{T}}} where T<:Float64","page":"Chamber.jl","title":"Chamber.record_erupt_end","text":"record_erupt_end(time::T, erupt_saved::EruptSaved{T}, param::Param{T}) where {T<:Float64}\n\nRecord duration, mass and volume of eruptions to EruptSaved\n\nThis function is used within the affect! function.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.record_erupt_start-Union{Tuple{T}, Tuple{T, T, T, T, T, T, EruptSaved{T}}} where T<:Float64","page":"Chamber.jl","title":"Chamber.record_erupt_start","text":"record_erupt_start(time::T, eps_g::T, eps_x::T, rho_m::T, rho_x::T, rho_g::T, erupt_saved::EruptSaved{T}) where {T<:Float64}\n\nRecord time, density of eruptions to EruptSaved\n\nThis function is used within the affect! function.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.rho_0_f-NTuple{5, Float64}","page":"Chamber.jl","title":"Chamber.rho_0_f","text":"rho_0_f(eps_g0::Float64, eps_x0::Float64, rho_g0::Float64, rho_m0::Float64, rho_x0::Float64)::Float64\n\nThis function is used within the chamber function.\n\nReturns\n\nrho_0: initial bulk density (kg/m³)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.rho_f-Union{Tuple{}, Tuple{T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.rho_f","text":"rho_f(;eps_m::T, eps_g::T, eps_x::T, rho_m::T, rho_g::T, rho_x::T)::T where {T<:Float64}\n\nThis function is used within the build_rho_rc function.\n\nReturns\n\nrho: bulk density (kg/m³)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.solve_NR-Union{Tuple{T}, Tuple{Any, Any, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.solve_NR","text":"solve_NR(f, f_prime, errorTol::T, count_max::T, Xc_initial::T)::T where {T<:Float64}\n\nFinding mole fraction of CO2 in gas (X_CO2).\nThis function is used within the exsolve3 function.\n\nArguments\n\nf: Water Paritioning Function\nf_prime: Function for the derivative of water with reference to X_CO2\nerrorTol: error tolerance, the default value is 1e-10\ncount_max: Maximum loop count, the default value is 1e2\nXc_initial: initial guess of X_CO2, the dedault value is 1e-2\n\nReturns\n\nX_CO2: mole fraction of CO2 in gas\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.solve_X_co2-Tuple{Mafic, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.solve_X_co2","text":"solve_X_co2(composition::Mafic, eps_g0::Float64, X_co2_prev::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_co2::Float64, Tol::Float64)::Float64\n\nThis function is used within the IC_Finder function to solve X_co20.\n\nReturns\n\nX_co20\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.solve_X_co2-Tuple{Silicic, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.solve_X_co2","text":"solve_X_co2(composition::Silicic, eps_g0::Float64, X_co2_prev::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_co2::Float64, Tol::Float64)::Float64\n\nThis function is used within the IC_Finder function to solve X_co20.\n\nReturns\n\nX_co20\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.stopChamber_MT-Tuple{Any, Vector{Float64}, Float64, Any, SW{Int8}, Param{Float64}}","page":"Chamber.jl","title":"Chamber.stopChamber_MT","text":"stopChamber_MT(out, u::Vector{Float64}, t::Float64, int, sw::SW{Int8}, param::Param{Float64})\n\nDefine the stopping criteria for an ODE solver that simulates a magma chamber.\n\nArguments\n\nout: An array where the function should save the condition value at the right index. The maximum index of out should be specified in the len property of callback, which allows for a chain of len events, triggering the ith event when out[i] = 0. The function returns the value of out[8] as the last condition. Checking Event Handling and Callback Functions page of DifferentialEquations.jl for more details.\nu: A vector containing the state of the system at time t.\nt: The current time of the ODE solver.\nint: The current state of the integrator. It's format is from the DifferentialEquations.jl package\nsw: A custom parameter used to control simulation behavior.\nparam: A custom parameter containing physical constants and other model parameters.\n\nThe arguments out, u, t, and int are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.\n\nReturns\n\nThe out array is modified in-place to contain the condition values at the current state of the system. The function computes several quantities based on the current state of the system and the model parameters, such as the crystal fraction, the maximum amount of exsolved fluid, and the amount of CO2 in the melt. It then uses these values to calculate the condition values to be stored in the out array, as follows:\n\nout[1]: the crystal fraction.\nout[2]: the ratio of crystal fraction to liquid fraction, minus 0.8.\nout[3]: if an eruption is not occurring, the pressure difference between the lithostatic pressure and the current pressure, minus the critical pressure difference. Otherwise, negative the critical pressure difference.\nout[4]: if an eruption is occurring, the lithostatic pressure minus the current pressure. Otherwise, negative the critical pressure difference.\nout[5]: the crystal fraction minus 0.5.\nout[6]: the difference between the amount of water in the melt and the maximum amount of exsolved fluid.\nout[7]: negative the difference between the initial lithostatic pressure and the current pressure plus the critical pressure difference.\nout[8]: the difference between the amount of CO2 in the melt and the saturation concentration.\n\nNote that the out and u arguments are in the format expected by the DifferentialEquations.jl package, and the function is intended to be used as a condition for a callback function.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.water-Union{Tuple{T}, Tuple{Mafic, T, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.water","text":"water(composition::Silicic, p::T, t::T, x::T, c::T)::T where {T<:Float64}\n\nWater Paritioning Function\nThis function is used within the exsolve3 function.\n\nArguments\n\np: pressure (Pa)\nt: temperature (K)\nx: The previous mole fraction of CO2 (X_CO2)\nc: amount of water\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.water-Union{Tuple{T}, Tuple{Silicic, T, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.water","text":"water(composition::Silicic, p::T, t::T, x::T, c::T)::T where {T<:Float64}\n\nWater Paritioning Function\nThis function is used within the exsolve3 function.\n\nArguments\n\np: pressure (Pa)\nt: temperature (K)\nx: The previous mole fraction of CO2 (X_CO2)\nc: amount of water\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.OdeSetting","page":"Chamber.jl","title":"Chamber.OdeSetting","text":"Settings for ODE Solver Calculation\n\n\n\n\n\n","category":"type"},{"location":"#Chamber.Param","page":"Chamber.jl","title":"Chamber.Param","text":"Parameters\n\n\n\n\n\n","category":"type"},{"location":"#Chamber.ParamICFinder","page":"Chamber.jl","title":"Chamber.ParamICFinder","text":"Settings for IC_Finder\n\n\n\n\n\n","category":"type"},{"location":"#Chamber.RheolComposition","page":"Chamber.jl","title":"Chamber.RheolComposition","text":"Rheology of the crust\n\n\n\n\n\n","category":"type"},{"location":"#Chamber.SW","page":"Chamber.jl","title":"Chamber.SW","text":"eruption/coolingmodule/viscousrelaxation control\n\n\n\n\n\n","category":"type"},{"location":"#Index","page":"Chamber.jl","title":"Index","text":"","category":"section"},{"location":"","page":"Chamber.jl","title":"Chamber.jl","text":"","category":"page"}] +[{"location":"#Chamber.jl","page":"Chamber.jl","title":"Chamber.jl","text":"","category":"section"},{"location":"","page":"Chamber.jl","title":"Chamber.jl","text":"This is the API documentation for Chamber.jl. See the package's README for instructions about general usage.","category":"page"},{"location":"#Functions","page":"Chamber.jl","title":"Functions","text":"","category":"section"},{"location":"","page":"Chamber.jl","title":"Chamber.jl","text":"Modules = [Chamber]\nOrder = [:function, :macro, :type]","category":"page"},{"location":"#Chamber.IC_Finder-Union{Tuple{T}, Tuple{Mafic, T, T, T, T, T, T, T, ParamICFinder{T}}} where T<:Float64","page":"Chamber.jl","title":"Chamber.IC_Finder","text":"IC_Finder(composition::Mafic, M_h2o::Float64, M_co2::Float64, M_tot::Float64, P::Float64, T::Float64, V::Float64, rho_m::Float64, param_IC::ParamICFinder{Float64})::NamedTuple{(:eps_g0, :X_co20, :mco2_diss, :phase),NTuple{4,Float64}}\n\nAn iterative function that uses thermodynamic modeling to determine the gas phase composition of a mafic magma chamber.\n\nArguments\n\ncomposition: Mafic()\nM_h2o: total mass of water in magma (kg)\nM_co2: total mass of CO2 in magma (kg)\nM_tot: total mass of magma (kg)\nP: Pressure (Pa)\nT: Temperature (K)\nV: chamber volume (m³)\nrho_m: density of the melt (kg/m³)\nparam_IC: An instance of the ParamICFinder composite type containing the parameters for IC_Finder\n\nReturns\n\nA NamedTuple with the following fields:\n\neps_g0: Initial gas fraction of the magma chamber\nX_co20: Initial mole fraction of CO2 in the gas phase\nmco2_diss: Total mass of CO2 dissolved in the melt (kg)\nphase: Integer representing the state of the magma\n\nDetails\n\nThe function uses a thermodynamic model to find the initial gas fraction (eps_g0) and initial mole fraction of CO2 in the gas phase (X_co20) for a mafic magma chamber. The model assumes that the chamber contains two phases: a liquid melt and a gas phase. The model calculates the saturation state of the magma with respect to CO2, and determines whether the gas phase contains only CO2 or a mixture of CO2 and H2O. If the chamber is in two-phase state, the model returns eps_g0 = 0.0, X_co20 = 0.0, mco2_diss = Total mass of CO2 dissolved in the melt, and phase = 2. If the chamber is in gas or liquid state, the function iteratively solves for eps_g0 and X_co20 using the solve_X_co2 and get_eps_g helper functions until the relative difference between eps_g0 and X_co20 in two consecutive iterations is less than the tolerance Tol, or until the maximum number of iterations max_count is reached. \n\n\n\n\n\n","category":"method"},{"location":"#Chamber.IC_Finder-Union{Tuple{T}, Tuple{Silicic, T, T, T, T, T, T, T, ParamICFinder{T}}} where T<:Float64","page":"Chamber.jl","title":"Chamber.IC_Finder","text":"IC_Finder(composition::Silicic, M_h2o::Float64, M_co2::Float64, M_tot::Float64, P::Float64, T::Float64, V::Float64, rho_m::Float64, param_IC::ParamICFinder{Float64})::NamedTuple{(:eps_g0, :X_co20, :mco2_diss, :phase),NTuple{4,Float64}}\n\nAn iterative function that uses thermodynamic modeling to determine the gas phase composition of a silicic magma chamber.\n\nArguments\n\ncomposition: Silicic()\nM_h2o: total mass of water in magma (kg)\nM_co2: total mass of CO2 in magma (kg)\nM_tot: total mass of magma (kg)\nP: Pressure (Pa)\nT: Temperature (K)\nV: chamber volume (m³)\nrho_m: density of the melt (kg/m³)\nparam_IC: An instance of the ParamICFinder composite type containing the parameters for IC_Finder\n\nReturns\n\nA NamedTuple with the following fields:\n\neps_g0: Initial gas fraction of the magma chamber\nX_co20: Initial mole fraction of CO2 in the gas phase\nmco2_diss: Total mass of CO2 dissolved in the melt (kg)\nphase: Integer representing the state of the magma\n\nDetails\n\nThe function uses a thermodynamic model to find the initial gas fraction (eps_g0) and initial mole fraction of CO2 in the gas phase (X_co20) for a silicic magma chamber. The model assumes that the chamber contains two phases: a liquid melt and a gas phase. The model calculates the saturation state of the magma with respect to CO2, and determines whether the gas phase contains only CO2 or a mixture of CO2 and H2O. If the chamber is in two-phase state, the model returns eps_g0 = 0.0, X_co20 = 0.0, mco2_diss = Total mass of CO2 dissolved in the melt, and phase = 2. If the chamber is in gas or liquid state, the function iteratively solves for eps_g0 and X_co20 using the solve_X_co2 and get_eps_g helper functions until the relative difference between eps_g0 and X_co20 in two consecutive iterations is less than the tolerance Tol, or until the maximum number of iterations max_count is reached. \n\n\n\n\n\n","category":"method"},{"location":"#Chamber.a1x_f-Union{Tuple{T}, NTuple{4, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.a1x_f","text":"This is for a11 and a12 a11: rho, drhodP, V, dVdP a12: rho, drhodT, V, dVdT\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.affect!-Tuple{Any, Any, SW{Int8}, Param{Float64}, ParamSaved{Float64}, ParamICFinder{Float64}, EruptSaved{Float64}}","page":"Chamber.jl","title":"Chamber.affect!","text":"affect!(int, idx, sw::SW{Int8}, param::Param{Float64}, param_saved_var::ParamSaved{Float64}, param_IC_Finder::ParamICFinder{Float64})\n\nRe-initialize the condition when the event happens. This function modifies the current state of the integrator (int.u) when a particular event occurs during the simulation. The function adjusts various parameters based on the current state of the integrator and the custom parameters that were passed in.\n\nArguments\n\nint: The current state of the integrator. It's format is from the DifferentialEquations.jl package\nidx: The index of the event that caused the function to be called.\nsw: A custom parameter used to control simulation behavior.\nparam: A custom parameter containing physical constants and other model parameters.\nparam_saved_var: A custom parameter used to store values from the previous time step.\nparam_IC_Finder: A custom parameter used to control the behavior of the IC_Finder function.\n\nThe arguments int and idx are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.boundary_conditions_new-Tuple{Float64, Float64, Float64, Float64, Float64, Float64, SW{Int8}, Float64, Float64, Float64, Float64, Param{Float64}, ParamSaved{Float64}}","page":"Chamber.jl","title":"Chamber.boundary_conditions_new","text":"boundary_conditions_new(P::Float64, T::Float64, V::Float64, rho_m::Float64, rho_x::Float64, c::Float64, sw::SW{Int8}, T_in::Float64, M_h2o::Float64, M_co2::Float64, total_Mass::Float64, param::Param{Float64}, param_saved_var::ParamSaved{Float64})\n\nArguments\n\nP: Pressure (Pa)\nT: Temperature (K)\nV: chamber volume (m³)\nrho_m: density of melt\nrho_x: density of crystal of magma\nc: heat of magma\nsw: eruption/coolingmodule/viscousrelaxation control\nT_in: Temperature\nM_h2o: total mess of H2O in the magma\nM_co2: total mess of CO2 in the magma\ntotal_Mass: total mess of magma chamber\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.build_co2-Union{Tuple{T}, NTuple{7, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.build_co2","text":"build_co2(Pw::T, Pc::T, Temp::T, dPwdP::T, dPcdP::T, dPwdXco2::T, dPcdXco2::T)::NamedTuple{(:C_co2, :dC_co2dT, :dC_co2dP, :dC_co2dXco2),NTuple{4,T}} where {T<:Float64}\n\nThis function is used within the exsolve function.\n\nReturns\n\nA NamedTuple with the following fields:\n\nC_co2\ndC_co2dT\ndC_co2dP\ndC_co2dXco2\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.build_mdot_in-Tuple{Bool, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.build_mdot_in","text":"build_mdot_in(fluxing::Bool, rho_m0::Float64, log_vfr::Float64, P_0::Float64, T_in::Float64)::Float64\n\nThis function is used within the chamber function.\n\nReturns\n\nmdot_in: mass inflow rate\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.build_meq-Union{Tuple{T}, Tuple{Mafic, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.build_meq","text":"build_meq(composition::Mafic, P::T, Temp::T, X_co2::T)::NamedTuple{(:meq, :dmeqdT, :dmeqdP, :dmeqdXco2),NTuple{4,T}} where {T<:Float64}\n\nThis function is used within the exsolve function.\n\nReturns\n\nA NamedTuple with the following fields:\n\nmeq\ndmeqdT\ndmeqdP\ndmeqdXco2\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.build_meq-Union{Tuple{T}, Tuple{Silicic, T, T, T, T, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.build_meq","text":"build_meq(composition::Silicic, Pw::T, Pc::T, Temp::T, dPwdP::T, dPcdP::T, dPwdXco2::T, dPcdXco2::T)::NamedTuple{(:meq, :dmeqdT, :dmeqdP, :dmeqdXco2),NTuple{4,T}} where {T<:Float64}\n\nThis function is used within the exsolve function.\n\nReturns\n\nA NamedTuple with the following fields:\n\nmeq\ndmeqdT\ndmeqdP\ndmeqdXco2\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.build_rho_rc-Union{Tuple{T}, NTuple{17, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.build_rho_rc","text":"build_rho_rc(eps_m::T, eps_g::T, eps_x::T, rho_m::T, rho_g::T, rho_x::T, drho_m_dP::T, drho_g_dP::T, drho_x_dP::T, drho_m_dT::T, drho_g_dT::T, drho_x_dT::T, c_x::T, c_m::T, c_g::T, deps_x_dP::T, deps_x_dT::T)::Vector{T} where {T<:Float64}\n\nThis function is used within the odeChamber function.\n\nReturns\n\n[rho, drho_dP, drho_dT, drho_deps_g, rc, drc_dP, drc_dT]\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.chamber","page":"Chamber.jl","title":"Chamber.chamber","text":"chamber(composition::Union{Silicic,Mafic}, end_time::Float64, log_volume_km3::Float64, InitialConc_H2O::Float64, InitialConc_CO2::Float64, log_vfr::Float64, depth::Float64, output_dirname::String; kwargs...)\n\nSimulate the eruption of a volcano using a model for the frequency of eruptions of upper crustal magma chambers based on Degruyter and Huber (2014).\n\nArguments\n\ncomposition: The magma composition. Use Silicic() for rhyolite composition (arc magma) or Mafic() for basalt composition (rift).\nend_time: Maximum magma chamber evolution duration in seconds.\nlog_volume_km3: The initial volume of the chamber in logarithmic scale. The actual initial chamber volume is calculated as 10^(log_volume_km3) in km³.\nInitialConc_H2O: The initial weight fraction of water in the magma (exsolved + dissolved).\nInitialConc_CO2: The initial weight fraction of CO₂ in the magma (exsolved + dissolved).\nlog_vfr: Magma recharge rate in km³/yr calculated as 10^(log_vfr).\ndepth: Depth of the magma chamber in meters.\noutput_dirname(optional): Name of the output directory. Defaults to current timestamp.\n\nKeyword Arguments\n\nplotfig(optional): (default: true). Generate and plot figures for each result if true.\n\nReturns\n\nA DataFrame containing the solution with columns:\n\ntime: Simulation timestamps in seconds.\nP+dP: Pressure in Pa.\nT: Temperature in K.\neps_g: Gas volume fraction.\nV: Volume of the magma chamber in m³.\nrho_m: Density of the melt in kg/m³.\nrho_x: Density of magma crystal in kg/m³.\nX_CO2: Mole fraction of CO2 in the gas.\ntotal_mass: Total mass of magma chamber in kg.\ntotal_mass_H2O: Total mass of water in the magma in kg.\ntotal_mass_CO2: Total mass of CO₂ in the magma in kg.\neps_x: Crystal volume fraction.\n\nOutputs\n\nA directory named after output_dirname or the default value, containing the following files:\n\nout.csv: a CSV file containing the solution columns listed above.\neruptions.csv, A CSV file containing the datas of eruptions with the following columns: timeoferuption (sec), durationoferuption (sec), masserupted (kg) and volumeerupted (km³).\nFigures for P+dP(t), T(t), epsg(t), V(t), XCO2(t), total_mass(t).\n\nReferences\n\nW. Degruyter and C. Huber (2014). A model for eruption frequency of upper crustal silicic magma chambers. Earth Planet. Sci. Lett. https://doi.org/10.1016/j.epsl.2014.06.047\n\nExamples\n\n# Run a simulation with silicic magma chamber\njulia> composition = Silicic()\njulia> end_time = 3e9\njulia> log_volume_km3 = 0.2\njulia> InitialConc_H2O = 0.04\njulia> InitialConc_CO2 = 0.001\njulia> log_vfr = -3.3\njulia> depth = 8e3\n\njulia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth)\n\n# Run a simulation with mafic magma chamber, with custom directory name \"MyDirname\"\njulia> composition = Mafic()\njulia> end_time = 3e9\njulia> log_volume_km3 = 0.2\njulia> InitialConc_H2O = 0.01\njulia> InitialConc_CO2 = 0.001\njulia> log_vfr = -3.3\njulia> depth = 8e3\njulia> output_dirname = \"MyDirname\"\n\njulia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth, output_dirname)\n\n\n\n\n\n","category":"function"},{"location":"#Chamber.chamber-2","page":"Chamber.jl","title":"Chamber.chamber","text":"chamber(composition::Union{Silicic,Mafic}, end_time::Float64, log_volume_km3_vector::Union{Float64,Vector{Float64}}, InitialConc_H2O_vector::Union{Float64,Vector{Float64}}, InitialConc_CO2_vector::Union{Float64,Vector{Float64}}, log_vfr_vector::Union{Float64,Vector{Float64}}, depth_vector::Union{Float64,Vector{Float64}}, output_dirname::String; kwargs...)\n\nSimulate the eruption of a volcano using a model for the frequency of eruptions of upper crustal magma chambers based on Degruyter and Huber (2014).\n\nArguments\n\ncomposition: The magma composition. Use Silicic() for rhyolite composition (arc magma) or Mafic() for basalt composition (rift).\nend_time: Maximum magma chamber evolution duration in seconds.\nlog_volume_km3: The initial volume of the chamber in logarithmic scale. The actual initial chamber volume is calculated as 10^(log_volume_km3) in km³.\nInitialConc_H2O: The initial weight fraction of water in the magma (exsolved + dissolved).\nInitialConc_CO2: The initial weight fraction of CO₂ in the magma (exsolved + dissolved).\nlog_vfr: Magma recharge rate in km³/yr calculated as 10^(log_vfr).\ndepth: Depth of the magma chamber in meters.\noutput_dirname(optional): Name of the output directory. Defaults to current timestamp.\n\nKeyword Arguments\n\nplotfig(optional): (default: true). Generate and plot figures for each result if true.\n\nReturns\n\nA DataFrame containing the solution with columns:\n\ntime: Simulation timestamps in seconds.\nP+dP: Pressure in Pa.\nT: Temperature in K.\neps_g: Gas volume fraction.\nV: Volume of the magma chamber in m³.\nrho_m: Density of the melt in kg/m³.\nrho_x: Density of magma crystal in kg/m³.\nX_CO2: Mole fraction of CO2 in the gas.\ntotal_mass: Total mass of magma chamber in kg.\ntotal_mass_H2O: Total mass of water in the magma in kg.\ntotal_mass_CO2: Total mass of CO₂ in the magma in kg.\neps_x: Crystal volume fraction.\n\nOutputs\n\nA directory named after output_dirname or the default value, containing the following files:\n\nout.csv: a CSV file containing the solution columns listed above.\neruptions.csv, A CSV file containing the datas of eruptions with the following columns: timeoferuption (sec), durationoferuption (sec), masserupted (kg) and volumeerupted (km³).\nFigures for P+dP(t), T(t), epsg(t), V(t), XCO2(t), total_mass(t).\n\nReferences\n\nW. Degruyter and C. Huber (2014). A model for eruption frequency of upper crustal silicic magma chambers. Earth Planet. Sci. Lett. https://doi.org/10.1016/j.epsl.2014.06.047\n\nExamples\n\n# Run a simulation with silicic magma chamber\njulia> composition = Silicic()\njulia> end_time = 3e9\njulia> log_volume_km3 = 0.2\njulia> InitialConc_H2O = [0.04, 0.045]\njulia> InitialConc_CO2 = [0.001, 0.0012]\njulia> log_vfr = -3.3\njulia> depth = 8e3\n\njulia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth)\n\n# Run a simulation with mafic magma chamber, with custom directory name \"MyDirname\"\njulia> composition = Mafic()\njulia> end_time = 3e9\njulia> log_volume_km3 = 0.2\njulia> InitialConc_H2O = [0.01, 0.012]\njulia> InitialConc_CO2 = 0.001\njulia> log_vfr = -3.3\njulia> depth = [7e3, 8e3]\njulia> output_dirname = \"MyDirname\"\n\njulia> chamber(composition, end_time, log_volume_km3, InitialConc_H2O, InitialConc_CO2, log_vfr, depth, output_dirname)\n\n\n\n\n\n","category":"function"},{"location":"#Chamber.check_for_duplicates-NTuple{5, Union{Float64, Vector{Float64}}}","page":"Chamber.jl","title":"Chamber.check_for_duplicates","text":"check_for_duplicates(log_volume_km3_vector::Union{Float64,Vector{Float64}}, InitialConc_H2O_vector::Union{Float64,Vector{Float64}}, InitialConc_CO2_vector::Union{Float64,Vector{Float64}}, log_vfr_vector::Union{Float64,Vector{Float64}}, depth_vector::Union{Float64,Vector{Float64}})::Nothing\n\nThis function checks if any of the input arrays contain duplicate elements. If duplicates are found, it raises an error indicating which arguments have duplicates.\n\nThis function is used within the chamber function\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.compute_dXdP_dXdT-Tuple{Float64, Param, String}","page":"Chamber.jl","title":"Chamber.compute_dXdP_dXdT","text":"compute_dXdP_dXdT(u::Float64, param::Param, var::String)::Tuple{Float64,Float64,Float64}\n\nThis function is used within the odeChamber function.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.crystal_fraction-Tuple{Mafic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.crystal_fraction","text":"crystal_fraction(composition::Mafic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::NamedTuple{(:eps_x, :deps_x_dP, :deps_x_dT, :deps_x_deps_g, :deps_x_dmco2_t, :deps_x_dmh2o_t), NTuple{6, Float64}}\n\nCalculate crystal volume fraction and its derivatives in magma at given temperature, pressure, and water and CO2 contents.\n\nArguments\n\ncomposition: Mafic()\nT: Temperature (K)\nP: Pressure (Pa)\nmH2O: Weight fration of the H2O in magma.\nmCO2: Weight fration of the CO2 in magma.\n\nReturns\n\nA NamedTuple with the following fields:\n\neps_x: Crystal volume fraction.\ndeps_x_dP: Derivative of eps_x with respect to pressure.\ndeps_x_dT: Derivative of eps_x with respect to temperature.\ndeps_x_deps_g: Derivative of eps_x with respect to gas volume fraction.\ndeps_x_dmco2_t: Derivative of eps_x with respect to CO2 content.\ndeps_x_dmh2o_t: Derivative of eps_x with respect to H2O content.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.crystal_fraction-Tuple{Silicic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.crystal_fraction","text":"crystal_fraction(composition::Silicic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::NamedTuple{(:eps_x, :deps_x_dP, :deps_x_dT, :deps_x_deps_g, :deps_x_dmco2_t, :deps_x_dmh2o_t), NTuple{6, Float64}}\n\nCalculate crystal volume fraction and its derivatives in magma at given temperature, pressure, and water and CO2 contents.\n\nArguments\n\ncomposition: Silicic()\nT: Temperature (K)\nP: Pressure (Pa)\nmH2O: Weight fration of the H2O in magma.\nmCO2: Weight fration of the CO2 in magma.\n\nReturns\n\nA NamedTuple with the following fields:\n\neps_x: Crystal volume fraction.\ndeps_x_dP: Derivative of eps_x with respect to pressure.\ndeps_x_dT: Derivative of eps_x with respect to temperature.\ndeps_x_deps_g: Derivative of eps_x with respect to gas volume fraction.\ndeps_x_dmco2_t: Derivative of eps_x with respect to CO2 content.\ndeps_x_dmh2o_t: Derivative of eps_x with respect to H2O content.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.crystal_fraction_eps_x-Tuple{Mafic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.crystal_fraction_eps_x","text":"crystal_fraction_eps_x(composition::Mafic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::Float64\n\nCalculates crystal volume fraction at given temperature, pressure, and water and CO2 contents.\nSpetialized version of crystal_fractionthat computeseps_x` only.\n\nReturns\n\neps_x: Crystal volume fraction.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.crystal_fraction_eps_x-Tuple{Silicic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.crystal_fraction_eps_x","text":"crystal_fraction_eps_x(composition::Silicic, T::Float64, P::Float64, mH2O::Float64, mCO2::Float64)::Float64\n\nCalculates crystal volume fraction at given temperature, pressure, and water and CO2 contents.\nSpetialized version of crystal_fraction that computes eps_x only.\n\nReturns\n\neps_x: Crystal volume fraction.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.dM_X_t_dt_f-Union{Tuple{T}, NTuple{7, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.dM_X_t_dt_f","text":"dM_X_t_dt_f(rho, V, Mdot_v_in, Mdot_v_out, m_h2o, Mdot_in, Mdot_out)\n\nFor dM_h2o_t_dt & dM_co2_t_dt\n\nMdotXin: Mdot_v_in or Mdot_c_in\nMdotXout: Mdot_v_out or Mdot_c_out\nmX: `mh2oorm_co2`\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.dX_dxdydz-Union{Tuple{T}, Tuple{Union{Mafic, Silicic}, String, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.dX_dxdydz","text":"dX_dxdydz(composition::Union{Silicic,Mafic}, s::String, x::T, y::T, z::T)::NamedTuple{(:X, :dXdx, :dXdy, :dXdz),NTuple{4,T}} where {T<:Float64}\n\nThis function is used within the parameters_melting_curve function.\nCalculate value from different parameter sets (# of parameter sets: Silicic: 3, Mafic: 2)\n\nArguments\n\ncomposition: Silicic() or Mafic()\ns: String that represents the parameter set to use. For Silicic, s can be \"a\", \"b\", or \"c\". For Mafic, s can be \"a\" or \"b\".\nx: Water (H2O)\ny: Gas (CO2)\nz: Pressure (P)\n\nReturns\n\nA NamedTuple with the following fields:\n\nX: the calculated value for the given parameter set\ndXdx: the derivative of X with respect to x\ndXdy: the derivative of X with respect to y\ndXdz: the derivative of X with respect to z\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.drc_dX_f-Union{Tuple{}, Tuple{T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.drc_dX_f","text":"drc_dX_f(;eps_x::T, c_x::T, drho_x_dX::T, eps_g::T, c_g::T, drho_g_dX::T, eps_m::T, c_m::T, drho_m_dX::T, rho_x::T, rho_m::T, deps_x_dX::T)::T where {T<:Float64}\n\nComputing the derivatives of the product of density and specific heat for the mixture\n\nX: represent P or T\nThis function is used within the build_rho_rc function.\n\nReturns\n\ndrc_dX: represent drc_dP or drc_dT\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.drho_dX_f-Union{Tuple{}, Tuple{T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.drho_dX_f","text":"drho_dX_f(;eps_m::T, eps_g::T, eps_x::T, drho_m_dX::T, drho_g_dX::T, drho_x_dX::T, rho_x::T, rho_m::T, deps_x_dX::T)::T where {T<:Float64}\n\nX: represent P or T\nThis function is used within the build_rho_rc function.\n\nReturns\n\ndrho_dX: represent drho_dP or drho_dT\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.dwater_dx-Union{Tuple{T}, Tuple{Mafic, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.dwater_dx","text":"dwater_dx(composition::Mafic, p::T, t::T, x::T)::T where {T<:Float64}\n\nDerivative of Water Partitioning Function with respect to X_CO2\nThis function is used within the exsolve3 function.\n\nArguments\n\np: pressure (Pa)\nt: temperature (K)\nx: The previous mole fraction of CO2 (X_CO2)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.dwater_dx-Union{Tuple{T}, Tuple{Silicic, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.dwater_dx","text":"dwater_dx(composition::Silicic, p::T, t::T, x::T)::T where {T<:Float64}\n\nFunction for the derivative of water with reference to X_CO2\nThis function is used within the exsolve3 function.\n\nArguments\n\np: pressure (Pa)\nt: temperature (K)\nx: The previous mole fraction of CO2 (X_CO2)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.eos_g-Tuple{Float64, Float64}","page":"Chamber.jl","title":"Chamber.eos_g","text":"eos_g(P::Float64, T::Float64)::EosG{Float64}\n\nparametrization of redlich kwong taken from Huber et al. 2010\n\nArguments\n\nP: Pressure (Pa)\nT: Temperature (K)\n\nReturns\n\nAn instance of the EosG struct, containing the following fields:\n\nrho_g: density of the gas (kg/m³).\ndrho_g_dP: partial derivative of the density with respect to pressure (kg/m³/Pa).\ndrho_g_dT: partial derivative of the density with respect to temperature (kg/m³/K).\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.eos_g_rho_g-Tuple{Float64, Float64}","page":"Chamber.jl","title":"Chamber.eos_g_rho_g","text":"eos_g_rho_g(P::Float64, T::Float64)::Float64\n\nSpetialized version of eos_g that computes rho_g only.\n\nArguments\n\nP: Pressure (Pa)\nT: Temperature (K)\n\nReturns\n\nrho_g: density of the gas in kg/m³.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve-Tuple{Mafic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve","text":"exsolve(composition::Mafic, P::Float64, T::Float64, X_co2::Float64)::NamedTuple{(:meq, :dmeqdP, :dmeqdT, :dmeqdXco2, :C_co2, :dC_co2dP, :dC_co2dT, :dC_co2dXco2), NTuple{8, Float64}}\n\nThis script uses Liu et al. (2006) to calculate the solubility of water\n\nArguments\n\ncomposition: Mafic()\nP: Pressure (Pa)\nT: Temperature (K)\nX_co2: mole fraction of CO2 in gas.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve-Tuple{Silicic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve","text":"exsolve(composition::Silicic, P::Float64, T::Float64, X_co2::Float64)::NamedTuple{(:meq, :dmeqdP, :dmeqdT, :dmeqdXco2, :C_co2, :dC_co2dP, :dC_co2dT, :dC_co2dXco2), NTuple{8, Float64}}\n\nThis script uses Liu et al. (2006) to calculate the solubility of water\n\nArguments\n\ncomposition: Silicic()\nP: Pressure (Pa)\nT: Temperature (K)\nX_co2: mole fraction of CO2 in gas.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve3-Tuple{Mafic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve3","text":"exsolve3(composition::Mafic, P::Float64, T::Float64, m_eq::Float64)::NamedTuple{(:C_co2, :X_co2), NTuple{2, Float64}}\n\nTakes pressure, temperature, and amount of water to solve for the concentration of CO2 and X_CO2 using a Newton Raphson scheme\n\nArguments\n\ncomposition: Mafic()\nP: pressure (Pa)\nT: temperature (K)\nm_eq: amount of water\n\nReturns\n\nA NamedTuple with the following fields:\n\nC_co2: The concentration of CO2 in the melt.\nX_co2: The mole fraction of CO2 in the gas.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve3-Tuple{Silicic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve3","text":"exsolve3(composition::Silicic, P::Float64, T::Float64, m_eq::Float64)::NamedTuple{(:C_co2, :X_co2), NTuple{2, Float64}}\n\nTakes pressure, temperature, and amount of water to solve for the concentration of CO2 and X_CO2 using a Newton Raphson scheme\n\nArguments\n\ncomposition: Silicic()\nP: pressure (Pa)\nT: temperature (K)\nm_eq: amount of water\n\nReturns\n\nA NamedTuple with the following fields:\n\nC_co2: The concentration of CO2 in the melt.\nX_co2: The mole fraction of CO2 in the gas.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve_meq-Tuple{Mafic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve_meq","text":"exsolve_meq(composition::Mafic, P::Float64, T::Float64, X_co2::Float64)::Float64\n\nSpetialized version of exsolve that computes meq only.\n\nArguments\n\ncomposition: Mafic()\nP: Pressure (Pa)\nT: Temperature (K)\nX_co2: mole fraction of CO2 in gas.\n\nReturns\n\nmeq: amount of water\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.exsolve_meq-Tuple{Silicic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.exsolve_meq","text":"exsolve_meq(composition::Silicic, P::Float64, T::Float64, X_co2::Float64)::Float64\n\nSpetialized version of exsolve that computes meq only.\n\nArguments\n\ncomposition: Silicic()\nP: Pressure (Pa)\nT: Temperature (K)\nX_co2: mole fraction of CO2 in gas.\n\nReturns\n\nmeq: amount of water\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.find_liq-Tuple{Mafic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.find_liq","text":"find_liq(composition::Mafic, water::Float64, co2::Float64, P::Float64, ini_eps_x::Float64)::Float64\n\nGiven the weight fractions of H2O and CO2 in magma, and the pressure, finds the temperature at which the magma will crystallize and reach the desired volume fraction of crystals. The function uses the parameters of the melting curve and an error function to estimate the liquidus temperature.\n\nArguments\n\ncomposition: Mafic()\nwater: Weight fration of the H2O in magma.\nco2: Weight fration of the CO2 in magma.\nP: Pressure (Pa)\nini_eps_x: The starting volumn fraction of crystal.\n\nReturns\n\nTl: the estimated liquidus temperature (K).\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.find_liq-Tuple{Silicic, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.find_liq","text":"find_liq(composition::Silicic, water::Float64, co2::Float64, P::Float64, ini_eps_x::Float64)::Float64\n\nGiven the weight fractions of H2O and CO2 in magma, and the pressure, finds the temperature at which the magma will crystallize and reach the desired volume fraction of crystals. The function uses the parameters of the melting curve and an error function to estimate the liquidus temperature.\n\nArguments\n\ncomposition: Silicic()\nwater: Weight fration of the H2O in magma.\nco2: Weight fration of the CO2 in magma.\nP: Pressure (Pa)\nini_eps_x: The starting volumn fraction of crystal.\n\nReturns\n\nTl: the estimated liquidus temperature (K).\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.fun-NTuple{11, Float64}","page":"Chamber.jl","title":"Chamber.fun","text":"fun(x::Float64, P::Float64, T::Float64, eps_g0::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, mm_co2::Float64, mm_h2o::Float64, M_co2::Float64)::Float64\n\nThis function is used within the solve_X_co2 function to solve X_co20.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.gas_heat_capacity-Tuple{Float64}","page":"Chamber.jl","title":"Chamber.gas_heat_capacity","text":"gas_heat_capacity(X_co2::Float64)\n\nArguments\n\nX_co2: mole fraction of CO2 in the gas.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.get_eps_g-Tuple{Union{Mafic, Silicic}, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.get_eps_g","text":"get_eps_g(composition::Union{Silicic,Mafic}, eps_g_prev::Float64, X_co20::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_h2o::Float64, M_co2::Float64)::NamedTuple{(:eps_g0, :mco2_diss),NTuple{2,Float64}}\n\nThis function is used within the IC_Finder function to get epsg0 and mco2diss.\n\nReturns\n\nA NamedTuple with the following fields:\n\neps_g0\nmco2_diss\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.get_phase-Tuple{Union{Mafic, Silicic}, Float64, Float64, Float64, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.get_phase","text":"get_phase(composition::Union{Silicic,Mafic}, P::Float64, T::Float64, V::Float64, rho_m::Float64, M_h2o::Float64, M_co2::Float64, eps_x0::Float64)::NamedTuple{(:phase, :m_co2_melt),NTuple{2,Float64}}\n\nThis function is used within the IC_Finder function to determine the initial phase.\n\nReturns\n\nA NamedTuple with the following fields:\n\nphase: 2 or 3\nm_co2_melt\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.heat_conduction_chamberCH-Tuple{Int64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, ParamSaved{Float64}}","page":"Chamber.jl","title":"Chamber.heat_conduction_chamberCH","text":"heat_conduction_chamberCH(maxn::Int64, a::Float64, c::Float64, dr::Float64, kappa::Float64, rho::Float64, cp::Float64, Tb::Float64, param_sv::ParamSaved{Float64})::Float64\n\nThe function calculates the heat conduction within a magma chamber by solving the heat equation in cylindrical coordinates.\n\nArguments\n\nmaxn: number of terms\na: radius of magma chamber (m)\nc: radius of outer shell (m)\ndr: grid spacing for calculating the heat transfer\nkappa: thermal diffusivity of host rocks (m^2/s)\nrho: density of the magma (kg/m³)\ncp: specific heat of magma (J/(kg K))\nTb: boundary temperature of the outer shell (K)\nparam_sv: a struct ParamSaved stores the previous results of the function\n\nReturns\n\nQ: heat flow rate through the magma chamber (J/s)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.heat_conduction_chamber_profileCH-Tuple{Int64, Float64, Float64, Vector{Float64}, Float64, Float64, ParamSaved{Float64}}","page":"Chamber.jl","title":"Chamber.heat_conduction_chamber_profileCH","text":"heat_conduction_chamber_profileCH(maxn::Int64, a::Float64, c::Float64, r::Float64, kappa::Float64, Tb::Float64, param_sv::ParamSaved{Float64})::Float64\n\nCalculates the heat transfer in a magma chamber based on the thermal diffusivity of the host rocks and the temperature profile of the outer shell.\n\nArguments\n\nmaxn: number of terms\na: radius of magma chamber (m)\nc: radius of outer shell (m)\nr: grid spacing of calculate the heat transfer\nkappa: thermal diffusivity of host rocks\nTb: boundary temperature of the outer shell (K)\nparam_sv: a struct ParamSaved stores the previous results of the function\n\nReturns\n\nTrt\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.ic_phase_conversion-Union{Tuple{T}, Tuple{T, Union{Mafic, Silicic}, T, T, T, T, T, T, T, ParamICFinder{T}}} where T<:Float64","page":"Chamber.jl","title":"Chamber.ic_phase_conversion","text":"ic_phase_conversion(phase_here::T, composition::Union{Silicic,Mafic}, M_h2o::T, M_co2::T, M_tot::T, P::T, Temp::T, V::T, rho_m::T, param_IC::ParamICFinder{T})::NamedTuple{(:eps_g_temp, :X_co2_temp, :C_co2_temp, :phase),NTuple{4,T}} where {T<:Float64}\n\nThis function is used to handle phase conversion by iteratively modifying the max_count or Tol parameters of function IC_Finder until the correct phase is obtained.\n\nThis function is used within the affect! function.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.mco2_dissolved_sat-Tuple{Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.mco2_dissolved_sat","text":"mco2_dissolved_sat(X::Float64, P::Float64, T::Float64)::Float64\n\nThis function is used within the solve_X_co2 function\n\nArguments\n\nX: mole fraction of CO2 in gas\nP: Pressure (Pa)\nT: Temperature (K)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.meq_water-Tuple{Mafic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.meq_water","text":"meq_water(composition::Mafic, X::Float64, P::Float64, T::Float64)::Float64\n\nThis function is used within the get_eps_g function\n\nArguments\n\nX: mole fration of H2O in gas\nP: Pressure (Pa)\nT: Temperature (K)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.meq_water-Tuple{Silicic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.meq_water","text":"meq_water(composition::Silicic, X::Float64, P::Float64, T::Float64)::Float64\n\nThis function is used within the get_eps_g function\n\nArguments\n\nX: mole fration of H2O in gas\nP: Pressure (Pa)\nT: Temperature (K)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.odeChamber-Tuple{Vector{Float64}, Vector{Float64}, Tuple{Param{Float64}, ParamSaved{Float64}, SW{Int8}}, Float64}","page":"Chamber.jl","title":"Chamber.odeChamber","text":"odeChamber(du::Vector{Float64}, u::Vector{Float64}, params::Tuple{Param{Float64}, ParamSaved{Float64}, SW{Int8}}, t::Float64)\n\nDefine the ODE equation.\nSolve the model for eruption frequency of upper crustal magma chambers using an ODE solver.\n\nArguments\n\ndu: An array that stores the output of the ODE solver, i.e., the values of the derivatives of the solution u with respect to time t.\nu: An array that stores the values of the solution at each time step t.\np: A tuple that stores the model parameters and some saved variables, which are described in more detail below.\nt: The time points corresponding to the saved values of the ODE solution.\n\nThe arguments du, u, p, and t are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.\n\nParameters\n\nparam: A custom parameter containing physical constants and other model parameters.\nparam_saved_var: A custom parameter used to store values from the previous time step.\nsw: A custom parameter used to control simulation behavior.\n\nReturns\n\nThe function modifies du in place to store the values of the derivatives of the solution u with respect to time t.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.parameters_melting_curve-Tuple{Mafic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.parameters_melting_curve","text":"parameters_melting_curve(composition::Mafic, mH2O::Float64, mCO2::Float64, P::Float64)::NamedTuple{(:a, :dadx, :dady, :dadz, :b, :dbdx, :dbdy, :dbdz), NTuple{8, Float64}}\n\nThis function is used within the find_liq, crystal_fraction, crystal_fraction_eps_x function.\n\nArguments\n\ncomposition: Mafic()\nmH2O: Weight fration of the H2O in magma.\nmCO2: Weight fration of the CO2 in magma.\nP: Pressure (Pa)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.parameters_melting_curve-Tuple{Silicic, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.parameters_melting_curve","text":"parameters_melting_curve(composition::Silicic, mH2O::Float64, mCO2::Float64, P::Float64)::NamedTuple{(:a, :dadx, :dady, :dadz, :b, :dbdx, :dbdy, :dbdz, :c, :dcdx, :dcdy, :dcdz), NTuple{12, Float64}}\n\nThis function is used within the find_liq, crystal_fraction, crystal_fraction_eps_x function.\n\nArguments\n\ncomposition: Silicic()\nmH2O: Weight fration of the H2O in magma.\nmCO2: Weight fration of the CO2 in magma.\nP: Pressure (Pa)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.rc_f-Union{Tuple{}, Tuple{T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.rc_f","text":"rc_f(;rho_x::T, eps_x::T, c_x::T, rho_m::T, eps_m::T, c_m::T, rho_g::T, eps_g::T, c_g::T)::T where {T<:Float64}\n\nComputing the product of density and specific heat \n\nThis function is used within the build_rho_rc function.\n\nReturns\n\nrc: the product of density and specific heat\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.record_erupt_end-Union{Tuple{T}, Tuple{T, EruptSaved{T}, Param{T}}} where T<:Float64","page":"Chamber.jl","title":"Chamber.record_erupt_end","text":"record_erupt_end(time::T, erupt_saved::EruptSaved{T}, param::Param{T}) where {T<:Float64}\n\nRecord duration, mass and volume of eruptions to EruptSaved\n\nThis function is used within the affect! function.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.record_erupt_start-Union{Tuple{T}, Tuple{T, T, T, T, T, T, EruptSaved{T}}} where T<:Float64","page":"Chamber.jl","title":"Chamber.record_erupt_start","text":"record_erupt_start(time::T, eps_g::T, eps_x::T, rho_m::T, rho_x::T, rho_g::T, erupt_saved::EruptSaved{T}) where {T<:Float64}\n\nRecord time, density of eruptions to EruptSaved\n\nThis function is used within the affect! function.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.rho_0_f-NTuple{5, Float64}","page":"Chamber.jl","title":"Chamber.rho_0_f","text":"rho_0_f(eps_g0::Float64, eps_x0::Float64, rho_g0::Float64, rho_m0::Float64, rho_x0::Float64)::Float64\n\nThis function is used within the chamber function.\n\nReturns\n\nrho_0: initial bulk density (kg/m³)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.rho_f-Union{Tuple{}, Tuple{T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.rho_f","text":"rho_f(;eps_m::T, eps_g::T, eps_x::T, rho_m::T, rho_g::T, rho_x::T)::T where {T<:Float64}\n\nThis function is used within the build_rho_rc function.\n\nReturns\n\nrho: bulk density (kg/m³)\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.solve_NR-Union{Tuple{T}, Tuple{Any, Any, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.solve_NR","text":"solve_NR(f, f_prime, errorTol::T, count_max::T, Xc_initial::T)::T where {T<:Float64}\n\nFinding mole fraction of CO2 in gas (X_CO2).\nThis function is used within the exsolve3 function.\n\nArguments\n\nf: Water Paritioning Function\nf_prime: Function for the derivative of water with reference to X_CO2\nerrorTol: error tolerance, the default value is 1e-10\ncount_max: Maximum loop count, the default value is 1e2\nXc_initial: initial guess of X_CO2, the dedault value is 1e-2\n\nReturns\n\nX_CO2: mole fraction of CO2 in gas\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.solve_X_co2-Tuple{Mafic, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.solve_X_co2","text":"solve_X_co2(composition::Mafic, eps_g0::Float64, X_co2_prev::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_co2::Float64, Tol::Float64)::Float64\n\nThis function is used within the IC_Finder function to solve X_co20.\n\nReturns\n\nX_co20\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.solve_X_co2-Tuple{Silicic, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64}","page":"Chamber.jl","title":"Chamber.solve_X_co2","text":"solve_X_co2(composition::Silicic, eps_g0::Float64, X_co2_prev::Float64, P::Float64, T::Float64, eps_x0::Float64, V::Float64, rho_m::Float64, rho_g::Float64, M_co2::Float64, Tol::Float64)::Float64\n\nThis function is used within the IC_Finder function to solve X_co20.\n\nReturns\n\nX_co20\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.stopChamber_MT-Tuple{Any, Vector{Float64}, Float64, Any, SW{Int8}, Param{Float64}}","page":"Chamber.jl","title":"Chamber.stopChamber_MT","text":"stopChamber_MT(out, u::Vector{Float64}, t::Float64, int, sw::SW{Int8}, param::Param{Float64})\n\nDefine the stopping criteria for an ODE solver that simulates a magma chamber.\n\nArguments\n\nout: An array where the function should save the condition value at the right index. The maximum index of out should be specified in the len property of callback, which allows for a chain of len events, triggering the ith event when out[i] = 0. The function returns the value of out[8] as the last condition. Checking Event Handling and Callback Functions page of DifferentialEquations.jl for more details.\nu: A vector containing the state of the system at time t.\nt: The current time of the ODE solver.\nint: The current state of the integrator. It's format is from the DifferentialEquations.jl package\nsw: A custom parameter used to control simulation behavior.\nparam: A custom parameter containing physical constants and other model parameters.\n\nThe arguments out, u, t, and int are from the DifferentialEquations.jl package. These argument formats are specific to the DifferentialEquations.jl package.\n\nReturns\n\nThe out array is modified in-place to contain the condition values at the current state of the system. The function computes several quantities based on the current state of the system and the model parameters, such as the crystal fraction, the maximum amount of exsolved fluid, and the amount of CO2 in the melt. It then uses these values to calculate the condition values to be stored in the out array, as follows:\n\nout[1]: the crystal fraction.\nout[2]: the ratio of crystal fraction to liquid fraction, minus 0.8.\nout[3]: if an eruption is not occurring, the pressure difference between the lithostatic pressure and the current pressure, minus the critical pressure difference. Otherwise, negative the critical pressure difference.\nout[4]: if an eruption is occurring, the lithostatic pressure minus the current pressure. Otherwise, negative the critical pressure difference.\nout[5]: the crystal fraction minus 0.5.\nout[6]: the difference between the amount of water in the melt and the maximum amount of exsolved fluid.\nout[7]: negative the difference between the initial lithostatic pressure and the current pressure plus the critical pressure difference.\nout[8]: the difference between the amount of CO2 in the melt and the saturation concentration.\n\nNote that the out and u arguments are in the format expected by the DifferentialEquations.jl package, and the function is intended to be used as a condition for a callback function.\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.water-Union{Tuple{T}, Tuple{Mafic, T, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.water","text":"water(composition::Silicic, p::T, t::T, x::T, c::T)::T where {T<:Float64}\n\nWater Paritioning Function\nThis function is used within the exsolve3 function.\n\nArguments\n\np: pressure (Pa)\nt: temperature (K)\nx: The previous mole fraction of CO2 (X_CO2)\nc: amount of water\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.water-Union{Tuple{T}, Tuple{Silicic, T, T, T, T}} where T<:Float64","page":"Chamber.jl","title":"Chamber.water","text":"water(composition::Silicic, p::T, t::T, x::T, c::T)::T where {T<:Float64}\n\nWater Paritioning Function\nThis function is used within the exsolve3 function.\n\nArguments\n\np: pressure (Pa)\nt: temperature (K)\nx: The previous mole fraction of CO2 (X_CO2)\nc: amount of water\n\n\n\n\n\n","category":"method"},{"location":"#Chamber.OdeSetting","page":"Chamber.jl","title":"Chamber.OdeSetting","text":"Settings for ODE Solver Calculation\n\n\n\n\n\n","category":"type"},{"location":"#Chamber.Param","page":"Chamber.jl","title":"Chamber.Param","text":"Parameters\n\n\n\n\n\n","category":"type"},{"location":"#Chamber.ParamICFinder","page":"Chamber.jl","title":"Chamber.ParamICFinder","text":"Settings for IC_Finder\n\n\n\n\n\n","category":"type"},{"location":"#Chamber.RheolComposition","page":"Chamber.jl","title":"Chamber.RheolComposition","text":"Rheology of the crust\n\n\n\n\n\n","category":"type"},{"location":"#Chamber.SW","page":"Chamber.jl","title":"Chamber.SW","text":"eruption/coolingmodule/viscousrelaxation control\n\n\n\n\n\n","category":"type"},{"location":"#Index","page":"Chamber.jl","title":"Index","text":"","category":"section"},{"location":"","page":"Chamber.jl","title":"Chamber.jl","text":"","category":"page"}] }