Skip to content

Commit e0c2af2

Browse files
authored
Merge pull request #343 from equinor/pvtupdate
add pvt examples
2 parents 09daf15 + 3cac95c commit e0c2af2

File tree

14 files changed

+1404
-55
lines changed

14 files changed

+1404
-55
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@ poetry.lock
3737

3838
test_gasoilprocess.zip
3939
test_gasoilprocess.neqsim
40+
41+
# Local CodeQL artifacts
42+
codeql-db/
43+
codeql-*.sarif
44+
tools/codeql/

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,14 @@ 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-
### Prerequisites
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+
147+
## 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).
143150

docs/pvt_simulation.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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 (auto-converted to `double[]` by JPype)
37+
38+
Example:
39+
40+
```python
41+
from neqsim import jneqsim
42+
43+
pressures = [400.0, 300.0, 200.0]
44+
temperatures = [373.15, 373.15, 373.15]
45+
46+
cme = jneqsim.pvtsimulation.simulation.ConstantMassExpansion(oil)
47+
cme.setTemperaturesAndPressures(temperatures, pressures)
48+
cme.runCalc()
49+
```
50+
51+
### Experimental data for tuning
52+
53+
For several experiments, NeqSim expects `double[1][n]` experimental data, i.e. a single row with `n` values aligned with your pressure/temperature points:
54+
55+
```python
56+
cme.setExperimentalData([[0.98, 1.02, 1.10]]) # relative volume values
57+
cme.runTuning()
58+
```
59+
60+
## Fluid characterization + PVT lumping
61+
62+
See `examples/pvtsimulation/fluid_characterization_and_lumping.py` for a typical black-oil characterization workflow using:
63+
64+
- `addTBPfraction(...)` and `addPlusFraction(...)`
65+
- `getCharacterization().setLumpingModel("PVTlumpingModel")`
66+
- `getCharacterization().characterisePlusFraction()`
67+
68+
## Run the examples
69+
70+
```bash
71+
python examples/pvtsimulation/pvt_experiments_java_access.py
72+
python examples/pvtsimulation/pvt_tuning_to_saturation.py
73+
python examples/pvtsimulation/pvt_tuning_cme.py
74+
python examples/pvtsimulation/pvt_tuning_cvd.py
75+
python examples/pvtsimulation/pvt_tuning_viscosity.py
76+
```
77+
78+
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)