Skip to main content

NeqSim Logo NeqSim Python

Python interface to the NeqSim engine — fluid properties, process simulation, and PVT analysis from Python and Jupyter notebooks.

Tests Publish PyPI Python License

Quick Start · Process Simulation · PVT Simulation · Examples · Docs · Community


What is NeqSim Python?

NeqSim Python is part of the NeqSim project — a Python interface to the NeqSim Java library for estimation of fluid behavior and process design for oil and gas production. For an introduction see Introduction to Process Modelling with NeqSim in Python.

It provides Python toolboxes such as thermoTools and processTools that streamline the use of NeqSim, plus direct access to the full Java API via the jneqsim gateway.

Capability What you get
Thermodynamics 60+ EOS models (SRK, PR, CPA, GERG-2008, …), flash calculations, phase envelopes
Physical properties Density, viscosity, thermal conductivity, surface tension
Process simulation 33+ equipment types — separators, compressors, heat exchangers, valves, pumps, reactors
PVT simulation CME, CVD, differential liberation, separator tests, swelling, viscosity
Pipeline & flow Steady-state multiphase pipe flow (Beggs & Brill), pipe networks

🚀 Quick Start

Install

pip (requires Java 17+)conda (Java included)
pip install neqsim
conda install -c conda-forge neqsim

Prerequisites: Python 3.10+ and Java 17+ (NeqSim 3.15+ requires Java 17 or higher; earlier NeqSim releases required Java 11+). The conda package automatically installs OpenJDK — no separate Java setup needed. For pip, install Java from Adoptium.

Try it now

from neqsim.thermo import fluid, TPflash, printFrame

# Create a natural gas fluid
fl = fluid('srk')
fl.addComponent('methane', 0.85)
fl.addComponent('ethane', 0.10)
fl.addComponent('propane', 0.05)
fl.setTemperature(25.0, 'C')
fl.setPressure(60.0, 'bara')
fl.setMixingRule('classic')

TPflash(fl)
printFrame(fl)

print(f"Gas density:    {fl.getPhase('gas').getDensity('kg/m3'):.2f} kg/m3")
print(f"Gas viscosity:  {fl.getPhase('gas').getViscosity('kg/msec'):.6f} kg/(m*s)")
print(f"Z-factor:       {fl.getPhase('gas').getZ():.4f}")

🔧 Process Simulation

NeqSim Python provides multiple ways to build process simulations:

1. Python Wrappers — recommended for beginners & notebooks

Simple functions with a global process — great for prototyping:

from neqsim.thermo import fluid
from neqsim.process import stream, compressor, separator, runProcess, clearProcess

clearProcess()
feed = fluid('srk')
feed.addComponent('methane', 0.9)
feed.addComponent('ethane', 0.1)
feed.setTemperature(30.0, 'C')
feed.setPressure(50.0, 'bara')
feed.setTotalFlowRate(10.0, 'MSm3/day')

inlet = stream('inlet', feed)
sep = separator('separator', inlet)
comp = compressor('compressor', sep.getGasOutStream(), pres=100.0)
runProcess()

print(f"Compressor power: {comp.getPower()/1e6:.2f} MW")
2. ProcessContext — recommended for production code

Context manager with explicit process control — supports multiple independent processes:

from neqsim.thermo import fluid
from neqsim.process import ProcessContext

feed = fluid('srk')
feed.addComponent('methane', 0.9)
feed.addComponent('ethane', 0.1)
feed.setTemperature(30.0, 'C')
feed.setPressure(50.0, 'bara')

with ProcessContext("Compression Train") as ctx:
    inlet = ctx.stream('inlet', feed)
    sep = ctx.separator('separator', inlet)
    comp = ctx.compressor('compressor', sep.getGasOutStream(), pres=100.0)
    ctx.run()
    print(f"Compressor power: {comp.getPower()/1e6:.2f} MW")
3. ProcessBuilder — fluent API for configuration-driven design

Chainable builder pattern:

from neqsim.thermo import fluid
from neqsim.process import ProcessBuilder

feed = fluid('srk')
feed.addComponent('methane', 0.9)
feed.addComponent('ethane', 0.1)
feed.setTemperature(30.0, 'C')
feed.setPressure(50.0, 'bara')

process = (ProcessBuilder("Compression Train")
    .add_stream('inlet', feed)
    .add_separator('separator', 'inlet')
    .add_compressor('compressor', 'separator', pressure=100.0)
    .run())

print(f"Compressor power: {process.get('compressor').getPower()/1e6:.2f} MW")
4. Direct Java Access — full control via jneqsim

Explicit process management using the Java API — for advanced features see the NeqSim Java repo:

from neqsim import jneqsim
from neqsim.thermo import fluid

feed = fluid('srk')
feed.addComponent('methane', 0.9)
feed.addComponent('ethane', 0.1)
feed.setTemperature(30.0, 'C')
feed.setPressure(50.0, 'bara')

# Create equipment using Java classes
inlet = jneqsim.process.equipment.stream.Stream('inlet', feed)
sep = jneqsim.process.equipment.separator.Separator('separator', inlet)
comp = jneqsim.process.equipment.compressor.Compressor('compressor', sep.getGasOutStream())
comp.setOutletPressure(100.0)

# Create and run process explicitly
process = jneqsim.process.processmodel.ProcessSystem()
process.add(inlet)
process.add(sep)
process.add(comp)
process.run()

print(f"Compressor power: {comp.getPower()/1e6:.2f} MW")

Choosing an Approach

Use Case Recommended Approach
Learning & prototyping Python wrappers
Jupyter notebooks Python wrappers
Production applications ProcessContext
Multiple parallel processes ProcessContext
Configuration-driven design ProcessBuilder
Advanced Java features Direct Java access

The jneqsim gateway is the first-class path for the long tail. Only a curated subset of NeqSim's ~2500 Java classes has hand-written Python wrappers. Mechanical design, safety, field development, automation, and most specialized equipment are used directly through jneqsim — no wrapper needed.


🔎 Discovering the Full API

Direct jneqsim access is powerful but hard to explore (a JPackage has no autocomplete). The neqsim.discovery module scans the API at runtime so you can list, search, and inspect every class from Python:

from neqsim import discovery

discovery.list_equipment()                 # every process-equipment class
discovery.list_packages('process')         # sub-packages of neqsim.process
discovery.find_classes('scrubber')         # search the whole API by keyword
print(discovery.describe('Compressor'))    # constructors + methods via reflection

Compressor = discovery.get_class('Compressor')   # JClass by simple or full name

For IDE autocomplete and type checking across the entire Java API, generate type stubs (already packaged as jneqsim-stubs, regenerate with python scripts/generate_stubs.py) and point your editor at src. An offline API manifest (python scripts/generate_api_manifest.py) lets discovery list, search, and describe classes instantly and JVM-free.

Typed, validated flowsheets (optional)

With pip install "neqsim[schema]" you can build flowsheets from typed pydantic models — autocomplete and validation before the JVM runs:

from neqsim.process.schema import ProcessModel, Fluid, Unit

model = ProcessModel(
    fluid=Fluid(eos="srk", components={"methane": 0.9, "ethane": 0.1}),
    process=[
        Unit(type="Stream", name="feed",
             properties={"flowRate": [50000.0, "kg/hr"], "pressure": [50.0, "bara"]}),
        Unit(type="Separator", name="HP Sep", inlet="feed"),
    ],
)
result = model.run()           # validates, builds, and runs

Component-name helpers

from neqsim.thermo.components import find_components, suggest_component
find_components("glycol")            # search the component database
suggest_component("methan")          # ['methane', 'methanol', ...] — catch typos

Rich Jupyter display

Streams and processes render as HTML tables in notebooks automatically (just display the object) — no extra call needed.

Results to pandas

One helper turns any process into a tidy stream table (works for every equipment type, because it walks the flowsheet's streams):

from neqsim.process import stream_table, equipment_table, runProcess

runProcess()
stream_table()        # one row per stream: flow, T, P, phases, density, molar mass
equipment_table()     # one row per unit: name, type, inlet/outlet counts

stream_table(my_process)   # or pass an explicit ProcessSystem / ProcessContext

🧪 PVT Simulation

NeqSim includes a pvtsimulation package for common PVT experiments (CCE/CME, CVD, differential liberation, separator tests, swelling, viscosity, etc.) and tuning workflows.


📂 Examples

Explore ready-to-run examples in the examples folder:


⚙️ Technical Notes

JPype bridges Python and Java. See the JPype installation guide for platform-specific details. Ensure Python and Java are both 64-bit (or both 32-bit) — mixing architectures will crash on import.

The full list of Python dependencies is on the dependencies page.

JVM Startup Control

By default, import neqsim starts the JVM immediately. This can be tuned via environment variables:

Variable Default Purpose
NEQSIM_JVM_AUTOSTART 1 Set to 0/false/no to disable automatic JVM startup on import. Call init_jvm() explicitly before using jneqsim.
NEQSIM_JVM_ARGS (none) Extra JVM startup arguments (space separated), appended after the default -Xrs.
NEQSIM_JVM_MAX_HEAP (none) Max JVM heap size, e.g. 2g — passed as -Xmx2g.
import os
os.environ["NEQSIM_JVM_AUTOSTART"] = "0"  # must be set before `import neqsim`

from neqsim.neqsimpython import init_jvm, is_jvm_started

print(is_jvm_started())        # False
init_jvm(jvm_args=["-Xrs"])     # start explicitly, e.g. with custom args
print(is_jvm_started())        # True

init_jvm() is safe to call multiple times — it is a no-op if the JVM is already running.


🏗️ Contributing

We welcome contributions — bug fixes, new examples, documentation improvements, and more.


📚 Documentation & Resources

Resource Link
NeqSim homepage equinor.github.io/neqsimhome
Python wiki neqsim-python/wiki
JavaDoc API JavaDoc
Discussion forum GitHub Discussions
NeqSim Java equinor/neqsim
MATLAB binding equinor/neqsimmatlab
Releases GitHub Releases

Versioning

NeqSim uses SemVer for versioning.

Authors

Even Solbraa (esolbraa@gmail.com), Marlene Louise Lund

NeqSim development was initiated at NTNU. A number of master and PhD students have contributed — we greatly acknowledge their contributions.

License

Apache-2.0

Release files for neqsim 3.20.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neqsim 3.20.0
File Size Uploaded
neqsim-3.20.0.tar.gz 57.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for neqsim 3.20.0
File Interpreter ABI Platform
neqsim-3.20.0-py3-none-any.whl Python 3 none any Details

Total release size:115.1 MB

Release files / neqsim-3.20.0.tar.gz

Download URL neqsim-3.20.0.tar.gz
Size 57.9 MB
Tags Source
SHA-256 checksum
How to use checksums
54faaedec2644b772c4224aa9a3561094600dc06a2dcd727dce05080ca587601
BLAKE2b-256 checksum
How to use checksums
892184dcd21147ab51ee0419e029c0e3016334fd4d7197cfc44a00e8fcfcbaa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release files / neqsim-3.20.0-py3-none-any.whl

Download URL neqsim-3.20.0-py3-none-any.whl
Size 57.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
bc0ebda20ff25131b81024d7d66413a1f1836458563d01eed9d9d90a2819dcbb
BLAKE2b-256 checksum
How to use checksums
d5123970e738c24713591a897f4879e7c76d4047ebc87de4e5fb64f8a2ec73e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

3.20.0 This release

2 release files

3.18.0

2 release files

3.16.0

2 release files

3.14.0

2 release files

3.12.0

2 release files

3.11.0

2 release files

3.10.0

2 release files

3.9.1

2 release files

3.9.0

2 release files

3.8.2

2 release files

3.8.0

2 release files

3.7.0

2 release files

3.6.1

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.5

2 release files

3.1.4

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.0

2 release files

3.0.50

2 release files

3.0.49

2 release files

3.0.48

2 release files

3.0.47

2 release files

3.0.43

2 release files

3.0.42

2 release files

3.0.39

2 release files

3.0.38

2 release files

3.0.30

2 release files

3.0.29

2 release files

3.0.28

2 release files

3.0.24

2 release files

3.0.22

2 release files

3.0.21

2 release files

3.0.18

2 release files

3.0.17

2 release files

3.0.16

2 release files

3.0.11

2 release files

3.0.8

2 release files

3.0.0

2 release files

2.5.35

2 release files

2.5.25

2 release files

2.5.21

2 release files

2.5.18

2 release files

2.5.14

2 release files

2.5.9

2 release files

2.5.8

2 release files

2.5.6

2 release files

2.5.5

2 release files

2.5.4

2 release files

2.5.3

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.4.14

2 release files

2.4.10

2 release files

2.4.8

2 release files

2.4.6

2 release files

2.4.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page