|
| 1 | +# NeqSim — Fast Context for Task Solving |
| 2 | + |
| 3 | +> **Purpose:** Get oriented in 60 seconds. This file is the single entry point for anyone |
| 4 | +> (human or AI) solving engineering tasks inside the NeqSim repo. |
| 5 | +
|
| 6 | +## What Is NeqSim? |
| 7 | + |
| 8 | +Java library for thermodynamic fluid properties and process simulation. |
| 9 | +Developed at NTNU, maintained by Equinor. Apache-2.0 license. |
| 10 | +`com.equinor.neqsim:neqsim` version 3.4.0 — **must compile with Java 8**. |
| 11 | + |
| 12 | +## Repo Map |
| 13 | + |
| 14 | +``` |
| 15 | +src/main/java/neqsim/ |
| 16 | + thermo/system/ 60 EOS classes (SystemSrkEos, SystemPrEos, ...) |
| 17 | + thermo/phase/ Phase implementations |
| 18 | + thermodynamicoperations/ Flash calculations (TP, PH, PS, dew, bubble) |
| 19 | + physicalproperties/ Density, viscosity, conductivity, surface tension |
| 20 | + process/equipment/ 33 equipment packages: |
| 21 | + stream/ separator/ compressor/ pump/ valve/ heatexchanger/ |
| 22 | + pipeline/ distillation/ mixer/ splitter/ expander/ reactor/ |
| 23 | + well/ reservoir/ membrane/ ejector/ filter/ flare/ ... |
| 24 | + process/processmodel/ ProcessSystem — the flowsheet orchestrator |
| 25 | + pvtsimulation/ CME, CVD, DL, saturation, GOR, swelling, MMP |
| 26 | + standards/ Gas quality, oil quality, sales contracts |
| 27 | + fluidmechanics/ Pipeline hydraulics |
| 28 | + chemicalreactions/ Reaction equilibrium/kinetics |
| 29 | + statistics/ Parameter fitting, Monte Carlo |
| 30 | + util/ Validation, exceptions, named interfaces |
| 31 | +
|
| 32 | +src/test/java/neqsim/ Mirrors production structure. JUnit 5. Extend NeqSimTest. |
| 33 | +src/main/resources/ Component databases, design data CSVs |
| 34 | +examples/notebooks/ 28+ Jupyter notebooks |
| 35 | +docs/ 350+ markdown files, Jekyll site |
| 36 | +.github/agents/ 12 Copilot Chat agents (thermo, process, test, PVT, ...) |
| 37 | +devtools/ neqsim_dev_setup.py for Jupyter development |
| 38 | +``` |
| 39 | + |
| 40 | +## Build & Test (30 seconds) |
| 41 | + |
| 42 | +```powershell |
| 43 | +# Full build |
| 44 | +.\mvnw.cmd install |
| 45 | +
|
| 46 | +# Tests only |
| 47 | +.\mvnw.cmd test |
| 48 | +
|
| 49 | +# Single test class |
| 50 | +.\mvnw.cmd test -Dtest=SeparatorTest |
| 51 | +
|
| 52 | +# Single test method |
| 53 | +.\mvnw.cmd test -Dtest=SeparatorTest#testTwoPhase |
| 54 | +
|
| 55 | +# Skip slow tests (default) |
| 56 | +.\mvnw.cmd test # excludes @Tag("slow") |
| 57 | +.\mvnw.cmd test -DexcludedTestGroups= # runs everything |
| 58 | +
|
| 59 | +# Static analysis |
| 60 | +.\mvnw.cmd checkstyle:check spotbugs:check pmd:check |
| 61 | +
|
| 62 | +# Package JAR + copy to Python |
| 63 | +.\mvnw.cmd package -DskipTests |
| 64 | +Copy-Item target\neqsim-3.3.0.jar C:\Users\ESOL\AppData\Roaming\Python\Python312\site-packages\neqsim\lib\java11\ -Force |
| 65 | +``` |
| 66 | + |
| 67 | +## Code Patterns — Copy-Paste Starters |
| 68 | + |
| 69 | +### Create a Fluid |
| 70 | + |
| 71 | +```java |
| 72 | +SystemInterface fluid = new SystemSrkEos(273.15 + 25.0, 60.0); // T in Kelvin, P in bara |
| 73 | +fluid.addComponent("methane", 0.85); |
| 74 | +fluid.addComponent("ethane", 0.10); |
| 75 | +fluid.addComponent("propane", 0.05); |
| 76 | +fluid.setMixingRule("classic"); // NEVER skip this |
| 77 | +``` |
| 78 | + |
| 79 | +### Run a Flash |
| 80 | + |
| 81 | +```java |
| 82 | +ThermodynamicOperations ops = new ThermodynamicOperations(fluid); |
| 83 | +ops.TPflash(); |
| 84 | +fluid.init(3); // full property init after flash |
| 85 | +double density = fluid.getDensity("kg/m3"); |
| 86 | +double viscosity = fluid.getPhase("gas").getViscosity("kg/msec"); |
| 87 | +``` |
| 88 | + |
| 89 | +### Build a Process |
| 90 | + |
| 91 | +```java |
| 92 | +ProcessSystem process = new ProcessSystem(); |
| 93 | + |
| 94 | +Stream feed = new Stream("feed", fluid); |
| 95 | +feed.setFlowRate(50000.0, "kg/hr"); |
| 96 | +feed.setTemperature(30.0, "C"); |
| 97 | +feed.setPressure(60.0, "bara"); |
| 98 | +process.add(feed); |
| 99 | + |
| 100 | +Separator sep = new Separator("HP Sep", feed); |
| 101 | +process.add(sep); |
| 102 | + |
| 103 | +Compressor comp = new Compressor("Compressor", sep.getGasOutStream()); |
| 104 | +comp.setOutletPressure(120.0, "bara"); |
| 105 | +process.add(comp); |
| 106 | + |
| 107 | +process.run(); |
| 108 | +System.out.println("Compressor power: " + comp.getPower("kW") + " kW"); |
| 109 | +``` |
| 110 | + |
| 111 | +### Write a Test |
| 112 | + |
| 113 | +```java |
| 114 | +public class MyFeatureTest extends neqsim.NeqSimTest { |
| 115 | + @Test |
| 116 | + void testSomething() { |
| 117 | + // 1. Create fluid |
| 118 | + // 2. Build process |
| 119 | + // 3. process.run() |
| 120 | + // 4. Assert on physical outputs |
| 121 | + assertEquals(expected, actual, tolerance); |
| 122 | + } |
| 123 | +} |
| 124 | +``` |
| 125 | + |
| 126 | +### Jupyter Notebook (Python) |
| 127 | + |
| 128 | +```python |
| 129 | +from neqsim import jneqsim |
| 130 | +SystemSrkEos = jneqsim.thermo.system.SystemSrkEos |
| 131 | +Stream = jneqsim.process.equipment.stream.Stream |
| 132 | +# ... see devtools/neqsim_dev_setup.py for local dev workflow |
| 133 | +``` |
| 134 | + |
| 135 | +## EOS Selection Quick Reference |
| 136 | + |
| 137 | +| Fluid Type | Class | Mixing Rule | |
| 138 | +|------------|-------|-------------| |
| 139 | +| Dry/lean gas | `SystemSrkEos` | `"classic"` | |
| 140 | +| Oil systems | `SystemPrEos` | `"classic"` | |
| 141 | +| Water/MEG/methanol | `SystemSrkCPAstatoil` | `10` | |
| 142 | +| Fiscal metering | `SystemGERG2008Eos` | — | |
| 143 | +| Electrolytes | `SystemElectrolyteCPAstatoil` | `10` | |
| 144 | + |
| 145 | +## Equipment Package → Class Cheat Sheet |
| 146 | + |
| 147 | +| Equipment | Package | Key Class | |
| 148 | +|-----------|---------|-----------| |
| 149 | +| Stream | `stream` | `Stream`, `EquilibriumStream` | |
| 150 | +| Separator | `separator` | `Separator`, `ThreePhaseSeparator` | |
| 151 | +| Compressor | `compressor` | `Compressor` | |
| 152 | +| Pump | `pump` | `Pump` | |
| 153 | +| Valve | `valve` | `ThrottlingValve` | |
| 154 | +| Heat exchanger | `heatexchanger` | `Cooler`, `Heater`, `HeatExchanger` | |
| 155 | +| Pipeline | `pipeline` | `AdiabaticPipe`, `PipeBeggsAndBrills` | |
| 156 | +| Mixer | `mixer` | `Mixer` | |
| 157 | +| Splitter | `splitter` | `Splitter` | |
| 158 | +| Distillation | `distillation` | `DistillationColumn` | |
| 159 | +| Expander | `expander` | `Expander` | |
| 160 | +| Ejector | `ejector` | `Ejector` | |
| 161 | +| Well | `well` | `SimpleWell` | |
| 162 | +| Recycle | `util` | `Recycle` | |
| 163 | +| Adjuster | `util` | `Adjuster` | |
| 164 | + |
| 165 | +Full package path: `neqsim.process.equipment.<package>.<Class>` |
| 166 | + |
| 167 | +## Where to Find Things |
| 168 | + |
| 169 | +| I need to... | Look in... | |
| 170 | +|-------------|-----------| |
| 171 | +| Pick an EOS | `src/main/java/neqsim/thermo/system/` | |
| 172 | +| Add equipment | `src/main/java/neqsim/process/equipment/<type>/` | |
| 173 | +| Run a PVT experiment | `src/main/java/neqsim/pvtsimulation/simulation/` | |
| 174 | +| Check gas quality | `src/main/java/neqsim/standards/gasquality/` | |
| 175 | +| See a working example | `examples/notebooks/` or `src/test/java/neqsim/process/` | |
| 176 | +| Read documentation | `docs/wiki/` (60+ topics) or `docs/REFERENCE_MANUAL_INDEX.md` | |
| 177 | +| Use an AI agent | `.github/agents/` (12 specialist agents) | |
| 178 | +| Set up Jupyter dev | `devtools/neqsim_dev_setup.py` | |
| 179 | +| Find design data | `src/main/resources/designdata/` | |
| 180 | +| Component database | `src/main/resources/` | |
| 181 | + |
| 182 | +## Key Constraints |
| 183 | + |
| 184 | +- **Java 8 only** — no `var`, `List.of()`, `Map.of()`, `String.repeat()`, text blocks, records |
| 185 | +- **Temperature in Kelvin** — constructors take `(T_kelvin, P_bara)` |
| 186 | +- **Always set mixing rule** — simulations fail silently without it |
| 187 | +- **Unique equipment names** — `ProcessSystem` enforces unique names |
| 188 | +- **Clone before branching** — `fluid.clone()` to avoid shared state |
| 189 | +- **Google Java Style** — 2-space indent, checkstyle enforced |
| 190 | + |
| 191 | +## Deeper Context |
| 192 | + |
| 193 | +| Topic | File | |
| 194 | +|-------|------| |
| 195 | +| Full AI coding instructions | `.github/copilot-instructions.md` | |
| 196 | +| Task-solving workflow | `docs/development/TASK_SOLVING_GUIDE.md` | |
| 197 | +| Solved task history | `docs/development/TASK_LOG.md` | |
| 198 | +| Developer setup | `docs/development/DEVELOPER_SETUP.md` | |
| 199 | +| Module architecture | `docs/modules.md` | |
| 200 | +| Contributing guide | `CONTRIBUTING.md` | |
| 201 | +| All documentation index | `docs/REFERENCE_MANUAL_INDEX.md` | |
0 commit comments