Class FluidBuilder

java.lang.Object
neqsim.thermo.system.FluidBuilder
All Implemented Interfaces:
Serializable

public class FluidBuilder extends Object implements Serializable
Fluent builder for creating pre-configured thermodynamic fluid systems.

Provides both a fluent builder API for custom fluids and static factory methods for common industry fluid types. All fluids are returned as SystemInterface with the mixing rule already set, ready for flash calculations.

Fluent Builder:

SystemInterface fluid = FluidBuilder.create(273.15 + 25.0, 60.0).addComponent("methane", 0.85)
    .addComponent("ethane", 0.10).addComponent("propane", 0.05).withMixingRule("classic")
    .build();

Preset Fluids:

SystemInterface gas = FluidBuilder.leanNaturalGas(273.15 + 25.0, 60.0);
SystemInterface oil = FluidBuilder.typicalBlackOil(273.15 + 80.0, 200.0);
SystemInterface co2 = FluidBuilder.co2Rich(273.15 + 40.0, 100.0);
Version:
1.0
Author:
Even Solbraa
See Also:
  • Field Details

    • serialVersionUID

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

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

      private double temperatureK
      Temperature in Kelvin.
    • pressureBara

      private double pressureBara
      Pressure in bara.
    • eosType

      private FluidBuilder.EOSType eosType
      EOS type to use.
    • mixingRuleName

      private String mixingRuleName
      Mixing rule name (for string-based rules).
    • mixingRuleNumber

      private int mixingRuleNumber
      Mixing rule number (for numeric rules like CPA).
    • components

      private final List<FluidBuilder.ComponentEntry> components
      Ordered component list (name, mole fraction).
    • tbpFractions

      private final List<FluidBuilder.TBPEntry> tbpFractions
      TBP fraction entries.
    • plusFraction

      private FluidBuilder.TBPEntry plusFraction
      Plus fraction entry (optional).
    • multiPhaseCheck

      private boolean multiPhaseCheck
      Whether to enable multi-phase check.
    • solidPhaseCheck

      private boolean solidPhaseCheck
      Whether to enable solid phase check.
    • numberOfLumpedComponents

      private int numberOfLumpedComponents
      Number of lumped components for characterization.
  • Constructor Details

    • FluidBuilder

      private FluidBuilder(double temperatureK, double pressureBara)
      Creates a new FluidBuilder with the given conditions.
      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
  • Method Details

    • create

      public static FluidBuilder create(double temperatureK, double pressureBara)
      Creates a new fluent builder for a thermodynamic fluid.
      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
      Returns:
      a new FluidBuilder instance
    • addComponent

      public FluidBuilder addComponent(String name, double moleFraction)
      Adds a component with a mole fraction.
      Parameters:
      name - component name (e.g., "methane", "CO2")
      moleFraction - mole fraction (0 to 1)
      Returns:
      this builder for chaining
    • addTBPFraction

      public FluidBuilder addTBPFraction(String name, double moleFraction, double molarMassKgPerMol, double density)
      Adds a TBP (True Boiling Point) fraction for oil characterization.
      Parameters:
      name - fraction name (e.g., "C7", "C8")
      moleFraction - mole fraction
      molarMassKgPerMol - molar mass in kg/mol
      density - density in g/cm3
      Returns:
      this builder for chaining
    • addPlusFraction

      public FluidBuilder addPlusFraction(String name, double moleFraction, double molarMassKgPerMol, double density)
      Adds a plus fraction (e.g., C20+) for oil characterization.
      Parameters:
      name - fraction name (e.g., "C20+")
      moleFraction - mole fraction
      molarMassKgPerMol - molar mass in kg/mol
      density - density in g/cm3
      Returns:
      this builder for chaining
    • withEOS

      public FluidBuilder withEOS(FluidBuilder.EOSType eosType)
      Selects the equation of state type.
      Parameters:
      eosType - the EOS type to use
      Returns:
      this builder for chaining
    • withMixingRule

      public FluidBuilder withMixingRule(String mixingRule)
      Sets the mixing rule by name (e.g., "classic", "HV", "WS").
      Parameters:
      mixingRule - the mixing rule name
      Returns:
      this builder for chaining
    • withMixingRule

      public FluidBuilder withMixingRule(int mixingRuleNumber)
      Sets the mixing rule by number (e.g., 10 for CPA).
      Parameters:
      mixingRuleNumber - the mixing rule number
      Returns:
      this builder for chaining
    • withMultiPhaseCheck

      public FluidBuilder withMultiPhaseCheck()
      Enables multi-phase check (needed for water-bearing systems).
      Returns:
      this builder for chaining
    • withSolidPhaseCheck

      public FluidBuilder withSolidPhaseCheck()
      Enables solid phase check (for wax, hydrate, or solid precipitation).
      Returns:
      this builder for chaining
    • withLumpedComponents

      public FluidBuilder withLumpedComponents(int numberOfLumpedComponents)
      Sets the number of lumped components for C7+ characterization.
      Parameters:
      numberOfLumpedComponents - number of lumped pseudo-components
      Returns:
      this builder for chaining
    • build

      public SystemInterface build()
      Builds the configured thermodynamic system.
      Returns:
      the configured SystemInterface, ready for flash calculations
    • createSystem

      private SystemInterface createSystem()
      Creates the appropriate SystemInterface implementation based on EOSType.
      Returns:
      a new SystemInterface instance
    • leanNaturalGas

      public static SystemInterface leanNaturalGas(double temperatureK, double pressureBara)
      Creates a lean natural gas (dry gas) with typical North Sea composition.

      Composition: CH4 (85%), C2H6 (8%), C3H8 (3%), iC4 (0.5%), nC4 (1%), N2 (1.5%), CO2 (1%). Uses SRK EOS with classic mixing rule.

      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
      Returns:
      configured lean gas fluid
    • richNaturalGas

      public static SystemInterface richNaturalGas(double temperatureK, double pressureBara)
      Creates a rich natural gas (wet gas) with heavier components.

      Composition: CH4 (72%), C2H6 (10%), C3H8 (6%), iC4 (2%), nC4 (3%), iC5 (1%), nC5 (1%), N2 (1%), CO2 (2%), nC6 (1%), nC8 (1%). Uses SRK EOS with classic mixing rule.

      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
      Returns:
      configured rich gas fluid
    • typicalBlackOil

      public static SystemInterface typicalBlackOil(double temperatureK, double pressureBara)
      Creates a typical black oil with C7+ characterization.

      Includes light ends plus TBP fractions for C7-C10 and a C20+ plus fraction. Uses PR EOS with classic mixing rule and automatic characterization with 6 lumped components.

      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
      Returns:
      configured black oil fluid
    • co2Rich

      public static SystemInterface co2Rich(double temperatureK, double pressureBara)
      Creates a CO2-rich stream typical for carbon capture and storage (CCS).

      Composition: CO2 (95%), N2 (2%), methane (2%), H2S (0.5%), water (0.5%). Uses SRK-CPA EOS (mixing rule 10) with multi-phase check to handle water-CO2 phase behavior.

      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
      Returns:
      configured CO2-rich fluid
    • acidGas

      public static SystemInterface acidGas(double temperatureK, double pressureBara)
      Creates an acid gas stream with significant H2S and CO2 content.

      Composition: methane (70%), CO2 (10%), H2S (5%), ethane (5%), propane (3%), n-butane (2%), water (2%), nitrogen (3%). Uses SRK-CPA EOS with multi-phase check.

      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
      Returns:
      configured acid gas fluid
    • gasCondensate

      public static SystemInterface gasCondensate(double temperatureK, double pressureBara)
      Creates a gas condensate fluid.

      Composition: CH4 (75%), C2H6 (7%), C3H8 (4%), iC4 (1.5%), nC4 (2%), iC5 (1%), nC5 (1%), nC6 (1.5%), plus C7-C10 TBP fractions and C15+ plus fraction. Uses SRK EOS.

      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
      Returns:
      configured gas condensate fluid
    • dryExportGas

      public static SystemInterface dryExportGas(double temperatureK, double pressureBara)
      Creates a dry export gas with simple composition.

      Composition: CH4 (92%), C2H6 (4%), C3H8 (1.5%), N2 (1.5%), CO2 (1%). Uses SRK EOS. Suitable for pipeline transport calculations.

      Parameters:
      temperatureK - temperature in Kelvin
      pressureBara - pressure in bara
      Returns:
      configured dry gas fluid