Skip to content

Commit 644ef50

Browse files
committed
add examples
1 parent 09daf15 commit 644ef50

10 files changed

Lines changed: 1165 additions & 0 deletions

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ print(f"Compressor power: {comp.getPower()/1e6:.2f} MW")
137137

138138
See the [examples folder](https://github.com/equinor/neqsim-python/tree/master/examples) for more process simulation examples, including [processApproaches.py](https://github.com/equinor/neqsim-python/blob/master/examples/processApproaches.py) which demonstrates all four approaches.
139139

140+
## PVT Simulation (PVTsimulation)
141+
142+
NeqSim also includes a `pvtsimulation` package for common PVT experiments (CCE/CME, CVD, differential liberation, separator tests, swelling, viscosity, etc.) and tuning workflows.
143+
144+
- Documentation: `docs/pvt_simulation.md`
145+
- Direct Java access examples: `examples/pvtsimulation/README.md`
146+
140147
### Prerequisites
141148

142149
Java version 8 or higher ([Java JDK](https://adoptium.net/)) needs to be installed. The Python package [JPype](https://github.com/jpype-project/jpype) is used to connect Python and Java. Read the [installation requirements for Jpype](https://jpype.readthedocs.io/en/latest/install.html). Be aware that mixing 64 bit Python with 32 bit Java and vice versa crashes on import of the jpype module. The needed Python packages are listed in the [NeqSim Python dependencies page](https://github.com/equinor/neqsim-python/network/dependencies).

docs/pvt_simulation.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# PVTsimulation (PVT experiments, characterization, tuning)
2+
3+
NeqSim’s `pvtsimulation` package contains common PVT laboratory experiments (CCE/CME, CVD, DL, separator tests, swelling, viscosity, etc.) and utilities for tuning fluid characterization to match measured data.
4+
5+
This repository supports two ways of running these experiments from Python:
6+
7+
1. **Python wrappers** in `neqsim.thermo` / `neqsim.thermo.thermoTools` (quickest)
8+
2. **Direct Java access** via `from neqsim import jneqsim` (full control, more outputs, tuning)
9+
10+
## Experiment coverage
11+
12+
| Experiment | Java class | Python wrapper | Example |
13+
| --- | --- | --- | --- |
14+
| Saturation pressure (bubble/dew point) | `jneqsim.pvtsimulation.simulation.SaturationPressure` | `neqsim.thermo.saturationpressure()` | `examples/pvtsimulation/pvt_experiments_java_access.py`, `examples/pvtsimulation/pvt_tuning_to_saturation.py` |
15+
| Constant mass expansion (CCE/CME) | `...ConstantMassExpansion` | `neqsim.thermo.CME()` | `examples/pvtsimulation/pvt_experiments_java_access.py`, `examples/pvtsimulation/pvt_tuning_cme.py` |
16+
| Constant volume depletion (CVD) | `...ConstantVolumeDepletion` | `neqsim.thermo.CVD()` | `examples/pvtsimulation/pvt_experiments_java_access.py`, `examples/pvtsimulation/pvt_tuning_cvd.py` |
17+
| Differential liberation (DL) | `...DifferentialLiberation` | `neqsim.thermo.difflib()` | `examples/pvtsimulation/pvt_experiments_java_access.py` |
18+
| Separator test | `...SeparatorTest` | `neqsim.thermo.separatortest()` | `examples/pvtsimulation/pvt_experiments_java_access.py` |
19+
| Swelling test | `...SwellingTest` | `neqsim.thermo.swellingtest()` | `examples/pvtsimulation/pvt_experiments_java_access.py` |
20+
| Viscosity | `...ViscositySim` | `neqsim.thermo.viscositysim()` | `examples/pvtsimulation/pvt_experiments_java_access.py`, `examples/pvtsimulation/pvt_tuning_viscosity.py` |
21+
| GOR / Bo | `...GOR` | `neqsim.thermo.GOR()` | `examples/pvtsimulation/pvt_experiments_java_access.py` |
22+
23+
Other available simulations (direct Java access):
24+
25+
- `jneqsim.pvtsimulation.simulation.WaxFractionSim` (wax appearance / wax fraction vs T,P; requires wax model setup)
26+
- `jneqsim.pvtsimulation.simulation.ViscosityWaxOilSim` (wax + viscosity)
27+
- `jneqsim.pvtsimulation.simulation.DensitySim`
28+
- `jneqsim.pvtsimulation.simulation.SlimTubeSim` (slim-tube style displacement simulation)
29+
30+
## Direct Java access: key patterns
31+
32+
### Passing arrays
33+
34+
Many PVTsimulation methods expect Java `double[]`. With JPype you can pass:
35+
36+
- A Python list (often auto-converted), or
37+
- An explicit `double[]` using `jpype.types.JDouble[:]`
38+
39+
Example:
40+
41+
```python
42+
from jpype.types import JDouble
43+
from neqsim import jneqsim
44+
45+
pressures = [400.0, 300.0, 200.0]
46+
temperatures = [373.15, 373.15, 373.15]
47+
48+
cme = jneqsim.pvtsimulation.simulation.ConstantMassExpansion(oil)
49+
cme.setTemperaturesAndPressures(JDouble[:](temperatures), JDouble[:](pressures))
50+
cme.runCalc()
51+
```
52+
53+
### Experimental data for tuning
54+
55+
For several experiments, NeqSim expects `double[1][n]` experimental data, i.e. a single row with `n` values aligned with your pressure/temperature points:
56+
57+
```python
58+
cme.setExperimentalData([[0.98, 1.02, 1.10]]) # relative volume values
59+
cme.runTuning()
60+
```
61+
62+
## Fluid characterization + PVT lumping
63+
64+
See `examples/pvtsimulation/fluid_characterization_and_lumping.py` for a typical black-oil characterization workflow using:
65+
66+
- `addTBPfraction(...)` and `addPlusFraction(...)`
67+
- `getCharacterization().setLumpingModel("PVTlumpingModel")`
68+
- `getCharacterization().characterisePlusFraction()`
69+
70+
## Run the examples
71+
72+
```bash
73+
python examples/pvtsimulation/pvt_experiments_java_access.py
74+
python examples/pvtsimulation/pvt_tuning_to_saturation.py
75+
python examples/pvtsimulation/pvt_tuning_cme.py
76+
python examples/pvtsimulation/pvt_tuning_cvd.py
77+
python examples/pvtsimulation/pvt_tuning_viscosity.py
78+
```
79+
80+
Tuning scripts default to skipping the actual tuning step; set `run_tuning = True` inside the script when you are ready to tune against measured data.

0 commit comments

Comments
 (0)