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.ComponentType
Component(clone; ...)
Component(clone, mol; μ)

Clones the parameters of a 'Component' but with change of 'mol' and/or 'μ'

PetroBase.ComponentType

Basic 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 component

  • molarmass::Float64: Molar mass (g/mol)

  • mol::Float64: Moles of the component

  • μ::Float64: Chemical potential (J/mol)

PetroBase.PetroSystemType

This 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' array

  • phases::Array{Phase}: Phases within the system

  • traceelements::Array{TraceElement}: Concentration of trace elements in the system

  • mol::Float64: Total moles of all components in the system

  • vol::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.PhaseType

This 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 phase

  • composition::Array{Component}: Composition of the phase as defined by a 'Component' array

  • traceelements::Array{TraceElement}: Concentration of trace elements in the phase

  • mol::Float64: Number of moles of the phase present in the system

  • vol::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.TraceElementType

Describes the trace element concentration of a phase or system. Typically the only value that will change is concentration

  • name::String: Name of the element

  • molarmass::Float64: Molar mass (g/mol)

  • concentration::Float64: Concentration in the system or phase (µg/g)

PetroBase.TraceElementMethod
TraceElement(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.concentrationMethod
concentration(comp::Component) -> Float64

Returns the 'mol' of 'comp', useful for broadcasting

PetroBase.concentrationMethod
concentration(te::TraceElement) -> Float64

Returns the 'concentration' of a 'TraceElement', useful for broadcasting

PetroBase.findchemicalMethod
findchemical(
    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.findchemicalMethod
findchemical(
    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.gibbsMethod
gibbs(phase::Phase) -> Float64

Returns 'G' of 'phase', useful for broadcasting

PetroBase.isuniqueMethod
isunique(chem::Array{<:Chemical}) -> Bool

Checks if each cell in a 'Chemical' array is not repeated elsewhere in the array.

PetroBase.molMethod
mol(phase::Phase) -> Float64

Returns the 'mol' of 'phase', useful for broadcasting

PetroBase.nameMethod
name(chem::Chemical) -> Any

Returns 'name' of a 'chem', useful for broadcasting

PetroBase.sum_massMethod
sum_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