Class FluidBuilder
- All Implemented Interfaces:
Serializable
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classInternal holder for component name and mole fraction.static enumSupported equation of state types.private static classInternal holder for TBP fraction data. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<FluidBuilder.ComponentEntry> Ordered component list (name, mole fraction).private FluidBuilder.EOSTypeEOS type to use.private static final org.apache.logging.log4j.LoggerLogger object for class.private StringMixing rule name (for string-based rules).private intMixing rule number (for numeric rules like CPA).private booleanWhether to enable multi-phase check.private intNumber of lumped components for characterization.private FluidBuilder.TBPEntryPlus fraction entry (optional).private doublePressure in bara.private static final longSerialization version.private booleanWhether to enable solid phase check.private final List<FluidBuilder.TBPEntry> TBP fraction entries.private doubleTemperature in Kelvin. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateFluidBuilder(double temperatureK, double pressureBara) Creates a new FluidBuilder with the given conditions. -
Method Summary
Modifier and TypeMethodDescriptionstatic SystemInterfaceacidGas(double temperatureK, double pressureBara) Creates an acid gas stream with significant H2S and CO2 content.addComponent(String name, double moleFraction) Adds a component with a mole fraction.addPlusFraction(String name, double moleFraction, double molarMassKgPerMol, double density) Adds a plus fraction (e.g., C20+) for oil characterization.addTBPFraction(String name, double moleFraction, double molarMassKgPerMol, double density) Adds a TBP (True Boiling Point) fraction for oil characterization.build()Builds the configured thermodynamic system.static SystemInterfaceco2Rich(double temperatureK, double pressureBara) Creates a CO2-rich stream typical for carbon capture and storage (CCS).static FluidBuildercreate(double temperatureK, double pressureBara) Creates a new fluent builder for a thermodynamic fluid.private SystemInterfaceCreates the appropriate SystemInterface implementation based on EOSType.static SystemInterfacedryExportGas(double temperatureK, double pressureBara) Creates a dry export gas with simple composition.static SystemInterfacegasCondensate(double temperatureK, double pressureBara) Creates a gas condensate fluid.static SystemInterfaceleanNaturalGas(double temperatureK, double pressureBara) Creates a lean natural gas (dry gas) with typical North Sea composition.static SystemInterfacerichNaturalGas(double temperatureK, double pressureBara) Creates a rich natural gas (wet gas) with heavier components.static SystemInterfacetypicalBlackOil(double temperatureK, double pressureBara) Creates a typical black oil with C7+ characterization.withEOS(FluidBuilder.EOSType eosType) Selects the equation of state type.withLumpedComponents(int numberOfLumpedComponents) Sets the number of lumped components for C7+ characterization.withMixingRule(int mixingRuleNumber) Sets the mixing rule by number (e.g., 10 for CPA).withMixingRule(String mixingRule) Sets the mixing rule by name (e.g., "classic", "HV", "WS").Enables multi-phase check (needed for water-bearing systems).Enables solid phase check (for wax, hydrate, or solid precipitation).
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version.- See Also:
-
logger
private static final org.apache.logging.log4j.Logger loggerLogger object for class. -
temperatureK
private double temperatureKTemperature in Kelvin. -
pressureBara
private double pressureBaraPressure in bara. -
eosType
EOS type to use. -
mixingRuleName
Mixing rule name (for string-based rules). -
mixingRuleNumber
private int mixingRuleNumberMixing rule number (for numeric rules like CPA). -
components
Ordered component list (name, mole fraction). -
tbpFractions
TBP fraction entries. -
plusFraction
Plus fraction entry (optional). -
multiPhaseCheck
private boolean multiPhaseCheckWhether to enable multi-phase check. -
solidPhaseCheck
private boolean solidPhaseCheckWhether to enable solid phase check. -
numberOfLumpedComponents
private int numberOfLumpedComponentsNumber 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 KelvinpressureBara- pressure in bara
-
-
Method Details
-
create
Creates a new fluent builder for a thermodynamic fluid.- Parameters:
temperatureK- temperature in KelvinpressureBara- pressure in bara- Returns:
- a new FluidBuilder instance
-
addComponent
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 fractionmolarMassKgPerMol- molar mass in kg/moldensity- 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 fractionmolarMassKgPerMol- molar mass in kg/moldensity- density in g/cm3- Returns:
- this builder for chaining
-
withEOS
Selects the equation of state type.- Parameters:
eosType- the EOS type to use- Returns:
- this builder for chaining
-
withMixingRule
Sets the mixing rule by name (e.g., "classic", "HV", "WS").- Parameters:
mixingRule- the mixing rule name- Returns:
- this builder for chaining
-
withMixingRule
Sets the mixing rule by number (e.g., 10 for CPA).- Parameters:
mixingRuleNumber- the mixing rule number- Returns:
- this builder for chaining
-
withMultiPhaseCheck
Enables multi-phase check (needed for water-bearing systems).- Returns:
- this builder for chaining
-
withSolidPhaseCheck
Enables solid phase check (for wax, hydrate, or solid precipitation).- Returns:
- this builder for chaining
-
withLumpedComponents
Sets the number of lumped components for C7+ characterization.- Parameters:
numberOfLumpedComponents- number of lumped pseudo-components- Returns:
- this builder for chaining
-
build
Builds the configured thermodynamic system.- Returns:
- the configured SystemInterface, ready for flash calculations
-
createSystem
Creates the appropriate SystemInterface implementation based on EOSType.- Returns:
- a new SystemInterface instance
-
leanNaturalGas
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 KelvinpressureBara- pressure in bara- Returns:
- configured lean gas fluid
-
richNaturalGas
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 KelvinpressureBara- pressure in bara- Returns:
- configured rich gas fluid
-
typicalBlackOil
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 KelvinpressureBara- pressure in bara- Returns:
- configured black oil fluid
-
co2Rich
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 KelvinpressureBara- pressure in bara- Returns:
- configured CO2-rich fluid
-
acidGas
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 KelvinpressureBara- pressure in bara- Returns:
- configured acid gas fluid
-
gasCondensate
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 KelvinpressureBara- pressure in bara- Returns:
- configured gas condensate fluid
-
dryExportGas
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 KelvinpressureBara- pressure in bara- Returns:
- configured dry gas fluid
-