Creating Fluids in NeqSim
This guide provides comprehensive documentation on how to create and configure thermodynamic fluids in NeqSim, including available equations of state, mixing rules, and best practices.
Table of Contents
- Basic Fluid Creation
- Equations of State Overview
- Cubic Equations of State
- Advanced Equations of State
- Reference Equations (Helmholtz-Based)
- Activity Coefficient Models
- Electrolyte Models
- Mixing Rules
- Adding Components
- Heavy Fraction Characterization
- Complete Examples
- Model Selection Guidelines
1. Basic Fluid Creation
Creating a fluid in NeqSim follows a consistent pattern:
import neqsim.thermo.system.SystemSrkEos;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicoperations.ThermodynamicOperations;
// 1. Create the fluid with initial temperature (K) and pressure (bara)
SystemInterface fluid = new SystemSrkEos(298.15, 10.0);
// 2. Add components
fluid.addComponent("methane", 0.90); // name, moles
fluid.addComponent("ethane", 0.05);
fluid.addComponent("propane", 0.05);
// 3. Set up the mixing rule
fluid.setMixingRule("classic");
// 4. Calculate equilibrium, then initialize physical properties
ThermodynamicOperations operations = new ThermodynamicOperations(fluid);
operations.TPflash();
fluid.initProperties();
Constructor Parameters
Most equation-of-state system classes provide a temperature/pressure constructor:
| Constructor | Description |
|---|---|
SystemXXX(T, P) |
Temperature in K and absolute pressure in bara |
SystemXXX() |
Model-specific defaults; do not assume one common state |
SystemXXX(T, P, checkForSolids) |
Available on many, but not all, system classes |
Use the explicit (T, P) form in reproducible examples. Check the selected
class’s JavaDoc before using a default or solid-checking overload.
2. Equations of State Overview
NeqSim provides a wide range of thermodynamic models organized into categories:
| Category | Use Cases | Examples |
|---|---|---|
| Cubic EoS | General hydrocarbon processing | SRK, PR, PR-1978 |
| CPA (Cubic Plus Association) | Polar/associating fluids (water, glycols, alcohols) | SRK-CPA, PR-CPA |
| Reference EoS | High-accuracy natural gas, CCS | GERG-2008, EOS-CG |
| SAFT-based | Complex molecular interactions | PC-SAFT |
| Activity Coefficient | Non-ideal liquid mixtures | UNIFAC, NRTL |
| Electrolyte | Aqueous salt solutions | Electrolyte-CPA, Pitzer |
| Specialized | Specific applications | Soreide-Whitson (sour gas/brine) |
3. Cubic Equations of State
3.1 Soave-Redlich-Kwong (SRK) Family
SystemSrkEos
The standard SRK equation of state. Best for general gas and light hydrocarbon applications.
SystemInterface fluid = new SystemSrkEos(300.0, 50.0);
fluid.addComponent("methane", 0.8);
fluid.addComponent("CO2", 0.2);
fluid.setMixingRule("classic");
SystemSrkPenelouxEos
SRK with Peneloux volume correction for improved liquid density predictions.
SystemInterface fluid = new SystemSrkPenelouxEos(300.0, 50.0);
SystemSrkMathiasCopeman
SRK with Mathias-Copeman alpha function for better vapor pressure predictions.
SystemInterface fluid = new SystemSrkMathiasCopeman(300.0, 50.0);
SystemSrkTwuCoonEos
SRK with Twu-Coon alpha function.
SystemInterface fluid = new SystemSrkTwuCoonEos(300.0, 50.0);
3.2 Peng-Robinson (PR) Family
SystemPrEos
Standard Peng-Robinson equation. Widely used for oil and gas applications.
SystemInterface fluid = new SystemPrEos(300.0, 50.0);
fluid.addComponent("methane", 0.7);
fluid.addComponent("n-heptane", 0.3);
fluid.setMixingRule("classic");
The PR equation is expressed as: \(P = \frac{RT}{v - b} - \frac{a \alpha}{v(v + b) + b(v - b)}\)
SystemPrEos1978
Original 1978 Peng-Robinson formulation with modified alpha function.
SystemInterface fluid = new SystemPrEos1978(300.0, 50.0);
SystemPrMathiasCopeman
PR with Mathias-Copeman alpha function for polar components.
SystemInterface fluid = new SystemPrMathiasCopeman(300.0, 50.0);
3.3 Other Cubic EoS
SystemRKEos
Original Redlich-Kwong equation (historical interest, less accurate).
SystemInterface fluid = new SystemRKEos(300.0, 50.0);
SystemTSTEos
Twu-Sim-Tassone equation of state.
SystemInterface fluid = new SystemTSTEos(300.0, 50.0);
4. Advanced Equations of State
4.1 CPA (Cubic Plus Association)
CPA models add an association term to handle hydrogen bonding in polar molecules like water, alcohols, and glycols.
SystemSrkCPAstatoil
The Equinor (formerly Statoil) implementation of SRK-CPA. Recommended for water-hydrocarbon systems.
SystemInterface fluid = new SystemSrkCPAstatoil(300.0, 50.0);
fluid.addComponent("water", 0.1);
fluid.addComponent("methane", 0.85);
fluid.addComponent("MEG", 0.05); // Mono-ethylene glycol
fluid.setMixingRule(10); // CPA mixing rule with temperature/composition dependency
SystemSrkCPA / SystemSrkCPAs
Alternative CPA implementations.
SystemInterface fluid = new SystemSrkCPA(300.0, 50.0);
fluid.setMixingRule(7); // CPA mixing rule
SystemPrCPA
Peng-Robinson with CPA association term.
SystemInterface fluid = new SystemPrCPA(300.0, 50.0);
4.2 PC-SAFT
Perturbed Chain Statistical Associating Fluid Theory. Good for polymers and complex molecules.
SystemInterface fluid = new SystemPCSAFT(300.0, 50.0);
fluid.addComponent("methane", 0.5);
fluid.addComponent("ethane", 0.5);
4.3 UMR-PRU (Universal Mixing Rule)
Peng-Robinson with UNIFAC-based mixing rules for improved predictions.
SystemInterface fluid = new SystemUMRPRUEos(300.0, 50.0);
5. Reference Equations (Helmholtz-Based)
For high-accuracy applications, NeqSim provides reference equations of state based on the Helmholtz free energy:
\[\alpha(\delta, \tau, \bar{x}) = \alpha^0(\delta, \tau, \bar{x}) + \alpha^r(\delta, \tau, \bar{x})\]5.1 GERG-2008
NeqSim includes a GERG-2008 implementation for the ISO 20765-2 natural-gas
reference equation. The current SystemGERG2008Eos source explicitly marks
parts of the implementation unfinished. Treat it as a calculation and
validation tool, not as sole evidence for custody-transfer or fiscal acceptance.
Mapped GERG-2008 components (21): Methane, Nitrogen, CO2, Ethane, Propane, n-Butane, i-Butane, n-Pentane, i-Pentane, n-Hexane, n-Heptane, n-Octane, n-Nonane, n-Decane, Hydrogen, Oxygen, CO, Water, H2S, Helium, Argon.
import neqsim.thermo.system.SystemGERG2008Eos;
SystemInterface fluid = new SystemGERG2008Eos(288.15, 50.0);
fluid.addComponent("methane", 0.90);
fluid.addComponent("ethane", 0.05);
fluid.addComponent("propane", 0.03);
fluid.addComponent("nitrogen", 0.02);
fluid.createDatabase(true);
// Access the GERG-specific density for comparison with validated references
double density = fluid.getPhase(0).getDensity_GERG2008();
5.2 EOS-CG
Extension of GERG-2008 for CCS (Carbon Capture and Storage) applications. Includes EOS-CG-2021 combustion-gas and amine impurity components.
EOS-CG-2021 components: CO2, H2O, N2, O2, Ar, CO, H2, CH4, H2S, SO2, MEA, DEA, HCl, Cl2, NH3, and MDEA.
import neqsim.thermo.system.SystemEOSCGEos;
SystemInterface fluid = new SystemEOSCGEos(300.0, 100.0);
fluid.addComponent("CO2", 0.95);
fluid.addComponent("nitrogen", 0.03);
fluid.addComponent("oxygen", 0.02);
5.3 Other Reference Equations
| Class | Description |
|---|---|
SystemSpanWagnerEos |
Span-Wagner equation for CO2 |
SystemLeachmanEos |
Leachman equation for hydrogen |
SystemBWRSEos |
Benedict-Webb-Rubin-Starling |
SystemBnsEos |
Burgoyne-Nielsen-Stanko Peng-Robinson correlation |
6. Activity Coefficient Models
For non-ideal liquid mixtures, especially polar and chemical systems:
6.1 UNIFAC
Group contribution method for activity coefficients.
import neqsim.thermo.system.SystemUNIFAC;
SystemInterface fluid = new SystemUNIFAC(300.0, 1.0);
fluid.addComponent("methanol", 0.3);
fluid.addComponent("water", 0.7);
6.2 NRTL
Non-Random Two-Liquid model.
import neqsim.thermo.system.SystemNRTL;
SystemInterface fluid = new SystemNRTL(300.0, 1.0);
fluid.addComponent("ethanol", 0.4);
fluid.addComponent("water", 0.6);
6.3 GE-Wilson
Wilson equation for activity coefficients.
import neqsim.thermo.system.SystemGEWilson;
SystemInterface fluid = new SystemGEWilson(300.0, 1.0);
7. Electrolyte Models
For systems containing salts and ions in aqueous solutions:
7.1 Electrolyte-CPA (Equinor)
import neqsim.thermo.system.SystemElectrolyteCPAstatoil;
SystemInterface fluid = new SystemElectrolyteCPAstatoil(298.15, 1.0);
fluid.addComponent("water", 1.0);
fluid.addComponent("Na+", 0.1);
fluid.addComponent("Cl-", 0.1);
7.2 Søreide-Whitson
Modified PR for sour gas systems and brine.
import neqsim.thermo.system.SystemSoreideWhitson;
SystemSoreideWhitson fluid = new SystemSoreideWhitson(350.0, 200.0);
fluid.addComponent("methane", 0.7);
fluid.addComponent("CO2", 0.15);
fluid.addComponent("H2S", 0.05);
fluid.addComponent("water", 0.1);
fluid.addSalinity(2.0, "mole/sec"); // Salt-equivalent molar flow, not concentration
fluid.setMixingRule(11); // Soreide-Whitson mixing rule
// Optional refreshed eight-gas drop-in BIPs; LEGACY remains the default
fluid.setSoreideWhitsonParameterization("BURGOYNE_NIELSEN_2026");
The Chabab option is validated against NaCl-brine data at approximately 1-3 mol/kg water, 323-373 K, and pressures up to 230 bar. See Søreide-Whitson Model for the correlation, units, comparison example, and extrapolation limits.
The Burgoyne-Nielsen option covers CO₂, H₂S, methane, nitrogen, hydrogen, ethane, propane, and n-butane water pairs. It is opt-in because the refreshed BIPs change results and the published fit used a specified pure-component property set.
7.3 Pitzer Model
7.3 Electrolyte GE Models and Hybrid VLLE
For electrolyte solutions, SystemPitzer, SystemDesmukhMather and SystemKentEisenberg provide a fixed-role hybrid
flash in which gas and hydrocarbon liquid use SRK while the aqueous liquid uses the selected GE model.
import neqsim.thermo.phase.PhaseType;
import neqsim.thermo.system.SystemPitzer;
import neqsim.thermodynamicoperations.ThermodynamicOperations;
SystemPitzer fluid = new SystemPitzer(313.15, 50.0);
fluid.addComponent("methane", 5.0);
fluid.addComponent("n-heptane", 2.0);
fluid.addComponent("water", 55.5);
fluid.addComponent("Na+", 1.0);
fluid.addComponent("Cl-", 1.0);
fluid.setMixingRule("classic");
fluid.setMultiPhaseCheck(true);
new ThermodynamicOperations(fluid).TPflash();
// Material roles are selected from gas (SRK), oil (SRK), and aqueous (Pitzer).
boolean hasAqueousPhase = fluid.hasPhaseType(PhaseType.AQUEOUS);
The creation-order role objects are stable even when active phases are density-ordered or disappear. A later flash
reconsiders inactive roles from the current feed and conditions. Neutral non-water species in the Pitzer phase use an
aqueous Henry reference; water alone uses the Pitzer osmotic/Raoult solvent convention. Calling
chemicalReactionInit() couples aqueous reaction equilibrium to the same fixed gas/oil/aqueous roles. This supports
activity-based scale-potential screening after reactive gas-aqueous or gas-oil-aqueous flashes. The result is a
saturation ratio; explicit mineral precipitation, solid amounts, solid-phase equilibrium and wax checks are not yet
supported by the hybrid strategy.
The solver is not restricted to Pitzer. Desmukh-Mather and Kent-Eisenberg use the same reactive coupling when
chemicalReactionInit() and setMultiPhaseCheck(true) are enabled. Other SystemEosGE systems can opt in explicitly:
SystemNRTL fluid = new SystemNRTL(313.15, 50.0);
fluid.addComponent("methane", 5.0);
fluid.addComponent("n-heptane", 2.0);
fluid.addComponent("water", 55.5);
fluid.createDatabase(true);
fluid.setMixingRule("classic");
fluid.enableHybridEosGeFlash();
new ThermodynamicOperations(fluid).TPflash();
enableHybridEosGeFlash() configures topology, not electrolyte parameters. Scale calculations require a GE phase
with meaningful activities for all requested aqueous species. Pitzer has the broadest concentrated-brine parameter
coverage; the amine models retain their narrower component and validity ranges. SystemDuanSun remains excluded from
this topology because its current public API accepts only CO2.
8. Mixing Rules
Mixing rules determine how pure-component parameters are combined for mixtures. Set via setMixingRule():
8.1 Available Mixing Rules
| Value | Name | Description |
|---|---|---|
| 1 | NO |
Classic with all kij = 0 (no interaction) |
| 2 | CLASSIC |
Classic van der Waals with kij from database |
| 3 | CLASSIC_HV |
Huron-Vidal with database parameters |
| 4 | HV |
Huron-Vidal including temperature-dependent HVDijT |
| 5 | WS |
Wong-Sandler (NRTL-based coupling) |
| 7 | CPA_MIX |
Classic with CPA kij from database |
| 8 | CLASSIC_T |
Classic with temperature-dependent kij |
| 9 | CLASSIC_T_CPA |
Classic T-dependent kij for CPA |
| 10 | CLASSIC_TX_CPA |
Classic T and composition dependent kij for CPA |
| 11 | SOREIDE_WHITSON |
Søreide-Whitson mixing rule |
| 12 | CLASSIC_T2 |
Alternative temperature-dependent classic |
8.2 Setting Mixing Rules
// By integer value
fluid.setMixingRule(2);
// By name (string)
fluid.setMixingRule("classic");
fluid.setMixingRule("HV");
fluid.setMixingRule("WS");
8.3 Mixing Rule Recommendations
| Application | Recommended Mixing Rule |
|---|---|
| Light hydrocarbons | classic (2) |
| CO2-hydrocarbon | classic (2) with tuned kij |
| Polar mixtures | HV (4) or WS (5) |
| Water-hydrocarbon (CPA) | CPA_MIX (7) or CLASSIC_TX_CPA (10) |
| Sour gas with brine | SOREIDE_WHITSON (11) |
9. Adding Components
9.1 Basic Component Addition
// Add by name and moles
fluid.addComponent("methane", 0.85);
fluid.addComponent("ethane", 0.10);
fluid.addComponent("propane", 0.05);
// Add with flow rate and unit
fluid.addComponent("methane", 100.0, "kg/hr");
fluid.addComponent("ethane", 50.0, "Sm3/day");
// Add multiple components at once
String[] names = {"methane", "ethane", "propane"};
double[] moles = {0.85, 0.10, 0.05};
fluid.addComponents(names, moles);
9.2 Supported Units
For addComponent(name, value, unit):
- Molar:
mol/sec,mol/hr - Mass:
kg/sec,kg/hr - Volumetric:
Sm3/hr,Sm3/day,MSm3/day,Nlitre/min
9.3 Common Component Names
NeqSim uses a database-backed component catalog. Verify exact names in the component list; common examples include:
Hydrocarbons:
methane, ethane, propane, i-butane, n-butane, i-pentane, n-pentane, n-hexane, n-heptane, n-octane, n-nonane, n-decane
Inorganics:
nitrogen, oxygen, CO2, H2S, water, hydrogen, helium, argon
Polar/Associating:
methanol, ethanol, MEG (mono-ethylene glycol), TEG (tri-ethylene glycol), DEG
Ions:
Na+, K+, Ca++, Mg++, Cl-, SO4--, HCO3-
10. Heavy Fraction Characterization
For petroleum fluids, NeqSim supports TBP (True Boiling Point) and plus-fraction characterization.
10.1 TBP Fractions
SystemInterface oil = new SystemSrkEos(350.0, 100.0);
// addTBPfraction(name, molarFlow, molarMass [kg/mol], specificGravity)
oil.addTBPfraction("C7", 0.05, 0.096, 0.738);
oil.addTBPfraction("C8", 0.04, 0.107, 0.765);
oil.addTBPfraction("C9", 0.03, 0.121, 0.781);
oil.addTBPfraction("C10", 0.02, 0.134, 0.792);
oil.setMixingRule("classic");
10.2 Plus Fractions
// Use a numeric label; NeqSim stores the pseudo-component with a _PC suffix.
// addPlusFraction(name, molarFlow, molarMass [kg/mol], specificGravity)
oil.addPlusFraction("C20", 0.10, 0.350, 0.88);
10.3 TBP Characterization Models
NeqSim provides several models for estimating critical properties from TBP data:
// Set TBP model before adding fractions
fluid.getCharacterization().setTBPModel("PedersenSRK"); // Default for SRK
fluid.getCharacterization().setTBPModel("PedersenPR"); // Default for PR
fluid.getCharacterization().setTBPModel("Lee-Kesler");
fluid.getCharacterization().setTBPModel("Twu");
fluid.getCharacterization().setTBPModel("RiaziDaubert");
11. Complete Examples
11.1 Natural Gas Processing
import neqsim.thermo.system.SystemSrkEos;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicoperations.ThermodynamicOperations;
public class NaturalGasExample {
public static void main(String[] args) {
// Create SRK fluid at pipeline conditions
SystemInterface gas = new SystemSrkEos(283.15, 70.0);
// Typical natural gas composition
gas.addComponent("nitrogen", 0.02);
gas.addComponent("CO2", 0.01);
gas.addComponent("methane", 0.85);
gas.addComponent("ethane", 0.06);
gas.addComponent("propane", 0.03);
gas.addComponent("i-butane", 0.01);
gas.addComponent("n-butane", 0.01);
gas.addComponent("i-pentane", 0.005);
gas.addComponent("n-pentane", 0.005);
gas.setMixingRule("classic");
// Flash calculation
ThermodynamicOperations ops = new ThermodynamicOperations(gas);
ops.TPflash();
gas.initProperties();
// Display results
System.out.println("Density: " + gas.getDensity("kg/m3") + " kg/m3");
System.out.println("Z-factor: " + gas.getZ());
System.out.println("Molecular weight: " + gas.getMolarMass() * 1000 + " g/mol");
}
}
11.2 Water-Hydrocarbon System with CPA
import neqsim.thermo.system.SystemSrkCPAstatoil;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicoperations.ThermodynamicOperations;
public class WaterHydrocarbonExample {
public static void main(String[] args) {
// CPA for associating systems
SystemInterface fluid = new SystemSrkCPAstatoil(323.15, 50.0);
fluid.addComponent("methane", 0.70);
fluid.addComponent("ethane", 0.10);
fluid.addComponent("propane", 0.05);
fluid.addComponent("water", 0.10);
fluid.addComponent("MEG", 0.05);
fluid.setMixingRule(10); // Temperature and composition dependent CPA
ThermodynamicOperations ops = new ThermodynamicOperations(fluid);
ops.TPflash();
System.out.println("Number of phases: " + fluid.getNumberOfPhases());
fluid.prettyPrint();
}
}
11.3 GERG-2008 Density Comparison
import neqsim.thermo.system.SystemGERG2008Eos;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicoperations.ThermodynamicOperations;
public class GergDensityComparisonExample {
public static void main(String[] args) {
// Compare NeqSim's GERG-2008 result with an approved reference
SystemInterface gas = new SystemGERG2008Eos(288.15, 40.0);
gas.addComponent("methane", 0.92);
gas.addComponent("ethane", 0.04);
gas.addComponent("propane", 0.02);
gas.addComponent("nitrogen", 0.01);
gas.addComponent("CO2", 0.01);
gas.createDatabase(true);
ThermodynamicOperations ops = new ThermodynamicOperations(gas);
ops.TPflash();
// GERG-specific high-accuracy density
double gergDensity = gas.getPhase(0).getDensity_GERG2008();
System.out.println("GERG-2008 Density: " + gergDensity + " kg/m3");
}
}
11.4 Oil Characterization
import neqsim.thermo.system.SystemPrEos;
import neqsim.thermo.system.SystemInterface;
import neqsim.thermodynamicoperations.ThermodynamicOperations;
public class OilCharacterizationExample {
public static void main(String[] args) {
SystemInterface oil = new SystemPrEos(350.0, 150.0);
// Light ends
oil.addComponent("nitrogen", 0.005);
oil.addComponent("CO2", 0.02);
oil.addComponent("methane", 0.35);
oil.addComponent("ethane", 0.08);
oil.addComponent("propane", 0.06);
oil.addComponent("i-butane", 0.02);
oil.addComponent("n-butane", 0.03);
oil.addComponent("i-pentane", 0.02);
oil.addComponent("n-pentane", 0.02);
oil.addComponent("n-hexane", 0.03);
// TBP fractions (molar flow, molar mass kg/mol, specific gravity)
oil.addTBPfraction("C7", 0.05, 0.096, 0.738);
oil.addTBPfraction("C8", 0.04, 0.107, 0.765);
oil.addTBPfraction("C9", 0.03, 0.121, 0.781);
oil.addTBPfraction("C10", 0.02, 0.134, 0.792);
// Use a numeric label; NeqSim stores this as C11_PC.
oil.addPlusFraction("C11", 0.18, 0.250, 0.85);
oil.setMixingRule("classic");
ThermodynamicOperations ops = new ThermodynamicOperations(oil);
ops.TPflash();
oil.initProperties();
oil.prettyPrint();
}
}
12. Model Selection Guidelines
Quick Reference Table
| System Type | Recommended Model | Mixing Rule |
|---|---|---|
| Dry natural gas | SystemSrkEos or SystemPrEos |
classic (2) |
| Wet gas / condensate | SystemPrEos |
classic (2) |
| Black oil | SystemPrEos with TBP |
classic (2) |
| Water-hydrocarbon | SystemSrkCPAstatoil |
CLASSIC_TX_CPA (10) |
| Glycol dehydration | SystemSrkCPAstatoil |
CPA_MIX (7) |
| Sour gas / brine | SystemSoreideWhitson |
SOREIDE_WHITSON (11) |
| Natural-gas reference-property comparison | SystemGERG2008Eos |
N/A |
| CCS / CO2 transport | SystemEOSCGEos |
N/A |
| Electrolyte solutions | SystemElectrolyteCPAstatoil |
N/A |
| Polar organics | SystemUNIFAC or SystemNRTL |
N/A |
Decision Flow
- Is a validated natural-gas reference calculation required? → Evaluate GERG-2008 against the applicable composition range and an approved reference
- Does the system contain water, glycols, or alcohols? → Evaluate CPA models
- Is it a sour gas system with brine? → Use Søreide-Whitson
- Is it a standard hydrocarbon system? → Use SRK or PR
- Does it contain electrolytes? → Use Electrolyte-CPA or Pitzer
- Is it a non-ideal organic mixture? → Use UNIFAC or NRTL
Model-Coverage Trade-offs
Accuracy depends on composition, state, parameters, and validation data; the labels below describe model scope rather than guaranteed error.
| Model Type | Typical Cost | Intended Scope |
|---|---|---|
| Cubic (SRK/PR) | Low | General hydrocarbon process calculations |
| CPA | Moderate | Associating mixtures within a validated parameter set |
| GERG-2008 | Higher | Natural-gas reference-property comparisons |
| UNIFAC | Moderate | Screening non-ideal liquid mixtures with available groups |
See Also
- Thermodynamic Workflows - Flash calculations and operations
- PVT and Fluid Characterization - Heavy fraction handling
- Mathematical Models - Equation details
- GERG-2008 and EOS-CG - Reference equation details
- Physical Properties - Transport property calculations