pygcc ===== .. py:module:: pygcc .. autoapi-nested-parse:: Init file Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pygcc/clay_thermocalc/index /autoapi/pygcc/pygcc_utils/index /autoapi/pygcc/read_db/index /autoapi/pygcc/solid_solution/index /autoapi/pygcc/species_eos/index /autoapi/pygcc/water_eos/index Attributes ---------- .. autoapisummary:: pygcc.eps pygcc.J_to_cal pygcc.IAPWS95_COEFFS pygcc.MW Classes ------- .. autoapisummary:: pygcc.db_reader pygcc.iapws95 pygcc.ZhangDuan pygcc.water_dielec pygcc.Driesner_NaCl pygcc.Dummy pygcc.heatcap pygcc.solidsolution_thermo pygcc.calcRxnlogK pygcc.write_database pygcc.db_reader pygcc.iapws95 pygcc.ZhangDuan pygcc.water_dielec pygcc.Driesner_NaCl pygcc.heatcap pygcc.solidsolution_thermo Functions --------- .. autoapisummary:: pygcc.dbaccess_modify pygcc.readIAPWS95data pygcc.convert_temperature pygcc.concentration_converter pygcc.supcrtaq pygcc.calclogKclays pygcc.calc_elem_count_molewt pygcc.importconfile pygcc.var_name pygcc.feval pygcc.roundup_tenth pygcc.roundup_hundredth pygcc.read_specific_lines pygcc.denormalize_phreeqc_species_charge pygcc.normalize_species_charges pygcc.normalize_phreeqc_species_charge pygcc.contains_missing_species pygcc.build_side_regex pygcc.derivative pygcc.info pygcc.drummondgamma pygcc.Henry_duan_sun pygcc.co2fugacity pygcc.gamma_correlation pygcc.Helgeson_activity pygcc.aw_correlation pygcc.outputfmt pygcc.main_function_name pygcc.dbaccess_modify pygcc.readIAPWS95data pygcc.convert_temperature pygcc.concentration_converter pygcc.supcrtaq pygcc.Element_counts pygcc.calclogKclays Package Contents ---------------- .. py:class:: db_reader(**kwargs) Class to read direct-access and source thermodynamic database :param dbaccess: path of the direct-access/sequential-access database, optional, default is speq21 :type dbaccess: string :param dbBerman_dir: path of the Berman mineral database, optional :type dbBerman_dir: string :param dbHP_dir: path of the supcrtbl mineral and gas database, optional :type dbHP_dir: string :param sourcedb: path of the source database, optional :type sourcedb: string :param sourceformat: specify the source database format, either 'GWB', 'EQ36' or 'PHREEQC', optional :type sourceformat: string :param dbaccessformat: specify the direct-access/sequential-access database format, either 'speq' or 'supcrtbl', default is 'speq' :type dbaccessformat: string, optional :param sourcedb_codecs: specify the name of the encoding used to decode or encode the sourcedb file, optional :type sourcedb_codecs: string :param dbaccess_codecs: specify the name of the encoding used to decode or encode the dbaccess file, optional :type dbaccess_codecs: string :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 .. rubric:: Examples >>> ps = db_reader(sourcedb = './default_db/thermo.com.dat', sourceformat = 'gwb', dbaccess = './default_db/speq23.dat') >>> ps.sourcedic, ps.dbaccessdic, ps.specielist .. py:attribute:: kwargs .. py:attribute:: Rd .. py:attribute:: d .. py:method:: __calc__(**kwargs) .. py:method:: 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 [-]) :param dbaccess filename and location of the direct-access database: :param dbBerman_dir filename and location of the Berman mineral database: :param dbHP_dir filename and location of the supcrtbl (Holland and Powell) mineral and gas database: :returns: * *dbaccessdic dictionary of minerals, gases, redox and aqueous species* * *dbaccess dat file name* Usage: ---------- [dbaccessdic, dbname] = readAqspecdb(dbaccess) .. py:method:: 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() .. py:method:: 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) .. py:method:: 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() .. py:function:: 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 :rtype: Output the newly modified direct-access with filename described in 'out_filename' if specified. .. rubric:: Examples >>> dbaccess_modify(in_filename = 'geotpd_data_block_cr.csv') .. py:class:: iapws95(**kwargs) Implementation of IAPWS Formulation 1995 for ordinary water substance, revised release of 2016 .. rubric:: Notes Temperature and Pressure input limits * -22 ≤ TC ≤ 1000 and 0 ≤ P ≤ 100,000 :param T: Temperature [°C] :type T: float, vector :param P: Pressure [bar] :type P: float, vector :param rho: Density [kg/m³] :type rho: float, vector :param rho0: Starting estimate of density [kg/m³] :type rho0: float, vector :param rhom: Molar density [kg/m³] :type rhom: float, vector :param delta: Reduced density, rho/rhoc :type delta: float, vector :param tau: Reduced temperature, Tc/T :type tau: float, vector :param v: Specific volume [m³/kg] :type v: float, vector :param vm: Specific molar volume [m³/mol] :type vm: float, vector :param Out_Unit: Expected units ('standard' or 'kilogram') :type Out_Unit: string :param FullEOSppt: Option to output all or essential water properties [False or True] :type FullEOSppt: bool :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 .. rubric:: 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 .. rubric:: 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 .. py:attribute:: kwargs .. py:attribute:: mwH2O :value: 18.015268 .. py:method:: __checker__(**kwargs) .. py:method:: __calc__(**kwargs) .. py:class:: ZhangDuan(**kwargs) Implementation of Zhang & Duan model Formulation for water at higher Temperature and Pressure conditions, i.e, Deep Earth Water - DEW .. rubric:: Notes Temperature and Pressure input limits * 0 ≤ TC ≤ 1726.85 and 1000 ≤ P ≤ 300,000 :param T: Temperature [°C] :type T: float, vector :param P: Pressure [bar] :type P: float, vector :param rho: Density [kg/m³] :type rho: float, vector :param rho0: Starting estimate of density [kg/m³] :type rho0: float, vector :param densityEquation: specify either 'ZD05' to use Zhang & Duan (2005) or 'ZD09' to use Zhang & Duan (2009) :type densityEquation: string :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³ .. rubric:: 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 .. rubric:: 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 .. py:attribute:: kwargs .. py:method:: __calc__(**kwargs) .. py:method:: ZD_Pressure_drhodP(TC, rhohat, method=None) .. py:method:: ZD_Density(TC, P, method='ZD05', error=None) .. py:method:: GibbsEnergy(TC, P, method='VolumeIntegral') .. py:class:: 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 :param T: Temperature [°C] :type T: float, vector :param P: Pressure [bar] :type P: float, vector :param rho: Density [kg/m³] :type rho: float, vector :param Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate dielectric constant (optional), if not specified, default - 'JN91' :type Dielec_method: string :param Dielec_DEWoutrange: specify either 'FGL97' or 'JN91' as the method to calculate dielectric constant for out of range for 'DEW' method if any :type Dielec_DEWoutrange: string :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 .. rubric:: 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 .. rubric:: 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 .. rubric:: 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 .. py:attribute:: kwargs .. py:method:: __checker__(**kwargs) .. py:method:: __calc__(**kwargs) .. py:method:: 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 .. rubric:: Notes Temperature and Pressure input limits: * -35 ≤ TC ≤ 600 and 0 ≤ P ≤ 12000 :param TC: :type TC: temperature [°C] :param rho: :type 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) .. rubric:: 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. .. py:method:: 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 .. rubric:: Notes Temperature and Pressure input limits: * 0 ≤ TC ≤ 1000 and 0 ≤ P ≤ 5000 :param TC: :type TC: temperature [°C] :param rho: :type 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_JN91( TC, rho) .. rubric:: 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. .. py:method:: 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. .. rubric:: Notes Temperature and Pressure input limits: * 100 ≤ TC ≤ 1200 and 1000 ≤ P ≤ 60000 :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] 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_DEW() .. rubric:: 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. .. py:function:: readIAPWS95data() returns all constants and coefficients needed for the IAPWS95 formulation, packed into a dictionary .. py:function:: convert_temperature(T, Out_Unit='C') This function converts temperatures from Celsius to Kelvin and vice-versa :param T: Temperature in °C or K :type T: float, vector :param Out_Unit: Expected temperature unit (C or K) :type Out_Unit: string :returns: **T** -- Temperature in °C or K :rtype: float, vector .. rubric:: Examples >>> TC = 100; convert_temperature( TC, Out_Unit = 'K' ) 373.15 >>> TK = 520; convert_temperature( TK, Out_Unit = 'C' ) 246.85 .. py:class:: Driesner_NaCl(**kwargs) Implementation of Driesner and Heinrich PTx Formulation for H2O-NaCl system :param T: Temperature [°C] :type T: float :param P: Pressure [bar] :type P: float :param xNaCl: mole fraction of NaCl in H2O [-] :type xNaCl: float :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 .. rubric:: 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) .. rubric:: 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. .. py:attribute:: kwargs .. py:method:: __calc__(**kwargs) .. py:method:: Driesner_NaCl(T, P) .. py:method:: Driesner_NaClII(T, P, xNaCl) .. py:method:: enthalpy_mu_heatcap(T, P, xNaCl) Enthalpy in J/g, viscosity in Pas and Cp in Joules per kilogram Kelvin .. py:function:: 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 :param val: Values to convert :type val: float :param In_Unit: unit of input concentration :type In_Unit: String :param Out_Unit: expected output concentration :type Out_Unit: String :returns: **Out** -- Converted values :rtype: float .. py:class:: Dummy Bases: :py:obj:`object` Class of functions to evaluate the IAPWS95 equation of state for calculating thermodynamic properties of water. .. py:attribute:: vEOSIAPWS95 .. py:attribute:: vauxMeltingTemp .. py:attribute:: vapxsatpropT .. py:attribute:: vapxsatpropP .. py:attribute:: vcalcsatpropT .. py:attribute:: vcalcsatpropP .. py:attribute:: vwaterviscosity .. py:method:: 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. :param TK: :type TK: temperature [K] :param rho: :type rho: density [kg/m3] :param FullEOSppt: :type 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) .. py:method:: 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. :param P: :type P: pressure [bar] :param TK: :type TK: temperature [K] :returns: **Pmelt** :rtype: melting pressure [bar] Usage ---------- [Pmelt] = auxMeltingPressure( TK, P) .. py:method:: 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** :rtype: temperature [K] Usage ---------- [Tmelt] = auxMeltingTemp( P) .. py:method:: 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. :param TC temperature [°C]: :param P pressure [bar]: :param rho density [kg/m3]: :rtype: visc viscosity [Pa.s] Usage ---------- [visc] = waterviscosity( TC, P, rho) .. py:method:: 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) .. py:method:: 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) .. py:method:: 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. :param TK temperature [K]: :returns: * *Psat saturation pressure [bar]* * *rhosl density of liquid [kg/m3]* * *rhosv density of vapor [kg/m3]* Usage ---------- [Psat, rhosl, rhosv] = calcsatpropT( TK) .. py:method:: 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. :param P pressure [bar]: :returns: * *Tsat temperature [K]* * *rhosl liquid density [kg/m3]* * *rhosv vapor density [kg/m3]* Usage ---------- [Tsat, rhosl, rhosv] = calcsatpropP( P) .. py:method:: 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) .. py:method:: 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), .. py:method:: 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), .. py:method:: 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') .. py:class:: heatcap(**kwargs) Class to heat capacity for mineral and gases using Maier-Kelley powerlaw, Haas-Fisher powerlaw, Holland and Powell and Berman's function :param T: Temperature [°C] :type T: float, vector :param P: Pressure [bar] :type P: float, vector :param Species_ppt: 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 :type Species_ppt: array :param Species: species name, optional for all cases except gases, Coesite and Quartz :type Species: string :param method: specify either 'SUPCRT' or 'berman88' or 'HP11' or 'HF76' to carry-out any mineral or gas heat capacity calculations, default is 'SUPCRT' :type method: string :returns: * **dG** (*float, vector*) -- Gibbs Energy [cal/mol] * **dCp** (*float, vector*) -- Heat capacity [cal/mol/K] .. rubric:: 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 .. rubric:: 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 .. py:attribute:: kwargs .. py:attribute:: TC :value: None .. py:attribute:: P :value: None .. py:attribute:: Species_ppt :value: None .. py:attribute:: method :value: None .. py:attribute:: Species :value: None .. py:method:: __calc__(**kwargs) .. py:method:: 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) :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param species: 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] ) :type species: array :returns: * **delGfPT** (*float, vector*) -- Gibbs Energy [cal/mol] * **delCp** (*float, vector*) -- Heat capacity [cal/mol/K] .. rubric:: References (1) Haas JL Jr, Fisher JR (1976) Simultaneous evaluation and correlation of thermodynamic data. American Journal of Science 276:525-545 .. py:method:: 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 :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param species: 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]] :type species: array :returns: * **delGfPT** (*float, vector*) -- Gibbs Energy [cal/mol] * **delCp** (*float, vector*) -- Heat capacity [cal/mol/K] .. rubric:: 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 .. py:method:: 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 :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param species: 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 :type species: array :param spec_name: species name, optional for all cases except gases, Coesite and Quartz :type spec_name: string :returns: * **delGfPT** (*float, vector*) -- Gibbs Energy [cal/mol] * **delCp** (*float, vector*) -- Heat capacity [cal/mol/K] .. rubric:: 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 .. py:method:: 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 :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param species: 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 [-]] :type species: array :returns: * **delGfPT** (*float, vector*) -- Gibbs Energy [cal/mol] * **delCp** (*float, vector*) -- Heat capacity [cal/mol/K] .. rubric:: 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. .. py:function:: 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 :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param specieppt: 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] ) :type specieppt: array :param Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: string :param ThermoInUnit: specify either 'cal' or 'KJ' as the input units for species properties (optional), if not specified default - 'cal' :type ThermoInUnit: string :param rhoE: dictionary of water properties like density (rho) and dielectric factor (E) (optional) :type rhoE: dict :returns: **delG** -- Gibbs energy [cal/mol] :rtype: 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') .. rubric:: 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 .. rubric:: 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 .. py:class:: solidsolution_thermo(**kwargs) Class to calculate Ideal mixing model for solid-solutions, supporting multisite ideal formalism :param X: End member mineral volume fraction or mole fraction of Mg in clinopyroxene :type X: float :param cpx_Ca: number of moles of Ca in clinopyroxene formula unit (=1 for Di, Hed) :type cpx_Ca: float :param T: Temperature [°C] :type T: float, vector :param P: Pressure [bar] :type P: float, vector :param dbaccessdic: dictionary of species from direct-access database, optional, default is speq23 :type dbaccessdic: dict :param solidsolution_type: 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' :type solidsolution_type: string :param Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: string 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' rhoEG : dict dictionary of water properties like density (rho), dielectric factor (E) and Gibbs Energy (optional) :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 .. rubric:: 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']} .. py:attribute:: kwargs .. py:method:: __calc__(**kwargs) .. py:method:: __checker__(**kwargs) .. py:method:: calclogKAnAb(XAn, TC, P, dbaccessdic, rhoEG, Dielec_method=None) This function calculates thermodynamic properties of solid solution of Plagioclase minerals :param XAn: :type XAn: volume fraction of Anorthite :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: calclogKFoFa(XFo, TC, P, dbaccessdic, rhoEG, Dielec_method=None) This function calculates thermodynamic properties of solid solution of olivine minerals :param XFo: :type XFo: volume fraction of Forsterite :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: calclogKEnFe(XEn, TC, P, dbaccessdic, rhoEG, Dielec_method=None) This function calculates thermodynamic properties of solid solution of pyroxene minerals :param XEn: :type XEn: volume fraction of Enstatite :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: 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) :param nCa: and must be greater than zero :type nCa: number of moles of Ca in formula unit (=1 for Di, Hed) :param XMg: XMg = (nMg/(nFe + nMg)) :type XMg: mole fraction of Mg :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: calclogKAbOr(XAb, TC, P, dbaccessdic, rhoEG, Dielec_method=None) This function calculates thermodynamic properties of solid solution of Alkaline-Feldspar minerals :param XAb: :type XAb: volume fraction of Albite :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: calclogKBiotite(XPh, TC, P, dbaccessdic, rhoEG, Dielec_method=None) This function calculates thermodynamic properties of solid solution of Biotite minerals :param XAb: :type XAb: volume fraction of Albite :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:function:: 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: :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param elem: 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'] :type elem: list :param dbacessdic: dictionary of species from direct-access database, optional, default is speq23 :type dbacessdic: dict :param group: 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 :type group: string :param cation_order: 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) :type cation_order: string :param Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate dielectric constant (optional), if not specified, default - 'JN91' :type Dielec_method: string :param ClayMintype: specify either 'Smectite' or 'Chlorite' or 'Mica' as the clay type, if not specified default - 'Smectites' :type ClayMintype: string :param Int_Mg_fract: 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 :type Int_Mg_fract: string :param Int_Li_fract: 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 :type Int_Li_fract: string :param heatcap_approx: 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+) :type heatcap_approx: 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 rhoEG: dictionary of water properties like density (rho), dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dict :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') .. rubric:: Examples >>> logK, Rxn = calclogKclays(50, 'T', *['Clinochlore', '3', '2', '0', '0', '5', '0', '0', '0', '0', '0'], group = '14A') >>> logK 57.29239957 .. rubric:: 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'] .. py:data:: eps :value: 2.220446049250313e-16 .. py:data:: J_to_cal :value: 4.184 .. py:data:: IAPWS95_COEFFS .. py:function:: 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 :param formula: chemical formula :type formula: string :param Elementdic: dictionary, containing the atomic mass of element database :type Elementdic: dict :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" . .. rubric:: Examples >>> elements, molewt = calc_elem_count_molewt("CuSO4:5H2O") >>> elements, molewt {'O': 9.0, 'H': 10.0, 'S': 1, 'Cu': 1}, 249.6773 .. py:function:: 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); .. py:function:: var_name(var) .. py:function:: feval(funcName, *args) .. py:function:: roundup_tenth(x) .. py:function:: roundup_hundredth(x) .. py:function:: read_specific_lines(file, lines_to_read) .. py:function:: 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' .. py:function:: normalize_species_charges(species) .. py:function:: 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)' .. py:function:: contains_missing_species(line, missing_spx) .. py:function:: 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- .. py:function:: 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 :rtype: float .. py:function:: info(name, dic) This function checks for naming convention of the species in the direct-access or source database :param name: species name :type name: string :param dic: dictionary of species from direct-access or source database :type dic: dict :returns: **lst** -- resulting search of all species with the input name :rtype: list .. rubric:: 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'] .. py:function:: drummondgamma(TK, I) This function models solubility of CO2 gas in brine using Drummond equation :param TK: Temperature [K] :type TK: float, vector :param I: Ionic strength :type I: float, vector Returns ---------- log10_gamma : float, vector co2 aqueous activity coefficients in log10 .. rubric:: Examples >>> log10_gamma = drummondgamma( 500, 0.5) >>> log10_gamma 0.0781512920184902 .. py:function:: Henry_duan_sun(TK, P, I) This function evaluates the solubility of CO2 gase in brine using Duan_Sun Formulation :param TK: Temperature [K] :type TK: float, vector :param P: Pressure [bar] :type P: float, vector :param I: Ionic strength :type I: float :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) .. rubric:: Examples >>> log10_co2_gamma, mco2 = Henry_duan_sun( 500, 250, 0.5) >>> log10_co2_gamma, mco2 0.06202532, 1.6062557 .. rubric:: 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. .. py:function:: 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) .. rubric:: 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]) .. py:function:: gamma_correlation(TC, P, method=None) This function calculates the CO2 activity correlation coefficients at given temperature T and pressure P :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param method: specify the activity model [``'Duan_Sun'`` or ``'Drummond'``] :type method: string Returns ---------- cco2 : float, vector co2 correlation coefficients Usage ---------- cco2 = gamma_correlation( TC, P) .. rubric:: Examples >>> log10_co2_gamma, mco2 = Henry_duan_sun( 500, 250, 0.5) >>> log10_co2_gamma, mco2 0.06202532, 1.6062557 .. rubric:: 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) .. py:function:: 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' rhoEDB : dictionary 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) .. py:function:: 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' rhoEDB : dictionary 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) .. py:class:: calcRxnlogK(**kwargs) This class implemetation calculates logK values for any reaction with the option for extrapolation where rho < 350kg/m3 :param T: Temperature [°C] :type T: float, vector :param P: Pressure [bar] :type P: float, vector :param Specie: 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' :type Specie: string :param Specie_class: specify the class of species like 'aqueous', 'minerals', 'liquids', or 'gases' :type Specie_class: string, optional :param elem: 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'] :type elem: list :param dbaccessdic: direct-acess database dictionary :type dbaccessdic: dict :param rhoEGextrap: dictionary of water properties like density (rho), dielectric factor (E) and Gibbs Energy for density region 350-550kg/m3 :type rhoEGextrap: dict :param group: 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 :type group: string :param ClayMintype: specify either 'Smectite' or 'Chlorite' or 'Mica' as the clay type, if not specified default - 'Smectites' :type ClayMintype: string :param X: volume fractions of any (Anorthite, Albite, Forsterite, Enstatite) or mole fraction of Mg :type X: float :param cpx_Ca: number of moles of Ca in formula unit (=1 for Di, Hed), must be greater than zero :type cpx_Ca: float :param sourcedic: source database reactions dictionary :type sourcedic: dict :param specielist: source database species grouped into categories [element, basis, redox, aqueous, minerals, gases, oxides] :type specielist: list of list, optional :param Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate dielectric constant, default is 'JN91' :type Dielec_method: string :param heatcap_method: specify either 'SUPCRT' or 'Berman88' or 'HP11' or 'HF76' as the method to calculate thermodynamic properties of any mineral or gas, default is 'SUPCRT' :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 Al_Si: 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' :type Al_Si: string :param Int_Mg_fract: 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 :type Int_Mg_fract: string :param Int_Li_fract: 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 :type Int_Li_fract: string :param heatcap_approx: 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+) :type heatcap_approx: string :param sourceformat: specify the source database format, either 'GWB', 'EQ36' or 'PHREEQC' :type sourceformat: string :param densityextrap: specify the extrapolation option for density-logK, 'Yes'/True or 'No'/False :type densityextrap: float, vector :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 .. rubric:: 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 .. py:attribute:: kwargs .. py:method:: __calc__(**kwargs) .. py:method:: AllRxnslogK(TC, P, rhoEG) This function calculates logK values of all reactions including solid-solution and clay minerals :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: RxnlogK(TC, P, Prod, rhoEG) This function calculates logK values of any reaction :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param Prod: :type Prod: Product species of the reaction :param dbaccessdic: :type dbaccessdic: direct-acess database dictionary :param sourcedic: :type sourcedic: source database reactions dictionary :param specielist: [element, basis, redox, aqueous, minerals, gases, oxides] :type specielist: source database species grouped into :param Dielec_method: to calculate dielectric constant, default is 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method :param sourceformat: :type sourceformat: source database format, either 'GWB' or 'EQ36', default is 'GWB' :param heatcap_method: of any mineral, default is 'SUPCRT' :type heatcap_method: specify either 'SUPCRT' or 'Berman88' or 'HP11' or 'HF76' as the method to calculate thermodynamic properties :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: densitylogKextrap(TC, P, rhoEGextrap) This function calculates logK values extrapolation for conditions where rho < 350kg/m3 :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param rhoEGextrap: Gibbs Energy for density region 350-550kg/m3 :type rhoEGextrap: dictionary of water properties like density (rho), dielectric factor (E) and :returns: **logK** :rtype: extrapolated logarithmic K value(s) Usage ------- [logK] = densitylogKextrap(TC, P, 'H2S(aq)', dbaccessdic = dbaccessdic, sourcedic = sourcedic, specielist = specielist), .. py:function:: 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 :param fid: file ID :type fid: string :param logK: logarithmic K value(s) :type logK: float, vector :param Rxn: dictionary of reaction thermodynamic properties :type Rxn: dict :param T: Temperature value(s), optional, required when 'polycoeffs' is specified for logK_form :type T: float, vector :param dataset: specify the dataset format, either 'GWB', 'EQ36', 'PHREEQC', 'Pflotran' or 'ToughReact' :type dataset: string :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' (optional) :type logK_form: string :rtype: Output data to the file with filename described in fid with any format mentioned above. .. rubric:: 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() .. py:class:: 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 :rtype: 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: (4) 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 .. rubric:: 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 .. py:attribute:: kwargs .. py:attribute:: T :value: None .. py:attribute:: P :value: None .. py:attribute:: dbaccessformat .. py:attribute:: dbBerman_dir .. py:attribute:: dbHP_dir .. py:attribute:: dataset .. py:attribute:: objdb .. py:attribute:: co2actmodel .. py:attribute:: ThermoInUnit .. py:attribute:: sourcedb_codecs .. py:attribute:: Dielec_method .. py:attribute:: cpx_Ca .. py:attribute:: logK_form .. py:attribute:: heatcap_method .. py:attribute:: dbaccess .. py:attribute:: sourceformat .. py:method:: __calc__(**kwargs) .. py:method:: _resolve_sourcedb(sourceformat, sourcedb) Resolve default source database based on format and user input. .. py:method:: _flag_to_yesno(value, default='No') Convert boolean/None/custom flag to Yes/No string. .. py:method:: _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. .. py:method:: _expand_temperature(T) Expand temperature input into proper array. .. py:method:: _build_message() Construct final success message. .. py:method:: 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 :rtype: 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 .. py:method:: 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 :rtype: 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 .. py:method:: 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 :rtype: 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 .. py:method:: 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 :rtype: 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 .. py:method:: 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 :rtype: 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 .. py:function:: 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. .. py:class:: db_reader(**kwargs) Class to read direct-access and source thermodynamic database :param dbaccess: path of the direct-access/sequential-access database, optional, default is speq21 :type dbaccess: string :param dbBerman_dir: path of the Berman mineral database, optional :type dbBerman_dir: string :param dbHP_dir: path of the supcrtbl mineral and gas database, optional :type dbHP_dir: string :param sourcedb: path of the source database, optional :type sourcedb: string :param sourceformat: specify the source database format, either 'GWB', 'EQ36' or 'PHREEQC', optional :type sourceformat: string :param dbaccessformat: specify the direct-access/sequential-access database format, either 'speq' or 'supcrtbl', default is 'speq' :type dbaccessformat: string, optional :param sourcedb_codecs: specify the name of the encoding used to decode or encode the sourcedb file, optional :type sourcedb_codecs: string :param dbaccess_codecs: specify the name of the encoding used to decode or encode the dbaccess file, optional :type dbaccess_codecs: string :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 .. rubric:: Examples >>> ps = db_reader(sourcedb = './default_db/thermo.com.dat', sourceformat = 'gwb', dbaccess = './default_db/speq23.dat') >>> ps.sourcedic, ps.dbaccessdic, ps.specielist .. py:attribute:: kwargs .. py:attribute:: Rd .. py:attribute:: d .. py:method:: __calc__(**kwargs) .. py:method:: 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 [-]) :param dbaccess filename and location of the direct-access database: :param dbBerman_dir filename and location of the Berman mineral database: :param dbHP_dir filename and location of the supcrtbl (Holland and Powell) mineral and gas database: :returns: * *dbaccessdic dictionary of minerals, gases, redox and aqueous species* * *dbaccess dat file name* Usage: ---------- [dbaccessdic, dbname] = readAqspecdb(dbaccess) .. py:method:: 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() .. py:method:: 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) .. py:method:: 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() .. py:function:: 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 :rtype: Output the newly modified direct-access with filename described in 'out_filename' if specified. .. rubric:: Examples >>> dbaccess_modify(in_filename = 'geotpd_data_block_cr.csv') .. py:class:: iapws95(**kwargs) Implementation of IAPWS Formulation 1995 for ordinary water substance, revised release of 2016 .. rubric:: Notes Temperature and Pressure input limits * -22 ≤ TC ≤ 1000 and 0 ≤ P ≤ 100,000 :param T: Temperature [°C] :type T: float, vector :param P: Pressure [bar] :type P: float, vector :param rho: Density [kg/m³] :type rho: float, vector :param rho0: Starting estimate of density [kg/m³] :type rho0: float, vector :param rhom: Molar density [kg/m³] :type rhom: float, vector :param delta: Reduced density, rho/rhoc :type delta: float, vector :param tau: Reduced temperature, Tc/T :type tau: float, vector :param v: Specific volume [m³/kg] :type v: float, vector :param vm: Specific molar volume [m³/mol] :type vm: float, vector :param Out_Unit: Expected units ('standard' or 'kilogram') :type Out_Unit: string :param FullEOSppt: Option to output all or essential water properties [False or True] :type FullEOSppt: bool :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 .. rubric:: 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 .. rubric:: 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 .. py:attribute:: kwargs .. py:attribute:: mwH2O :value: 18.015268 .. py:method:: __checker__(**kwargs) .. py:method:: __calc__(**kwargs) .. py:class:: ZhangDuan(**kwargs) Implementation of Zhang & Duan model Formulation for water at higher Temperature and Pressure conditions, i.e, Deep Earth Water - DEW .. rubric:: Notes Temperature and Pressure input limits * 0 ≤ TC ≤ 1726.85 and 1000 ≤ P ≤ 300,000 :param T: Temperature [°C] :type T: float, vector :param P: Pressure [bar] :type P: float, vector :param rho: Density [kg/m³] :type rho: float, vector :param rho0: Starting estimate of density [kg/m³] :type rho0: float, vector :param densityEquation: specify either 'ZD05' to use Zhang & Duan (2005) or 'ZD09' to use Zhang & Duan (2009) :type densityEquation: string :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³ .. rubric:: 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 .. rubric:: 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 .. py:attribute:: kwargs .. py:method:: __calc__(**kwargs) .. py:method:: ZD_Pressure_drhodP(TC, rhohat, method=None) .. py:method:: ZD_Density(TC, P, method='ZD05', error=None) .. py:method:: GibbsEnergy(TC, P, method='VolumeIntegral') .. py:class:: 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 :param T: Temperature [°C] :type T: float, vector :param P: Pressure [bar] :type P: float, vector :param rho: Density [kg/m³] :type rho: float, vector :param Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate dielectric constant (optional), if not specified, default - 'JN91' :type Dielec_method: string :param Dielec_DEWoutrange: specify either 'FGL97' or 'JN91' as the method to calculate dielectric constant for out of range for 'DEW' method if any :type Dielec_DEWoutrange: string :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 .. rubric:: 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 .. rubric:: 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 .. rubric:: 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 .. py:attribute:: kwargs .. py:method:: __checker__(**kwargs) .. py:method:: __calc__(**kwargs) .. py:method:: 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 .. rubric:: Notes Temperature and Pressure input limits: * -35 ≤ TC ≤ 600 and 0 ≤ P ≤ 12000 :param TC: :type TC: temperature [°C] :param rho: :type 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) .. rubric:: 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. .. py:method:: 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 .. rubric:: Notes Temperature and Pressure input limits: * 0 ≤ TC ≤ 1000 and 0 ≤ P ≤ 5000 :param TC: :type TC: temperature [°C] :param rho: :type 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_JN91( TC, rho) .. rubric:: 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. .. py:method:: 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. .. rubric:: Notes Temperature and Pressure input limits: * 100 ≤ TC ≤ 1200 and 1000 ≤ P ≤ 60000 :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] 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_DEW() .. rubric:: 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. .. py:function:: readIAPWS95data() returns all constants and coefficients needed for the IAPWS95 formulation, packed into a dictionary .. py:function:: convert_temperature(T, Out_Unit='C') This function converts temperatures from Celsius to Kelvin and vice-versa :param T: Temperature in °C or K :type T: float, vector :param Out_Unit: Expected temperature unit (C or K) :type Out_Unit: string :returns: **T** -- Temperature in °C or K :rtype: float, vector .. rubric:: Examples >>> TC = 100; convert_temperature( TC, Out_Unit = 'K' ) 373.15 >>> TK = 520; convert_temperature( TK, Out_Unit = 'C' ) 246.85 .. py:class:: Driesner_NaCl(**kwargs) Implementation of Driesner and Heinrich PTx Formulation for H2O-NaCl system :param T: Temperature [°C] :type T: float :param P: Pressure [bar] :type P: float :param xNaCl: mole fraction of NaCl in H2O [-] :type xNaCl: float :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 .. rubric:: 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) .. rubric:: 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. .. py:attribute:: kwargs .. py:method:: __calc__(**kwargs) .. py:method:: Driesner_NaCl(T, P) .. py:method:: Driesner_NaClII(T, P, xNaCl) .. py:method:: enthalpy_mu_heatcap(T, P, xNaCl) Enthalpy in J/g, viscosity in Pas and Cp in Joules per kilogram Kelvin .. py:function:: 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 :param val: Values to convert :type val: float :param In_Unit: unit of input concentration :type In_Unit: String :param Out_Unit: expected output concentration :type Out_Unit: String :returns: **Out** -- Converted values :rtype: float .. py:class:: heatcap(**kwargs) Class to heat capacity for mineral and gases using Maier-Kelley powerlaw, Haas-Fisher powerlaw, Holland and Powell and Berman's function :param T: Temperature [°C] :type T: float, vector :param P: Pressure [bar] :type P: float, vector :param Species_ppt: 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 :type Species_ppt: array :param Species: species name, optional for all cases except gases, Coesite and Quartz :type Species: string :param method: specify either 'SUPCRT' or 'berman88' or 'HP11' or 'HF76' to carry-out any mineral or gas heat capacity calculations, default is 'SUPCRT' :type method: string :returns: * **dG** (*float, vector*) -- Gibbs Energy [cal/mol] * **dCp** (*float, vector*) -- Heat capacity [cal/mol/K] .. rubric:: 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 .. rubric:: 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 .. py:attribute:: kwargs .. py:attribute:: TC :value: None .. py:attribute:: P :value: None .. py:attribute:: Species_ppt :value: None .. py:attribute:: method :value: None .. py:attribute:: Species :value: None .. py:method:: __calc__(**kwargs) .. py:method:: 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) :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param species: 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] ) :type species: array :returns: * **delGfPT** (*float, vector*) -- Gibbs Energy [cal/mol] * **delCp** (*float, vector*) -- Heat capacity [cal/mol/K] .. rubric:: References (1) Haas JL Jr, Fisher JR (1976) Simultaneous evaluation and correlation of thermodynamic data. American Journal of Science 276:525-545 .. py:method:: 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 :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param species: 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]] :type species: array :returns: * **delGfPT** (*float, vector*) -- Gibbs Energy [cal/mol] * **delCp** (*float, vector*) -- Heat capacity [cal/mol/K] .. rubric:: 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 .. py:method:: 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 :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param species: 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 :type species: array :param spec_name: species name, optional for all cases except gases, Coesite and Quartz :type spec_name: string :returns: * **delGfPT** (*float, vector*) -- Gibbs Energy [cal/mol] * **delCp** (*float, vector*) -- Heat capacity [cal/mol/K] .. rubric:: 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 .. py:method:: 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 :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param species: 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 [-]] :type species: array :returns: * **delGfPT** (*float, vector*) -- Gibbs Energy [cal/mol] * **delCp** (*float, vector*) -- Heat capacity [cal/mol/K] .. rubric:: 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. .. py:function:: 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 :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param specieppt: 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] ) :type specieppt: array :param Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: string :param ThermoInUnit: specify either 'cal' or 'KJ' as the input units for species properties (optional), if not specified default - 'cal' :type ThermoInUnit: string :param rhoE: dictionary of water properties like density (rho) and dielectric factor (E) (optional) :type rhoE: dict :returns: **delG** -- Gibbs energy [cal/mol] :rtype: 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') .. rubric:: 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 .. rubric:: 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 .. py:function:: 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 :param formula: Chemical formula :type formula: string :returns: **elements** -- dictionary of elemental composition and their respective number of atoms :rtype: 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" . .. py:class:: solidsolution_thermo(**kwargs) Class to calculate Ideal mixing model for solid-solutions, supporting multisite ideal formalism :param X: End member mineral volume fraction or mole fraction of Mg in clinopyroxene :type X: float :param cpx_Ca: number of moles of Ca in clinopyroxene formula unit (=1 for Di, Hed) :type cpx_Ca: float :param T: Temperature [°C] :type T: float, vector :param P: Pressure [bar] :type P: float, vector :param dbaccessdic: dictionary of species from direct-access database, optional, default is speq23 :type dbaccessdic: dict :param solidsolution_type: 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' :type solidsolution_type: string :param Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: string 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' rhoEG : dict dictionary of water properties like density (rho), dielectric factor (E) and Gibbs Energy (optional) :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 .. rubric:: 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']} .. py:attribute:: kwargs .. py:method:: __calc__(**kwargs) .. py:method:: __checker__(**kwargs) .. py:method:: calclogKAnAb(XAn, TC, P, dbaccessdic, rhoEG, Dielec_method=None) This function calculates thermodynamic properties of solid solution of Plagioclase minerals :param XAn: :type XAn: volume fraction of Anorthite :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: calclogKFoFa(XFo, TC, P, dbaccessdic, rhoEG, Dielec_method=None) This function calculates thermodynamic properties of solid solution of olivine minerals :param XFo: :type XFo: volume fraction of Forsterite :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: calclogKEnFe(XEn, TC, P, dbaccessdic, rhoEG, Dielec_method=None) This function calculates thermodynamic properties of solid solution of pyroxene minerals :param XEn: :type XEn: volume fraction of Enstatite :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: 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) :param nCa: and must be greater than zero :type nCa: number of moles of Ca in formula unit (=1 for Di, Hed) :param XMg: XMg = (nMg/(nFe + nMg)) :type XMg: mole fraction of Mg :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: calclogKAbOr(XAb, TC, P, dbaccessdic, rhoEG, Dielec_method=None) This function calculates thermodynamic properties of solid solution of Alkaline-Feldspar minerals :param XAb: :type XAb: volume fraction of Albite :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:method:: calclogKBiotite(XPh, TC, P, dbaccessdic, rhoEG, Dielec_method=None) This function calculates thermodynamic properties of solid solution of Biotite minerals :param XAb: :type XAb: volume fraction of Albite :param TC: :type TC: temperature [°C] :param P: :type P: pressure [bar] :param dbaccessdic: :type dbaccessdic: dictionary of species from direct-access database :param Dielec_method: dielectric constant (optional), if not specified default - 'JN91' :type Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate :param rhoEG: dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dictionary of water properties like density (rho), :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') .. py:function:: 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: :param TC: Temperature [°C] :type TC: float, vector :param P: Pressure [bar] :type P: float, vector :param elem: 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'] :type elem: list :param dbacessdic: dictionary of species from direct-access database, optional, default is speq23 :type dbacessdic: dict :param group: 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 :type group: string :param cation_order: 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) :type cation_order: string :param Dielec_method: specify either 'FGL97' or 'JN91' or 'DEW' as the method to calculate dielectric constant (optional), if not specified, default - 'JN91' :type Dielec_method: string :param ClayMintype: specify either 'Smectite' or 'Chlorite' or 'Mica' as the clay type, if not specified default - 'Smectites' :type ClayMintype: string :param Int_Mg_fract: 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 :type Int_Mg_fract: string :param Int_Li_fract: 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 :type Int_Li_fract: string :param heatcap_approx: 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+) :type heatcap_approx: 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 rhoEG: dictionary of water properties like density (rho), dielectric factor (E) and Gibbs Energy (optional) :type rhoEG: dict :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') .. rubric:: Examples >>> logK, Rxn = calclogKclays(50, 'T', *['Clinochlore', '3', '2', '0', '0', '5', '0', '0', '0', '0', '0'], group = '14A') >>> logK 57.29239957 .. rubric:: 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'] .. py:data:: MW