LCOV - code coverage report
Current view: top level - include/utils - GeochemistryIonicStrength.h (source / functions) Hit Total Coverage
Test: idaholab/moose geochemistry: 2bf808 Lines: 3 3 100.0 %
Date: 2025-07-17 01:29:12 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #pragma once
      11             : 
      12             : #include "PertinentGeochemicalSystem.h"
      13             : 
      14             : /**
      15             :  * Calculators to compute ionic strength and stoichiometric ionic strength
      16             :  */
      17             : class GeochemistryIonicStrength
      18             : {
      19             : public:
      20             :   /**
      21             :    * @param max_ionic_strength maximum value of ionic strength ever returned by this class
      22             :    * @param max_stoichiometric_ionic_strength maximum value of stoichiometric ionic strength ever
      23             :    * returned by this class
      24             :    * @param use_only_basis_molality If true, use only the basis molalities in the ionic strength and
      25             :    * stoichiometric ionic strength calculations.  Since basis molality is usually much greater than
      26             :    * equilibrium molality, and the whole concept of activity coefficients depending on ionic
      27             :    * strength is only approximate in practice, setting use_only_basis_molality=true is often a
      28             :    * reasonable approximation, and it can help with convergence of geochemistry algorithms since it
      29             :    * eliminates problems associated with unphysical huge equilibrium molalities that can occur
      30             :    * during Newton-iteration to the equilibrium solution
      31             :    * @param use_only_Cl_molality If true, set the stoichiometric ionic strength to the Chlorine-
      32             :    * molality.  Note that this is the method used by the Geochemists Workbench
      33             :    */
      34             :   GeochemistryIonicStrength(Real max_ionic_strength,
      35             :                             Real max_stoichiometric_ionic_strength,
      36             :                             bool use_only_basis_molality,
      37             :                             bool use_only_Cl_molality);
      38             : 
      39             :   bool operator==(const GeochemistryIonicStrength & rhs) const
      40             :   {
      41           4 :     return (_max_ionic_strength == rhs._max_ionic_strength) &&
      42           2 :            (_max_stoichiometric_ionic_strength == rhs._max_stoichiometric_ionic_strength) &&
      43           4 :            (_use_only_basis_molality == rhs._use_only_basis_molality) &&
      44             :            (_use_only_Cl_molality == rhs._use_only_Cl_molality);
      45             :   };
      46             : 
      47             :   /**
      48             :    * Compute ionic strength
      49             :    * @param mgd the Model Geochemical database
      50             :    * @param basis_species_molality Molalities of the basis species in mgd
      51             :    * @param eqm_species_molality Molalities of the equilibrium species in mgd
      52             :    * @param kin_species_molality Molalities of the kinetic species
      53             :    * @return the ionic strength of the aqueous solution
      54             :    */
      55             :   Real ionicStrength(const ModelGeochemicalDatabase & mgd,
      56             :                      const std::vector<Real> & basis_species_molality,
      57             :                      const std::vector<Real> & eqm_species_molality,
      58             :                      const std::vector<Real> & kin_species_molality) const;
      59             : 
      60             :   /**
      61             :    * Compute stoichiometric ionic strength
      62             :    * @param mgd the Model Geochemical database
      63             :    * @param basis_species_molality Molalities of the basis species in mgd
      64             :    * @param eqm_species_molality Molalities of the equilibrium species in mgd
      65             :    * @param kin_species_molality Molalities of the kinetic species
      66             :    * @return the stoichiometric ionic strength of the aqueous solution
      67             :    */
      68             :   Real stoichiometricIonicStrength(const ModelGeochemicalDatabase & mgd,
      69             :                                    const std::vector<Real> & basis_species_molality,
      70             :                                    const std::vector<Real> & eqm_species_molality,
      71             :                                    const std::vector<Real> & kin_species_molality) const;
      72             : 
      73             :   /// Set the maximum ionic strength
      74             :   void setMaxIonicStrength(Real max_ionic_strength);
      75             : 
      76             :   /// Return the value of maximum ionic strength
      77             :   Real getMaxIonicStrength() const;
      78             : 
      79             :   /// Set the maximum stoichiometric ionic strength
      80             :   void setMaxStoichiometricIonicStrength(Real max_stoichiometric_ionic_strength);
      81             : 
      82             :   /// Return the value of maximum stoichiometric ionic strength
      83             :   Real getMaxStoichiometricIonicStrength() const;
      84             : 
      85             :   /// Set the value of use_only_basis_molality
      86             :   void setUseOnlyBasisMolality(bool use_only_basis_molality);
      87             : 
      88             :   /// Return the value of use_only_basis_molality
      89             :   Real getUseOnlyBasisMolality() const;
      90             : 
      91             :   /// Set the value of use_only_Cl_molality
      92             :   void setUseOnlyClMolality(bool use_only_Cl_molality);
      93             : 
      94             :   /// Return the value of use_only_Cl_molality
      95             :   Real getUseOnlyClMolality() const;
      96             : 
      97             : private:
      98             :   /// maximum ionic strength
      99             :   Real _max_ionic_strength;
     100             : 
     101             :   /// maximum stoichiometric ionic strength
     102             :   Real _max_stoichiometric_ionic_strength;
     103             : 
     104             :   /// use only basis molality in the ionic strength calculations
     105             :   bool _use_only_basis_molality;
     106             : 
     107             :   /// set the stoichiometric ionic strength to the Cl- molality
     108             :   bool _use_only_Cl_molality;
     109             : };

Generated by: LCOV version 1.14