pygcc

Init file

Submodules

Attributes

eps

J_to_cal

IAPWS95_COEFFS

MW

Classes

db_reader

Class to read direct-access and source thermodynamic database

iapws95

Implementation of IAPWS Formulation 1995 for ordinary water substance, revised release of 2016

ZhangDuan

Implementation of Zhang & Duan model Formulation for water at higher Temperature and Pressure conditions, i.e, Deep Earth Water - DEW

water_dielec

Class Implementation of Water dielectric constants, the Debye-Huckel "A" and "B" parameters and their derivatives at ambient to deep-earth Temperature and Pressure conditions with three different formulations

Driesner_NaCl

Implementation of Driesner and Heinrich PTx Formulation for H2O-NaCl system

Dummy

Class of functions to evaluate the IAPWS95 equation of state for calculating thermodynamic

heatcap

Class to heat capacity for mineral and gases using Maier-Kelley powerlaw, Haas-Fisher powerlaw, Holland and Powell and Berman's function

solidsolution_thermo

Class to calculate Ideal mixing model for solid-solutions, supporting multisite ideal formalism

calcRxnlogK

This class implemetation calculates logK values for any reaction with the option for extrapolation where rho < 350kg/m3

write_database

Class to write the new database for either GWB, EQ3/6, ToughReact, Pflotran or PHREEQC into

db_reader

Class to read direct-access and source thermodynamic database

iapws95

Implementation of IAPWS Formulation 1995 for ordinary water substance, revised release of 2016

ZhangDuan

Implementation of Zhang & Duan model Formulation for water at higher Temperature and Pressure conditions, i.e, Deep Earth Water - DEW

water_dielec

Class Implementation of Water dielectric constants, the Debye-Huckel "A" and "B" parameters and their derivatives at ambient to deep-earth Temperature and Pressure conditions with three different formulations

Driesner_NaCl

Implementation of Driesner and Heinrich PTx Formulation for H2O-NaCl system

heatcap

Class to heat capacity for mineral and gases using Maier-Kelley powerlaw, Haas-Fisher powerlaw, Holland and Powell and Berman's function

solidsolution_thermo

Class to calculate Ideal mixing model for solid-solutions, supporting multisite ideal formalism

Functions

dbaccess_modify([in_filename, dbaccess, out_filename])

This function loads thermodynamic data from a csv files and appends/replace the corresponding species thermo data and writes out a modified direct-access database

readIAPWS95data()

returns all constants and coefficients needed for the IAPWS95 formulation, packed into a dictionary

convert_temperature(T[, Out_Unit])

This function converts temperatures from Celsius to Kelvin and vice-versa

concentration_converter([val, In_Unit, Out_Unit])

This function converts concentration between several units like

supcrtaq(TC, P, specieppt[, Dielec_method, ThermoInUnit])

This function evaluates the Gibbs free energy of aqueous species at T and P

calclogKclays(TC, P, *elem[, dbaccessdic, group, ...])

This function calculates logK values and reaction parameters of clay reactions using below references:

calc_elem_count_molewt(formula, **kwargs)

This function calculates the molecular mass and the elemental composition of a substance given

importconfile(filename, *Rows)

This function imports numeric data from a text file as column vectors.

var_name(var)

feval(funcName, *args)

roundup_tenth(x)

roundup_hundredth(x)

read_specific_lines(file, lines_to_read)

denormalize_phreeqc_species_charge(j)

Helper function to reverse the normalization of PHREEQC species charge notation.

normalize_species_charges(species)

normalize_phreeqc_species_charge(j)

Helper function to normalize PHREEQC species charge notation.

contains_missing_species(line, missing_spx)

build_side_regex(side)

Build a regex to match one side of a chemical reaction.

derivative(f, a[, method, h])

Compute the derivative of f, f'(a) with step size h.

info(name, dic)

This function checks for naming convention of the species in the direct-access or source database

drummondgamma(TK, I)

This function models solubility of CO2 gas in brine using Drummond equation

Henry_duan_sun(TK, P, I)

This function evaluates the solubility of CO2 gase in brine using Duan_Sun Formulation

co2fugacity(TK, P[, poy])

This function computes the fugacity and density of CO2 by Duan and Sun 2003

gamma_correlation(TC, P[, method])

This function calculates the CO2 activity correlation coefficients at

Helgeson_activity(TC, P, I[, Dielec_method])

This function calculates the solute activity coefficient, solvent osmotic coefficient,

aw_correlation(TC, P[, Dielec_method])

Calculates the water activity correlation coefficients at given temperature and pressure

outputfmt(fid, logK, Rxn, *T[, dataset, logK_form])

This function writes logK and Rxn data to any file using GWB, EQ36, PHREEQC, Pflotran and ToughReact format

main_function_name(module)

Return the names of essential public functions and classes in the given module.

dbaccess_modify([in_filename, dbaccess, out_filename])

This function loads thermodynamic data from a csv files and appends/replace the corresponding species thermo data and writes out a modified direct-access database

readIAPWS95data()

returns all constants and coefficients needed for the IAPWS95 formulation, packed into a dictionary

convert_temperature(T[, Out_Unit])

This function converts temperatures from Celsius to Kelvin and vice-versa

concentration_converter([val, In_Unit, Out_Unit])

This function converts concentration between several units like

supcrtaq(TC, P, specieppt[, Dielec_method, ThermoInUnit])

This function evaluates the Gibbs free energy of aqueous species at T and P

Element_counts(formula)

This function calculates the elemental composition of a substance given by its chemical formula

calclogKclays(TC, P, *elem[, dbaccessdic, group, ...])

This function calculates logK values and reaction parameters of clay reactions using below references:

Package Contents

class pygcc.db_reader(**kwargs)

Class to read direct-access and source thermodynamic database

Parameters:
  • dbaccess (string) – path of the direct-access/sequential-access database, optional, default is speq21

  • dbBerman_dir (string) – path of the Berman mineral database, optional

  • dbHP_dir (string) – path of the supcrtbl mineral and gas database, optional

  • sourcedb (string) – path of the source database, optional

  • sourceformat (string) – specify the source database format, either ‘GWB’, ‘EQ36’ or ‘PHREEQC’, optional

  • dbaccessformat (string, optional) – specify the direct-access/sequential-access database format, either ‘speq’ or ‘supcrtbl’, default is ‘speq’

  • sourcedb_codecs (string) – specify the name of the encoding used to decode or encode the sourcedb file, optional

  • dbaccess_codecs (string) – specify the name of the encoding used to decode or encode the dbaccess file, optional

Returns:

  • dbaccessdic (dict) – dictionary of minerals, gases, redox and aqueous species

  • dbaccess (string) – direct-access database file name

  • sourcedic (dict) – dictionary of reaction coefficients and species

  • specielist (list) – list of species segmented into the different categories [element, basis, redox, aqueous, minerals, gases, oxides]

  • speciecat (list) – list of species categories listed in ‘specielist’

  • chargedic (dict) – dictionary of charges of species

  • MWdic (dict) – dictionary of MW of species

  • Mineraltype (dict) – mineral type for minerals

  • fugacity_info (dict) – fugacity information as stored in new tdat database for chi and critical ppts

  • Sptype (dict) – specie types and eq3/6 and revised date info

  • Elemlist (dict) – dictionary of elements and coefficients

  • Rd (list) – each line of sourcedb in an array

  • d (dict) – dictionary of database headers and corresponding line numbers in Rd

Examples

>>> ps = db_reader(sourcedb = './default_db/thermo.com.dat',
                   sourceformat = 'gwb',
                   dbaccess = './default_db/speq23.dat')
>>> ps.sourcedic, ps.dbaccessdic, ps.specielist
kwargs
Rd
d
__calc__(**kwargs)
readAqspecdb()

This function reads direct access thermodynamic database and can add other database sources at the bottom returns all constants of Maier-Kelley power function for minerals and gases (dG [cal/mol], dH [cal/mol], S [cal/mol-K], V [cm3/mol] a [cal/mol-K], b [*10**3 cal/mol/K^2],

c [*10^-5 cal/mol/K], Ttrans [K], Htr [cal/mol], Vtr [cm³/mol], dPdTtr [bar/K] ) and

aqueous species (dG [cal/mol], dH [cal/mol], S [cal/mol-K], V [cm3/mol], a1 [10 cal/mol/bar], a2 [*10*-2 cal/mol], a3 [cal-K/mol/bar], a4 [10*-4 cal-K/mol], c1 [cal/mol/K], c2 [10*-4 cal-K/mol], ω [10*-5 cal/mol] ) packed into a dbacess dictionary. In addition, the function can read Berman’s mineral properties such as (dG [J/mol], dH [J/mol], S [J/mol-K], V [cm³/mol], k0, k1, k2, k3, v1 [*10^5 K^-1], v2 [*10^5 K^-2], v3 [*10^5 bar^-1], v4 [*10^8 bar^-2], dTdP [K/bar], Tlambda [K], Tref [K], l1 [(J/mol)^0.5/K], l2 [(J/mol)^0.5/K^2], DtH, d0 [J/mol], d1 [J/mol], d2 [J/mol], d3 [J/mol], d4 [J/mol], d5 [J/mol], Tmin [K], Tmax [K]). In addition, the function can read supcrtbl’s mineral and gas properties such as (dG [kJ/mol], dH [kJ/mol], S [J/mol-K], V [J/bar], a [kJ/mol-K], b [*10^5 kJ/mol/K^2], c [kJ-mol-K], d [kJ/mol/K^0.5], alpha [*10^5 K^-1], kappa0 [kbar], kappa0_d [kbar], kappa0_dd [kbar], n_atom [-], Tc0 [K], Smax [J/mol-K], Vmax [J/bar], dH [KJ/mol], dV [J/bar], W [kJ/mol], Wv [J/bar], n [-], SF [-])

Parameters:
  • database (dbHP_dir filename and location of the supcrtbl (Holland and Powell) mineral and gas)

  • database

  • database

Returns:

  • dbaccessdic dictionary of minerals, gases, redox and aqueous species

  • dbaccess dat file name

Usage:

[dbaccessdic, dbname] = readAqspecdb(dbaccess)

readSourceGWBdb()

This function reads source GWB thermodynamic database and reaction coefficients of ‘eh’ and ‘e-’ has been added at the bottom returns all reaction coefficients and species, group species into redox, minerals, gases, oxides and aqueous species :param sourcedb: :type sourcedb: filename of the source database

Returns:

  • sourcedic (dictionary of reaction coefficients and species)

  • specielist (list of species segmented into the different categories) – [element, basis, redox, aqueous, minerals, gases, oxides]

  • speciecat (list of species categories listed in ‘specielist’)

  • chargedic (dictionary of charges of species)

  • MWdic (dictionary of MW of species)

  • Mineraltype (mineral type for minerals)

  • fugacity_info (fugacity information as stored in new tdat database for chi and critical ppts)

Usage:

[sourcedic, specielist, chargedic, MWdic, Mineraltype, fugacity_info, activity_model] = readSourceGWBdb()

readSourceEQ36db()

This function reads source EQ3/6 thermodynamic database and reaction coefficients of ‘eh’ and ‘e-’ has been added at the bottom returns all reaction coefficients and species, group species into basis, auxiliary basis, minerals, gases, liquids and aqueous species :param sourcedb: :type sourcedb: filename of the source database

Returns:

  • sourcedic (dictionary of reaction coefficients and species)

  • specielist (list of species segmented into the different categories) – [element, basis, redox, aqueous, minerals, gases, oxides]

  • speciecat (list of species categories listed in ‘specielist’)

  • chargedic (dictionary of charges of species and DHazero info)

  • MWdic (dictionary of MW of species)

  • Sptype (specie types and eq3/6 and revised date info)

  • Elemlist (dictionary of elements and coefficients)

Usage:

[sourcedic, specielist, chargedic, MWdic, block_info, Elemlist, act_param] = readSourceEQ36db(sourcedb)

readSourcePHREEQCdb()

This function reads source PHREEQC thermodynamic database and group species into solution, phases, exchange and surface species :param sourcedb: :type sourcedb: filename of the source database

Returns:

  • sourcedic (dictionary of reaction coefficients and species)

  • specielist (list of species segmented into the different categories) – [element, basis, redox, aqueous, minerals, gases, oxides]

  • speciecat (list of species categories listed in ‘specielist’)

  • chargedic (dictionary of charges of species)

Usage:

[sourcedic, specielist, chargedic, act_param] = readSourcePHREEQCdb()

pygcc.dbaccess_modify(in_filename=None, dbaccess=None, out_filename=None)

This function loads thermodynamic data from a csv files and appends/replace the corresponding species thermo data and writes out a modified direct-access database :param in_filename: CSV filename and location :type in_filename: string :param dbaccess: direct-access database filename and location (optional) :type dbaccess: string :param out_filename: newly modified direct-access database filename and location (optional) :type out_filename: string

Return type:

Output the newly modified direct-access with filename described in ‘out_filename’ if specified.

Examples

>>> dbaccess_modify(in_filename = 'geotpd_data_block_cr.csv')
class pygcc.iapws95(**kwargs)

Implementation of IAPWS Formulation 1995 for ordinary water substance, revised release of 2016

Notes

Temperature and Pressure input limits
  • -22 ≤ TC ≤ 1000 and 0 ≤ P ≤ 100,000

Parameters:
  • T (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • rho (float, vector) – Density [kg/m³]

  • rho0 (float, vector) – Starting estimate of density [kg/m³]

  • rhom (float, vector) – Molar density [kg/m³]

  • delta (float, vector) – Reduced density, rho/rhoc

  • tau (float, vector) – Reduced temperature, Tc/T

  • v (float, vector) – Specific volume [m³/kg]

  • vm (float, vector) – Specific molar volume [m³/mol]

  • Out_Unit (string) – Expected units (‘standard’ or ‘kilogram’)

  • FullEOSppt (bool) – Option to output all or essential water properties [False or True]

Returns:

  • The calculated instance has the following potential properties

  • rho (float, vector) – Density [kg/m3]

  • G (float, vector) – Gibbs energy [cal/mol] or [kJ/kg]

  • H (float, vector) – Enthalpy [cal/mol] or [kJ/kg]

  • S (float, vector) – Entropy [cal/mol/K] or [kJ/kg/K]

  • V (float, vector) – Volume [m3/mol] or [m3/kg]

  • P (float, vector) – Pressure [bar]

  • TC (float, vector) – Temperature [°C]

  • TK (float, vector) – Temperature [K]

  • U (float, vector) – Internal energy [cal/mol] or [kJ/kg] if FullEOSppt is True

  • F (float, vector) – Helmholtz energy [cal/mol/K] or [kJ/kg-K] if FullEOSppt is True

  • Cp (float, vector) – Isobaric heat capacity [cal/mol/K]

  • rhosl (float, vector) – Density of liquid [kg/m3]

  • rhosv (float, vector) – Density of vapor [kg/m3]

  • pdx (float, vector) – Derivative of pressure with respect to delta in bar

  • adx (float, vector) – Helmholtz energy derivative with respect to delta

  • ztx (float, vector) – zeta value (needed to calculate viscosity)

  • ptx (float, vector) – Derivative of pressure with respect to tau in bar

  • gdx (float, vector) – Gibbs energy derivative [kJ/kg] if FullEOSppt is True

  • ktx (float, vector) – Compressibility [/bar]

  • avx (float, vector) – Thermal expansion coefficient (thermal expansivity)

  • mu (float, vector) – viscosity [Pa-s] if FullEOSppt is True

  • bsx (float, vector) – Isentropic temperature-pressure coefficient [K-m3/kJ] if FullEOSppt is True

  • dtx (float, vector) – Isothermal throttling coefficient [kJ/kg/bar] if FullEOSppt is True

  • mux (float, vector) – Joule-Thomsen coefficient [K-m3/kJ] if FullEOSppt is True

  • cvx (float, vector) – Isochoric heat capacity [kJ/kg/K] if FullEOSppt is True

  • wx (float, vector) – Speed of sound [m/s] if FullEOSppt is True

Usage:

The general usage of iapws95 is as follows:

  1. For water properties at any Temperature and Pressure not on steam saturation curve:

    water = iapws95(T = T, P = P),

    where T is temperature in celsius and P is pressure in bar

  2. For water properties at any Temperature and Pressure on steam saturation curve:

    water = iapws95(T = T, P = ‘T’),

    where T is temperature in celsius, followed with a quoted character ‘T’ to reflect steam saturation pressure

    water = iapws95(T = ‘P’, P = P),

    where P is pressure in bar, followed with a quoted character ‘P’ to reflect steam saturation temperature

  3. For water properties at any Temperature and density :

    water = iapws95(T = T, rho = rho),

    where T is temperature in celsius and rho is density in kg/m³

  4. For water properties at any Pressure and density :

    water = iapws95(P = P, rho = rho),

    where P is pressure in bar and rho is density in kg/m³

  5. For water saturation properties at any saturation Temperature :

    water = iapws95(T = T),

    where T is temperature in celsius

  6. For water saturation properties at any saturation Pressure :

    water = iapws95(P = P),

    where P is pressure in bar

Examples

>>> water = iapws95(T = 200., P = 50, FullEOSppt = True)
>>> water.rho, water.G, water.H, water.S, water.V, water.P, water.T, water.mu
    867.2595, -60368.41787, -65091.03895,  25.14869,  4.96478e-03,  50.00000,
    200.000, 0.00013546
>>> water = iapws95(T=200, rho=996.5560, Out_Unit='kilogram', FullEOSppt=True)
>>> water.P, water.F, water.S, water.H, water.G, water.V, water.Cp, water.pdx
    2872.063, -234.204, 2.051, 1024.747, 53.994, 1.0035e-03, 3.883, 10079.17
>>> water.adx, water.ztx, water.ptx, water.ktx, water.avx, water.mu, water.gdx
    93.120, 2.189e-03, -7.348e+03,  3.205e-05,  6.809e-04, 1.914e-04, 1011.40
>>> water = iapws95(T = 350)
>>> water.P, water.rhosl, water.rhosv
    165.2942 574.7065 113.6056
>>> water = iapws95(P = 150)
>>> water.TC, water.rhosl, water.rhosv
    342.1553, 603.5179, 96.7271

References

  1. Wagner, W., Pruß, A., 2002. The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use. J. Phys. Chem. Ref. Data 31, 387–535. https://doi.org/10.1063/1.1461829

kwargs
mwH2O = 18.015268
__checker__(**kwargs)
__calc__(**kwargs)
class pygcc.ZhangDuan(**kwargs)

Implementation of Zhang & Duan model Formulation for water at higher Temperature and Pressure conditions, i.e, Deep Earth Water - DEW

Notes

Temperature and Pressure input limits
  • 0 ≤ TC ≤ 1726.85 and 1000 ≤ P ≤ 300,000

Parameters:
  • T (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • rho (float, vector) – Density [kg/m³]

  • rho0 (float, vector) – Starting estimate of density [kg/m³]

  • densityEquation (string) – specify either ‘ZD05’ to use Zhang & Duan (2005) or ‘ZD09’ to use Zhang & Duan (2009)

Returns:

  • The calculated instance has the following potential properties

  • rho (float, vector) – Density [kg/m3]

  • rhohat (float, vector) – Density [g/cm³]

  • G (float, vector) – Gibbs energy [cal/mol]

  • drhodP_T (float, vector) – Partial derivative of density with respect to pressure at constant temperature

  • drhodT_P (float, vector) – Partial derivative of density with respect to temperature at constant pressure

Usage:

The general usage of ZhangDuan is as follows:

  1. For water properties at any Temperature and Pressure:

    deepearth = ZhangDuan(T = T, P = P),

    where T is temperature in celsius and P is pressure in bar

  2. For water properties at any Temperature and density :

    deepearth = ZhangDuan(T = T, rho = rho),

    where T is temperature in celsius and rho is density in kg/m³

Examples

>>> deepearth = ZhangDuan(T = 25, P = 5000)
>>> deepearth.rho, deepearth.G, deepearth.drhodP_T, deepearth.drhodT_P
    1145.3065, -54631.5351, 2.3283e-05, -0.0004889
>>> deepearth = ZhangDuan(T = 200, rho = 1100)
>>> deepearth.P, deepearth.G, deepearth.drhodP_T, deepearth.drhodT_P
    7167.2231, -57319.0980, 2.3282e-05, -0.0005122

References

  1. Zhang, Z., Duan, Z., 2005. Prediction of the PVT properties of water over wide range of temperatures and pressures from molecular dynamics simulation. Phys. Earth Planet. Inter. 149, 335–354. https://doi.org/10.1016/j.pepi.2004.11.003.

  2. Zhang, C. and Duan, Z., 2009. “A model for C-O-H fluid in the Earth’s mantle”, Geochimica et Cosmochimica Acta, vol. 73, no. 7, pp. 2089–2102, doi:10.1016/j.gca.2009.01.021.

  3. Sverjensky, D.A., Harrison, B., Azzolini, D., 2014. Water in the deep Earth: The dielectric constant and the solubilities of quartz and corundum to 60kb and 1200°C. Geochim. Cosmochim. Acta 129, 125–145. https://doi.org/10.1016/j.gca.2013.12.019

kwargs
__calc__(**kwargs)
ZD_Pressure_drhodP(TC, rhohat, method=None)
ZD_Density(TC, P, method='ZD05', error=None)
GibbsEnergy(TC, P, method='VolumeIntegral')
class pygcc.water_dielec(**kwargs)

Class Implementation of Water dielectric constants, the Debye-Huckel “A” and “B” parameters and their derivatives at ambient to deep-earth Temperature and Pressure conditions with three different formulations

Parameters:
  • T (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • rho (float, vector) – Density [kg/m³]

  • Dielec_method (string) – specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric constant (optional), if not specified, default - ‘JN91’

  • Dielec_DEWoutrange (string) – specify either ‘FGL97’ or ‘JN91’ as the method to calculate dielectric constant for out of range for ‘DEW’ method if any

Returns:

  • The calculated instance has the following potential properties

  • E (float, vector) – dielectric constant of water

  • rhohat (float, vector) – density [g/cm³]

  • Ah (float, vector) – Debye-Huckel “A” parameters [kg^1/2 mol^-1/2]

  • Bh (float, vector) – Debye-Huckel “B” parameters [kg^1/2 mol^-1/2 Angstrom^-1]

  • bdot (float, vector) – bdot at any given temperature T

  • Adhh (float, vector) – Debye-Huckel “A” parameters associated with apparent molar enthalpy

  • Adhv (float, vector) – Debye-Huckel “A” parameters associated with apparent molar volume

  • Bdhh (float, vector) – Debye-Huckel “B” parameters associated with apparent molar enthalpy

  • Bdhv (float, vector) – Debye-Huckel “B” parameters associated with apparent molar volume

  • dEdP_T (float, vector) – Partial derivative of dielectric constant with respect to pressure at constant temperature

  • dEdT_P (float, vector) – Partial derivative of dielectric constant with respect to temperature at constant pressure

Notes

FGL97 Temperature and Pressure input limits:
  • -35 ≤ TC ≤ 600 and 0 ≤ P ≤ 12000

DEW Temperature and Pressure input limits:
  • 100 ≤ TC ≤ 1200 and 1000 ≤ P ≤ 60000

JN91 Temperature and Pressure input limits:
  • 0 ≤ TC ≤ 1000 and 0 ≤ P ≤ 5000

Usage

The general usage of water_dielec is as follows:

  1. For water dielectric properties at any Temperature and Pressure:

    dielect = water_dielec(T = T, P = P, Dielec_method = ‘JN91’),

    where T is temperature in celsius and P is pressure in bar

  2. For water dielectric properties at any Temperature and density :

    dielect = water_dielec(T = T, rho = rho, Dielec_method = ‘JN91’),

    where T is temperature in celsius and rho is density in kg/m³

  3. For water dielectric properties at any Temperature and Pressure on steam saturation curve:

    dielect = water_dielec(T = T, P = ‘T’, Dielec_method = ‘JN91’),

    where T is temperature in celsius and P is assigned a quoted character ‘T’ to reflect steam saturation pressure

    dielect = water_dielec(P = P, T = ‘P’, Dielec_method = ‘JN91’),

    where P is pressure in bar and T is assigned a quoted character ‘P’ to reflect steam saturation temperature

Examples

>>> dielect = water_dielec(T = 50, P = 500, Dielec_method = 'JN91')
>>> dielect.E, dielect.rhohat, dielect.Ah, dielect.Bh, dielect.bdot
    71.547359, 1.00868586, 0.52131899,   0.33218072,   0.04088528
>>> dielect.Adhh, dielect.Adhv, dielect.Bdhh, dielect.Bdhv
    0.64360153,   2.13119279,  15.6936832 , -14.52571678
>>> dielect.dEdP_T, dielect.dEdT_P
    0.03293026,   -0.32468033
>>> dielect = water_dielec(T = 200, rho = 1100, Dielec_method = 'FGL97')
>>> dielect.E, dielect.rhohat, dielect.Ah, dielect.Bh, dielect.bdot
    49.73131404,  1.1,  0.5302338, 0.34384714,  0.04452579
>>> dielect.Adhh, dielect.Adhv, dielect.Bdhh, dielect.Bdhv
    1.21317825,  2.21165281, 28.0047878, -34.21216547
>>> dielect.dEdP_T, dielect.dEdT_P
    0.01444368, -0.16864644
>>> dielect = water_dielec(T = 250, P = 5000, Dielec_method = 'DEW')
>>> dielect.E, dielect.rhohat, dielect.Ah, dielect.Bh, dielect.bdot, dielect.Adhh
    39.46273008,  1.0238784,  0.62248141,   0.35417088, 0.02878662, 0.80688122
>>> dielect.Adhv, dielect.Bdhh, dielect.Bdhv, dielect.dEdP_T, dielect.dEdT_P
     3.13101408, 39.76402294, -35.29670957, 0.0129006 , -0.08837842

References

  1. Release on the Static Dielectric Constant of Ordinary Water Substance for Temperatures from 238 K to 873 K and Pressures up to 1000 MPa” (IAPWS R8-97, 1997).

  2. Fernandez D. P., Goodwin A. R. H., Lemmon E. W., Levelt Sengers J. M. H., and Williams R. C. (1997) A Formulation for the Permittivity of Water and Steam at Temperatures from 238 K to 873 K at Pressures up to 1200 MPa, including Derivatives and Debye-Hückel Coefficients. J. Phys. Chem. Ref. Data 26, 1125-1166.

  3. Helgeson H. C. and Kirkham D. H. (1974) Theoretical Prediction of the Thermodynamic Behavior of Aqueous Electrolytes at High Pressures and Temperatures: II. Debye-Huckel Parameters for Activity Coefficients and Relative Partial Molal Properties. Am. J. Sci. 274, 1199-1251.

  4. Johnson JW, Norton D (1991) Critical phenomena in hydrothermal systems: State, thermodynamic, electrostatic, and transport properties of H2O in the critical region. American Journal of Science 291:541-648

  5. D. A. Sverjensky, B. Harrison, and D. Azzolini, “Water in the deep Earth: the dielectric constant and the solubilities of quartz and corundum to 60 kb and 1200 °C,” Geochimica et Cosmochimica Acta, vol. 129, pp. 125–145, 2014

kwargs
__checker__(**kwargs)
__calc__(**kwargs)
dielec_FGL97(TC, rho)

This function employs the FGL91 formulation to calculate the dielectric constant of water (E), the Debye-Huckel “A” parameters and Debye-Huckel “B” parameters (3) and their derivatives as a function of temperature and pressure

Notes

Temperature and Pressure input limits:
  • -35 ≤ TC ≤ 600 and 0 ≤ P ≤ 12000

Parameters:
  • TC (temperature [°C])

  • rho (density [kg/m3])

Returns:

  • E (dielectric constant of water)

  • rhohat (density [g/cm³])

  • Ah (Debye-Huckel “A” parameters [kg^1/2 mol^-1/2])

  • Bh (Debye-Huckel “B” parameters [kg^1/2 mol^-1/2 Angstrom^-1])

  • bdot (bdot at any given temperature T)

  • Adhh (Debye-Huckel “A” parameters associated with apparent molar enthalpy)

  • Adhv (Debye-Huckel “A” parameters associated with apparent molar volume)

  • Bdhh (Debye-Huckel “B” parameters associated with apparent molar enthalpy)

  • Bdhv (Debye-Huckel “B” parameters associated with apparent molar volume)

  • dEdP_T (Partial derivative of dielectric constant with respect to pressure at constant temperature)

  • dEdT_P (Partial derivative of dielectric constant with respect to temperature at constant pressure)

Usage

[E, rhohat, Ah, Bh, bdot, Adhh, Adhv, Bdhh, Bdhv, dEdP_T, dEdT_P] = dielec_FGL97( TC, rho)

References

  1. Release on the Static Dielectric Constant of Ordinary Water Substance for Temperatures from 238 K to 873 K and Pressures up to 1000 MPa” (IAPWS R8-97, 1997).

  2. Fernandez D. P., Goodwin A. R. H., Lemmon E. W., Levelt Sengers J. M. H., and Williams R. C. (1997) A Formulation for the Permittivity of Water and Steam at Temperatures from 238 K to 873 K at Pressures up to 1200 MPa, including Derivatives and Debye-Hückel Coefficients. J. Phys. Chem. Ref. Data 26, 1125-1166.

  3. Helgeson H. C. and Kirkham D. H. (1974) Theoretical Prediction of the Thermodynamic Behavior of Aqueous Electrolytes at High Pressures and Temperatures: II. Debye-Huckel Parameters for Activity Coefficients and Relative Partial Molal Properties. Am. J. Sci. 274, 1199-1251.

dielec_JN91(TC, rho)

This dielec_JN91 implementation employs the JN91 formulation to calculate the dielectric properties of water and steam, the Debye-Huckel “A” parameters and Debye-Huckel “B” parameters and their derivatives

Notes

Temperature and Pressure input limits:
  • 0 ≤ TC ≤ 1000 and 0 ≤ P ≤ 5000

Parameters:
  • TC (temperature [°C])

  • rho

rhohat : density [g/cm³]

Ah : Debye-Huckel “A” parameters [kg^1/2 mol^-1/2]

Bh : Debye-Huckel “B” parameters [kg^1/2 mol^-1/2 Angstrom^-1]

bdot : bdot at any given temperature T

Adhh : Debye-Huckel “A” parameters associated with apparent molar enthalpy

Adhv : Debye-Huckel “A” parameters associated with apparent molar volume

Bdhh : Debye-Huckel “B” parameters associated with apparent molar enthalpy

Bdhv : Debye-Huckel “B” parameters associated with apparent molar volume

dEdP_T : Partial derivative of dielectric constant with respect to pressure at constant temperature

dEdT_P : Partial derivative of dielectric constant with respect to temperature at constant pressure

Usage

References

  1. Johnson JW, Norton D (1991) Critical phenomena in hydrothermal systems: State, thermodynamic, electrostatic, and transport properties of H2O in the critical region. American Journal of Science 291:541-648

  2. Helgeson H. C. and Kirkham D. H. (1974) Theoretical Prediction of the Thermodynamic Behavior of Aqueous Electrolytes at High Pressures and Temperatures: II. Debye-Huckel Parameters for Activity Coefficients and Relative Partial Molal Properties. Am. J. Sci. 274, 1199-1251.

dielec_DEW()

This watercalc implementation employs the DEW formulation embedded in Sverjensky et al. (2014) to calculate the dielectric properties of water and steam, the Debye-Huckel “A” parameters and Debye-Huckel “B” parameters and their derivatives. This function has been set up to use either Johnson and Norton (1991) or Fernandez et al. (1997) formulation below 5000 bar and Sverjensky et al. (2014) formulation above 5000 bar.

Notes

Temperature and Pressure input limits:
  • 100 ≤ TC ≤ 1200 and 1000 ≤ P ≤ 60000

Parameters:
  • TC (temperature [°C])

  • P

rhohat : density [g/cm³]

Ah : Debye-Huckel “A” parameters [kg^1/2 mol^-1/2]

Bh : Debye-Huckel “B” parameters [kg^1/2 mol^-1/2 Angstrom^-1]

bdot : bdot at any given temperature T

Adhh : Debye-Huckel “A” parameters associated with apparent molar enthalpy

Adhv : Debye-Huckel “A” parameters associated with apparent molar volume

Bdhh : Debye-Huckel “B” parameters associated with apparent molar enthalpy

Bdhv : Debye-Huckel “B” parameters associated with apparent molar volume

dEdP_T : Partial derivative of dielectric constant with respect to pressure at constant temperature

dEdT_P : Partial derivative of dielectric constant with respect to temperature at constant pressure

Usage

References

  1. D. A. Sverjensky, B. Harrison, and D. Azzolini, “Water in the deep Earth: the dielectric constant and the solubilities of quartz and corundum to 60 kb and 1200 °C,” Geochimica et Cosmochimica Acta, vol. 129, pp. 125–145, 2014

  2. Helgeson H. C. and Kirkham D. H. (1974) Theoretical Prediction of the Thermodynamic Behavior of Aqueous Electrolytes at High Pressures and Temperatures: II. Debye-Huckel Parameters for Activity Coefficients and Relative Partial Molal Properties. Am. J. Sci. 274, 1199-1251.

pygcc.readIAPWS95data()

returns all constants and coefficients needed for the IAPWS95 formulation, packed into a dictionary

pygcc.convert_temperature(T, Out_Unit='C')

This function converts temperatures from Celsius to Kelvin and vice-versa

Parameters:
  • T (float, vector) – Temperature in °C or K

  • Out_Unit (string) – Expected temperature unit (C or K)

Returns:

T – Temperature in °C or K

Return type:

float, vector

Examples

>>> TC = 100; convert_temperature( TC, Out_Unit = 'K' )
    373.15
>>> TK = 520; convert_temperature( TK, Out_Unit = 'C' )
    246.85
class pygcc.Driesner_NaCl(**kwargs)

Implementation of Driesner and Heinrich PTx Formulation for H2O-NaCl system

Parameters:
  • T (float) – Temperature [°C]

  • P (float) – Pressure [bar]

  • xNaCl (float) – mole fraction of NaCl in H2O [-]

Returns:

  • The calculated instance has the following potential properties

  • PVLH (float) – Pressure of vapor + liquid + halite coexistence [bar]

  • Pcrit (float) – Critical pressure (of a H2O–NaCl mixture) [bar]

  • Xcrit (float) – Critical Composition [-]

  • xL_NaCl (float) – Composition of halite-saturated liquid (halite liquidus) Hypothetical [-]

  • xV_NaCl (float) – Composition of halite-saturated vapor [-]

  • xVL_Liq (float) – Composition of liquid at vapor + liquid coexistence [-]

  • xVL_Vap (float) – Composition of vapor at vapor+liquid coexistence [-]

  • rho (float) – Liquid NaCl density [kg/m3]

  • vm (float) – molar volume [mol/m3]

  • TstarH (float) – Scaled temperature for enthalpy correlation [°C]

  • H (float) – Specific enthalpy of an H2O–NaCl solution [J/kg]

  • Cp (float) – Isobaric heat capacity [J/kg/K]

  • mu (float) – viscosity [Pa-s]

Usage:

The general usage of Driesner_NaCl is as follows:

  1. For water-NaCl properties at any Temperature and Pressure:

    water_salt = Driesner_NaCl(T = T, P = P),

    where T is temperature in celsius and P is pressure in bar

Examples

>>> water_salt = Driesner_NaCl(T = 400., P = 150)
>>> water_salt.PVLH, water_salt.xL_NaCl, water_salt.xV_NaCl, water_salt.xVL_Liq, water_salt.xVL_Vap, water_salt.Xcrit
    176.12604181993797,
     0.21548565081529097,
     1.1606891909548725e-05,
     0.27785803505887324,
     1.1606891909548725e-05,
     0.006832050956381021
>>> water_salt = Driesner_NaCl(T = 400., P = 150, xNaCl = 0.00919)
>>> water_salt.PVLH, water_salt.xL_NaCl, water_salt.xV_NaCl, water_salt.xVL_Liq, water_salt.xVL_Vap, water_salt.rho, water_salt.vm, water_salt.H, water_salt.mu, water_salt.Cp
    (176.12604181993797,
     0.21548565081529097,
     1.1606891909548725e-05,
     0.27785803505887324,
     1.1606891909548725e-05,
     0.06932873574838519,
     265.2138005082347,
     2934.6231778877977,
     2.4596312351131325e-05,
     4394.068874696437)

References

  1. Driesner, T, and Heinrich, C. A. (2007). The system H2O–NaCl. Part I: Correlation formulae for phase relations in temperature–pressure–composition space from 0 to 1000 C, 0 to 5000 bar, and 0 to 1 XNaCl. Geochimica et Cosmochimica Acta. 71(20), 4880-4901. https://doi.org/10.1016/j.gca.2006.01.033

(2) Driesner, T. (2007). “The system H2O-NaCl. II. Correlations for molar volume, enthalpy, and isobaric heat capacity from 0 to 1000 °C, 1 to 5000 bar, # and 0 to 1 X-NaCl.” Geochimica et Cosmochimica Acta 71(20): 4902-4919.

kwargs
__calc__(**kwargs)
Driesner_NaCl(T, P)
Driesner_NaClII(T, P, xNaCl)
enthalpy_mu_heatcap(T, P, xNaCl)

Enthalpy in J/g, viscosity in Pas and Cp in Joules per kilogram Kelvin

pygcc.concentration_converter(val=1.0, In_Unit='x_wt', Out_Unit='x_wt')

This function converts concentration between several units like wt fraction, mole fraction, molality, mol/kg solution and volume fraction Values must be in fraction except it is molality

Parameters:
  • val (float) – Values to convert

  • In_Unit (String) – unit of input concentration

  • Out_Unit (String) – expected output concentration

Returns:

Out – Converted values

Return type:

float

class pygcc.Dummy

Bases: object

Class of functions to evaluate the IAPWS95 equation of state for calculating thermodynamic properties of water.

vEOSIAPWS95
vauxMeltingTemp
vapxsatpropT
vapxsatpropP
vcalcsatpropT
vcalcsatpropP
vwaterviscosity
EOSIAPWS95(TK, rho, FullEOSppt=False)

This function evaluates the IAPWS basic equation of state to calculate thermodynamic properties of water, which is written as a function of temperature and density.

Parameters:
  • TK (temperature [K])

  • rho (density [kg/m3])

  • FullEOSppt (Option to output all or essential water properties [False or True])

Returns:

  • px (pressure [bar])

  • ax (Helmholtz energy [kJ/kg-K])

  • sx (Entropy [kJ/kg/K])

  • hx (Enthalpy [kJ/kg])

  • gx (Gibbs energy [kJ/kg])

  • vx (Volume [m3/kg])

  • pdx (Derivative of pressure with respect to delta in bar)

  • adx (Helmholtz energy derivative with respect to delta)

  • ztx (zeta value (needed to calculate viscosity))

  • ptx (Derivative of pressure with respect to tau in bar)

  • ktx (Compressibility [/bar])

  • avx (Thermal expansion coefficient (thermal expansivity))

  • ux (Internal energy [kJ/kg] if FullEOSppt is True)

  • gdx (Gibbs energy derivative in kJ/kg if FullEOSppt is True)

  • bsx (Isentropic temperature-pressure coefficient [K-m3/kJ] if FullEOSppt is True)

  • dtx (Isothermal throttling coefficient [kJ/kg/bar] if FullEOSppt is True)

  • mux (Joule-Thomsen coefficient [K-m3/kJ] if FullEOSppt is True)

  • cpx (Isobaric heat capacity [kJ/kg/K] if FullEOSppt is True)

  • cvx (Isochoric heat capacity [kJ/kg/K] if FullEOSppt is True)

  • wx (Speed of sound [m/s] if FullEOSppt is True)

Usage

[px, ax, ux, sx, hx, gx, vx, pdx, adx, gdx, ztx, ptx, ktx, avx, bsx, dtx, mux, cpx, cvx, wx] = EOSIAPW95( TK, rho)

auxMeltingPressure(TK, P)

This function calculates the melting pressure of ice as a function of temperature.

This model is described in IAPWS R14-08(2011), Revised Release on the Pressure along the Melting and Sublimation Curves of Ordinary Water Substance, as may be found at: http://www.iapws.org/relguide/MeltSub.html

Five ice phases are covered here. The melting pressure is not a single-valued function of temperature as there is some overlap in the temperature ranges of the individual phases. There is no overlap in the temperature ranges of Ices III, V, VI, and VII, which together span the range 251.165 - 715K. The melting pressure is continuous and monotonically increasing over this range, albeit with discontinuities in slope at the triple points where two ice phases and liquid are in equilibrium. The problem comes in with Ice Ih, whose temperature range completely overlaps that of Ice III and partially overlaps that of Ice V. For a temperature in the range for Ice Ih, there are two possible melting pressures.

The possible ambiguity here in the meaning of melting pressure is not present if the temperature is greater than or equal to the triple point temperature of 273.16K, or if the pressure is greater than or equal to 2085.66 bar (the triple point pressure for Ice Ih-Ice III-liquid). If neither of these conditions are satisfied, then the Ice Ih-liquid curve will be used. To deal with the pressure condition noted above, this function assumes that an actual pressure is specified.

Parameters:
  • P (pressure [bar])

  • TK (temperature [K])

Returns:

Pmelt

Return type:

melting pressure [bar]

Usage

[Pmelt] = auxMeltingPressure( TK, P)

auxMeltingTemp(P)

This function calculates the melting temperature of ice as a function of pressure.

This inverts the model for the melting pressure as a function of temperature. That model is described in IAPWS R14-08(2011), Revised Release on the Pressure along the Melting and Sublimation Curves of Ordinary Water Substance as may be found at: http://www.iapws.org/relguide/MeltSub.html

Inversion of the model for the melting pressure is done here using the secant method. This is chosen instead of the Newton-Raphson method to avoid potential problems with slope discontinuites at boundaries between the ice phases for pressures above 208.566 MPa, which is the equilibrium pressure for Ice Ih-Ice III-liquid. The corresponding equlibrium temperature is 251.165K. Putative melting temperatures should not be less than this for pressures above 208.566 Mpa, nor more than this for pressures less than this. :param P: :type P: pressure [bar]

Returns:

Tmelt

Return type:

temperature [K]

Usage

[Tmelt] = auxMeltingTemp( P)

waterviscosity(TC, P, rho)

This function calculates the viscosity of water using Ref:

  1. “IAPWS Formulation 2008 for the Viscosity of Ordinary Water Substance” (IAPWS R12-08).

  2. Huber M.L., Perkins R.A., Laesecke A., Friend D.G., Sengers J.V., Assael M.J., Metaxa I.N., Vogel E., Mares R., and Miyagawa K. (2009) New International Formulation for the Viscosity of H2O. J. Phys. Chem. Ref. Data 38, 101-125.

Parameters:
  • [°C] (TC temperature)

  • [bar] (P pressure)

  • [kg/m3] (rho density)

Return type:

visc viscosity [Pa.s]

Usage

[visc] = waterviscosity( TC, P, rho)

apxsatpropT(TK)

This function evaluates the approximate pressure (psat) as a function of temperature along the vapor-liquid equilibrium curve, using equation 2.5 of Wagner and Pruss (2002). It also calculates the derivative of saturation pressure wrt temperature as well as the densities of the liquid and vapor phases using equations 2.6 and 2.7 from the same source.

Parameters:

TK temperature [K] (saturation temperature)

Returns:

Psat saturation pressure [bar]

Psat_t Derivative of saturation pressure with respect to temperature

rhosl density of liquid [kg/m3]

rhosv density of vapor [kg/m3]

Usage:

[Psat, Psat_t, rhosl, rhosv] = apxsatpropT( TK)

apxsatpropP(P)

This function evaluates the approximate temperature (tsat) as a function of pressure along the vapor-liquid equilibrium curve, using equation 2.5 of Wagner and Pruss (2002). This is similar to apxsatpropT(TK), but evaluates the inverse problem (Tsat as a function of pressure instead of psat as a function of temperature). Newton-Raphson iteration is used.

Parameters:

P pressure [bar]

Returns:

Tsat saturation temperature [K]

Usage:

[Tsat] = apxsatpropP( P)

calcsatpropT(TK)

This function calculates the saturation properties as a function of specified temperature. This is achieved using Newton-Raphson iteration to refine values of pressure, vapor density, and liquid density, starting with results obtained using approximate equations included by Wagner and Pruss (2002) in their description of the IAPWS-95 model.

Parameters:

[K] (TK temperature)

Returns:

  • Psat saturation pressure [bar]

  • rhosl density of liquid [kg/m3]

  • rhosv density of vapor [kg/m3]

Usage

[Psat, rhosl, rhosv] = calcsatpropT( TK)

calcsatpropP(P)

This function calculates the saturation properties as a function of specified pressure. This is done by iterating using Newton method on pressure to obtain the desired temperature. This implementation calls calcsatpropT(TK) to calculate the saturation pressure, liquid and vapor densities.

Parameters:

[bar] (P pressure)

Returns:

  • Tsat temperature [K]

  • rhosl liquid density [kg/m3]

  • rhosv vapor density [kg/m3]

Usage

[Tsat, rhosl, rhosv] = calcsatpropP( P)

fluidDescriptor(P, TK, *rho)

This function calculates the appropriate description of the H2O fluid at any given temperature and pressure

A problem may occur if the pressure is equal or nearly equal to the saturation pressure. Here comparing the pressure with the saturation pressure pressure may lead to the wrong description, as vapor and liquid coexist at the saturation pressure. It then becomes neccesary to compare the fluid density with the saturated vapor and saturated liquid densities. If the density is known, it will be used. If it is not known, the results obtained here will determine the starting density estimate, thus in essence choosing “vapor” or “liquid” for pressures close to the saturation pressure.

Parameters:

P pressure [bar]

TK temperature [K]

rho density [kg/m3] (optional)

Returns:

phase fluid description

rhosl liquid density [kg/m3]

rhosv vapor density [kg/m3]

Usage:

[udescr, rhosl, rhosv] = fluidDescriptor( P, TK)

calcwaterppt(TC, P, *rho0, FullEOSppt=False)

This function evaluates thermodynamic properties of water at given temperature and pressure. The problem reduces to finding the value of density that is consistent with the desired pressure. The Newton-Raphson method is employed. Small negative values of calculated pressure are okay. Zero or negative values for calculated “pdx” (pressure derivative with respect to delta) imply the unstable zone and must be avoided.

Parameters:

T : temperature [°C]

P : pressure [bar]

rho0 : starting estimate of density [kg/m3] (optional) FullEOSppt: Option to output all or essential water properties [False or True]

Returns:

rho : density [kg/m3]

gx : Gibbs energy [cal/mol]

hx : Enthalpy [cal/mol]

sx : Entropy [cal/mol/K]

vx : Volume [m3/mol]

Pout : pressure [bar]

Tout : temperature [°C]

ux : Internal energy [cal/mol] if FullEOSppt is True

ax : Helmholtz energy [cal/mol/K] if FullEOSppt is True

cpx : Isobaric heat capacity [cal/mol/K] if FullEOSppt is True

Usage:

[rho, gxcu, hxcu, sxcu, vxcu, uxcu, axcu, cpxcu, Pout, Tout] = calcwaterppt(T, P),

calcwaterppt_Prho(P, rho, FullEOSppt=False)

This function evaluates thermodynamic properties of water at given density and pressure. The problem reduces to finding the value of temperature that is consistent with the desired pressure.

Parameters:

P : pressure [bar]

rho : density [kg/m3]

FullEOSppt: Option to output all or essential water properties [False or True]

Returns:

rho : density [kg/m3]

gx : Gibbs energy [cal/mol]

hx : Enthalpy [cal/mol]

sx : Entropy [cal/mol/K]

vx : Volume [m3/mol]

Pout : pressure [bar]

Tout : temperature [°C]

ux : Internal energy [cal/mol] if FullEOSppt is True

ax : Helmholtz energy [cal/mol/K] if FullEOSppt is True

cpx : Isobaric heat capacity [cal/mol/K] if FullEOSppt is True

Usage:

[rho, gxcu, hxcu, sxcu, vxcu, uxcu, axcu, cpxcu, Pout, Tout] = calcwaterppt_Prho(P, rho),

calcwaterstdppt(TK, hx, sx, vx, ux=None, cpx=None, Out_Unit='standard')

This function converts thermodynamic properties of water from kilogram units to standard thermochemical scale (calorie units) and vice-versa.

Parameters:

TK : temperature [K]

hx : Enthalpy [kJ/kg] or [cal/mol]

sx : Entropy [kJ/kg/K] or [cal/mol/K]

vx : Volume [m3/kg] or [m3/mol]

ux : Internal energy [kJ/kg] or [cal/mol]

cpx : Isobaric heat capacity [kJ/kg/K] or [cal/mol/K]

Returns:

gx : Gibbs energy [kJ/kg] or [cal/mol]

hx : Enthalpy [kJ/kg] or [cal/mol]

sx : Entropy [kJ/kg/K] or[cal/mol/K]

vx : Volume [m3/kg] or[m3/mol]

ax : Helmholtz energy [kJ/kg/K] or[cal/mol/K]

ux : Internal energy [kJ/kg] or [cal/mol]

cpx : Isobaric heat capacity [kJ/kg/K] or[cal/mol/K]

Usage:

[gx, hx, sx, vx, ux, ax, cpx] = calcwaterstdppt(TK, hx, sx, vx, ux, cpx, Out_Unit = ‘kilogram’)

class pygcc.heatcap(**kwargs)

Class to heat capacity for mineral and gases using Maier-Kelley powerlaw, Haas-Fisher powerlaw, Holland and Powell and Berman’s function

Parameters:
  • T (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • Species_ppt (array) –

    Properties such as Supcrt92 (dG [cal/mol], dH [cal/mol], S [cal/mol-K], V [cm3/mol] a [cal/mol-K], b [*10**3 cal/mol/K^2],

    c [*10^-5 cal/mol/K], Ttrans [K], Htr [cal/mol], Vtr [cm³/mol], dPdTtr [bar/K] ): Berman’s database

    properties such as (dG [J/mol], dH [J/mol], S [J/mol-K], V [cm³/mol], k0, k1, k2, k3, v1 [*10^5 K^-1], v2 [*10^5 K^-2], v3 [*10^5 bar^-1], v4 [*10^8 bar^-2], dTdP [K/bar], Tlambda [K], Tref [K], l1 [(J/mol)^0.5/K], l2 [(J/mol)^0.5/K^2], DtH, d0 [J/mol], d1 [J/mol], d2 [J/mol], d3 [J/mol], d4 [J/mol], d5 [J/mol], Tmin [K], Tmax [K]): Supcrtbl’s database properties such as (dG [kJ/mol], dH [kJ/mol], S [J/mol-K], V [J/bar], a [kJ/mol-K], b [*10^5 kJ/mol/K^2], c [kJ-mol-K], d [kJ/mol/K^0.5], alpha [*10^5 K^-1], kappa0 [kbar], kappa0_d [kbar], kappa0_dd [kbar], n_atom [-], Tc0 [K], Smax [J/mol-K], Vmax [J/bar], dH [KJ/mol], dV [J/bar], W [kJ/mol], Wv [J/bar], n [-], SF [-]), etc

  • Species (string) – species name, optional for all cases except gases, Coesite and Quartz

  • method (string) – specify either ‘SUPCRT’ or ‘berman88’ or ‘HP11’ or ‘HF76’ to carry-out any mineral or gas heat capacity calculations, default is ‘SUPCRT’

Returns:

  • dG (float, vector) – Gibbs Energy [cal/mol]

  • dCp (float, vector) – Heat capacity [cal/mol/K]

Examples

>>> # Example with Maier-Kelley powerlaw function as implemented in SUPCRT92
>>> from pygcc.pygcc_utils import db_reader
>>> ps = db_reader() # utilizes the default direct-access database, speq21
>>> sp = heatcap( T = 100, P = 50, Species = 'H2S(g)', Species_ppt = ps.dbaccessdic['H2S(g)'], method = 'SUPCRT')
>>> sp.dG, sp.dCp
    -11782.47165818, 8.58416135
>>> sp = heatcap( T = 100, P = 50, Species_ppt = ps.dbaccessdic['Quartz'], method = 'SUPCRT',
                      Species = 'Quartz')
>>> sp.dG, sp.dCp
    -205292.75498942, 12.34074489
>>> # Example with Haas-Fisher powerlaw function
>>> from pygcc.pygcc_utils import db_reader
>>> ps = db_reader() # utilizes the default direct-access database, speq21
>>> sp = heatcap( T = 100, P = 50, Species_ppt = ps.dbaccessdic['ss_Anorthite'], method = 'HF76',
                 Species = 'ss_Anorthite')
>>> sp.dG, sp.dCp
    -960440.79915641, 57.46776903
>>> # Example with Berman's function
>>> from pygcc.pygcc_utils import db_reader
>>> # utilizes the default speq21 and specified Berman dataset database
>>> ps = db_reader(dbBerman_dir = './default_db/Berman.dat')
>>> sp = heatcap( T = 100, P = 50, Species_ppt = ps.dbaccessdic['Quartz'], method = 'berman88',
                 Species = 'Quartz')
>>> sp.dG, sp.dCp
    -205472.3365716, 12.32381279
>>> # Example with Holland and Powell's function
>>> from pygcc.pygcc_utils import db_reader
>>> # utilizes the default speq21 and specified SUPCRTBL (HP2011) dataset database
>>> ps = db_reader(dbHP_dir = './default_db/supcrtbl.dat')
>>> sp = heatcap( T = 100, P = 50, Species_ppt = ps.dbaccessdic['Hematite'], method = 'HP11',
                 Species = 'Hematite')
>>> sp.dG, sp.dCp
    -179494.62259123, 28.09545987

References

  1. Helgeson, H. C., Delany, J. M., Nesbitt, H. W. and Bird, D. K.(1978). Summary and critique of the thermodynamic properties of rock-forming minerals.

  2. Kelley K. K (1960) Contributions to the data on theoretical metallurgy. XIII. High temperature heat content, heat capacity and entropy data for elements and inorganic compounds US Bur Mines Bull 548: 232 p

  3. Haas JL Jr, Fisher JR (1976) Simultaneous evaluation and correlation of thermodynamic data. American Journal of Science 276:525-545

  4. Berman, R. G. (1988). Internally-consistent thermodynamic data for minerals in the system Na2O-K2O-CaO-MgO-FeO-Fe2O3-Al2O3-SiO2-TiO2-H2O-CO2. Journal of petrology, 29(2), 445-522.

  5. Berman RG, Brown TH (1985) Heat Capacities of minerals in the system Na2O-K2O-CaO-MgO-FeO-Fe2O3-Al2O3-SiO2-TiO2-H2O-CO2: Representation, estimation, and high temperature extrapolation. Contrib Mineral Petrol 89:168-183

  6. Holland, T. and Powell, R., 2011. An improved and extended internally consistent thermodynamic dataset for phases of petrological interest, involving a new equation of state for solids. Journal of Metamorphic Geology. 29, 333–383.

  7. Holland, T.J.B. and Powell, R., 1998. An internally-consistent thermodynamic dataset for phases of petrological interest. Journal of Metamorphic Geology, 16, 309–344.

  8. Zimmer, K., Zhang, Y.L., Lu, P., Chen, Y.Y., Zhang, G.R., Dalkilic, M. and Zhu, C. (2016) SUPCRTBL: A revised and extended thermodynamic dataset and software package of SUPCRT92. Computer and Geosciences 90:97-111

kwargs
TC = None
P = None
Species_ppt = None
method = None
Species = None
__calc__(**kwargs)
heatcapusgscal(TC, P, species)

This function evaluates Gibbs energy and heat capacity as a function of temperature and pressure for any mineral or gas specie using Haas and Fisher (1976)’s heat capacity parameter fit (utilized for solid-solutions)

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • species (array) – Properties such as [dG [cal/ml], dH [cal/mol], S [cal/mol-K], V [cm³/mol], a [cal/mol-K], b [cal/mol/K^2], c [cal/mol/K], g [cal/mol/K^0.5], f [cal/mol/K^3] )

Returns:

  • delGfPT (float, vector) – Gibbs Energy [cal/mol]

  • delCp (float, vector) – Heat capacity [cal/mol/K]

References

  1. Haas JL Jr, Fisher JR (1976) Simultaneous evaluation and correlation of thermodynamic data. American Journal of Science 276:525-545

heatcap_Berman(TC, P, species)

This function evaluates Gibbs energy and heat capacity as a function of temperature and pressure for any mineral or gas specie using Berman (1988) equations and datasets with Berman and Brown (1985)’s heat capacity parameter fit

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • species (array) –

    Properties such as [dG [J/mol], dH [J/mol], S [J/mol-K], V [cm³/mol], k0, k1, k2, k3,

    v1 [*10^5 K^-1], v2 [*10^5 K^-2], v3 [*10^5 bar^-1], v4 [*10^8 bar^-2], dTdP [K/bar], Tlambda [K], Tref [K], l1 [(J/mol)^0.5/K], l2 [(J/mol)^0.5/K^2], DtH, d0 [J/mol], d1 [J/mol], d2 [J/mol], d3 [J/mol], d4 [J/mol], d5 [J/mol], Tmin [K], Tmax [K]]

Returns:

  • delGfPT (float, vector) – Gibbs Energy [cal/mol]

  • delCp (float, vector) – Heat capacity [cal/mol/K]

References

  1. Berman, R. G. (1988). Internally-consistent thermodynamic data for minerals in the system Na2O-K2O-CaO-MgO-FeO-Fe2O3-Al2O3-SiO2-TiO2-H2O-CO2. Journal of petrology, 29(2), 445-522.

  2. Berman RG, Brown TH (1985) Heat Capacities of minerals in the system Na2O-K2O-CaO-MgO-FeO-Fe2O3-Al2O3-SiO2-TiO2-H2O-CO2: Representation, estimation, and high temperature extrapolation. Contrib Mineral Petrol 89:168-183

heatcapsup(TC, P, species, **kwargs)

This function evaluates Gibbs energy and heat capacity as a function of temperature and pressure for any mineral or gas specie using Helgeson et al (1978) equations and Maier-Kelley power function for heat capacity as implemented in SUPCRT92

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • species (array) –

    Properties such as ( dG [cal/mol], dH [cal/mol], S [cal/mol-K], V [cm³/mol], a [cal/mol-K],

    b [*10^3 cal/mol/K^2], c [*10^-5 cal/mol/K], Ttrans [K], Htr [cal/mol], Vtr [cm³/mol], dPdTtr [bar/K] ), etc

  • spec_name (string) – species name, optional for all cases except gases, Coesite and Quartz

Returns:

  • delGfPT (float, vector) – Gibbs Energy [cal/mol]

  • delCp (float, vector) – Heat capacity [cal/mol/K]

References

  1. Helgeson, H. C., Delany, J. M., Nesbitt, H. W. and Bird, D. K.(1978). Summary and critique of the thermodynamic properties of rock-forming minerals.

  2. Kelley K. K (1960) Contributions to the data on theoretical metallurgy. XIII. High temperature heat content, heat capacity and entropy data for elements and inorganic compounds US Bur Mines Bull 548: 232 p

heatcaphp(TC, P, species)

This function evaluates Gibbs energy and heat capacity as a function of temperature and pressure for any mineral or gas specie using Holland and Powell (2011)’s heat capacity parameter fit and database based on SUPCRTBL

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • species (array) –

    Properties such as [dG [kJ/mol], dH [kJ/mol], S [J/mol-K], V [J/bar], a [kJ/mol-K],

    b [*10^5 kJ/mol/K^2], c [kJ-mol-K], d [kJ/mol/K^0.5], alpha [*10^5 K^-1], kappa0 [kbar], kappa0_d [kbar], kappa0_dd [kbar], n_atom [-], Tc0 [K], Smax [J/mol-K], Vmax [J/bar], dH [KJ/mol], dV [J/bar], W [kJ/mol], Wv [J/bar], n [-], SF [-]]

Returns:

  • delGfPT (float, vector) – Gibbs Energy [cal/mol]

  • delCp (float, vector) – Heat capacity [cal/mol/K]

References

  1. Holland, T. and Powell, R., 2011. An improved and extended internally consistent thermodynamic dataset for phases of petrological interest, involving a new equation of state for solids. Journal of Metamorphic Geology. 29, 333–383.

  2. Zimmer, K., Zhang, Y.L., Lu, P., Chen, Y.Y., Zhang, G.R., Dalkilic, M. and Zhu, C. (2016) SUPCRTBL: A revised and extended thermodynamic dataset and software package of SUPCRT92. Computer and Geosciences 90:97-111

  3. Holland, T.J.B. and Powell, R., 1998. An internally-consistent thermodynamic dataset for phases of petrological interest. Journal of Metamorphic Geology, 16, 309–344.

pygcc.supcrtaq(TC, P, specieppt, Dielec_method=None, ThermoInUnit='cal', **rhoE)

This function evaluates the Gibbs free energy of aqueous species at T and P using the revised HKF equation of state

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • specieppt (array) – Properties such as (dG [cal/mol], dH [cal/mol], S [cal/mol-K], a1 [10 cal/mol/bar], a2 [*10*-2 cal/mol], a3 [cal-K/mol/bar], a4 [10*-4 cal-K/mol], c1 [cal/mol/K], c2 [10*-4 cal-K/mol], ω [10*-5 cal/mol] )

  • Dielec_method (string) – specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric constant (optional), if not specified default - ‘JN91’

  • ThermoInUnit (string) – specify either ‘cal’ or ‘KJ’ as the input units for species properties (optional), if not specified default - ‘cal’

  • rhoE (dict) – dictionary of water properties like density (rho) and dielectric factor (E) (optional)

Returns:

delG – Gibbs energy [cal/mol]

Return type:

float, vector

Usage

The general usage of supcrtaq without the optional arguments is as follows:

  1. Not on steam saturation curve:

    delG = supcrtaq(TC, P, specieppt)

    where T is temperature in celsius and P is pressure in bar

  2. On steam saturation curve:

    delG = supcrtaq(TC, ‘T’, specieppt),

    where T is temperature in celsius, followed with a quoted char ‘T’

    delG = supcrtaq(P, ‘P’, specieppt),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    delG = supcrtaq(TC, P, specieppt, Dielec_method = ‘FGL97’)

Examples

>>> from pygcc.pygcc_utils import db_reader
>>> ps = db_reader() # utilizes the default direct-access database, speq21
>>> delG = supcrtaq( 100, 50, ps.dbaccessdic['H2S(aq)'], Dielec_method = 'JN91')
    -9221.81721068
>>> delG = supcrtaq( 100, 50, ps.dbaccessdic['H2S(aq)'], Dielec_method = 'FGL97')
    -9221.6542038

References

  1. Johnson JW, Oelkers EH, Helgeson HC. 1992. SUPCRT92: A software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000°C. Computers & Geosciences 18(7): 899-947. doi: 10.1016/0098-3004(92)90029-Q

class pygcc.solidsolution_thermo(**kwargs)

Class to calculate Ideal mixing model for solid-solutions, supporting multisite ideal formalism

Parameters:
  • X (float) – End member mineral volume fraction or mole fraction of Mg in clinopyroxene

  • cpx_Ca (float) – number of moles of Ca in clinopyroxene formula unit (=1 for Di, Hed)

  • T (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • dbaccessdic (dict) – dictionary of species from direct-access database, optional, default is speq23

  • solidsolution_type (string) – specify either ‘All’ or ‘plagioclase’ or ‘olivine’ or ‘pyroxene’ or ‘cpx’ or ‘alk-feldspar’ or ‘biotite’ to carry-out all or any solid-solution calculations, default is ‘All’

  • Dielec_method – specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric constant (optional), if not specified default - ‘JN91’

Returns:

  • if ‘All’ is specified for solidsolution_type, each case has the follwowing prefix - AnAb_, FoFa_, EnFe_, cpx_, AlkFed_, Biotite_

  • logK (float, vector) – logarithmic K values

  • Rxn (dict) – The calculated dictionary of reaction thermodynamic properties has the following properties:

    • type: solid-solution mineral type, [-]

    • name: solid-solution name, [K]

    • formula: solid-solution mineral formula, [-]

    • MW: Molecular weight, [g/mol]

    • min: solid-solution mineral properties, [‘formula’, ‘source date’, dG[cal/ml], dH[cal/mol], S[cal/mol-K], V[cm3/mol], a[cal/mol-K], b[10^3 cal/mol/K^2], c[10^-5 cal/mol/K]]

    • spec: list of species, [-]

    • coeff: list of corresponding coefficients of species above, [-]

    • nSpec: Total number of species, [-]

    • V: Molar volume, [cm3/mol]

    • source: Source of thermo data, [kJ/kg·K]

    • elements: list of elements and their total numbers, [-]

Usage

The general usage of water_dielec is as follows:

  1. For water dielectric properties at any Temperature and Pressure:

    ss = solidsolution_thermo(T = T, P = P, X = X, solidsolution_type = ‘All’, Dielec_method = ‘JN91’),

    where T is temperature in celsius and P is pressure in bar

  2. For water dielectric properties at any Temperature and density :

    ss = solidsolution_thermo(T = T, rho = rho, X = X, solidsolution_type = ‘All’, Dielec_method = ‘JN91’),

    where T is temperature in celsius and rho is density in kg/m³

  3. For water dielectric properties at any Temperature and Pressure on steam saturation curve:

    ss = solidsolution_thermo(T = T, P = ‘T’, X = X, solidsolution_type = ‘All’, Dielec_method = ‘JN91’),

    where T is temperature in celsius and P is assigned a quoted character ‘T’ to reflect steam saturation pressure

    ss = solidsolution_thermo(P = P, T = ‘P’, X = X, solidsolution_type = ‘All’, Dielec_method = ‘JN91’),

    where P is pressure in bar and T is assigned a quoted character ‘P’ to reflect steam saturation temperature

Examples

>>> ss = solidsolution_thermo(cpx_Ca = 0.5, X = 0.85, T = 30, P = 50,
                              solidsolution_type = 'All')
>>> ss.AnAb_logK, ss.FoFa_logK, ss.EnFe_logK, ss.cpx_logK, ss.AlkFed_logK,
    ss.Biotite_logK
    21.750590, 26.570902, 10.793372, 20.577152,  3.756792, 32.96363
>>> ss = solidsolution_thermo(cpx_Ca = 1, X = 0.85, T = 50, P = 100,
                              solidsolution_type = 'cpx')
>>> ss.logK
    18.81769186
>>> ss.Rxn
    {'type': 'cpx', 'name': 'Di85Hed15',
     'formula': 'Ca1.00Mg0.85Fe0.15Si2O6', 'MW': 221.2817,
     'min': ['Ca1.00Mg0.85Fe0.15Si2O6', ' R&H95, Stef2001',
             -711392.7391800061, nan, 37.032850185405415, 66.369,
             106.66383843212236, -0.019588551625239002, -16326.4818355,
             -1052.9517208413004, 5.714746653919693e-06],
     'spec': ['H+', 'Ca++', 'Mg++', 'Fe++', 'SiO2(aq)', 'H2O'],
     'coeff': [-4, 1.0, 0.85, 0.15, 2, 2], 'nSpec': 6, 'V': 66.369,
     'source': ' R&H95, Stef2001', 'elements': ['1.0000', 'Ca', '0.8500',
                                                'Mg', '0.1500', 'Fe', '2.0000',
                                                'Si', '6.0000', 'O']}
>>> ss = solidsolution_thermo(X = 0.5, T = 50, P = 100,
                              solidsolution_type = 'plagioclase')
>>> ss.logK
    12.62488394
>>> ss.Rxn
    {'type': 'plag', 'name': 'An50', 'formula': 'Ca0.50Na0.50Al1.50Si2.50O8',
     'MW': 270.215145, 'min': ['Ca0.50Na0.50Al1.50Si2.50O8', ' R&H95,
                               Stef2001', -919965.222804649, nan,
                               47.33081919017781, 100.43, 131.53908221797,
                               -0.022148661567686426, 32265.761759082205,
                               -1316.0836615678777, 7.719885114722753e-06],
     'spec': ['H+', 'Al+++', 'Na+', 'Ca++', 'SiO2(aq)', 'H2O'],
     'coeff': [-6.0, 1.5, 0.5, 0.5, 2.5, 3.0], 'nSpec': 6, 'V': 100.43,
     'source': ' R&H95, Stef2001', 'elements': ['0.5000', 'Ca', '0.5000',
                                                'Na', '1.5000', 'Al', '2.5000',
                                                'Si', '8.0000', 'O']}
kwargs
__calc__(**kwargs)
__checker__(**kwargs)
calclogKAnAb(XAn, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of Plagioclase minerals

Parameters:
  • XAn (volume fraction of Anorthite)

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logKplag (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKAnAb without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKAnAb(XAn, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKAnAb(XAn, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKAnAb(XAn, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKAnAb(XAn, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

calclogKFoFa(XFo, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of olivine minerals

Parameters:
  • XFo (volume fraction of Forsterite)

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logK_ol (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKFoFa without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKFoFa(XFo, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKFoFa(XFo, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKFoFa(XFo, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKFoFa(XFo, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

calclogKEnFe(XEn, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of pyroxene minerals

Parameters:
  • XEn (volume fraction of Enstatite)

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logK_opx (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKEnFe without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKEnFe(XEn, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKEnFe(XEn, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKEnFe(XEn, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKEnFe(XEn, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

calclogKDiHedEnFe(nCa, XMg, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of clinopyroxene minerals (Di, Hed, En and Fe)

Parameters:
  • nCa (number of moles of Ca in formula unit (=1 for Di, Hed)) – and must be greater than zero

  • XMg (mole fraction of Mg) – XMg = (nMg/(nFe + nMg))

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logK_cpx (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKDiHedEnFe without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKDiHedEnFe(nCa, XMg, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKDiHedEnFe(nCa, XMg, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKDiHedEnFe(nCa, XMg, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKDiHedEnFe(nCa, XMg, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

calclogKAbOr(XAb, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of Alkaline-Feldspar minerals

Parameters:
  • XAb (volume fraction of Albite)

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logKalkfeld (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKAnAb without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKAbOr(XAb, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKAbOr(XAb, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKAbOr(XAb, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKAbOr(XAb, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

calclogKBiotite(XPh, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of Biotite minerals

Parameters:
  • XAb (volume fraction of Albite)

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logKalkfeld (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKAnAb without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKAbOr(XAb, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKAbOr(XAb, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKAbOr(XAb, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKAbOr(XAb, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

pygcc.calclogKclays(TC, P, *elem, dbaccessdic=None, group=None, cation_order=None, export_struct_formula=None, Dielec_method=None, ClayMintype=None, Int_Mg_fract=None, Int_Li_fract=None, heatcap_approx=None, ThermoInUnit='cal', **rhoEG)

This function calculates logK values and reaction parameters of clay reactions using below references:

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • elem (list) – list containing nine or ten parameters with clay names and elements compositions with the following format [‘Montmorillonite_Lc_MgK’, ‘Si’, ‘Al’, ‘FeIII’, ‘FeII’, ‘Mg’, ‘K’, ‘Na’, ‘Ca’, ‘Li’, ‘H3O’]

  • dbacessdic (dict) – dictionary of species from direct-access database, optional, default is speq23

  • group (string) – specify the structural layering of the phyllosilicate, for layers composed of 1 tetrahedral + 1 octahedral sheet (1:1 layer) - specify ‘7A’, 2 tetrahedral + 1 octahedral sheet (2:1 layer) - specify ‘10A’, or the latter with a brucitic sheet in the interlayer (2:1:1 layer) - specify ‘14A’ (optional), if not specified, default is based on charge balance on the cations and anions

  • cation_order (string) – specify ordering of Si and Al ions either ‘Eastonite’, ‘Ordered’, ‘Random’, or ‘HDC’ (optional), if not specified, default is based on guidelines by Vinograd (1995)

  • Dielec_method (string) – specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric constant (optional), if not specified, default - ‘JN91’

  • ClayMintype (string) – specify either ‘Smectite’ or ‘Chlorite’ or ‘Mica’ as the clay type, if not specified default - ‘Smectites’

  • Int_Mg_fract (string) – specify the fraction of Mg to partition into Interlayer sheet and the remainder will be partitioned into Octahedral sheet, if not specified, default is 1

  • Int_Li_fract (string) – specify the fraction of Li to partition into Interlayer sheet and the remainder will be partitioned into Octahedral sheet, if not specified, default is 1

  • heatcap_approx (string) – specify either ‘Maier-Kelley’ or ‘constant’ as the approximation method for clay minerals’ specific heat capacity calculation, default is ‘constant’, based on ClayTherm’s definition for specific cations (Octahedral sites: Li+, Mn2+, Cr3+, Ni2+, Co2+, Zn2+; Interlayer sites: Cs+, Rb+, Li+, Ba2+, Sr2+, Mg2+, Cu2+, Co2+, Zn2+, H3O+)

  • ThermoInUnit (string) – specify either ‘cal’ or ‘KJ’ as the input units for species properties (optional), particularly used to covert KJ data to cal by supcrtaq function if not specified default - ‘cal’

  • rhoEG (dict) – dictionary of water properties like density (rho), dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logK_clay (float, vector) – logarithmic K values

  • Rxn (dict) – dictionary of reaction thermodynamic properties

Usage

The general usage of calclogKclays is as follows:

  1. Without the optional arguments, not on steam saturation curve:

    [logK, Rxn] = calclogKclays(TC, P, *elem),

    where T is temperature in celsius and P is pressure in bar;

  2. Without the optional arguments, on steam saturation curve:

    [logK, Rxn] = calclogKclays(TC, ‘T’, *elem),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKclays(P, ‘P’, *elem),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKclays(TC, P, *elem, dbacessdic = dbacessdic, group = ‘10A’, cation_order = ‘HDC’, Dielec_method = ‘FGL97’)

Examples

>>> logK, Rxn = calclogKclays(50, 'T', *['Clinochlore', '3', '2', '0', '0',
                                         '5', '0', '0', '0', '0', '0'],
                              group = '14A')
>>> logK
    57.29239957

References

  1. Blanc, P., Vieillard, P., Gailhanou, H., Gaboreau, S., Gaucher, É., Fialips, C. I., Madé, B & Giffaut, E. (2015). A generalized model for predicting the thermodynamic properties of clay minerals. American journal of science, 315(8), 734-780.

  2. Blanc, P., Gherardi, F., Vieillard, P., Marty, N. C. M., Gailhanou, H., Gaboreau, S., Letat, B., Geloni, C., Gaucher, E.C. and Madé, B. (2021). Thermodynamics for clay minerals: calculation tools and application to the case of illite/smectite interstratified minerals. Applied Geochemistry, 104986.

  3. Vinograd, V.L., 1995. Substitution of [4]Al in layer silicates: Calculation of the Al-Si configurational entropy according to 29Si NMR Spectra. Physics and Chemistry of Minerals 22, 87-98. ( saponite-H-Li Li0.165H0.165)(Mg3)(Si3.67Al0.33)O10(OH)2 saponite-Mg-Li(VI) (Mg0.17)(Li0.33Mg2.835)(Si3.66Al0.34)O10(OH)2 [‘Name’, ‘Si’, ‘Al’, ‘FeIII’, ‘FeII’, ‘Mg’, ‘K’, ‘Na’, ‘Ca’, ‘Li’, ‘H3O’]

pygcc.eps = 2.220446049250313e-16
pygcc.J_to_cal = 4.184
pygcc.IAPWS95_COEFFS
pygcc.calc_elem_count_molewt(formula, **kwargs)

This function calculates the molecular mass and the elemental composition of a substance given by its chemical formula. This is modified from https://github.com/cgohlke/molmass/blob/master/molmass/molmass.py

Parameters:
  • formula (string) – chemical formula

  • Elementdic (dict) – dictionary, containing the atomic mass of element database

Returns:

  • elements (dict) – dictionary of elemental composition and their respective number of atoms

  • molewt (float) – Calculated Molecular Weights [g/mol]

Usage:

[elements, molewt] = calc_elem_count_molewt(formula)

Examples of valid formulas are “H2O”, “[2H]2O”, “CH3COOH”, “EtOH”, “CuSO4:5H2O”, “(COOH)2”, “AgCuRu4(H)2[CO]12{PPh3}2”, “CGCGAATTCGCG”, and, “MDRGEQGLLK” .

Examples

>>> elements, molewt = calc_elem_count_molewt("CuSO4:5H2O")
>>> elements, molewt
    {'O': 9.0, 'H': 10.0, 'S': 1, 'Cu': 1}, 249.6773
pygcc.importconfile(filename, *Rows)
This function imports numeric data from a text file as column vectors.

[Var1, Var2] = importconfile(filename) Reads data from text file filename for the default selection.

[Var1, Var2] = importconfile(filename, StartRow, EndRow) Reads data from rows StartRow through EndRow of text file filename.

Example:

[Var1, Var2] = importconfile(‘100bar.con’, 6, 13);

pygcc.var_name(var)
pygcc.feval(funcName, *args)
pygcc.roundup_tenth(x)
pygcc.roundup_hundredth(x)
pygcc.read_specific_lines(file, lines_to_read)
pygcc.denormalize_phreeqc_species_charge(j)

Helper function to reverse the normalization of PHREEQC species charge notation. - Convert expanded charges back into compact notation (e.g., ‘Ca++’ -> ‘Ca+2’). - Remove ‘(aq)’ from neutral species. - Keep integers or floats unchanged.

Examples: ‘Ca++’ -> ‘Ca+2’ ‘Fe—’ -> ‘Fe-3’ ‘H2O(aq)’ -> ‘H2O’ ‘CH4(aq)’ -> ‘CH4’ ‘-1’ -> ‘-1’ ‘3.5’ -> ‘3.5’

pygcc.normalize_species_charges(species)
pygcc.normalize_phreeqc_species_charge(j)

Helper function to normalize PHREEQC species charge notation. - Replace charge notation like +2, -3, +4 etc. with expanded ‘+’ or ‘-’ symbols. - Skip cases where the entire string is just an integer (e.g., ‘1’, ‘-1’, ‘+2’). - If the species has no explicit charge, append ‘(aq)’.

Examples: ‘Ca+2’ -> ‘Ca++’ ‘Fe-3’ -> ‘Fe—’ ‘-1’ -> ‘-1’ ‘H2O’ -> ‘H2O(aq)’ ‘CH4’ -> ‘CH4(aq)’

pygcc.contains_missing_species(line, missing_spx)
pygcc.build_side_regex(side)

Build a regex to match one side of a chemical reaction. - Optional numeric coefficients (integer, decimal, scientific notation) - Flexible spacing around ‘+’ signs - Species with charges, e.g., CO3-2, Eu+3, H+, e-

pygcc.derivative(f, a, method='central', h=0.001)

Compute the derivative of f, f’(a) with step size h. :param f: Vectorized function of one variable :type f: function :param a: Compute derivative at x = a :type a: number :param method: Difference formula: ‘forward’, ‘backward’ or ‘central’ :type method: string :param h: Step size in difference formula :type h: number

Returns:

Difference formula:

central: f(a + h) - f(a - h))/2h forward: f(a + h) - f(a))/h backward: f(a) - f(a-h))/h

Return type:

float

pygcc.info(name, dic)

This function checks for naming convention of the species in the direct-access or source database

Parameters:
  • name (string) – species name

  • dic (dict) – dictionary of species from direct-access or source database

Returns:

lst – resulting search of all species with the input name

Return type:

list

Examples

>>> from pygcc.pygcc_utils import db_reader
>>> ps = db_reader() # utilizes the default direct-access database, speq21
>>> info('ss_', ps.dbaccessdic)
    ['ss_Anorthite',  'ss_Albite_high', 'ss_K-feldspar', 'ss_Ferrosilite',
     'ss_Enstatite', 'ss_Clinoenstatite', 'ss_Hedenbergite', 'ss_Diopside',
     'ss_Forsterite', 'ss_Fayalite', 'ss_Annite',  'ss_Phlogopite',
     'ss_Anorthite',  'ss_Albite_high', 'ss_K-feldspar', 'ss_Ferrosilite',
     'ss_Enstatite', 'ss_Clinoenstatite', 'ss_Hedenbergite', 'ss_Diopside',
     'ss_Forsterite',  'ss_Fayalite', 'ss_Annite', 'ss_Phlogopite']
pygcc.drummondgamma(TK, I)

This function models solubility of CO2 gas in brine using Drummond equation

Parameters:
  • TK (float, vector) – Temperature [K]

  • I – Ionic strength

Examples

>>> log10_gamma = drummondgamma( 500, 0.5)
>>> log10_gamma
    0.0781512920184902
pygcc.Henry_duan_sun(TK, P, I)

This function evaluates the solubility of CO2 gase in brine using Duan_Sun Formulation

Parameters:
  • TK (float, vector) – Temperature [K]

  • P (float, vector) – Pressure [bar]

  • I (float) – Ionic strength

Returns:

  • log10_co2_gamma (float, vector) – co2 aqueous activity coefficients in log10

  • mco2 (float, vector) – co2 aqueous molalities

Usage

log10_co2_gamma, mco2 = Henry_duan_sun( TK, P, I)

Examples

>>> log10_co2_gamma, mco2 = Henry_duan_sun( 500, 250, 0.5)
>>> log10_co2_gamma, mco2
    0.06202532, 1.6062557

References

  1. Duan, Z. and Sun, R., 2003. An improved model calculating CO2 solubility in pure water and aqueous NaCl solutions from 273 to 533 K and from 0 to 2000 bar. Chemical geology, 193(3-4), pp.257-271.

pygcc.co2fugacity(TK, P, poy=True)

This function computes the fugacity and density of CO2 by Duan and Sun 2003 Also Calculate the Saturation Index SI and partial pressure of CO2(g) at any given T, P using the Duan equation of state. A Poynting correction factor is also applied. :param TK: Temperature [K] :type TK: float, vector :param P: pressure [bar] :type P: float, vector :param poy: Option to apply a Poynting correction factor [True is the default] :type poy: bool

Returns:

  • fCO2 (float, vector) – co2 fugacity [bar]

  • denCO2 (float, vector) – co2 density [g/cm3]

  • SI (float, vector) – co2 saturation index

  • pCO2 (float, vector) – co2 partial pressure [bar]

Usage

[fCO2, denCO2, SI, pCO2] = co2fugacity( TK, P)

Examples

>>> fCO2, denCO2, SI, pCO2 = co2fugacity( np.array([400,420]), np.array([150, 200]))
>>> fCO2
    array([114.50387423, 150.87672517])
>>> denCO2
    array([2.6741242 , 3.33134397])
>>> SI
    array([1.73291553, 1.84597591])
>>> pCO2
    array([54.78127571, 71.0710152])
pygcc.gamma_correlation(TC, P, method=None)

This function calculates the CO2 activity correlation coefficients at given temperature T and pressure P

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • method – specify the activity model ['Duan_Sun' or 'Drummond']

Usage

Examples

>>> log10_co2_gamma, mco2 = Henry_duan_sun( 500, 250, 0.5)
>>> log10_co2_gamma, mco2
    0.06202532, 1.6062557

References

  1. Segal Edward Drummond, 1981, Boiling and Mixing of Hydrothermal Fluids: Chemical Effects on Mineral Precipitation, page 19

  2. Wolery, T. J., Lawrence Livermore National Laboratory, United States Dept. of Energy, 1992. EQ3/6: A software package for geochemical modeling of aqueous systems: package overview and installation guide (version 7.0)

pygcc.Helgeson_activity(TC, P, I, Dielec_method=None, **rhoEDB)

This function calculates the solute activity coefficient, solvent osmotic coefficient, and solvent activity at given temperature and pressure using equations 298, 190 and 106 in Helgeson, Kirkham and Flowers, 1981, A.J.S. p.1249-1516 Parameters: ———-

TC : Temperature [°C] P : pressure [bar] I : ionic strength Dielec_method : specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric

constant (optional), if not specified default - ‘JN91’

rhoEDBdictionary of water properties like density (rho), dielectric factor (E) and

Debye–Hückel coefficients (optional)

Returns:

aw : solvent activity phi : solvent osmotic coefficient mean_act : solute activity coefficient

Usage

[aw, phi, mean_act] = Helgeson_activity( TC, P, I)

pygcc.aw_correlation(TC, P, Dielec_method=None, **rhoEDB)

Calculates the water activity correlation coefficients at given temperature and pressure Parameters: ———-

TC : Temperature [°C] P : pressure [bar] Dielec_method : specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric

constant (optional), if not specified default - ‘JN91’

rhoEDBdictionary of water properties like density (rho), dielectric factor (E) and

Debye-Hückel coefficients (optional)

Returns:

ch20 : water activity correlation coefficients

Usage

[ch20] = aw_correlation( TC, P)

class pygcc.calcRxnlogK(**kwargs)

This class implemetation calculates logK values for any reaction with the option for extrapolation where rho < 350kg/m3

Parameters:
  • T (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • Specie (string) – specify the species for logK calculation, either the Product species of any reaction or solid solutions or clay like ‘AnAb’ or ‘AbOr’ or ‘FoFa’ or ‘EnFe’ or ‘DiHedEnFe’ or ‘clay’

  • Specie_class (string, optional) – specify the class of species like ‘aqueous’, ‘minerals’, ‘liquids’, or ‘gases’

  • elem (list) – list containing nine or ten parameters with clay names and elements compositions with the following format [‘Montmorillonite_Lc_MgK’, ‘Si’, ‘Al’, ‘FeIII’, ‘FeII’, ‘Mg’, ‘K’, ‘Na’, ‘Ca’, ‘Li’, ‘H3O’]

  • dbaccessdic (dict) – direct-acess database dictionary

  • rhoEGextrap (dict) – dictionary of water properties like density (rho), dielectric factor (E) and Gibbs Energy for density region 350-550kg/m3

  • group (string) – specify the structural layering of the phyllosilicate, for layers composed of 1 tetrahedral + 1 octahedral sheet (1:1 layer) - specify '7A', 2 tetrahedral + 1 octahedral sheet (2:1 layer) - specify '10A', or the latter with a brucitic sheet in the interlayer (2:1:1 layer) - specify '14A' (optional), if not specified, default is ‘10A’ for smectites, micas, et cetera

  • ClayMintype (string) – specify either ‘Smectite’ or ‘Chlorite’ or ‘Mica’ as the clay type, if not specified default - ‘Smectites’

  • X (float) – volume fractions of any (Anorthite, Albite, Forsterite, Enstatite) or mole fraction of Mg

  • cpx_Ca (float) – number of moles of Ca in formula unit (=1 for Di, Hed), must be greater than zero

  • sourcedic (dict) – source database reactions dictionary

  • specielist (list of list, optional) – source database species grouped into categories [element, basis, redox, aqueous, minerals, gases, oxides]

  • Dielec_method (string) – specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric constant, default is ‘JN91’

  • heatcap_method (string) – specify either ‘SUPCRT’ or ‘Berman88’ or ‘HP11’ or ‘HF76’ as the method to calculate thermodynamic properties of any mineral or gas, default is ‘SUPCRT’

  • ThermoInUnit (string) – specify either ‘cal’ or ‘KJ’ as the input units for species properties (optional), particularly used to covert KJ data to cal by supcrtaq function if not specified default - ‘cal’

  • Al_Si (string) – specify either ‘pygcc’ or ‘Arnórsson_Stefánsson’ as the input to express Al and Si species in solid solution (optional), ‘Arnórsson_Stefánsson’ expresses them as ‘Al(OH)4-’ and ‘H4SiO4(aq)’, respectively while pygcc uses ‘Al3+’ and ‘SiO2(aq)’, respectively if not specified default - ‘pygcc’

  • Int_Mg_fract (string) – specify the fraction of Mg to partition into Interlayer sheet and the remainder will be partitioned into Octahedral sheet, if not specified, default is 1

  • Int_Li_fract (string) – specify the fraction of Li to partition into Interlayer sheet and the remainder will be partitioned into Octahedral sheet, if not specified, default is 1

  • heatcap_approx (string) – specify either ‘Maier-Kelley’ or ‘constant’ as the approximation method for clay minerals’ specific heat capacity calculation, default is ‘constant’, based on ClayTherm’s definition for specific cations (Octahedral sites: Li+, Mn2+, Cr3+, Ni2+, Co2+, Zn2+; Interlayer sites: Cs+, Rb+, Li+, Ba2+, Sr2+, Mg2+, Cu2+, Co2+, Zn2+, H3O+)

  • sourceformat (string) – specify the source database format, either ‘GWB’, ‘EQ36’ or ‘PHREEQC’

  • densityextrap (float, vector) – specify the extrapolation option for density-logK, ‘Yes’/True or ‘No’/False

Returns:

  • log_K (float, vector) – logarithmic K value(s)

  • dGrxn (float, vector) – Total reaction Gibbs energy [cal/mol]

Usage

The general usage of water_dielec is as follows:

  1. For water dielectric properties at any Temperature and Pressure:

    calclogK = calcRxnlogK(T = T, P = P, Dielec_method = ‘JN91’, **kwargs),

    where T is temperature in celsius and P is pressure in bar

  2. For water dielectric properties at any Temperature and density :

    calclogK = calcRxnlogK(T = T, rho = rho, Dielec_method = ‘JN91’, **kwargs),

    where T is temperature in celsius and rho is density in kg/m³

  3. For water dielectric properties at any Temperature and Pressure on steam saturation curve:

    calclogK = calcRxnlogK(T = T, P = ‘T’, Dielec_method = ‘JN91’, **kwargs),

    where T is temperature in celsius, followed with a quoted character ‘T’ to reflect steam saturation pressure

    calclogK = calcRxnlogK(P = P, T = ‘P’, Dielec_method = ‘JN91’, **kwargs),

    where P is pressure in bar, followed with a quoted character ‘P’ to reflect steam saturation temperature

Examples

>>> ps = db_reader(sourcedb = './default_db/thermo.com.dat',
                   sourceformat = 'gwb', dbaccess = './default_db/speq21.dat')
>>> calclogK = calcRxnlogK(T = 100, P = 50, Specie = 'H2S(aq)',
                           Specie_class = 'aqueous',
                           dbaccessdic = ps.dbaccessdic,
                           sourcedic = ps.sourcedic, specielist = ps.specielist)
>>> calclogK.logK, calclogK.dGrxn
     -6.4713,       11049.3168
kwargs
__calc__(**kwargs)
AllRxnslogK(TC, P, rhoEG)

This function calculates logK values of all reactions including solid-solution and clay minerals

Parameters:
  • TC (temperature [°C])

  • P (pressure [bar])

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logK (logarithmic K value(s))

  • dGrxn (Total reaction Gibbs energy [cal/mol])

  • dGP (Product specie Gibbs energy [cal/mol])

  • dGRs (Reactant species Gibbs energy [cal/mol])

  • Rxn (dict)

  • The calculated dictionary of reaction thermodynamic properties has the following properties

    • type: solid-solution mineral type, [-]

    • name: solid-solution name, [K]

    • formula: solid-solution mineral formula, [-]

    • MW: Molecular weight, [g/mol]

    • min: solid-solution mineral properties, [‘formula’, ‘source date’, dG[cal/ml], dH[cal/mol], S[cal/mol-K], V[cm3/mol], a[cal/mol-K], b[10^3 cal/mol/K^2], c[10^-5 cal/mol/K]]

    • spec: list of species, [-]

    • coeff: list of corresponding coefficients of species above, [-]

    • nSpec: Total number of species, [-]

    • V: Molar volume, [cm3/mol]

    • source: Source of thermo data, [kJ/kg·K]

    • elements: list of elements and their total numbers, [-]

Usage

The general usage of calcRxnlogK without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, dGrxn, dGP, dGRs] = AllRxnslogK(TC, P, Prod, dbaccessdic, sourcedic, specielist),

    where TC is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, dGrxn, dGP, dGRs] = AllRxnslogK(TC, ‘T’, Prod, dbaccessdic, sourcedic, specielist),

    where TC is temperature in celsius, followed with a quoted char ‘T’

    [logK, dGrxn, dGP, dGRs] = AllRxnslogK(P, ‘P’, Prod, dbaccessdic, sourcedic, specielist),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, dGrxn, dGP, dGRs] = AllRxnslogK( TC, P, Prod, dbaccessdic, sourcedic, specielist, Dielec_method = ‘FGL97’)

RxnlogK(TC, P, Prod, rhoEG)

This function calculates logK values of any reaction

Parameters:
  • TC (temperature [°C])

  • P (pressure [bar])

  • Prod (Product species of the reaction)

  • dbaccessdic (direct-acess database dictionary)

  • sourcedic (source database reactions dictionary)

  • specielist (source database species grouped into) – [element, basis, redox, aqueous, minerals, gases, oxides]

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method) – to calculate dielectric constant, default is ‘JN91’

  • sourceformat (source database format, either 'GWB' or 'EQ36', default is 'GWB')

  • heatcap_method (specify either 'SUPCRT' or 'Berman88' or 'HP11' or 'HF76' as the method to calculate thermodynamic properties) – of any mineral, default is ‘SUPCRT’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logK (logarithmic K value(s))

  • dGrxn (Total reaction Gibbs energy [cal/mol])

  • dGP (Product specie Gibbs energy [cal/mol])

  • dGRs (Reactant species Gibbs energy [cal/mol])

Usage

The general usage of calcRxnlogK without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, dGrxn, dGP, dGRs] = RxnlogK(TC, P, Prod, dbaccessdic, sourcedic, specielist),

    where TC is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, dGrxn, dGP, dGRs] = RxnlogK(TC, ‘T’, Prod, dbaccessdic, sourcedic, specielist),

    where TC is temperature in celsius, followed with a quoted char ‘T’

    [logK, dGrxn, dGP, dGRs] = RxnlogK(P, ‘P’, Prod, dbaccessdic, sourcedic, specielist),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, dGrxn, dGP, dGRs] = RxnlogK( TC, P, Prod, dbaccessdic, sourcedic, specielist, Dielec_method = ‘FGL97’)

densitylogKextrap(TC, P, rhoEGextrap)

This function calculates logK values extrapolation for conditions where rho < 350kg/m3

Parameters:
  • TC (temperature [°C])

  • P (pressure [bar])

  • rhoEGextrap (dictionary of water properties like density (rho), dielectric factor (E) and) – Gibbs Energy for density region 350-550kg/m3

Returns:

logK

Return type:

extrapolated logarithmic K value(s)

Usage

[logK] = densitylogKextrap(TC, P, ‘H2S(aq)’, dbaccessdic = dbaccessdic, sourcedic = sourcedic, specielist = specielist),

pygcc.outputfmt(fid, logK, Rxn, *T, dataset=None, logK_form=None)

This function writes logK and Rxn data to any file using GWB, EQ36, PHREEQC, Pflotran and ToughReact format

Parameters:
  • fid (string) – file ID

  • logK (float, vector) – logarithmic K value(s)

  • Rxn (dict) – dictionary of reaction thermodynamic properties

  • T (float, vector) – Temperature value(s), optional, required when ‘polycoeffs’ is specified for logK_form

  • dataset (string) – specify the dataset format, either ‘GWB’, ‘EQ36’, ‘PHREEQC’, ‘Pflotran’ or ‘ToughReact’

  • logK_form (string) – specify the format of logK either as a set of eight values one for each of the dataset’s principal temperatures, or blocks of polynomial coefficients, [values, polycoeffs], default is ‘a set of eight values’ (optional)

Return type:

Output data to the file with filename described in fid with any format mentioned above.

Examples

>>> fid = open('./logK_details.txt', 'w')
>>> logKRxn = calcRxnlogK(T = 100, P = 'T', X = 0.634,
                          Specie = 'Plagioclase', densityextrap = True)
>>> # output in EQ36 format
>>> outputfmt(fid, logKRxn.logK, logKRxn.Rxn, dataset = 'EQ36')
>>> fid.close()
class pygcc.write_database(**kwargs)

Class to write the new database for either GWB, EQ3/6, ToughReact, Pflotran or PHREEQC into a new folder called “output” n :param T: Temperature [°C] n :type T: float, vector :param P: Pressure [bar] n :type P: float, vector :param cpx_Ca: number of moles of Ca in solid solution of clinopyroxene (optional) if it is ommitted solid solution of clinopyroxene will not be included, 0 < nCa >=1 n :type cpx_Ca: string :param solid_solution: specify the inclusion of solid-solution [Yes/True or No/False], default is ‘No’ n :type solid_solution: string, bool :param clay_thermo: specify the inclusion of clay thermodynamic properties [Yes/True or No/False], default is ‘No’ n :type clay_thermo: float, vector :param logK_form: specify the format of logK either as a set of eight values one for each of the dataset’s principal temperatures, or blocks of polynomial coefficients, [values, polycoeffs] default is ‘a set of eight values’ n :type logK_form: float, vector :param densityextrap: specify the utilization of density extrapolation [Yes/True or No/False], default is ‘Yes’ n :type densityextrap: float, vector :param dbaccess: direct-access database filename and location (optional) n :type dbaccess: string :param dbBerman_dir: filename and location of the Berman mineral database (optional) n :type dbBerman_dir: string :param dbHP_dir: filename and location of the supcrtbl mineral and gas database, optional :type dbHP_dir: string :param dbaccessformat: specify the direct-access/sequential-access database format, either ‘speq’ or ‘supcrtbl’, default is ‘speq’ :type dbaccessformat: string, optional :param sourcedb: source database filename and location (optional) n :type sourcedb: string :param sourceformat: source database format, either ‘GWB’, ‘EQ36’ or ‘PHREEQC’, default is ‘GWB’ :type sourceformat: string :param sourcedb_codecs: specify the name of the encoding used to decode or encode the sourcedb file, optional :type sourcedb_codecs: string :param objdb: new database filename and location (optional) n :type objdb: string :param co2actmodel: co2 activity model equation [Duan_Sun or Drummond] (optional), if not specified, default is ‘Drummond’ n :type co2actmodel: string :param Dielec_method: specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric constant, default is ‘JN91’ (optional) n :type Dielec_method: string :param heatcap_method: specify either ‘SUPCRT’ or ‘Berman88’ or ‘HP11’ or ‘HF76’ the method to calculate thermodynamic properties of any mineral, default is ‘SUPCRT’ n :type heatcap_method: string :param ThermoInUnit: specify either ‘cal’ or ‘KJ’ as the input units for species properties (optional), particularly used to covert KJ data to cal by supcrtaq function if not specified default - ‘cal’ :type ThermoInUnit: string :param dataset: specify the dataset format, either ‘GWB’, ‘EQ36’, ‘PHREEQC’, ‘Pflotran’ or ‘ToughReact’, default is old GWB database [‘GWB’] (optional) n :type dataset: string :param print_msg: print debug message [True or False], default is False n :type print_msg: string, bool

Return type:

Output the new database to an ASCII file with filename described in ‘objdb’ if specified.

Usage

With any Temperature and Pressure:
  1. General format with default dielectric constant and CO2 activity model and exclusions of solid solutions for GWB n write_database(T = T, P = P, cpx_Ca = nCa, dataset = ‘GWB’, sourceformat = ‘GWB’) n

  2. Inclusion of solid solutions and exclusion of solid solution of clinopyroxene and clay thermo n write_database(T = T, P = P, solid_solution = ‘Yes’, clay_thermo = ‘Yes’, dataset = ‘GWB’, sourceformat = ‘GWB’) n

  3. Inclusion of all solid solutions and clay thermo with \emph{‘Duan_Sun’} CO2 activity model and ‘FGL97’ dielectric constant calculation n write_database(T = T, P = P, cpx_Ca = nCa, solid_solution = ‘Yes’, clay_thermo = ‘Yes’, co2actmodel = ‘Duan_Sun’, Dielec_method = ‘FGL97’, dataset = ‘GWB’, sourceformat = ‘GWB’) n

With any Temperature or Pressure on the steam saturation curve:
  1. General format with default dielectric constant and CO2 activity model n write_database(T = T, P = ‘T’, cpx_Ca = nCa, dataset = ‘GWB’, sourceformat = ‘GWB’), n where T is temperature in celsius and P is assigned a quoted character ‘T’ to reflect steam saturation pressure n write_database(P = P, T = ‘P’, cpx_Ca = nCa, dataset = ‘GWB’, sourceformat = ‘GWB’), n where P is pressure in bar and T is assigned a quoted character ‘P’ to reflect steam saturation temperature

Examples

>>> write_database(T=np.array([ 0.010, 25., 60., 100., 150.,  200.,
                               250.,  300.]), P=200, cpx_Ca = 0.5,
                   sourceformat = 'GWB', solid_solution = True,
                   clay_thermo = True, dataset = 'GWB')  \n
>>> write_database(T=np.array([ 0.010, 25., 60., 100., 150.,  200.,  250.,
                               300.]), P=200, cpx_Ca = 0.5,
                   sourceformat = 'GWB', solid_solution = True,
                   clay_thermo = True, dataset = 'Pflotran',
                   sourcedb = './pygcc/default_db/thermo.2021.dat')  \n
kwargs
T = None
P = None
dbaccessformat
dbBerman_dir
dbHP_dir
dataset
objdb
co2actmodel
ThermoInUnit
sourcedb_codecs
Dielec_method
cpx_Ca
logK_form
heatcap_method
dbaccess
sourceformat
__calc__(**kwargs)
_resolve_sourcedb(sourceformat, sourcedb)

Resolve default source database based on format and user input.

_flag_to_yesno(value, default='No')

Convert boolean/None/custom flag to Yes/No string.

_process_PT()

Process temperature and pressure arrays safely.

Accepted string sentinels:

P == ‘T’ -> P is computed along the saturation curve for the given T T == ‘P’ -> T is computed along the saturation curve for the given P

Any other string raises ValueError. All == against the sentinels is gated on isinstance(..., str) so an ndarray is never compared to a string (which produces NumPy FutureWarning / breaks under NumPy 2.x). Saturation properties are computed directly via Dummy().vcalcsatpropT / Dummy().vcalcsatpropP instead of going through a full iapws95(...) call.

_expand_temperature(T)

Expand temperature input into proper array.

_build_message()

Construct final success message.

write_GWBdb(T, P)

This function writes the new GWB database into a new folder called “output” n :param T: :type T: temperature [°C] n :param P: :type P: pressure [bar] n

Return type:

Outputs the new database to an ASCII file with filename described in ‘objdb’. n

Usage

Example:
  1. General format with default dielectric constant and CO2 activity model and exclusions of solid solutions n write_GWBdb(T, P) n

  2. Inclusion of solid solutions and clay thermo and exclusion of solid solution of clinopyroxene n write_GWBdb(T, P) n

  3. Inclusion of all solid solutions and clay thermo with \emph{‘Duan_Sun’} CO2 activity model and ‘JN91’ dielectric constant calculation n write_GWBdb(T, P) n

write_EQ36db(T, P)

This function writes the new EQ3/6 database into a new folder called “output” n :param T: :type T: temperature [°C] n :param P: :type P: pressure [bar] n

Return type:

Outputs the new database to an ASCII file with filename described in ‘objdb’. n

Usage

Example:
  1. General format with default dielectric constant and CO2 activity model and exclusions of solid solutions n write_EQ36db(T, P ) n

  2. Inclusion of solid solutions and clay thermo and exclusion of solid solution of clinopyroxene n write_EQ36db(T, P ) n

  3. Inclusion of all solid solutions and clay thermo with \emph{‘Duan_Sun’} CO2 activity model and ‘FGL97’ dielectric constant calculation n write_EQ36db(T, P ) n

write_PHREEQCdb(T, P)

This function writes the new PHREEQC database into a new folder called “output” n :param T: :type T: temperature [°C] n :param P: :type P: pressure [bar] n

Return type:

Outputs the new database to an ASCII file with filename described in ‘objdb’. n

Usage

Example:
  1. General format with default dielectric constant and CO2 activity model and exclusions of solid solutions n write_PHREEQCdb(T, P ) n

  2. Inclusion of solid solutions and clay thermo and exclusion of solid solution of clinopyroxene n write_PHREEQCdb(T, P ) n

  3. Inclusion of all solid solutions and clay thermo with \emph{‘Duan_Sun’} CO2 activity model and ‘FGL97’ dielectric constant calculation n write_PHREEQCdb(T, P ) n

write_pflotrandb(T, P)

This function writes the new pflotran database into a new folder called “output” n :param T: :type T: temperature [°C] n :param P: :type P: pressure [bar] n

Return type:

Outputs the new database to an ASCII file with filename described in ‘objdb’. n

Usage

Example:
  1. General format with default dielectric constant and CO2 activity model and exclusions of solid solutions n write_pflotrandb(T, P ) n

  2. Inclusion of solid solutions and clay thermo and exclusion of solid solution of clinopyroxene n write_pflotrandb(T, P ) n

  3. Inclusion of all solid solutions and clay thermo with \emph{‘Duan_Sun’} CO2 activity model and ‘FGL97’ dielectric constant calculation n write_pflotrandb(T, P ) n

write_ToughReactdb(T, P)

This function writes the new ToughReact database into a new folder called “output” n :param T: :type T: temperature [°C] n :param P: :type P: pressure [bar] n

Return type:

Outputs the new database to an ASCII file with filename described in ‘objdb’. n

Usage

Example:
  1. General format with default dielectric constant and CO2 activity model and exclusions of solid solutions n write_ToughReactdb(T, P, dbaccess = ‘location’, sourcedb = ‘location’,

    objdb = ‘location’, sourceformat = ‘GWB’) n

  2. Inclusion of solid solutions and clay thermo and exclusion of solid solution of clinopyroxene n write_ToughReactdb(T, P, solid_solution = ‘Yes’, clay_thermo = ‘Yes’, dbaccess = ‘location’,

    sourcedb = ‘location’, objdb = ‘location’, sourceformat = ‘GWB’) n

  3. Inclusion of all solid solutions and clay thermo with \emph{‘Duan_Sun’} CO2 activity model and ‘FGL97’ dielectric constant calculation n write_ToughReactdb(T, P, nCa, solid_solution = ‘Yes’, clay_thermo = ‘Yes’, dbaccess = ‘location’,

    sourcedb = ‘location’, objdb = ‘location’, co2actmodel = ‘Duan_Sun’, Dielec_method = ‘FGL97’, sourceformat = ‘GWB’) n

pygcc.main_function_name(module)

Return the names of essential public functions and classes in the given module.

Filters out imported third-party names, stdlib helpers, internal constants, and private utility functions so that only the user-facing API is listed.

class pygcc.db_reader(**kwargs)

Class to read direct-access and source thermodynamic database

Parameters:
  • dbaccess (string) – path of the direct-access/sequential-access database, optional, default is speq21

  • dbBerman_dir (string) – path of the Berman mineral database, optional

  • dbHP_dir (string) – path of the supcrtbl mineral and gas database, optional

  • sourcedb (string) – path of the source database, optional

  • sourceformat (string) – specify the source database format, either ‘GWB’, ‘EQ36’ or ‘PHREEQC’, optional

  • dbaccessformat (string, optional) – specify the direct-access/sequential-access database format, either ‘speq’ or ‘supcrtbl’, default is ‘speq’

  • sourcedb_codecs (string) – specify the name of the encoding used to decode or encode the sourcedb file, optional

  • dbaccess_codecs (string) – specify the name of the encoding used to decode or encode the dbaccess file, optional

Returns:

  • dbaccessdic (dict) – dictionary of minerals, gases, redox and aqueous species

  • dbaccess (string) – direct-access database file name

  • sourcedic (dict) – dictionary of reaction coefficients and species

  • specielist (list) – list of species segmented into the different categories [element, basis, redox, aqueous, minerals, gases, oxides]

  • speciecat (list) – list of species categories listed in ‘specielist’

  • chargedic (dict) – dictionary of charges of species

  • MWdic (dict) – dictionary of MW of species

  • Mineraltype (dict) – mineral type for minerals

  • fugacity_info (dict) – fugacity information as stored in new tdat database for chi and critical ppts

  • Sptype (dict) – specie types and eq3/6 and revised date info

  • Elemlist (dict) – dictionary of elements and coefficients

  • Rd (list) – each line of sourcedb in an array

  • d (dict) – dictionary of database headers and corresponding line numbers in Rd

Examples

>>> ps = db_reader(sourcedb = './default_db/thermo.com.dat',
                   sourceformat = 'gwb',
                   dbaccess = './default_db/speq23.dat')
>>> ps.sourcedic, ps.dbaccessdic, ps.specielist
kwargs
Rd
d
__calc__(**kwargs)
readAqspecdb()

This function reads direct access thermodynamic database and can add other database sources at the bottom returns all constants of Maier-Kelley power function for minerals and gases (dG [cal/mol], dH [cal/mol], S [cal/mol-K], V [cm3/mol] a [cal/mol-K], b [*10**3 cal/mol/K^2],

c [*10^-5 cal/mol/K], Ttrans [K], Htr [cal/mol], Vtr [cm³/mol], dPdTtr [bar/K] ) and

aqueous species (dG [cal/mol], dH [cal/mol], S [cal/mol-K], V [cm3/mol], a1 [10 cal/mol/bar], a2 [*10*-2 cal/mol], a3 [cal-K/mol/bar], a4 [10*-4 cal-K/mol], c1 [cal/mol/K], c2 [10*-4 cal-K/mol], ω [10*-5 cal/mol] ) packed into a dbacess dictionary. In addition, the function can read Berman’s mineral properties such as (dG [J/mol], dH [J/mol], S [J/mol-K], V [cm³/mol], k0, k1, k2, k3, v1 [*10^5 K^-1], v2 [*10^5 K^-2], v3 [*10^5 bar^-1], v4 [*10^8 bar^-2], dTdP [K/bar], Tlambda [K], Tref [K], l1 [(J/mol)^0.5/K], l2 [(J/mol)^0.5/K^2], DtH, d0 [J/mol], d1 [J/mol], d2 [J/mol], d3 [J/mol], d4 [J/mol], d5 [J/mol], Tmin [K], Tmax [K]). In addition, the function can read supcrtbl’s mineral and gas properties such as (dG [kJ/mol], dH [kJ/mol], S [J/mol-K], V [J/bar], a [kJ/mol-K], b [*10^5 kJ/mol/K^2], c [kJ-mol-K], d [kJ/mol/K^0.5], alpha [*10^5 K^-1], kappa0 [kbar], kappa0_d [kbar], kappa0_dd [kbar], n_atom [-], Tc0 [K], Smax [J/mol-K], Vmax [J/bar], dH [KJ/mol], dV [J/bar], W [kJ/mol], Wv [J/bar], n [-], SF [-])

Parameters:
  • database (dbHP_dir filename and location of the supcrtbl (Holland and Powell) mineral and gas)

  • database

  • database

Returns:

  • dbaccessdic dictionary of minerals, gases, redox and aqueous species

  • dbaccess dat file name

Usage:

[dbaccessdic, dbname] = readAqspecdb(dbaccess)

readSourceGWBdb()

This function reads source GWB thermodynamic database and reaction coefficients of ‘eh’ and ‘e-’ has been added at the bottom returns all reaction coefficients and species, group species into redox, minerals, gases, oxides and aqueous species :param sourcedb: :type sourcedb: filename of the source database

Returns:

  • sourcedic (dictionary of reaction coefficients and species)

  • specielist (list of species segmented into the different categories) – [element, basis, redox, aqueous, minerals, gases, oxides]

  • speciecat (list of species categories listed in ‘specielist’)

  • chargedic (dictionary of charges of species)

  • MWdic (dictionary of MW of species)

  • Mineraltype (mineral type for minerals)

  • fugacity_info (fugacity information as stored in new tdat database for chi and critical ppts)

Usage:

[sourcedic, specielist, chargedic, MWdic, Mineraltype, fugacity_info, activity_model] = readSourceGWBdb()

readSourceEQ36db()

This function reads source EQ3/6 thermodynamic database and reaction coefficients of ‘eh’ and ‘e-’ has been added at the bottom returns all reaction coefficients and species, group species into basis, auxiliary basis, minerals, gases, liquids and aqueous species :param sourcedb: :type sourcedb: filename of the source database

Returns:

  • sourcedic (dictionary of reaction coefficients and species)

  • specielist (list of species segmented into the different categories) – [element, basis, redox, aqueous, minerals, gases, oxides]

  • speciecat (list of species categories listed in ‘specielist’)

  • chargedic (dictionary of charges of species and DHazero info)

  • MWdic (dictionary of MW of species)

  • Sptype (specie types and eq3/6 and revised date info)

  • Elemlist (dictionary of elements and coefficients)

Usage:

[sourcedic, specielist, chargedic, MWdic, block_info, Elemlist, act_param] = readSourceEQ36db(sourcedb)

readSourcePHREEQCdb()

This function reads source PHREEQC thermodynamic database and group species into solution, phases, exchange and surface species :param sourcedb: :type sourcedb: filename of the source database

Returns:

  • sourcedic (dictionary of reaction coefficients and species)

  • specielist (list of species segmented into the different categories) – [element, basis, redox, aqueous, minerals, gases, oxides]

  • speciecat (list of species categories listed in ‘specielist’)

  • chargedic (dictionary of charges of species)

Usage:

[sourcedic, specielist, chargedic, act_param] = readSourcePHREEQCdb()

pygcc.dbaccess_modify(in_filename=None, dbaccess=None, out_filename=None)

This function loads thermodynamic data from a csv files and appends/replace the corresponding species thermo data and writes out a modified direct-access database :param in_filename: CSV filename and location :type in_filename: string :param dbaccess: direct-access database filename and location (optional) :type dbaccess: string :param out_filename: newly modified direct-access database filename and location (optional) :type out_filename: string

Return type:

Output the newly modified direct-access with filename described in ‘out_filename’ if specified.

Examples

>>> dbaccess_modify(in_filename = 'geotpd_data_block_cr.csv')
class pygcc.iapws95(**kwargs)

Implementation of IAPWS Formulation 1995 for ordinary water substance, revised release of 2016

Notes

Temperature and Pressure input limits
  • -22 ≤ TC ≤ 1000 and 0 ≤ P ≤ 100,000

Parameters:
  • T (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • rho (float, vector) – Density [kg/m³]

  • rho0 (float, vector) – Starting estimate of density [kg/m³]

  • rhom (float, vector) – Molar density [kg/m³]

  • delta (float, vector) – Reduced density, rho/rhoc

  • tau (float, vector) – Reduced temperature, Tc/T

  • v (float, vector) – Specific volume [m³/kg]

  • vm (float, vector) – Specific molar volume [m³/mol]

  • Out_Unit (string) – Expected units (‘standard’ or ‘kilogram’)

  • FullEOSppt (bool) – Option to output all or essential water properties [False or True]

Returns:

  • The calculated instance has the following potential properties

  • rho (float, vector) – Density [kg/m3]

  • G (float, vector) – Gibbs energy [cal/mol] or [kJ/kg]

  • H (float, vector) – Enthalpy [cal/mol] or [kJ/kg]

  • S (float, vector) – Entropy [cal/mol/K] or [kJ/kg/K]

  • V (float, vector) – Volume [m3/mol] or [m3/kg]

  • P (float, vector) – Pressure [bar]

  • TC (float, vector) – Temperature [°C]

  • TK (float, vector) – Temperature [K]

  • U (float, vector) – Internal energy [cal/mol] or [kJ/kg] if FullEOSppt is True

  • F (float, vector) – Helmholtz energy [cal/mol/K] or [kJ/kg-K] if FullEOSppt is True

  • Cp (float, vector) – Isobaric heat capacity [cal/mol/K]

  • rhosl (float, vector) – Density of liquid [kg/m3]

  • rhosv (float, vector) – Density of vapor [kg/m3]

  • pdx (float, vector) – Derivative of pressure with respect to delta in bar

  • adx (float, vector) – Helmholtz energy derivative with respect to delta

  • ztx (float, vector) – zeta value (needed to calculate viscosity)

  • ptx (float, vector) – Derivative of pressure with respect to tau in bar

  • gdx (float, vector) – Gibbs energy derivative [kJ/kg] if FullEOSppt is True

  • ktx (float, vector) – Compressibility [/bar]

  • avx (float, vector) – Thermal expansion coefficient (thermal expansivity)

  • mu (float, vector) – viscosity [Pa-s] if FullEOSppt is True

  • bsx (float, vector) – Isentropic temperature-pressure coefficient [K-m3/kJ] if FullEOSppt is True

  • dtx (float, vector) – Isothermal throttling coefficient [kJ/kg/bar] if FullEOSppt is True

  • mux (float, vector) – Joule-Thomsen coefficient [K-m3/kJ] if FullEOSppt is True

  • cvx (float, vector) – Isochoric heat capacity [kJ/kg/K] if FullEOSppt is True

  • wx (float, vector) – Speed of sound [m/s] if FullEOSppt is True

Usage:

The general usage of iapws95 is as follows:

  1. For water properties at any Temperature and Pressure not on steam saturation curve:

    water = iapws95(T = T, P = P),

    where T is temperature in celsius and P is pressure in bar

  2. For water properties at any Temperature and Pressure on steam saturation curve:

    water = iapws95(T = T, P = ‘T’),

    where T is temperature in celsius, followed with a quoted character ‘T’ to reflect steam saturation pressure

    water = iapws95(T = ‘P’, P = P),

    where P is pressure in bar, followed with a quoted character ‘P’ to reflect steam saturation temperature

  3. For water properties at any Temperature and density :

    water = iapws95(T = T, rho = rho),

    where T is temperature in celsius and rho is density in kg/m³

  4. For water properties at any Pressure and density :

    water = iapws95(P = P, rho = rho),

    where P is pressure in bar and rho is density in kg/m³

  5. For water saturation properties at any saturation Temperature :

    water = iapws95(T = T),

    where T is temperature in celsius

  6. For water saturation properties at any saturation Pressure :

    water = iapws95(P = P),

    where P is pressure in bar

Examples

>>> water = iapws95(T = 200., P = 50, FullEOSppt = True)
>>> water.rho, water.G, water.H, water.S, water.V, water.P, water.T, water.mu
    867.2595, -60368.41787, -65091.03895,  25.14869,  4.96478e-03,  50.00000,
    200.000, 0.00013546
>>> water = iapws95(T=200, rho=996.5560, Out_Unit='kilogram', FullEOSppt=True)
>>> water.P, water.F, water.S, water.H, water.G, water.V, water.Cp, water.pdx
    2872.063, -234.204, 2.051, 1024.747, 53.994, 1.0035e-03, 3.883, 10079.17
>>> water.adx, water.ztx, water.ptx, water.ktx, water.avx, water.mu, water.gdx
    93.120, 2.189e-03, -7.348e+03,  3.205e-05,  6.809e-04, 1.914e-04, 1011.40
>>> water = iapws95(T = 350)
>>> water.P, water.rhosl, water.rhosv
    165.2942 574.7065 113.6056
>>> water = iapws95(P = 150)
>>> water.TC, water.rhosl, water.rhosv
    342.1553, 603.5179, 96.7271

References

  1. Wagner, W., Pruß, A., 2002. The IAPWS formulation 1995 for the thermodynamic properties of ordinary water substance for general and scientific use. J. Phys. Chem. Ref. Data 31, 387–535. https://doi.org/10.1063/1.1461829

kwargs
mwH2O = 18.015268
__checker__(**kwargs)
__calc__(**kwargs)
class pygcc.ZhangDuan(**kwargs)

Implementation of Zhang & Duan model Formulation for water at higher Temperature and Pressure conditions, i.e, Deep Earth Water - DEW

Notes

Temperature and Pressure input limits
  • 0 ≤ TC ≤ 1726.85 and 1000 ≤ P ≤ 300,000

Parameters:
  • T (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • rho (float, vector) – Density [kg/m³]

  • rho0 (float, vector) – Starting estimate of density [kg/m³]

  • densityEquation (string) – specify either ‘ZD05’ to use Zhang & Duan (2005) or ‘ZD09’ to use Zhang & Duan (2009)

Returns:

  • The calculated instance has the following potential properties

  • rho (float, vector) – Density [kg/m3]

  • rhohat (float, vector) – Density [g/cm³]

  • G (float, vector) – Gibbs energy [cal/mol]

  • drhodP_T (float, vector) – Partial derivative of density with respect to pressure at constant temperature

  • drhodT_P (float, vector) – Partial derivative of density with respect to temperature at constant pressure

Usage:

The general usage of ZhangDuan is as follows:

  1. For water properties at any Temperature and Pressure:

    deepearth = ZhangDuan(T = T, P = P),

    where T is temperature in celsius and P is pressure in bar

  2. For water properties at any Temperature and density :

    deepearth = ZhangDuan(T = T, rho = rho),

    where T is temperature in celsius and rho is density in kg/m³

Examples

>>> deepearth = ZhangDuan(T = 25, P = 5000)
>>> deepearth.rho, deepearth.G, deepearth.drhodP_T, deepearth.drhodT_P
    1145.3065, -54631.5351, 2.3283e-05, -0.0004889
>>> deepearth = ZhangDuan(T = 200, rho = 1100)
>>> deepearth.P, deepearth.G, deepearth.drhodP_T, deepearth.drhodT_P
    7167.2231, -57319.0980, 2.3282e-05, -0.0005122

References

  1. Zhang, Z., Duan, Z., 2005. Prediction of the PVT properties of water over wide range of temperatures and pressures from molecular dynamics simulation. Phys. Earth Planet. Inter. 149, 335–354. https://doi.org/10.1016/j.pepi.2004.11.003.

  2. Zhang, C. and Duan, Z., 2009. “A model for C-O-H fluid in the Earth’s mantle”, Geochimica et Cosmochimica Acta, vol. 73, no. 7, pp. 2089–2102, doi:10.1016/j.gca.2009.01.021.

  3. Sverjensky, D.A., Harrison, B., Azzolini, D., 2014. Water in the deep Earth: The dielectric constant and the solubilities of quartz and corundum to 60kb and 1200°C. Geochim. Cosmochim. Acta 129, 125–145. https://doi.org/10.1016/j.gca.2013.12.019

kwargs
__calc__(**kwargs)
ZD_Pressure_drhodP(TC, rhohat, method=None)
ZD_Density(TC, P, method='ZD05', error=None)
GibbsEnergy(TC, P, method='VolumeIntegral')
class pygcc.water_dielec(**kwargs)

Class Implementation of Water dielectric constants, the Debye-Huckel “A” and “B” parameters and their derivatives at ambient to deep-earth Temperature and Pressure conditions with three different formulations

Parameters:
  • T (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • rho (float, vector) – Density [kg/m³]

  • Dielec_method (string) – specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric constant (optional), if not specified, default - ‘JN91’

  • Dielec_DEWoutrange (string) – specify either ‘FGL97’ or ‘JN91’ as the method to calculate dielectric constant for out of range for ‘DEW’ method if any

Returns:

  • The calculated instance has the following potential properties

  • E (float, vector) – dielectric constant of water

  • rhohat (float, vector) – density [g/cm³]

  • Ah (float, vector) – Debye-Huckel “A” parameters [kg^1/2 mol^-1/2]

  • Bh (float, vector) – Debye-Huckel “B” parameters [kg^1/2 mol^-1/2 Angstrom^-1]

  • bdot (float, vector) – bdot at any given temperature T

  • Adhh (float, vector) – Debye-Huckel “A” parameters associated with apparent molar enthalpy

  • Adhv (float, vector) – Debye-Huckel “A” parameters associated with apparent molar volume

  • Bdhh (float, vector) – Debye-Huckel “B” parameters associated with apparent molar enthalpy

  • Bdhv (float, vector) – Debye-Huckel “B” parameters associated with apparent molar volume

  • dEdP_T (float, vector) – Partial derivative of dielectric constant with respect to pressure at constant temperature

  • dEdT_P (float, vector) – Partial derivative of dielectric constant with respect to temperature at constant pressure

Notes

FGL97 Temperature and Pressure input limits:
  • -35 ≤ TC ≤ 600 and 0 ≤ P ≤ 12000

DEW Temperature and Pressure input limits:
  • 100 ≤ TC ≤ 1200 and 1000 ≤ P ≤ 60000

JN91 Temperature and Pressure input limits:
  • 0 ≤ TC ≤ 1000 and 0 ≤ P ≤ 5000

Usage

The general usage of water_dielec is as follows:

  1. For water dielectric properties at any Temperature and Pressure:

    dielect = water_dielec(T = T, P = P, Dielec_method = ‘JN91’),

    where T is temperature in celsius and P is pressure in bar

  2. For water dielectric properties at any Temperature and density :

    dielect = water_dielec(T = T, rho = rho, Dielec_method = ‘JN91’),

    where T is temperature in celsius and rho is density in kg/m³

  3. For water dielectric properties at any Temperature and Pressure on steam saturation curve:

    dielect = water_dielec(T = T, P = ‘T’, Dielec_method = ‘JN91’),

    where T is temperature in celsius and P is assigned a quoted character ‘T’ to reflect steam saturation pressure

    dielect = water_dielec(P = P, T = ‘P’, Dielec_method = ‘JN91’),

    where P is pressure in bar and T is assigned a quoted character ‘P’ to reflect steam saturation temperature

Examples

>>> dielect = water_dielec(T = 50, P = 500, Dielec_method = 'JN91')
>>> dielect.E, dielect.rhohat, dielect.Ah, dielect.Bh, dielect.bdot
    71.547359, 1.00868586, 0.52131899,   0.33218072,   0.04088528
>>> dielect.Adhh, dielect.Adhv, dielect.Bdhh, dielect.Bdhv
    0.64360153,   2.13119279,  15.6936832 , -14.52571678
>>> dielect.dEdP_T, dielect.dEdT_P
    0.03293026,   -0.32468033
>>> dielect = water_dielec(T = 200, rho = 1100, Dielec_method = 'FGL97')
>>> dielect.E, dielect.rhohat, dielect.Ah, dielect.Bh, dielect.bdot
    49.73131404,  1.1,  0.5302338, 0.34384714,  0.04452579
>>> dielect.Adhh, dielect.Adhv, dielect.Bdhh, dielect.Bdhv
    1.21317825,  2.21165281, 28.0047878, -34.21216547
>>> dielect.dEdP_T, dielect.dEdT_P
    0.01444368, -0.16864644
>>> dielect = water_dielec(T = 250, P = 5000, Dielec_method = 'DEW')
>>> dielect.E, dielect.rhohat, dielect.Ah, dielect.Bh, dielect.bdot, dielect.Adhh
    39.46273008,  1.0238784,  0.62248141,   0.35417088, 0.02878662, 0.80688122
>>> dielect.Adhv, dielect.Bdhh, dielect.Bdhv, dielect.dEdP_T, dielect.dEdT_P
     3.13101408, 39.76402294, -35.29670957, 0.0129006 , -0.08837842

References

  1. Release on the Static Dielectric Constant of Ordinary Water Substance for Temperatures from 238 K to 873 K and Pressures up to 1000 MPa” (IAPWS R8-97, 1997).

  2. Fernandez D. P., Goodwin A. R. H., Lemmon E. W., Levelt Sengers J. M. H., and Williams R. C. (1997) A Formulation for the Permittivity of Water and Steam at Temperatures from 238 K to 873 K at Pressures up to 1200 MPa, including Derivatives and Debye-Hückel Coefficients. J. Phys. Chem. Ref. Data 26, 1125-1166.

  3. Helgeson H. C. and Kirkham D. H. (1974) Theoretical Prediction of the Thermodynamic Behavior of Aqueous Electrolytes at High Pressures and Temperatures: II. Debye-Huckel Parameters for Activity Coefficients and Relative Partial Molal Properties. Am. J. Sci. 274, 1199-1251.

  4. Johnson JW, Norton D (1991) Critical phenomena in hydrothermal systems: State, thermodynamic, electrostatic, and transport properties of H2O in the critical region. American Journal of Science 291:541-648

  5. D. A. Sverjensky, B. Harrison, and D. Azzolini, “Water in the deep Earth: the dielectric constant and the solubilities of quartz and corundum to 60 kb and 1200 °C,” Geochimica et Cosmochimica Acta, vol. 129, pp. 125–145, 2014

kwargs
__checker__(**kwargs)
__calc__(**kwargs)
dielec_FGL97(TC, rho)

This function employs the FGL91 formulation to calculate the dielectric constant of water (E), the Debye-Huckel “A” parameters and Debye-Huckel “B” parameters (3) and their derivatives as a function of temperature and pressure

Notes

Temperature and Pressure input limits:
  • -35 ≤ TC ≤ 600 and 0 ≤ P ≤ 12000

Parameters:
  • TC (temperature [°C])

  • rho (density [kg/m3])

Returns:

  • E (dielectric constant of water)

  • rhohat (density [g/cm³])

  • Ah (Debye-Huckel “A” parameters [kg^1/2 mol^-1/2])

  • Bh (Debye-Huckel “B” parameters [kg^1/2 mol^-1/2 Angstrom^-1])

  • bdot (bdot at any given temperature T)

  • Adhh (Debye-Huckel “A” parameters associated with apparent molar enthalpy)

  • Adhv (Debye-Huckel “A” parameters associated with apparent molar volume)

  • Bdhh (Debye-Huckel “B” parameters associated with apparent molar enthalpy)

  • Bdhv (Debye-Huckel “B” parameters associated with apparent molar volume)

  • dEdP_T (Partial derivative of dielectric constant with respect to pressure at constant temperature)

  • dEdT_P (Partial derivative of dielectric constant with respect to temperature at constant pressure)

Usage

[E, rhohat, Ah, Bh, bdot, Adhh, Adhv, Bdhh, Bdhv, dEdP_T, dEdT_P] = dielec_FGL97( TC, rho)

References

  1. Release on the Static Dielectric Constant of Ordinary Water Substance for Temperatures from 238 K to 873 K and Pressures up to 1000 MPa” (IAPWS R8-97, 1997).

  2. Fernandez D. P., Goodwin A. R. H., Lemmon E. W., Levelt Sengers J. M. H., and Williams R. C. (1997) A Formulation for the Permittivity of Water and Steam at Temperatures from 238 K to 873 K at Pressures up to 1200 MPa, including Derivatives and Debye-Hückel Coefficients. J. Phys. Chem. Ref. Data 26, 1125-1166.

  3. Helgeson H. C. and Kirkham D. H. (1974) Theoretical Prediction of the Thermodynamic Behavior of Aqueous Electrolytes at High Pressures and Temperatures: II. Debye-Huckel Parameters for Activity Coefficients and Relative Partial Molal Properties. Am. J. Sci. 274, 1199-1251.

dielec_JN91(TC, rho)

This dielec_JN91 implementation employs the JN91 formulation to calculate the dielectric properties of water and steam, the Debye-Huckel “A” parameters and Debye-Huckel “B” parameters and their derivatives

Notes

Temperature and Pressure input limits:
  • 0 ≤ TC ≤ 1000 and 0 ≤ P ≤ 5000

Parameters:
  • TC (temperature [°C])

  • rho

rhohat : density [g/cm³]

Ah : Debye-Huckel “A” parameters [kg^1/2 mol^-1/2]

Bh : Debye-Huckel “B” parameters [kg^1/2 mol^-1/2 Angstrom^-1]

bdot : bdot at any given temperature T

Adhh : Debye-Huckel “A” parameters associated with apparent molar enthalpy

Adhv : Debye-Huckel “A” parameters associated with apparent molar volume

Bdhh : Debye-Huckel “B” parameters associated with apparent molar enthalpy

Bdhv : Debye-Huckel “B” parameters associated with apparent molar volume

dEdP_T : Partial derivative of dielectric constant with respect to pressure at constant temperature

dEdT_P : Partial derivative of dielectric constant with respect to temperature at constant pressure

Usage

References

  1. Johnson JW, Norton D (1991) Critical phenomena in hydrothermal systems: State, thermodynamic, electrostatic, and transport properties of H2O in the critical region. American Journal of Science 291:541-648

  2. Helgeson H. C. and Kirkham D. H. (1974) Theoretical Prediction of the Thermodynamic Behavior of Aqueous Electrolytes at High Pressures and Temperatures: II. Debye-Huckel Parameters for Activity Coefficients and Relative Partial Molal Properties. Am. J. Sci. 274, 1199-1251.

dielec_DEW()

This watercalc implementation employs the DEW formulation embedded in Sverjensky et al. (2014) to calculate the dielectric properties of water and steam, the Debye-Huckel “A” parameters and Debye-Huckel “B” parameters and their derivatives. This function has been set up to use either Johnson and Norton (1991) or Fernandez et al. (1997) formulation below 5000 bar and Sverjensky et al. (2014) formulation above 5000 bar.

Notes

Temperature and Pressure input limits:
  • 100 ≤ TC ≤ 1200 and 1000 ≤ P ≤ 60000

Parameters:
  • TC (temperature [°C])

  • P

rhohat : density [g/cm³]

Ah : Debye-Huckel “A” parameters [kg^1/2 mol^-1/2]

Bh : Debye-Huckel “B” parameters [kg^1/2 mol^-1/2 Angstrom^-1]

bdot : bdot at any given temperature T

Adhh : Debye-Huckel “A” parameters associated with apparent molar enthalpy

Adhv : Debye-Huckel “A” parameters associated with apparent molar volume

Bdhh : Debye-Huckel “B” parameters associated with apparent molar enthalpy

Bdhv : Debye-Huckel “B” parameters associated with apparent molar volume

dEdP_T : Partial derivative of dielectric constant with respect to pressure at constant temperature

dEdT_P : Partial derivative of dielectric constant with respect to temperature at constant pressure

Usage

References

  1. D. A. Sverjensky, B. Harrison, and D. Azzolini, “Water in the deep Earth: the dielectric constant and the solubilities of quartz and corundum to 60 kb and 1200 °C,” Geochimica et Cosmochimica Acta, vol. 129, pp. 125–145, 2014

  2. Helgeson H. C. and Kirkham D. H. (1974) Theoretical Prediction of the Thermodynamic Behavior of Aqueous Electrolytes at High Pressures and Temperatures: II. Debye-Huckel Parameters for Activity Coefficients and Relative Partial Molal Properties. Am. J. Sci. 274, 1199-1251.

pygcc.readIAPWS95data()

returns all constants and coefficients needed for the IAPWS95 formulation, packed into a dictionary

pygcc.convert_temperature(T, Out_Unit='C')

This function converts temperatures from Celsius to Kelvin and vice-versa

Parameters:
  • T (float, vector) – Temperature in °C or K

  • Out_Unit (string) – Expected temperature unit (C or K)

Returns:

T – Temperature in °C or K

Return type:

float, vector

Examples

>>> TC = 100; convert_temperature( TC, Out_Unit = 'K' )
    373.15
>>> TK = 520; convert_temperature( TK, Out_Unit = 'C' )
    246.85
class pygcc.Driesner_NaCl(**kwargs)

Implementation of Driesner and Heinrich PTx Formulation for H2O-NaCl system

Parameters:
  • T (float) – Temperature [°C]

  • P (float) – Pressure [bar]

  • xNaCl (float) – mole fraction of NaCl in H2O [-]

Returns:

  • The calculated instance has the following potential properties

  • PVLH (float) – Pressure of vapor + liquid + halite coexistence [bar]

  • Pcrit (float) – Critical pressure (of a H2O–NaCl mixture) [bar]

  • Xcrit (float) – Critical Composition [-]

  • xL_NaCl (float) – Composition of halite-saturated liquid (halite liquidus) Hypothetical [-]

  • xV_NaCl (float) – Composition of halite-saturated vapor [-]

  • xVL_Liq (float) – Composition of liquid at vapor + liquid coexistence [-]

  • xVL_Vap (float) – Composition of vapor at vapor+liquid coexistence [-]

  • rho (float) – Liquid NaCl density [kg/m3]

  • vm (float) – molar volume [mol/m3]

  • TstarH (float) – Scaled temperature for enthalpy correlation [°C]

  • H (float) – Specific enthalpy of an H2O–NaCl solution [J/kg]

  • Cp (float) – Isobaric heat capacity [J/kg/K]

  • mu (float) – viscosity [Pa-s]

Usage:

The general usage of Driesner_NaCl is as follows:

  1. For water-NaCl properties at any Temperature and Pressure:

    water_salt = Driesner_NaCl(T = T, P = P),

    where T is temperature in celsius and P is pressure in bar

Examples

>>> water_salt = Driesner_NaCl(T = 400., P = 150)
>>> water_salt.PVLH, water_salt.xL_NaCl, water_salt.xV_NaCl, water_salt.xVL_Liq, water_salt.xVL_Vap, water_salt.Xcrit
    176.12604181993797,
     0.21548565081529097,
     1.1606891909548725e-05,
     0.27785803505887324,
     1.1606891909548725e-05,
     0.006832050956381021
>>> water_salt = Driesner_NaCl(T = 400., P = 150, xNaCl = 0.00919)
>>> water_salt.PVLH, water_salt.xL_NaCl, water_salt.xV_NaCl, water_salt.xVL_Liq, water_salt.xVL_Vap, water_salt.rho, water_salt.vm, water_salt.H, water_salt.mu, water_salt.Cp
    (176.12604181993797,
     0.21548565081529097,
     1.1606891909548725e-05,
     0.27785803505887324,
     1.1606891909548725e-05,
     0.06932873574838519,
     265.2138005082347,
     2934.6231778877977,
     2.4596312351131325e-05,
     4394.068874696437)

References

  1. Driesner, T, and Heinrich, C. A. (2007). The system H2O–NaCl. Part I: Correlation formulae for phase relations in temperature–pressure–composition space from 0 to 1000 C, 0 to 5000 bar, and 0 to 1 XNaCl. Geochimica et Cosmochimica Acta. 71(20), 4880-4901. https://doi.org/10.1016/j.gca.2006.01.033

(2) Driesner, T. (2007). “The system H2O-NaCl. II. Correlations for molar volume, enthalpy, and isobaric heat capacity from 0 to 1000 °C, 1 to 5000 bar, # and 0 to 1 X-NaCl.” Geochimica et Cosmochimica Acta 71(20): 4902-4919.

kwargs
__calc__(**kwargs)
Driesner_NaCl(T, P)
Driesner_NaClII(T, P, xNaCl)
enthalpy_mu_heatcap(T, P, xNaCl)

Enthalpy in J/g, viscosity in Pas and Cp in Joules per kilogram Kelvin

pygcc.concentration_converter(val=1.0, In_Unit='x_wt', Out_Unit='x_wt')

This function converts concentration between several units like wt fraction, mole fraction, molality, mol/kg solution and volume fraction Values must be in fraction except it is molality

Parameters:
  • val (float) – Values to convert

  • In_Unit (String) – unit of input concentration

  • Out_Unit (String) – expected output concentration

Returns:

Out – Converted values

Return type:

float

class pygcc.heatcap(**kwargs)

Class to heat capacity for mineral and gases using Maier-Kelley powerlaw, Haas-Fisher powerlaw, Holland and Powell and Berman’s function

Parameters:
  • T (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • Species_ppt (array) –

    Properties such as Supcrt92 (dG [cal/mol], dH [cal/mol], S [cal/mol-K], V [cm3/mol] a [cal/mol-K], b [*10**3 cal/mol/K^2],

    c [*10^-5 cal/mol/K], Ttrans [K], Htr [cal/mol], Vtr [cm³/mol], dPdTtr [bar/K] ): Berman’s database

    properties such as (dG [J/mol], dH [J/mol], S [J/mol-K], V [cm³/mol], k0, k1, k2, k3, v1 [*10^5 K^-1], v2 [*10^5 K^-2], v3 [*10^5 bar^-1], v4 [*10^8 bar^-2], dTdP [K/bar], Tlambda [K], Tref [K], l1 [(J/mol)^0.5/K], l2 [(J/mol)^0.5/K^2], DtH, d0 [J/mol], d1 [J/mol], d2 [J/mol], d3 [J/mol], d4 [J/mol], d5 [J/mol], Tmin [K], Tmax [K]): Supcrtbl’s database properties such as (dG [kJ/mol], dH [kJ/mol], S [J/mol-K], V [J/bar], a [kJ/mol-K], b [*10^5 kJ/mol/K^2], c [kJ-mol-K], d [kJ/mol/K^0.5], alpha [*10^5 K^-1], kappa0 [kbar], kappa0_d [kbar], kappa0_dd [kbar], n_atom [-], Tc0 [K], Smax [J/mol-K], Vmax [J/bar], dH [KJ/mol], dV [J/bar], W [kJ/mol], Wv [J/bar], n [-], SF [-]), etc

  • Species (string) – species name, optional for all cases except gases, Coesite and Quartz

  • method (string) – specify either ‘SUPCRT’ or ‘berman88’ or ‘HP11’ or ‘HF76’ to carry-out any mineral or gas heat capacity calculations, default is ‘SUPCRT’

Returns:

  • dG (float, vector) – Gibbs Energy [cal/mol]

  • dCp (float, vector) – Heat capacity [cal/mol/K]

Examples

>>> # Example with Maier-Kelley powerlaw function as implemented in SUPCRT92
>>> from pygcc.pygcc_utils import db_reader
>>> ps = db_reader() # utilizes the default direct-access database, speq21
>>> sp = heatcap( T = 100, P = 50, Species = 'H2S(g)', Species_ppt = ps.dbaccessdic['H2S(g)'], method = 'SUPCRT')
>>> sp.dG, sp.dCp
    -11782.47165818, 8.58416135
>>> sp = heatcap( T = 100, P = 50, Species_ppt = ps.dbaccessdic['Quartz'], method = 'SUPCRT',
                      Species = 'Quartz')
>>> sp.dG, sp.dCp
    -205292.75498942, 12.34074489
>>> # Example with Haas-Fisher powerlaw function
>>> from pygcc.pygcc_utils import db_reader
>>> ps = db_reader() # utilizes the default direct-access database, speq21
>>> sp = heatcap( T = 100, P = 50, Species_ppt = ps.dbaccessdic['ss_Anorthite'], method = 'HF76',
                 Species = 'ss_Anorthite')
>>> sp.dG, sp.dCp
    -960440.79915641, 57.46776903
>>> # Example with Berman's function
>>> from pygcc.pygcc_utils import db_reader
>>> # utilizes the default speq21 and specified Berman dataset database
>>> ps = db_reader(dbBerman_dir = './default_db/Berman.dat')
>>> sp = heatcap( T = 100, P = 50, Species_ppt = ps.dbaccessdic['Quartz'], method = 'berman88',
                 Species = 'Quartz')
>>> sp.dG, sp.dCp
    -205472.3365716, 12.32381279
>>> # Example with Holland and Powell's function
>>> from pygcc.pygcc_utils import db_reader
>>> # utilizes the default speq21 and specified SUPCRTBL (HP2011) dataset database
>>> ps = db_reader(dbHP_dir = './default_db/supcrtbl.dat')
>>> sp = heatcap( T = 100, P = 50, Species_ppt = ps.dbaccessdic['Hematite'], method = 'HP11',
                 Species = 'Hematite')
>>> sp.dG, sp.dCp
    -179494.62259123, 28.09545987

References

  1. Helgeson, H. C., Delany, J. M., Nesbitt, H. W. and Bird, D. K.(1978). Summary and critique of the thermodynamic properties of rock-forming minerals.

  2. Kelley K. K (1960) Contributions to the data on theoretical metallurgy. XIII. High temperature heat content, heat capacity and entropy data for elements and inorganic compounds US Bur Mines Bull 548: 232 p

  3. Haas JL Jr, Fisher JR (1976) Simultaneous evaluation and correlation of thermodynamic data. American Journal of Science 276:525-545

  4. Berman, R. G. (1988). Internally-consistent thermodynamic data for minerals in the system Na2O-K2O-CaO-MgO-FeO-Fe2O3-Al2O3-SiO2-TiO2-H2O-CO2. Journal of petrology, 29(2), 445-522.

  5. Berman RG, Brown TH (1985) Heat Capacities of minerals in the system Na2O-K2O-CaO-MgO-FeO-Fe2O3-Al2O3-SiO2-TiO2-H2O-CO2: Representation, estimation, and high temperature extrapolation. Contrib Mineral Petrol 89:168-183

  6. Holland, T. and Powell, R., 2011. An improved and extended internally consistent thermodynamic dataset for phases of petrological interest, involving a new equation of state for solids. Journal of Metamorphic Geology. 29, 333–383.

  7. Holland, T.J.B. and Powell, R., 1998. An internally-consistent thermodynamic dataset for phases of petrological interest. Journal of Metamorphic Geology, 16, 309–344.

  8. Zimmer, K., Zhang, Y.L., Lu, P., Chen, Y.Y., Zhang, G.R., Dalkilic, M. and Zhu, C. (2016) SUPCRTBL: A revised and extended thermodynamic dataset and software package of SUPCRT92. Computer and Geosciences 90:97-111

kwargs
TC = None
P = None
Species_ppt = None
method = None
Species = None
__calc__(**kwargs)
heatcapusgscal(TC, P, species)

This function evaluates Gibbs energy and heat capacity as a function of temperature and pressure for any mineral or gas specie using Haas and Fisher (1976)’s heat capacity parameter fit (utilized for solid-solutions)

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • species (array) – Properties such as [dG [cal/ml], dH [cal/mol], S [cal/mol-K], V [cm³/mol], a [cal/mol-K], b [cal/mol/K^2], c [cal/mol/K], g [cal/mol/K^0.5], f [cal/mol/K^3] )

Returns:

  • delGfPT (float, vector) – Gibbs Energy [cal/mol]

  • delCp (float, vector) – Heat capacity [cal/mol/K]

References

  1. Haas JL Jr, Fisher JR (1976) Simultaneous evaluation and correlation of thermodynamic data. American Journal of Science 276:525-545

heatcap_Berman(TC, P, species)

This function evaluates Gibbs energy and heat capacity as a function of temperature and pressure for any mineral or gas specie using Berman (1988) equations and datasets with Berman and Brown (1985)’s heat capacity parameter fit

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • species (array) –

    Properties such as [dG [J/mol], dH [J/mol], S [J/mol-K], V [cm³/mol], k0, k1, k2, k3,

    v1 [*10^5 K^-1], v2 [*10^5 K^-2], v3 [*10^5 bar^-1], v4 [*10^8 bar^-2], dTdP [K/bar], Tlambda [K], Tref [K], l1 [(J/mol)^0.5/K], l2 [(J/mol)^0.5/K^2], DtH, d0 [J/mol], d1 [J/mol], d2 [J/mol], d3 [J/mol], d4 [J/mol], d5 [J/mol], Tmin [K], Tmax [K]]

Returns:

  • delGfPT (float, vector) – Gibbs Energy [cal/mol]

  • delCp (float, vector) – Heat capacity [cal/mol/K]

References

  1. Berman, R. G. (1988). Internally-consistent thermodynamic data for minerals in the system Na2O-K2O-CaO-MgO-FeO-Fe2O3-Al2O3-SiO2-TiO2-H2O-CO2. Journal of petrology, 29(2), 445-522.

  2. Berman RG, Brown TH (1985) Heat Capacities of minerals in the system Na2O-K2O-CaO-MgO-FeO-Fe2O3-Al2O3-SiO2-TiO2-H2O-CO2: Representation, estimation, and high temperature extrapolation. Contrib Mineral Petrol 89:168-183

heatcapsup(TC, P, species, **kwargs)

This function evaluates Gibbs energy and heat capacity as a function of temperature and pressure for any mineral or gas specie using Helgeson et al (1978) equations and Maier-Kelley power function for heat capacity as implemented in SUPCRT92

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • species (array) –

    Properties such as ( dG [cal/mol], dH [cal/mol], S [cal/mol-K], V [cm³/mol], a [cal/mol-K],

    b [*10^3 cal/mol/K^2], c [*10^-5 cal/mol/K], Ttrans [K], Htr [cal/mol], Vtr [cm³/mol], dPdTtr [bar/K] ), etc

  • spec_name (string) – species name, optional for all cases except gases, Coesite and Quartz

Returns:

  • delGfPT (float, vector) – Gibbs Energy [cal/mol]

  • delCp (float, vector) – Heat capacity [cal/mol/K]

References

  1. Helgeson, H. C., Delany, J. M., Nesbitt, H. W. and Bird, D. K.(1978). Summary and critique of the thermodynamic properties of rock-forming minerals.

  2. Kelley K. K (1960) Contributions to the data on theoretical metallurgy. XIII. High temperature heat content, heat capacity and entropy data for elements and inorganic compounds US Bur Mines Bull 548: 232 p

heatcaphp(TC, P, species)

This function evaluates Gibbs energy and heat capacity as a function of temperature and pressure for any mineral or gas specie using Holland and Powell (2011)’s heat capacity parameter fit and database based on SUPCRTBL

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • species (array) –

    Properties such as [dG [kJ/mol], dH [kJ/mol], S [J/mol-K], V [J/bar], a [kJ/mol-K],

    b [*10^5 kJ/mol/K^2], c [kJ-mol-K], d [kJ/mol/K^0.5], alpha [*10^5 K^-1], kappa0 [kbar], kappa0_d [kbar], kappa0_dd [kbar], n_atom [-], Tc0 [K], Smax [J/mol-K], Vmax [J/bar], dH [KJ/mol], dV [J/bar], W [kJ/mol], Wv [J/bar], n [-], SF [-]]

Returns:

  • delGfPT (float, vector) – Gibbs Energy [cal/mol]

  • delCp (float, vector) – Heat capacity [cal/mol/K]

References

  1. Holland, T. and Powell, R., 2011. An improved and extended internally consistent thermodynamic dataset for phases of petrological interest, involving a new equation of state for solids. Journal of Metamorphic Geology. 29, 333–383.

  2. Zimmer, K., Zhang, Y.L., Lu, P., Chen, Y.Y., Zhang, G.R., Dalkilic, M. and Zhu, C. (2016) SUPCRTBL: A revised and extended thermodynamic dataset and software package of SUPCRT92. Computer and Geosciences 90:97-111

  3. Holland, T.J.B. and Powell, R., 1998. An internally-consistent thermodynamic dataset for phases of petrological interest. Journal of Metamorphic Geology, 16, 309–344.

pygcc.supcrtaq(TC, P, specieppt, Dielec_method=None, ThermoInUnit='cal', **rhoE)

This function evaluates the Gibbs free energy of aqueous species at T and P using the revised HKF equation of state

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • specieppt (array) – Properties such as (dG [cal/mol], dH [cal/mol], S [cal/mol-K], a1 [10 cal/mol/bar], a2 [*10*-2 cal/mol], a3 [cal-K/mol/bar], a4 [10*-4 cal-K/mol], c1 [cal/mol/K], c2 [10*-4 cal-K/mol], ω [10*-5 cal/mol] )

  • Dielec_method (string) – specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric constant (optional), if not specified default - ‘JN91’

  • ThermoInUnit (string) – specify either ‘cal’ or ‘KJ’ as the input units for species properties (optional), if not specified default - ‘cal’

  • rhoE (dict) – dictionary of water properties like density (rho) and dielectric factor (E) (optional)

Returns:

delG – Gibbs energy [cal/mol]

Return type:

float, vector

Usage

The general usage of supcrtaq without the optional arguments is as follows:

  1. Not on steam saturation curve:

    delG = supcrtaq(TC, P, specieppt)

    where T is temperature in celsius and P is pressure in bar

  2. On steam saturation curve:

    delG = supcrtaq(TC, ‘T’, specieppt),

    where T is temperature in celsius, followed with a quoted char ‘T’

    delG = supcrtaq(P, ‘P’, specieppt),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    delG = supcrtaq(TC, P, specieppt, Dielec_method = ‘FGL97’)

Examples

>>> from pygcc.pygcc_utils import db_reader
>>> ps = db_reader() # utilizes the default direct-access database, speq21
>>> delG = supcrtaq( 100, 50, ps.dbaccessdic['H2S(aq)'], Dielec_method = 'JN91')
    -9221.81721068
>>> delG = supcrtaq( 100, 50, ps.dbaccessdic['H2S(aq)'], Dielec_method = 'FGL97')
    -9221.6542038

References

  1. Johnson JW, Oelkers EH, Helgeson HC. 1992. SUPCRT92: A software package for calculating the standard molal thermodynamic properties of minerals, gases, aqueous species, and reactions from 1 to 5000 bar and 0 to 1000°C. Computers & Geosciences 18(7): 899-947. doi: 10.1016/0098-3004(92)90029-Q

pygcc.Element_counts(formula)

This function calculates the elemental composition of a substance given by its chemical formula It was a modified version of https://github.com/cgohlke/molmass/blob/master/molmass/molmass.py

Parameters:

formula (string) – Chemical formula

Returns:

elements – dictionary of elemental composition and their respective number of atoms

Return type:

dict

Usage:

[elements] = Element_counts(formula)

Examples of valid formulas are “H2O”, “[2H]2O”, “CH3COOH”, “EtOH”, “CuSO4:5H2O”, “(COOH)2”, “AgCuRu4(H)2[CO]12{PPh3}2”, “CGCGAATTCGCG”, and, “MDRGEQGLLK” .

class pygcc.solidsolution_thermo(**kwargs)

Class to calculate Ideal mixing model for solid-solutions, supporting multisite ideal formalism

Parameters:
  • X (float) – End member mineral volume fraction or mole fraction of Mg in clinopyroxene

  • cpx_Ca (float) – number of moles of Ca in clinopyroxene formula unit (=1 for Di, Hed)

  • T (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • dbaccessdic (dict) – dictionary of species from direct-access database, optional, default is speq23

  • solidsolution_type (string) – specify either ‘All’ or ‘plagioclase’ or ‘olivine’ or ‘pyroxene’ or ‘cpx’ or ‘alk-feldspar’ or ‘biotite’ to carry-out all or any solid-solution calculations, default is ‘All’

  • Dielec_method – specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric constant (optional), if not specified default - ‘JN91’

Returns:

  • if ‘All’ is specified for solidsolution_type, each case has the follwowing prefix - AnAb_, FoFa_, EnFe_, cpx_, AlkFed_, Biotite_

  • logK (float, vector) – logarithmic K values

  • Rxn (dict) – The calculated dictionary of reaction thermodynamic properties has the following properties:

    • type: solid-solution mineral type, [-]

    • name: solid-solution name, [K]

    • formula: solid-solution mineral formula, [-]

    • MW: Molecular weight, [g/mol]

    • min: solid-solution mineral properties, [‘formula’, ‘source date’, dG[cal/ml], dH[cal/mol], S[cal/mol-K], V[cm3/mol], a[cal/mol-K], b[10^3 cal/mol/K^2], c[10^-5 cal/mol/K]]

    • spec: list of species, [-]

    • coeff: list of corresponding coefficients of species above, [-]

    • nSpec: Total number of species, [-]

    • V: Molar volume, [cm3/mol]

    • source: Source of thermo data, [kJ/kg·K]

    • elements: list of elements and their total numbers, [-]

Usage

The general usage of water_dielec is as follows:

  1. For water dielectric properties at any Temperature and Pressure:

    ss = solidsolution_thermo(T = T, P = P, X = X, solidsolution_type = ‘All’, Dielec_method = ‘JN91’),

    where T is temperature in celsius and P is pressure in bar

  2. For water dielectric properties at any Temperature and density :

    ss = solidsolution_thermo(T = T, rho = rho, X = X, solidsolution_type = ‘All’, Dielec_method = ‘JN91’),

    where T is temperature in celsius and rho is density in kg/m³

  3. For water dielectric properties at any Temperature and Pressure on steam saturation curve:

    ss = solidsolution_thermo(T = T, P = ‘T’, X = X, solidsolution_type = ‘All’, Dielec_method = ‘JN91’),

    where T is temperature in celsius and P is assigned a quoted character ‘T’ to reflect steam saturation pressure

    ss = solidsolution_thermo(P = P, T = ‘P’, X = X, solidsolution_type = ‘All’, Dielec_method = ‘JN91’),

    where P is pressure in bar and T is assigned a quoted character ‘P’ to reflect steam saturation temperature

Examples

>>> ss = solidsolution_thermo(cpx_Ca = 0.5, X = 0.85, T = 30, P = 50,
                              solidsolution_type = 'All')
>>> ss.AnAb_logK, ss.FoFa_logK, ss.EnFe_logK, ss.cpx_logK, ss.AlkFed_logK,
    ss.Biotite_logK
    21.750590, 26.570902, 10.793372, 20.577152,  3.756792, 32.96363
>>> ss = solidsolution_thermo(cpx_Ca = 1, X = 0.85, T = 50, P = 100,
                              solidsolution_type = 'cpx')
>>> ss.logK
    18.81769186
>>> ss.Rxn
    {'type': 'cpx', 'name': 'Di85Hed15',
     'formula': 'Ca1.00Mg0.85Fe0.15Si2O6', 'MW': 221.2817,
     'min': ['Ca1.00Mg0.85Fe0.15Si2O6', ' R&H95, Stef2001',
             -711392.7391800061, nan, 37.032850185405415, 66.369,
             106.66383843212236, -0.019588551625239002, -16326.4818355,
             -1052.9517208413004, 5.714746653919693e-06],
     'spec': ['H+', 'Ca++', 'Mg++', 'Fe++', 'SiO2(aq)', 'H2O'],
     'coeff': [-4, 1.0, 0.85, 0.15, 2, 2], 'nSpec': 6, 'V': 66.369,
     'source': ' R&H95, Stef2001', 'elements': ['1.0000', 'Ca', '0.8500',
                                                'Mg', '0.1500', 'Fe', '2.0000',
                                                'Si', '6.0000', 'O']}
>>> ss = solidsolution_thermo(X = 0.5, T = 50, P = 100,
                              solidsolution_type = 'plagioclase')
>>> ss.logK
    12.62488394
>>> ss.Rxn
    {'type': 'plag', 'name': 'An50', 'formula': 'Ca0.50Na0.50Al1.50Si2.50O8',
     'MW': 270.215145, 'min': ['Ca0.50Na0.50Al1.50Si2.50O8', ' R&H95,
                               Stef2001', -919965.222804649, nan,
                               47.33081919017781, 100.43, 131.53908221797,
                               -0.022148661567686426, 32265.761759082205,
                               -1316.0836615678777, 7.719885114722753e-06],
     'spec': ['H+', 'Al+++', 'Na+', 'Ca++', 'SiO2(aq)', 'H2O'],
     'coeff': [-6.0, 1.5, 0.5, 0.5, 2.5, 3.0], 'nSpec': 6, 'V': 100.43,
     'source': ' R&H95, Stef2001', 'elements': ['0.5000', 'Ca', '0.5000',
                                                'Na', '1.5000', 'Al', '2.5000',
                                                'Si', '8.0000', 'O']}
kwargs
__calc__(**kwargs)
__checker__(**kwargs)
calclogKAnAb(XAn, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of Plagioclase minerals

Parameters:
  • XAn (volume fraction of Anorthite)

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logKplag (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKAnAb without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKAnAb(XAn, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKAnAb(XAn, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKAnAb(XAn, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKAnAb(XAn, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

calclogKFoFa(XFo, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of olivine minerals

Parameters:
  • XFo (volume fraction of Forsterite)

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logK_ol (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKFoFa without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKFoFa(XFo, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKFoFa(XFo, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKFoFa(XFo, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKFoFa(XFo, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

calclogKEnFe(XEn, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of pyroxene minerals

Parameters:
  • XEn (volume fraction of Enstatite)

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logK_opx (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKEnFe without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKEnFe(XEn, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKEnFe(XEn, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKEnFe(XEn, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKEnFe(XEn, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

calclogKDiHedEnFe(nCa, XMg, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of clinopyroxene minerals (Di, Hed, En and Fe)

Parameters:
  • nCa (number of moles of Ca in formula unit (=1 for Di, Hed)) – and must be greater than zero

  • XMg (mole fraction of Mg) – XMg = (nMg/(nFe + nMg))

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logK_cpx (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKDiHedEnFe without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKDiHedEnFe(nCa, XMg, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKDiHedEnFe(nCa, XMg, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKDiHedEnFe(nCa, XMg, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKDiHedEnFe(nCa, XMg, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

calclogKAbOr(XAb, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of Alkaline-Feldspar minerals

Parameters:
  • XAb (volume fraction of Albite)

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logKalkfeld (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKAnAb without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKAbOr(XAb, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKAbOr(XAb, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKAbOr(XAb, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKAbOr(XAb, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

calclogKBiotite(XPh, TC, P, dbaccessdic, rhoEG, Dielec_method=None)

This function calculates thermodynamic properties of solid solution of Biotite minerals

Parameters:
  • XAb (volume fraction of Albite)

  • TC (temperature [°C])

  • P (pressure [bar])

  • dbaccessdic (dictionary of species from direct-access database)

  • Dielec_method (specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate) – dielectric constant (optional), if not specified default - ‘JN91’

  • rhoEG (dictionary of water properties like density (rho),) – dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logKalkfeld (logarithmic K values)

  • Rxn (dictionary of reaction thermodynamic properties)

Usage

The general usage of calclogKAnAb without the optional argument is as follows:

  1. Not on steam saturation curve:

    [logK, Rxn] = calclogKAbOr(XAb, TC, P, dbaccessdic),

    where T is temperature in celsius and P is pressure in bar;

  2. On steam saturation curve:

    [logK, Rxn] = calclogKAbOr(XAb, TC, ‘T’, dbaccessdic),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKAbOr(XAb, P, ‘P’, dbaccessdic),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKAbOr(XAb, TC, P, dbaccessdic, Dielec_method = ‘FGL97’)

pygcc.calclogKclays(TC, P, *elem, dbaccessdic=None, group=None, cation_order=None, export_struct_formula=None, Dielec_method=None, ClayMintype=None, Int_Mg_fract=None, Int_Li_fract=None, heatcap_approx=None, ThermoInUnit='cal', **rhoEG)

This function calculates logK values and reaction parameters of clay reactions using below references:

Parameters:
  • TC (float, vector) – Temperature [°C]

  • P (float, vector) – Pressure [bar]

  • elem (list) – list containing nine or ten parameters with clay names and elements compositions with the following format [‘Montmorillonite_Lc_MgK’, ‘Si’, ‘Al’, ‘FeIII’, ‘FeII’, ‘Mg’, ‘K’, ‘Na’, ‘Ca’, ‘Li’, ‘H3O’]

  • dbacessdic (dict) – dictionary of species from direct-access database, optional, default is speq23

  • group (string) – specify the structural layering of the phyllosilicate, for layers composed of 1 tetrahedral + 1 octahedral sheet (1:1 layer) - specify ‘7A’, 2 tetrahedral + 1 octahedral sheet (2:1 layer) - specify ‘10A’, or the latter with a brucitic sheet in the interlayer (2:1:1 layer) - specify ‘14A’ (optional), if not specified, default is based on charge balance on the cations and anions

  • cation_order (string) – specify ordering of Si and Al ions either ‘Eastonite’, ‘Ordered’, ‘Random’, or ‘HDC’ (optional), if not specified, default is based on guidelines by Vinograd (1995)

  • Dielec_method (string) – specify either ‘FGL97’ or ‘JN91’ or ‘DEW’ as the method to calculate dielectric constant (optional), if not specified, default - ‘JN91’

  • ClayMintype (string) – specify either ‘Smectite’ or ‘Chlorite’ or ‘Mica’ as the clay type, if not specified default - ‘Smectites’

  • Int_Mg_fract (string) – specify the fraction of Mg to partition into Interlayer sheet and the remainder will be partitioned into Octahedral sheet, if not specified, default is 1

  • Int_Li_fract (string) – specify the fraction of Li to partition into Interlayer sheet and the remainder will be partitioned into Octahedral sheet, if not specified, default is 1

  • heatcap_approx (string) – specify either ‘Maier-Kelley’ or ‘constant’ as the approximation method for clay minerals’ specific heat capacity calculation, default is ‘constant’, based on ClayTherm’s definition for specific cations (Octahedral sites: Li+, Mn2+, Cr3+, Ni2+, Co2+, Zn2+; Interlayer sites: Cs+, Rb+, Li+, Ba2+, Sr2+, Mg2+, Cu2+, Co2+, Zn2+, H3O+)

  • ThermoInUnit (string) – specify either ‘cal’ or ‘KJ’ as the input units for species properties (optional), particularly used to covert KJ data to cal by supcrtaq function if not specified default - ‘cal’

  • rhoEG (dict) – dictionary of water properties like density (rho), dielectric factor (E) and Gibbs Energy (optional)

Returns:

  • logK_clay (float, vector) – logarithmic K values

  • Rxn (dict) – dictionary of reaction thermodynamic properties

Usage

The general usage of calclogKclays is as follows:

  1. Without the optional arguments, not on steam saturation curve:

    [logK, Rxn] = calclogKclays(TC, P, *elem),

    where T is temperature in celsius and P is pressure in bar;

  2. Without the optional arguments, on steam saturation curve:

    [logK, Rxn] = calclogKclays(TC, ‘T’, *elem),

    where T is temperature in celsius, followed with a quoted char ‘T’

    [logK, Rxn] = calclogKclays(P, ‘P’, *elem),

    where P is pressure in bar, followed with a quoted char ‘P’.

  3. Meanwhile, usage with any specific dielectric constant method (‘FGL97’) for condition not on steam saturation curve is as follows. Default method is ‘JN91’

    [logK, Rxn] = calclogKclays(TC, P, *elem, dbacessdic = dbacessdic, group = ‘10A’, cation_order = ‘HDC’, Dielec_method = ‘FGL97’)

Examples

>>> logK, Rxn = calclogKclays(50, 'T', *['Clinochlore', '3', '2', '0', '0',
                                         '5', '0', '0', '0', '0', '0'],
                              group = '14A')
>>> logK
    57.29239957

References

  1. Blanc, P., Vieillard, P., Gailhanou, H., Gaboreau, S., Gaucher, É., Fialips, C. I., Madé, B & Giffaut, E. (2015). A generalized model for predicting the thermodynamic properties of clay minerals. American journal of science, 315(8), 734-780.

  2. Blanc, P., Gherardi, F., Vieillard, P., Marty, N. C. M., Gailhanou, H., Gaboreau, S., Letat, B., Geloni, C., Gaucher, E.C. and Madé, B. (2021). Thermodynamics for clay minerals: calculation tools and application to the case of illite/smectite interstratified minerals. Applied Geochemistry, 104986.

  3. Vinograd, V.L., 1995. Substitution of [4]Al in layer silicates: Calculation of the Al-Si configurational entropy according to 29Si NMR Spectra. Physics and Chemistry of Minerals 22, 87-98. ( saponite-H-Li Li0.165H0.165)(Mg3)(Si3.67Al0.33)O10(OH)2 saponite-Mg-Li(VI) (Mg0.17)(Li0.33Mg2.835)(Si3.66Al0.34)O10(OH)2 [‘Name’, ‘Si’, ‘Al’, ‘FeIII’, ‘FeII’, ‘Mg’, ‘K’, ‘Na’, ‘Ca’, ‘Li’, ‘H3O’]

pygcc.MW