Class ProducedWaterFluidBuilder

java.lang.Object
neqsim.thermo.util.ProducedWaterFluidBuilder

public class ProducedWaterFluidBuilder extends Object
Factory class for creating produced water thermodynamic systems with the Electrolyte-CPA EOS.

This builder eliminates common user errors when configuring electrolyte CPA systems:

  • Automatically selects SystemElectrolyteCPAstatoil with mixing rule 10
  • Automatically calls chemicalReactionInit() — prevents silently wrong results
  • Provides preset produced water compositions (seawater, formation water, etc.)
  • Converts TDS (mg/L) to component mole fractions
  • Validates ion charge balance
Version:
1.0
Author:
Copilot
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final double
    Molar mass of Ca++ in g/mol.
    private static final double
    Molar mass of Cl- in g/mol.
    private static final double
    Molar mass of HCO3- in g/mol.
    private static final double
    Molar mass of K+ (approximated as Na+ for simplicity).
    private static final double
    Molar mass of Mg++ in g/mol.
    private static final double
    Molar mass of Na+ in g/mol.
    private static final double
    Molar mass of NaCl in g/mol.
    private static final double
    Molar mass of SO4-- in g/mol.
    private static final double
    Molar mass of water in g/mol.
    private static final double
    Density of water at standard conditions in g/L.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Private constructor to prevent instantiation.
  • Method Summary

    Modifier and Type
    Method
    Description
    addGasToWater(SystemInterface system, Map<String,Double> gasComposition, double gasToWaterMoleRatio)
    Adds gas components to an existing produced water system.
    private static void
    Configures the system with the correct mixing rule, database, and chemical reactions.
    createFromIons(double temperatureK, double pressureBara, Map<String,Double> ionConcentrations)
    Creates a produced water system from explicit ionic composition in mg/L.
    createFromTDS(double temperatureK, double pressureBara, double tds, double waterMoleFraction)
    Creates a produced water system from total dissolved solids (TDS) concentration.
    createFromType(double temperatureK, double pressureBara, String waterType)
    Creates a produced water system from a predefined water type.
    private static double
    Returns the molar mass of a given ion in g/mol.
    private static Map<String,Double>
    Returns the preset ionic composition for a given water type as mole fractions.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MW_NACL

      private static final double MW_NACL
      Molar mass of NaCl in g/mol.
      See Also:
    • MW_NA

      private static final double MW_NA
      Molar mass of Na+ in g/mol.
      See Also:
    • MW_CL

      private static final double MW_CL
      Molar mass of Cl- in g/mol.
      See Also:
    • MW_CA

      private static final double MW_CA
      Molar mass of Ca++ in g/mol.
      See Also:
    • MW_MG

      private static final double MW_MG
      Molar mass of Mg++ in g/mol.
      See Also:
    • MW_HCO3

      private static final double MW_HCO3
      Molar mass of HCO3- in g/mol.
      See Also:
    • MW_SO4

      private static final double MW_SO4
      Molar mass of SO4-- in g/mol.
      See Also:
    • MW_K

      private static final double MW_K
      Molar mass of K+ (approximated as Na+ for simplicity).
      See Also:
    • MW_WATER

      private static final double MW_WATER
      Molar mass of water in g/mol.
      See Also:
    • WATER_DENSITY_G_PER_L

      private static final double WATER_DENSITY_G_PER_L
      Density of water at standard conditions in g/L.
      See Also:
  • Constructor Details

    • ProducedWaterFluidBuilder

      private ProducedWaterFluidBuilder()
      Private constructor to prevent instantiation.
  • Method Details

    • createFromTDS

      public static SystemInterface createFromTDS(double temperatureK, double pressureBara, double tds, double waterMoleFraction)
      Creates a produced water system from total dissolved solids (TDS) concentration.

      Assumes the TDS is predominantly NaCl. For more complex compositions, use createFromIons(double, double, Map) instead.

      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
      tds - total dissolved solids in mg/L
      waterMoleFraction - water mole fraction in the overall system (0 to 1)
      Returns:
      configured SystemInterface with electrolyte CPA and chemical reactions initialized
    • createFromType

      public static SystemInterface createFromType(double temperatureK, double pressureBara, String waterType)
      Creates a produced water system from a predefined water type.

      Available water types:

      Predefined water types and their characteristics
      Type TDS (mg/L) Description
      condensed_water 0 Pure condensed water
      brackish 5,000 Brackish water
      seawater 35,000 Standard seawater composition
      formation_low 50,000 Low-salinity formation water
      formation_high 150,000 High-salinity formation water
      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
      waterType - one of "condensed_water", "brackish", "seawater", "formation_low", "formation_high"
      Returns:
      configured SystemInterface with electrolyte CPA and chemical reactions initialized
      Throws:
      IllegalArgumentException - if waterType is not recognized
    • createFromIons

      public static SystemInterface createFromIons(double temperatureK, double pressureBara, Map<String,Double> ionConcentrations)
      Creates a produced water system from explicit ionic composition in mg/L.

      The method converts mg/L concentrations to mole fractions and creates an Electrolyte-CPA system. Supported ions: Na+, Cl-, Ca++, Mg++, HCO3-, SO4--.

      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
      ionConcentrations - map of ion name to concentration in mg/L. Supported keys: "Na+", "Cl-", "Ca++", "Mg++", "HCO3-", "SO4--"
      Returns:
      configured SystemInterface with electrolyte CPA and chemical reactions initialized
    • addGasToWater

      public static SystemInterface addGasToWater(SystemInterface system, Map<String,Double> gasComposition, double gasToWaterMoleRatio)
      Adds gas components to an existing produced water system.

      This method adds gas components (methane, CO2, H2S, etc.) to a system that was previously configured with createFromTDS(double, double, double, double), createFromType(double, double, String), or createFromIons(double, double, Map). The gas composition is specified as mole fractions that are normalized to fit the requested gas-to-water ratio.

      Parameters:
      system - existing electrolyte CPA system
      gasComposition - map of component name to mole fraction (will be normalized)
      gasToWaterMoleRatio - ratio of total gas moles to total water-phase moles
      Returns:
      the same system with gas components added
    • configureSystem

      private static void configureSystem(SystemInterface system)
      Configures the system with the correct mixing rule, database, and chemical reactions.
      Parameters:
      system - the system to configure
    • getPresetComposition

      private static Map<String,Double> getPresetComposition(String waterType)
      Returns the preset ionic composition for a given water type as mole fractions.
      Parameters:
      waterType - the water type identifier
      Returns:
      map of component name to mole fraction
      Throws:
      IllegalArgumentException - if waterType is not recognized
    • getIonMolarMass

      private static double getIonMolarMass(String ionName)
      Returns the molar mass of a given ion in g/mol.
      Parameters:
      ionName - the ion name (e.g., "Na+", "Cl-", "Ca++")
      Returns:
      molar mass in g/mol
      Throws:
      IllegalArgumentException - if ion is not recognized