PetroBuffer’s Code Documentation
Contents
petrobuffer.buffers
Module containing the buffer models
- petrobuffer.buffers.calcBuffer(name, T, P)[source]
Main function to calculate the fO2 of a given buffer under specified T P conditions.
- Parameters
buffer_name (str) – Possible buffers are: QIF, IW, WM, IM, CoCoO, FMQ, NNO, MH.
T (float) – Temperature in degrees K
P (float) – Pressure in bar
- Returns
absolute fO2, as log10(fO2)
- Return type
float
- petrobuffer.buffers.calc_iw_highp(P, T)[source]
Define IW buffer value at P, T at high pressure.
- Parameters
P (float) – Pressure in GPa
T (float) – Temperature in degrees K
- Returns
log10(fO2)
- Return type
float
References
Campbell et al. (2009) High-pressure effects on the iron-iron oxide and nickel-nickel oxide oxygen fugacity buffers - Table S4
Notes
log10 fO2 = (a0 + a1*P) + (b0 + b1*P + b2*P^2 + b3*P^3)/T
a0: 6.54106 a1: 0.0012324 b0: -28163.6 b1: 546.32 b2: -1.13412 b3: 0.0019274
- petrobuffer.buffers.calc_nno_highp(P, T)[source]
Define NNO buffer value at P, T at high pressure.
- Parameters
P (float) – Pressure in GPa
T (float) – Temperature in degrees K
- Returns
log10(fO2)
- Return type
float
References
Campbell et al. (2009) High-pressure effects on the iron-iron oxide and nickel-nickel oxide oxygen fugacity buffers - Table S5
Notes
log10 fO2 = (a0 + a1*P + a2*P^2 + a3*P^3 + a4*P^4) + (b0 + b1*P + b2*P^2 + b3*P^3)/T
a0: 8.699 a1: 0.01642 a2: -0.0002755 a3: 0.000002683 a4: -1.015E-08 b0: -24205 b1: 444.73 b2: -0.59288 b3: 0.0015292
- petrobuffer.buffers.frost1991(buffer_name, T, P)[source]
Calculate mineral buffer at given T and P as listed in Frost 1991
- Parameters
buffer_name (str) – Possible buffers are: QIF_highT, QIF_lowT, IW, WM, IM, CoCoO, FMQ_highT, FMQ_lowT, NNO, MH_highT, MH_midT, MH_lowT.
T (float) – Temperature in degrees K
P (float) – Pressure in bar
- Returns
log10(fO2)
- Return type
float
References
Frost (1991) Mineralogical Society of America “Reviews in Mineralogy”, Volume 25
petrobuffer.conversions
Module containing the main PetroBuffer functions
- petrobuffer.conversions.convert_buffer(fO2: Union[float, int], old_buffer: str, new_buffer: str, T: Union[float, int], P: Union[float, int], celsius: bool = False) float[source]
Translate an fO2 value from one relative buffer to another.
- Parameters
fO2 (float or int) – The current fO2, relative to old_buffer.
old_buffer (str) – Name of the original buffer the fO2 is relative to. One from: QIF, IW, WM, IM, CoCoO, FMQ, NNO, MH.
new_buffer (str) – Name of the new buffer the fO2 should be relative to. One from: QIF, IW, WM, IM, CoCoO, FMQ, NNO, MH.
T (float or int) – Temperature in degrees K
P (float or int) – Pressure in bar
celsius (bool, default=False) – Whether temperatures are in Kelvin (False) or celsius (True)
- Returns
fO2 relative to the new buffer, given as log10(fO2)
- Return type
float
- petrobuffer.conversions.get_absolute_fo2(fO2, buffer, T, P, celsius=False)[source]
Main function to calculate fO2 in terms of a given buffer.
- Parameters
fO2 (float) – fO2 relative to buffer
buffer (str) – name of the buffer to give fO2 as relative to. one from: QIF, IW, WM, IM, CoCoO, FMQ, NNO, MH.
T (float) – Temperature in degrees K
P (float) – Pressure in bar
celsius (bool, default=False) – Whether temperatures are in Kelvin (False) or celsius (True)
- Returns
fO2 relative to the specified buffer, given as log10(fO2)
- Return type
float
- petrobuffer.conversions.get_ironOxide(C: dict, fO2: Union[float, int], T: Union[float, int], P: Union[float, int], celsius=False, normalised_comp=True, buffer: Optional[str] = None, force_model: Optional[str] = None) float[source]
Returns the ferric/ferrous (Fe2O3/FeO) mole ratio of a melt given fO2.
- Parameters
C (dict) – Major element composition of the silicate melt as weight percents. Required species: Al2O3, FeOt, CaO, Na2O (+ K2O if using r2013)
fO2 (float or int) – fO2 as either an absolute value given as log10(fO2), or relative to a buffer if one is specified in the buffer argument.
T (float) – Temperature in degrees K
P (float) – Pressure in bar
celsius (bool, default=False) – If true, T can be given in Celsius rather than degrees Kelvin.
normalised_comp (bool, default=True) – Selects whether the composition being returned is normalised, or if only the Fe2O3 and FeO is recalculated.
buffer (str, optional) – The buffer fO2 is relative to if it is not an absolute value. One of QIF, IW, WM, IM, CoCoO, FMQ, NNO, MH.
force_model (str, optional) – Forces the model used, rather than allowing selection based on total FeO content. One from kc1991 (Kress & Carmichael 1991) or r2013 (Righter et.al., 2013).
- Returns
float – Fe2O3/FeO mole ratio
dict – New melt major oxide composition as wt%
- petrobuffer.conversions.get_meltfO2(C: dict, T: Union[float, int], P: Union[float, int], celsius=False, buffer: Optional[str] = None, force_model: Optional[str] = None) float[source]
Returns the fO2 of a melt, given the FeO and Fe2O3 content.
- Parameters
C (dict) – Major element composition of the silicate melt as weight percents. Required species: Al2O3, FeOt, CaO, Na2O (+ K2O if using r2013)
T (float) – Temperature in degrees K
P (float) – Pressure in bar
celsius (bool, default=False) – If true, T can be given in Celsius rather than degrees Kelvin.
buffer (str, optional) – The buffer the returned fO2 should be is relative to. If None, fO2 is returned as an absolute value (log10(fO2)). One of QIF, IW, WM, IM, CoCoO, FMQ, NNO, MH.
force_model (str, optional) – Forces the model used, rather than allowing selection based on total FeO content. One from kc1991 (Kress & Carmichael 1991) or r2013 (Righter et.al., 2013).
- Returns
float – fO2 as log10(fO2)
str – buffer fO2 is relative to, set with buffer, otherwise ‘absolute’.
- petrobuffer.conversions.get_relative_fo2(fO2, buffer, T, P, celsius=False)[source]
Main function to calculate fO2 in terms of a given buffer.
- Parameters
fO2 (float) – absolute fO2, as log10(fO2)
buffer (str) – name of the buffer to give fO2 as relative to. one from: QIF, IW, WM, IM, CoCoO, FMQ, NNO, MH.
T (float) – Temperature in degrees K
P (float) – Pressure in bar
celsius (bool, default=False) – Whether temperatures are in Kelvin (False) or celsius (True)
- Returns
fO2 relative to the specified buffer, given as log10(fO2)
- Return type
float
petrobuffer.core
Module containing core data and conversions
- exception petrobuffer.core.Error[source]
Bases:
ExceptionBase class for exceptions in this module.
- exception petrobuffer.core.InputError(message)[source]
Bases:
ErrorException raised for errors in the input.
- expression -- input expression in which the error occurred
- message -- explanation of the error
petrobuffer.ferric
Module containing the ferric/ferrous <-> fO2 conversion models
- petrobuffer.ferric.fo2_to_iron_kc91(C, T, P, lnfo2)[source]
Calculates the Fe2O3/FeO mole ratio of a melt where the fO2 is known.
- Parameters
C (dictionary) – Major element composition of the silicate melt as MOLE FRACTIONS Required species: Al2O3, FeOt, CaO, Na2O, K2O
T (float) – Temperature in degrees K
P (float) – Pressure in pascals (Pa)
lnfo2 (float) – ln(fO2)
- Returns
Fe2O3/FeO mole ratio
- Return type
float
References
Kress and Carmichael (1991) The compressibility of silicate liquids containing Fe2O3 and the effect of composition, temperature, oxygen fugacity and pressure on their redox states
Notes
- ln(X_Fe2O3/X_FeO) = a*FO2 + b/T + c + sum(d_i*X_i) + e*[1-T0/T-ln(T/T0)]
f*P/T + g*[(T-T0)*P]/T + h*P^2/T
a = 0.196 b = 1.1492e4 K c = -6.675 dal2o3 = -2.243 dfeo = -1.828 dcao = 3.201 dna2o = 5.854 dk2o = 6.215 e = -3.36 f = -7.01e-7 K/Pa g = -1.54e-10 /Pa h = 3.85e-17 K/Pa^2
- petrobuffer.ferric.fo2_to_iron_r13(C, T, P, lnfo2)[source]
Calculates the Fe2O3/FeO mole ratio of an FeOt>15 wt% melt where the fO2 is known.
- Parameters
C (dictionary) – Major element composition of the silicate melt as mole fractions Required species: Al2O3, FeOt, CaO, Na2O, K2O, P2O5
T (float) – Temperature in degrees K
P (float) – Pressure in gigapascals (GPa)
lnfo2 (float) – ln(fO2)
- Returns
Fe2O3/FeO mole ratio
- Return type
float
References
Righter et al. (2013) Redox systematics of martian magmas with implications for magnetite stability.
- petrobuffer.ferric.iron_to_fo2_kc91(C, T, P)[source]
Calculates the oxygen fugacity (fO2) of a melt given where the ferric/ ferrous ratio is known.
- Parameters
C (dictionary) – Major element composition of the silicate melt as mole fractions Required species: Al2O3, FeO, Fe2O3, CaO, Na2O, K2O
T (float) – Temperature in degrees K
P (float) – Pressure in pascals (Pa)
- Returns
ln(fO2)
- Return type
float
References
Kress and Carmichael (1991) The compressibility of silicate liquids containing Fe2O3 and the effect of composition, temperature, oxygen fugacity and pressure on their redox states
Notes
- ln(fO2) = [ln(X_Fe2O3/X_FeO) - b/T - c - sum(d_i*X_i)
e*[1-T0/T-ln(T/T0)] - f*P/T - g*[(T-T0)*P]/T - h*P^2/T]/a
a = 0.196 b = 1.1492e4 K c = -6.675 dal2o3 = -2.243 dfeo = -1.828 dcao = 3.201 dna2o = 5.854 dk2o = 6.215 e = -3.36 f = -7.01e-7 K/Pa g = -1.54e-10 /Pa h = 3.85e-17 K/Pa^2
- petrobuffer.ferric.iron_to_fo2_r13(C, T, P)[source]
Calculates the oxygen fugacity (fO2) of an FeOt>15 wt% melt given where the ferric/ferrous ratio is known.
- Parameters
C (dictionary) – Major element composition of the silicate melt as mole fractions Required species: Al2O3, FeOt, CaO, Na2O, K2O, P2O5
T (float) – Temperature in degrees K
P (float) – Pressure in gigapascals (GPa)
- Returns
ln(fO2)
- Return type
float
References
Righter et al. (2013) Redox systematics of martian magmas with implications for magnetite stability.