PetroBase.jl
Documentation for the PetroBase.jl package. This is a basic package with some useful type definitions and functions for petrological modelling. This is intended for use with JPerpleX and other modelling packages I have developed to provide an easy way to interoperate between them.
PetroBase.PetroBase
PetroBase.Chemical
PetroBase.Component
PetroBase.Component
PetroBase.PetroSystem
PetroBase.Phase
PetroBase.TraceElement
PetroBase.TraceElement
Base.:*
Base.:*
Base.:+
Base.:+
Base.:+
Base.:+
Base.:-
Base.:-
Base.:-
Base.:-
Base.:/
Base.:/
Base.:≈
PetroBase.:≃
PetroBase.concentration
PetroBase.concentration
PetroBase.findchemical
PetroBase.findchemical
PetroBase.gibbs
PetroBase.isunique
PetroBase.mol
PetroBase.name
PetroBase.sum_mass
PetroBase.PetroBase
— ModuleMain module for PetroBase, provides basic types and functions to solve petrological problems.
Exports
PetroBase.Chemical
— TypeAbstract supertype for chemical components and trace elements
PetroBase.Component
— TypeComponent(clone; ...)
Component(clone, mol; μ)
Clones the parameters of a 'Component' but with change of 'mol' and/or 'μ'
PetroBase.Component
— TypeBasic unit in describing composition of a phase or system. Critical to most calculations. Typically the only values that will ever changed are mol and chemical potential.
name::String
: Name of the componentmolarmass::Float64
: Molar mass (g/mol)mol::Float64
: Moles of the componentμ::Float64
: Chemical potential (J/mol)
PetroBase.PetroSystem
— TypeThis type is defined to contain all the most relevant properties of a petrological system, any number of variables can be initialized and defaults will be 0 or empty arrays/strings. Units are selected based on convenience for petrological modelling.
composition::Array{Component}
: Composition of the system as defined by a 'Component' arrayphases::Array{Phase}
: Phases within the systemtraceelements::Array{TraceElement}
: Concentration of trace elements in the systemmol::Float64
: Total moles of all components in the systemvol::Float64
: Total volume of all phases in the system(J/bar [m^3/10^5])mass::Float64
: Total mass of the system(g)ρ::Float64
: Density of the system (kg/m^3)molarmass::Float64
: Molar mass of the system (kg/m^3)G::Float64
: Gibbs free energy (J/mol)H::Float64
: Enthalpy (J/mol)S::Float64
: Entropy (J/K·mol)Cp::Float64
: Heat capacity (J/K·mol)Vmol::Float64
: Molar volume (J/bar·mol)Cp_Cv::Float64
: Cp/Cv (heat capacity ratio)α::Float64
: Thermal expansion coefficient(1/K)β::Float64
: Compressibility (1/bar)
PetroBase.Phase
— TypeThis type is defined to contain all the most relevant properties of a phase, any number of variables can be initialized and defaults will be 0 or empty arrays/strings. Units are selected based on convenience for petrological modelling.
name::String
: Name of the phasecomposition::Array{Component}
: Composition of the phase as defined by a 'Component' arraytraceelements::Array{TraceElement}
: Concentration of trace elements in the phasemol::Float64
: Number of moles of the phase present in the systemvol::Float64
: Volume of phase present in the system (J/bar [m^3/10^5])mass::Float64
: Total mass of the phase present in the system (g)ρ::Float64
: Density (kg/m^3)molarmass::Float64
: Molar mass (g/mol)G::Float64
: Gibbs free energy (J/mol)H::Float64
: Enthalpy (J/mol)S::Float64
: Entropy (J/mol)Cp::Float64
: Heat capacity (J/K·mol)Vmol::Float64
: Molar volume (J/bar·mol)Cp_Cv::Float64
: Cp/Cv (heat capacity ratio)α::Float64
: Thermal expansion coefficient(1/K)β::Float64
: Compressibility (1/bar)
PetroBase.TraceElement
— TypeDescribes the trace element concentration of a phase or system. Typically the only value that will change is concentration
name::String
: Name of the elementmolarmass::Float64
: Molar mass (g/mol)concentration::Float64
: Concentration in the system or phase (µg/g)
PetroBase.TraceElement
— MethodTraceElement(clone, conc)
Clones the parameters of a 'TraceElement' but with change of 'concentration'
Base.:*
— Method*(comp1::Component, num::Real) -> Component
Multiplies the 'mol' parameter of 'comp1' by 'num'
Base.:*
— Method*(te1::TraceElement, num::Real) -> TraceElement
Multiplies the 'concentration' parameter of 'te1' by 'num'
Base.:+
— Method+(comp1::Component, comp2::Component) -> Component
Adds together the 'mol' parameter of two 'Component' variables that have the same name and molar mass. This will return a 'Component' with the chemical potential of the first argument.
Base.:+
— Method+(comp1::Component, num::Real) -> Component
Adds 'num' to the 'mol' of 'comp1'
Base.:+
— Method+(te1::TraceElement, num::Real) -> TraceElement
Adds 'num' to the 'concentration' paremeter of 'te1'
Base.:+
— Method+(te1::TraceElement, te2::TraceElement) -> TraceElement
Adds together the 'concentration' parameter of two 'TraceElement' variables that have the same name and molar mass
Base.:-
— Method-(comp1::Component, comp2::Component) -> Component
Subtracts the 'mol' parameter of 'comp2' from 'comp1' as long as they have the same name and molar mass. This will return a 'Component' with the chemical potential of the first argument.
Base.:-
— Method-(comp1::Component, num::Real) -> Component
Subtracts 'num' to the 'mol' parameter of 'comp1'
Base.:-
— Method-(te1::TraceElement, num::Real) -> TraceElement
Subtracts 'num' to the 'concentration' parameter of 'te1'
Base.:-
— Method-(te1::TraceElement, te2::TraceElement) -> TraceElement
Subtracts the 'concentration' parameter of 'te2' from 'te1' as long as they have the same name and molar mass
Base.:/
— Method/(comp1::Component, num::Real) -> Component
Divides the 'mol' parameter of 'comp1' by 'num'
Base.:/
— Method/(te1::TraceElement, num::Real) -> TraceElement
Divides the 'concentration' parameter of 'te1' by 'num'
Base.:≈
— Method≈(comp1::Chemical, comp2::Chemical) -> Bool
This is a simple boolean operator that returns true if two 'Chemical' variables have the same name. molar mass, and amount of moles
PetroBase.:≃
— Method≃(comp1::Chemical, comp2::Chemical) -> Bool
This is a simple boolean operator that returns true if two 'Chemical' variables have the same name and molar mass
PetroBase.concentration
— Methodconcentration(comp::Component) -> Float64
Returns the 'mol' of 'comp', useful for broadcasting
PetroBase.concentration
— Methodconcentration(te::TraceElement) -> Float64
Returns the 'concentration' of a 'TraceElement', useful for broadcasting
PetroBase.findchemical
— Methodfindchemical(
chem::Array{<:Chemical},
fChem::Chemical
) -> Int64
Finds the first index of 'fChem' in the 'chem' array. Returns 0 if 'fChem' isnt present. Best used with arrays of unique 'Chemical' variables.
PetroBase.findchemical
— Methodfindchemical(
chem::Array{<:Chemical},
fchem::String
) -> Int64
Finds the first index of an element in the 'chem' array with the name of 'fChem'. Returns 0 if 'fChem' isnt present. Best used with arrays of unique 'Chemical' variables.
PetroBase.gibbs
— Methodgibbs(phase::Phase) -> Float64
Returns 'G' of 'phase', useful for broadcasting
PetroBase.isunique
— Methodisunique(chem::Array{<:Chemical}) -> Bool
Checks if each cell in a 'Chemical' array is not repeated elsewhere in the array.
PetroBase.mol
— Methodmol(phase::Phase) -> Float64
Returns the 'mol' of 'phase', useful for broadcasting
PetroBase.name
— Methodname(chem::Chemical) -> Any
Returns 'name' of a 'chem', useful for broadcasting
PetroBase.sum_mass
— Methodsum_mass(comps::Array{Component}) -> Union{Float64, Int64}
Calculates the molar mass of an array of 'Component' variables by adding up the product of the molar mass and mol of each 'Component' in the array. Intent of use is calculating molar mass of a phase that is described using a 'Component' array