Neqsim wax calculations

From equinor/neqsim · View interactive version

Neqsim wax calculations is an AI agent skill from the GitHub repository equinor/neqsim. Use when: performing NeqSim wax calculations, wax appearance temperature (WAT), wax fraction versus temperature curves, wax precipitation, waxy-oil viscosity, wax model tuning, or wax inhibitor screening for flow assurance studies. Covers the verified Java and Python API setup for wax-forming oils w

How to use this skill

Skill file

NeqSim Wax Calculations

Use this skill when a task needs a real NeqSim wax workflow rather than the simple wax-margin screening placeholder. Typical outputs are wax appearance temperature (WAT), wax weight fraction versus temperature, wax fraction along a pressure profile, waxy-oil viscosity sensitivity, and optional inhibitor dose-response screening.

When to Use

For a quick margin calculation when WAT is already known, use neqsim-wax-margin-check. For broader pipeline and hydrate/wax/asphaltene context, also load neqsim-flow-assurance.

Required Inputs

Wax Fluid Setup

Wax calculations need a characterized heavy-end oil and an explicit wax solid phase. The verified Java setup pattern is:

SystemInterface oil = new SystemSrkEos(273.15 + 60.0, 50.0);
oil.addComponent("methane", 0.30);
oil.addComponent("ethane", 0.10);
oil.addTBPfraction("C10", 0.15, 134.0 / 1000.0, 0.78);
oil.addTBPfraction("C15", 0.15, 206.0 / 1000.0, 0.83);
oil.addTBPfraction("C19", 0.10, 270.0 / 1000.0, 0.814);
oil.addPlusFraction("C20", 0.20, 350.0 / 1000.0, 0.88);

oil.getCharacterization().characterisePlusFraction();
oil.getWaxModel().addTBPWax();
oil.createDatabase(true);
oil.setMixingRule(2);
oil.addSolidComplexPhase("wax");
oil.setMultiphaseWaxCheck(true);
oil.setMultiPhaseCheck(true);
oil.init(0);
oil.init(1);

Notes:

Named n-paraffin feeds

Fluids whose wax formers are named database n-paraffins (nC14, nC20, nC24, ...) need no

TBP characterization, and getWaxModel().addTBPWax() may be called before or after

addSolidComplexPhase("wax"). Named wax formers are not split. They keep measured database

fusion data (n-hexane, n-heptane, nC11-nC14, nC16); nC15 and nC17-nC24 only have the database

placeholder (273.0 K, 6000 J/mol), and addTBPWax() replaces it with the Pedersen correlations

(nC20 melts at about 310.5 K). Call addTBPWax() for named nC15/nC17-nC24 feeds — without it

the 273 K placeholder puts the WAT near 270 K instead of near the n-paraffin melting point.

Re-calling it after changing setParameterWaxTriplePointTemperature/setParameterWaxHeatOfFusion

re-applies the tuning. Verified on methane/nC20 = 0.3/0.7 mol, SRK, 5 bara, 260-330 K

(WaxFractionSimTest, 2026-11-22; equinor/neqsim#5210).

Wax Appearance Temperature

Use ThermodynamicOperations#calcWAT() for a direct WAT. The operation changes the system temperature to the calculated wax appearance temperature.

ThermodynamicOperations ops = new ThermodynamicOperations(oil);
ops.calcWAT();
double watC = oil.getTemperature() - 273.15;

Use this for a single pressure point when the fluid has already been configured for wax calculations.

Wax Fraction Curve

Use neqsim.pvtsimulation.flowassurance.WaxCurveCalculator for a WAT and wax weight fraction curve with monotonicity enforcement.

WaxCurveCalculator wax = new WaxCurveCalculator(oil);
wax.setPressure(50.0);
wax.setTemperatureRange(-10.0, 80.0, 2.0);
wax.calculate();

double watC = wax.getWaxAppearanceTemperatureC();
double[] temperaturesC = wax.getTemperaturesC();
double[] waxWeightFractions = wax.getWaxWeightFractions();
int failedFlashes = wax.getFailCount();
int corrections = wax.getMonotonicityCorrections();

Temperature values are stored from high to low temperature. Wax fraction should increase as temperature decreases. Record failedFlashes and corrections in the task results so reviewers can judge numerical quality.

Pipeline Pressure Sensitivity

Use calculateAtMultiplePressures(double[], double) to evaluate wax fraction at one temperature across a pipeline pressure profile.

double[] pressuresBara = new double[] {120.0, 90.0, 60.0, 30.0};
Map<Double, Double> waxByPressure = wax.calculateAtMultiplePressures(pressuresBara, 25.0);

For a full pipeline profile, combine this with the pipeline temperature profile from a NeqSim pipe model or measured operating data. Compare local temperature against WAT at local pressure, and report wax fraction at each profile point.

PVT Wax Fraction Simulation

Use WaxFractionSim when the task follows the PVT simulation pattern or needs compatibility with existing PVT reports.

WaxFractionSim waxSim = new WaxFractionSim(oil);
double[] temperaturesK = new double[] {333.15, 313.15, 293.15, 273.15};
double[] pressuresBara = new double[] {50.0, 50.0, 50.0, 50.0};
waxSim.setTemperaturesAndPressures(temperaturesK, pressuresBara);
waxSim.runCalc();
double[] waxFractions = waxSim.getWaxFraction();

The array returned by getWaxFraction() is the system weight fraction in the wax phase at each pressure and temperature point.

Waxy-Oil Viscosity

Use ViscosityWaxOilSim when viscosity increase below WAT or shear-rate sensitivity matters. Configure the wax fluid as above, then set matching temperature, pressure, and shear-rate arrays. Treat results as model-sensitive and validate against lab viscosity data when available.

Wax Inhibitor Screening

For inhibitor or pour-point-depressant screening, first calculate the untreated WAT using WaxCurveCalculator or calcWAT(). Then use neqsim.process.chemistry.wax.WaxInhibitorPerformance for a transparent dose-response estimate.

WaxInhibitorPerformance inhibitor = new WaxInhibitorPerformance();
inhibitor.setBaseWaxAppearanceTemperatureC(watC);
inhibitor.setBasePourPointC(24.0);
inhibitor.setDoseMgL(200.0);
inhibitor.setMaxPourPointDepressionC(18.0);
inhibitor.setDoseAt50PctEfficacyMgL(150.0);
inhibitor.evaluate();

double inhibitedWatC = inhibitor.getInhibitedWaxAppearanceTemperatureC();
double efficacy = inhibitor.getEfficacyFraction();
List<String> warnings = inhibitor.getWarnings();

This inhibitor model is a screening relation. Use lab bottle tests, cold-finger data, and field-trial evidence for design decisions.

For the wider chemical picture — compatibility of the wax inhibitor with the other products in

the same injection line, dose bookkeeping through an InhibitorInjectionPoint, and chemical

root-cause of a deposit that may be wax, scale or an amorphous scavenger product — load

neqsim-production-chemistry.

Python Notebook Pattern

In repository task notebooks, use devtools/neqsim_dev_setup.py and direct Java classes through ns so the workspace classes are used.

SystemSrkEos = ns.SystemSrkEos
ThermodynamicOperations = ns.ThermodynamicOperations
WaxCurveCalculator = ns.JClass("neqsim.pvtsimulation.flowassurance.WaxCurveCalculator")

oil = SystemSrkEos(273.15 + 60.0, 50.0)
oil.addComponent("methane", 0.30)
oil.addComponent("ethane", 0.10)
oil.addTBPfraction("C10", 0.15, 134.0 / 1000.0, 0.78)
oil.addTBPfraction("C15", 0.15, 206.0 / 1000.0, 0.83)
oil.addPlusFraction("C20", 0.20, 350.0 / 1000.0, 0.88)

oil.getCharacterization().characterisePlusFraction()
oil.getWaxModel().addTBPWax()
oil.createDatabase(True)
oil.setMixingRule(2)
oil.addSolidComplexPhase("wax")
oil.setMultiphaseWaxCheck(True)
oil.setMultiPhaseCheck(True)
oil.init(0)
oil.init(1)

wax = WaxCurveCalculator(oil)
wax.setPressure(50.0)
wax.setTemperatureRange(-10.0, 80.0, 2.0)
wax.calculate()

wat_c = wax.getWaxAppearanceTemperatureC()
temperatures_c = list(wax.getTemperaturesC())
wax_weight_fractions = list(wax.getWaxWeightFractions())

Validation Checklist

Common Failure Modes

| Symptom | Likely Cause | Fix |

| --- | --- | --- |

| No wax phase appears | Wax phase not added or wax check disabled | Add addSolidComplexPhase("wax"), enable setMultiphaseWaxCheck(true), and rerun |

| NullPointerException: ... getPhases()[5] is null from calcWAT() | addSolidComplexPhase("wax") was never called, so the wax phase slot does not exist | Follow the full setup order in "Wax Fluid Setup"; addTBPWax() alone does not create the phase |

| ArrayIndexOutOfBoundsException: Index -3 in Characterise.characterisePlusFraction | Plus-fraction name contains + (e.g. "C36+") — the carbon number cannot be parsed | Drop the +: use addPlusFraction("C36", ...) |

| WAT near the light-paraffin freezing point (e.g. about -112 C with n-heptane) on a characterized oil | NeqSim before the PedersenWaxSplitTest fix, wax phase added without createDatabase(true): TBP wax pseudo components became non-wax methane templates | Update NeqSim, or call createDatabase(true) (with temporary tables) before addSolidComplexPhase("wax") |

| NaN moles for C*_PC / waxC*_PC after addTBPWax() | NeqSim before the same fix: a fraction not denser than the Pedersen n-paraffin gave a negative power base | Update NeqSim; the fraction is now treated as entirely wax forming |

| WAT is unrealistically low | Heavy-end characterization is too light or missing n-paraffins | Review TBP cuts, plus-fraction molar mass, density, and wax model parameters |

| WAT calculation fails | Search range or initial fluid state is poor | Use WaxCurveCalculator over a broad temperature range and inspect failed flashes |

| calcWAT() throws molarVolumeAnalytical - compressibility factor is NaN, or WaxCurveCalculator returns NaN WAT | Synthetic/hand-built heavy end with no n-paraffin distribution — the wax model has nothing physical to solve against | Do not substitute a guessed WAT. Report it as a lab-data gap and require a measured WAT/DSC or a real PVTsim/E300 characterization |

| Wax fraction decreases or gas/wax disappears when cooling | Possible phase-selection or convergence artifact | Inspect unsmoothed independent TP trials, phase identities, conserved inventories and component fugacities; material balance or monotonicity smoothing alone cannot validate stability. See the #4324 cold-start regression in the wax guide. |

| IllegalStateException: Invalid reference-liquid fugacity coefficient for nC20, or a wax mass fraction above 1 / phase mass fractions not summing to 1, on a named-paraffin feed | NeqSim before the #5210 fix: placeholder nC20 fusion data and a wax beta solver that stopped before a re-entering gas phase converged | Update NeqSim; call getWaxModel().addTBPWax() for the named feed and check getPhaseFraction(...,"mass") sums to 1 |

| Python notebook sees old API | Installed neqsim package is stale | Use the devtools setup cell with workspace classes or rebuild/package the JAR |

Reporting Requirements

For task reports, include:

Related NeqSim Classes

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.