# Neqsim H2s Phase Partitioning

> Educational H2S gas/oil/water partitioning with NeqSim SRK-CPA through a separator train, and back-calculation of wellstream H2S from measured separator-gas H2S. USE WHEN: a task has H2S measured in separator or export gas and needs wellstream H2S, the H2S split between gas, oil and produced water, a sour-service pH2S screen, or a gas-to-well H2S conversion table.

- Skill: `equinor/neqsim-h2s-phase-partitioning` (Agent Skill, multi-file: 7 files)
- Install (CLI): `npx get-skill add equinor/neqsim-h2s-phase-partitioning`
- Raw SKILL.md: https://api.skillmd.com/api/skills/equinor/neqsim-h2s-phase-partitioning/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: equinor (https://skillmd.com/u/equinor)
- Updated: 2026-11-14
- Page: https://skillmd.com/skills/equinor/neqsim-h2s-phase-partitioning

---


# H2S Phase Partitioning and Separator-Gas to Wellstream Conversion

Use this skill to turn a measured **separator gas H2S** into a **wellstream H2S**, and to see where H2S goes in a separation train. Gas H2S is what is routinely measured; the reservoir and well question (souring versus injected-water fraction) is about the wellstream. The two differ by the gas/oil/water split, which depends on pressure, temperature, water fraction and composition.

## When to Use

- Convert measured separator or export gas H2S (ppmv) to wellstream H2S (mol fraction or ppmv) per well or per test.
- Build a lookup `factor = wellstream H2S / gas H2S` versus water mole fraction to embed in a larger model.
- Report H2S in oil (ppmw), produced water (mg/L) and each gas stream for a train, with mass-balance closure.
- Screen sour service: H2S partial pressure against the ISO 15156-2 / NACE MR0175 threshold of 0.3 kPa.
- Feed the next step in the souring chain: `neqsim-reservoir-souring-correlation` (fit per-well correlation versus seawater fraction).

## Inputs

- Dry wellstream composition (mole fractions) from the process model, PVT report or E300 file; or use the default demonstration composition.
- Water mole fraction of the wellstream (use `water_mole_fraction(water_sm3_d, dry_kmol_d)` from rates).
- `SeparatorStage(temperature_c, pressure_bara)` list, first stage first, and which stage the gas measurement belongs to.
- Measured gas H2S in ppmv (dry, in the stage gas).

## Outputs

- `ConversionResult`: wellstream H2S (mol fraction, ppmv), conversion factor, full `TrainResult` and warnings.
- `TrainResult`: per stage gas ppmv, oil ppmw, water ppmw and mg/L, pH2S in kPa, and the fractions of H2S leaving with gas, oil and water.
- `conversion_factor_curve(...)`: `(water_mol_fraction, factor)` table for plugging into a setup.

## Engineering Method

1. Build the wellstream with SRK-CPA (`SystemSrkCPAstatoil`, mixing rule 10) including water and H2S; multiphase check on.
2. Flash through `ThreePhaseSeparator` stages. Gas leaves each stage, oil feeds the next stage, water drains with its dissolved H2S.
3. Gas H2S ppmv is monotonic in wellstream H2S, so the back-calculation is a log-space bisection on wellstream H2S to match the measured value (tolerance 1e-6 relative). A measurement outside the reachable bracket raises `ValueError` rather than extrapolating.
4. In the dilute limit gas H2S is linear in wellstream H2S, so one probe level gives the factor curve.

### Two ways to get wellstream H2S

| Method | Function | Use when |
| --- | --- | --- |
| Back-calculation | `wellstream_h2s_from_separator_gas` | The wellstream composition and water fraction are trusted; only H2S is unknown. Scales H2S alone. |
| Recombination | `recombine_to_gor_and_h2s` | A test-separator GOR is measured with the gas H2S and the wellstream hydrocarbon composition is uncertain. Matches GOR and gas H2S together. |

Recombination, per pass: flash at the separator conditions; set gas H2S to the measurement and rescale the other gas components; set oil H2S from the calculated K value; recombine gas and oil at the measured GOR (Sm3 standard gas per m3 actual separator oil, volumes from the compressibility factor); hold water at a fixed mole fraction. Convergence is relative on GOR and gas H2S, because an absolute composition tolerance such as 1e-5 is looser than a trace H2S mole fraction of 1e-4 or less. Water takes up some H2S that the gas/oil K correction does not see, so a damped multiplicative trim on total H2S is applied once gas H2S is within 5 percent. Tested: starting from a wellstream with 7 times too little H2S, three passes recover the true wellstream H2S and reproduce GOR and gas H2S to 1e-4.

Use `separator_gor_and_gas_h2s(fluid, stage)` to get the calculated GOR and gas H2S of any wellstream for a round-trip check.

### Given an E300 model: do not build a fluid

When the field already has a characterised E300 model (for example the Snorre E300) and the wellstream composition comes from FluidMagic, **do not create a fluid, add pseudo-components, re-characterise or tune the EOS**. The E300 file is the EOS model; only the composition and the recombination logic are used:

1. `load_e300_fluid(model_e300)` reads the file as is (EOS, pseudo-components, BIPs, shifts, CNAMES order). Pass `add_water=True` only if the file has no water and water is needed.
2. `apply_e300_composition(fluid, model_e300, composition)` sets the wellstream composition from the FluidMagic E300 export (path), a dict keyed by CNAMES, or a list in CNAMES order. Names must match the model file; the call raises otherwise.
3. `recombine_to_gor_and_h2s(fluid, stage, gor_measured, y_h2s_measured)` adjusts the composition only (component by component) so the separator reproduces the measured GOR and gas H2S. The EOS parameters never change, so there is nothing to re-characterise between iterations.

The E300 must contain `H2S` (and `H2O` if water is to be modelled). If it does not, ask for an E300 with H2S from the characterisation owner; do not add the component here, because that changes the EOS model.

Worked demonstration (default composition, one stage at 70 C and 10 bara): the factor wellstream/gas falls from 0.81 at a dry stream to 0.58 at 30 percent water and 0.34 at 60 percent water mole fraction. Gas is richer in H2S than the wellstream, and more water carries more H2S to the water phase. These are demonstration values, not field values.

## Python Usage Pattern

```python
from h2s_partitioning import (SeparatorStage, make_wellstream, wellstream_h2s_from_separator_gas,
                              conversion_factor_curve, is_sour_service)

stages = [SeparatorStage(70.0, 10.0, "HP"), SeparatorStage(60.0, 2.0, "LP")]
fluid = make_wellstream(composition=None, water_mol_fraction=0.3, h2s_mol_fraction=1e-5)
res = wellstream_h2s_from_separator_gas(fluid, stages, measured_gas_h2s_ppmv=170.0, stage_index=0)
print(res.wellstream_h2s_ppmv, res.conversion_factor, res.train.to_water_fraction)
table = conversion_factor_curve(None, stages, [0.0, 0.1, 0.3, 0.5])

# GOR measured together with the gas H2S: recombine so both are reproduced
from h2s_partitioning import recombine_to_gor_and_h2s
rec = recombine_to_gor_and_h2s(fluid, stages[0], gor_measured=380.0, y_h2s_measured=4.5e-4)
print(rec.converged, rec.wellstream_h2s_mol_fraction)

# With a given E300 model and a FluidMagic composition: no new fluid, no new characterisation
from h2s_partitioning import load_e300_fluid, apply_e300_composition
model = load_e300_fluid("field_model.e300")
apply_e300_composition(model, "field_model.e300", "fluidmagic_composition.e300")
rec = recombine_to_gor_and_h2s(model, stages[0], gor_measured=380.0, y_h2s_measured=4.5e-4)
```

Use the project interpreter with `neqsim` installed; for a real field pass the field composition (and a plus-fraction characterisation) instead of the default.

## Validation Checklist

- [ ] H2S balance closure `to_gas + to_oil + to_water` within 2 percent (a warning is raised otherwise).
- [ ] Round trip: flash with the solved wellstream H2S and reproduce the measured gas ppmv (and, for recombination, the measured GOR).
- [ ] Recombination convergence is relative (1e-4) on GOR and gas H2S; never accept an absolute composition tolerance for trace H2S.
- [ ] GOR basis stated: standard gas per actual separator-oil volume, not per stock-tank oil.
- [ ] Composition, GOR and water fraction come from the same test or period as the H2S measurement.
- [ ] Separator pressure and temperature are the measured values at the sample time, not design values.
- [ ] Sample point: gas from the stage actually sampled, dry or wet basis stated, ppmv versus mol-ppm treated consistently.
- [ ] Sensitivity run on water fraction and composition (a factor curve), because the factor moves strongly with water.
- [ ] Results reported with the limits below.

## Limitations
- Physical partitioning only. H2S ionisation in produced water (HS-, depends on pH, CO2 and alkalinity) and reaction with iron or scale are not modelled; at high pH or high water fraction the real water phase holds more H2S than predicted.
- No PVT tuning for H2S: check against a measured H2S distribution when one exists.
- Water drains per stage (no produced-water degasser, no recycle); compressor recycles and recompressed gas change the measured gas H2S and are not in the simple train.
- Gas sampled wet or after dehydration changes ppmv basis; state it.

## Common Mistakes

- Treating separator gas ppmv as wellstream ppmv. The ratio is 0.3 to 0.9 in the demonstration range, not 1.
- Using one factor for all water fractions. The factor depends strongly on water mole fraction (and so on seawater breakthrough).
- Forgetting `init(0)` on cloned fluids before reading `getz()`; this skill's helpers do it.
- Reporting mg/L in water from mole fractions without the water density.
- Using `getNumberOfMolesInPhase` for phase mole totals; use beta times total moles, or stream flow rates as done here.

## References

- NeqSim documentation and source: <https://github.com/equinor/neqsim> (CPA/SRK flash, `ThermodynamicOperations`).
- Measured H2S distribution or sampling basis for the field (lab report) when available; see the Validation Checklist.

