Class PhasePitzer

All Implemented Interfaces:
Serializable, Cloneable, PhaseGEInterface, PhaseInterface, ThermodynamicConstantsInterface

public class PhasePitzer extends PhaseGE
Phase implementation for the Pitzer activity coefficient model.
Author:
esol
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version UID.
      See Also:
    • logger

      private static final org.apache.logging.log4j.Logger logger
      Logger object for class.
    • beta0

      private double[][] beta0
    • beta1

      private double[][] beta1
    • cphi

      private double[][] cphi
    • beta2

      private double[][] beta2
      Second virial coefficient for 2-2 electrolytes (Harvie & Weare 1984).
    • theta

      private double[][] theta
      Cation-cation or anion-anion mixing parameter theta (Harvie & Weare 1984).
    • psi

      private double[][][] psi
      Ternary mixing parameter psi (cation-cation-anion or anion-anion-cation).
    • beta0T1

      private double[][] beta0T1
      T-dependent coefficients for beta0: beta0(T) = beta0_25 + T1*(1/T-1/Tr) + T2*ln(T/Tr).
    • beta0T2

      private double[][] beta0T2
    • beta1T1

      private double[][] beta1T1
      T-dependent coefficients for beta1.
    • beta1T2

      private double[][] beta1T2
    • cphiT1

      private double[][] cphiT1
      T-dependent coefficients for Cphi.
    • cphiT2

      private double[][] cphiT2
    • parametersLoaded

      private boolean parametersLoaded
      Whether parameters have been loaded from database.
  • Constructor Details

    • PhasePitzer

      public PhasePitzer()
      Constructor for PhasePitzer.
  • Method Details

    • addComponent

      public void addComponent(String name, double moles, double molesInPhase, int compNumber)

      Add component to component array and update moles variables.

      Parameters:
      name - Name of component.
      moles - Total number of moles of component.
      molesInPhase - Number of moles in phase.
      compNumber - Index number of component in phase object component array.
    • getExcessGibbsEnergy

      public double getExcessGibbsEnergy(PhaseInterface phase, int numberOfComponents, double temperature, double pressure, PhaseType pt)

      getExcessGibbsEnergy.

      Parameters:
      phase - a PhaseInterface object
      numberOfComponents - a int
      temperature - a double
      pressure - a double
      pt - the PhaseType of the phase
      Returns:
      a double
    • setMixingRule

      public void setMixingRule(MixingRuleTypeInterface mr)

      setMixingRule.

      Specified by:
      setMixingRule in interface PhaseInterface
      Overrides:
      setMixingRule in class PhaseGE
      Parameters:
      mr - a MixingRuleTypeInterface
    • setAlpha

      public void setAlpha(double[][] alpha)

      setAlpha.

      Parameters:
      alpha - an array of type double
    • setDij

      public void setDij(double[][] Dij)

      setDij.

      Parameters:
      Dij - an array of type double
    • setDijT

      public void setDijT(double[][] DijT)

      setDijT.

      Parameters:
      DijT - an array of type double
    • setBinaryParameters

      public void setBinaryParameters(int i, int j, double b0, double b1, double c)
      Set binary Pitzer parameters.
      Parameters:
      i - component i
      j - component j
      b0 - beta0 parameter
      b1 - beta1 parameter
      c - cPhi parameter
    • setBeta0T

      public void setBeta0T(int i, int j, double t1, double t2)
      Set T-dependent coefficients for beta0 (Silvester-Pitzer form).
      Parameters:
      i - component index i
      j - component index j
      t1 - coefficient for (1/T - 1/Tr) term
      t2 - coefficient for ln(T/Tr) term
    • setBeta1T

      public void setBeta1T(int i, int j, double t1, double t2)
      Set T-dependent coefficients for beta1 (Silvester-Pitzer form).
      Parameters:
      i - component index i
      j - component index j
      t1 - coefficient for (1/T - 1/Tr) term
      t2 - coefficient for ln(T/Tr) term
    • setCphiT

      public void setCphiT(int i, int j, double t1, double t2)
      Set T-dependent coefficients for Cphi (Silvester-Pitzer form).
      Parameters:
      i - component index i
      j - component index j
      t1 - coefficient for (1/T - 1/Tr) term
      t2 - coefficient for ln(T/Tr) term
    • loadParametersFromDatabase

      public void loadParametersFromDatabase()
      Loads Pitzer binary parameters from the PitzerParameters database table.

      Matches ion names to components present in this phase and sets beta0, beta1, Cphi and their temperature-dependent coefficients.

    • getBeta0ij

      public double getBeta0ij(int i, int j, double TK)
      Get T-dependent beta0 parameter.
      Parameters:
      i - component index i
      j - component index j
      TK - temperature in Kelvin
      Returns:
      beta0 at temperature T
    • getBeta1ij

      public double getBeta1ij(int i, int j, double TK)
      Get T-dependent beta1 parameter.
      Parameters:
      i - component index i
      j - component index j
      TK - temperature in Kelvin
      Returns:
      beta1 at temperature T
    • getCphiij

      public double getCphiij(int i, int j, double TK)
      Get T-dependent Cphi parameter.
      Parameters:
      i - component index i
      j - component index j
      TK - temperature in Kelvin
      Returns:
      Cphi at temperature T
    • isParametersLoaded

      public boolean isParametersLoaded()
      Returns whether parameters have been loaded from database.
      Returns:
      true if loaded
    • getBeta2ij

      public double getBeta2ij(int i, int j)
      Get beta2 parameter for 2-2 electrolytes.
      Parameters:
      i - component index i
      j - component index j
      Returns:
      beta2 parameter
    • setBeta2

      public void setBeta2(int i, int j, double value)
      Set beta2 parameter for 2-2 electrolytes.
      Parameters:
      i - component index i
      j - component index j
      value - beta2 value
    • getThetaij

      public double getThetaij(int i, int j)
      Get theta mixing parameter for same-sign ion pair.
      Parameters:
      i - component index i
      j - component index j
      Returns:
      theta parameter
    • setTheta

      public void setTheta(int i, int j, double value)
      Set theta mixing parameter for same-sign ion pair.
      Parameters:
      i - component index i
      j - component index j
      value - theta value
    • getPsiijk

      public double getPsiijk(int i, int j, int k)
      Get psi ternary mixing parameter.
      Parameters:
      i - component index i
      j - component index j
      k - component index k
      Returns:
      psi parameter
    • setPsi

      public void setPsi(int i, int j, int k, double value)
      Set psi ternary mixing parameter.
      Parameters:
      i - component index i
      j - component index j
      k - component index k
      value - psi value
    • getBeta0ij

      public double getBeta0ij(int i, int j)
      Get beta0 parameter.
      Parameters:
      i - component index i
      j - component index j
      Returns:
      beta0 parameter for components i and j
    • getBeta1ij

      public double getBeta1ij(int i, int j)
      Get beta1 parameter.
      Parameters:
      i - component index i
      j - component index j
      Returns:
      beta1 parameter for components i and j
    • getCphiij

      public double getCphiij(int i, int j)
      Get Cphi parameter.
      Parameters:
      i - component index i
      j - component index j
      Returns:
      Cphi parameter for components i and j
    • getIonicStrength

      public double getIonicStrength()
      Calculate ionic strength.
      Returns:
      ionic strength
    • getSolventWeight

      public double getSolventWeight()
      Get mass of solvent in kilograms.
      Returns:
      solvent mass
    • getActivityCoefficient

      public double getActivityCoefficient(int k)

      getActivityCoefficient.

      Specified by:
      getActivityCoefficient in interface PhaseInterface
      Overrides:
      getActivityCoefficient in class PhaseGE
      Parameters:
      k - a int
      Returns:
      a double
    • getDensity

      public double getDensity()
      Get density of a phase note: does not use Peneloux volume correction.

      note: at the moment return density of water (997 kg/m3)

      Computes brine density as a function of temperature, pressure, and salinity using the Rowe-Chou (1970) correlation for NaCl-equivalent brine, extended with pressure correction. Fall-back is pure water density from Kell (1975). Much more accurate than the inherited hard-coded 997 kg/m3.

      Specified by:
      getDensity in interface PhaseInterface
      Overrides:
      getDensity in class PhaseGE
      Returns:
      density with unit kg/m3
    • molarVolume

      public double molarVolume(double pressure, double temperature, double A, double B, PhaseType pt) throws IsNaNException, TooManyIterationsException

      molarVolume.

      Parameters:
      pressure - a double
      temperature - a double
      A - a double
      B - a double
      pt - the PhaseType of the phase
      Returns:
      a double
      Throws:
      IsNaNException - if any.
      TooManyIterationsException - if any.
    • getHresTP

      public double getHresTP()

      getHresTP.

      Specified by:
      getHresTP in interface PhaseInterface
      Overrides:
      getHresTP in class Phase
      Returns:
      a double
    • getHresdP

      public double getHresdP()

      getHresdP.

      Overrides:
      getHresdP in class Phase
      Returns:
      a double
    • getSresTV

      public double getSresTV()

      getSresTV.

      Overrides:
      getSresTV in class Phase
      Returns:
      a double
    • getSresTP

      public double getSresTP()

      getSresTP.

      Specified by:
      getSresTP in interface PhaseInterface
      Overrides:
      getSresTP in class Phase
      Returns:
      a double
    • getCpres

      public double getCpres()

      getCpres.

      Calculates the excess heat capacity via finite-difference temperature derivatives of the activity coefficients. In the current implementation the Pitzer binary parameters are temperature independent, so the residual contribution evaluates to zero.

      Specified by:
      getCpres in interface PhaseInterface
      Overrides:
      getCpres in class Phase
      Returns:
      a double
    • getCvres

      public double getCvres()

      getCvres.

      Overrides:
      getCvres in class Phase
      Returns:
      a double
    • getCp

      public double getCp()
      method to return specific heat capacity (Cp).
      Specified by:
      getCp in interface PhaseInterface
      Overrides:
      getCp in class PhaseGE
      Returns:
      Cp in unit J/K
    • getCv

      public double getCv()
      method to return specific heat capacity (Cv).
      Specified by:
      getCv in interface PhaseInterface
      Overrides:
      getCv in class PhaseGE
      Returns:
      Cv in unit J/K