Skip to content

Commit

Permalink
fix: changed package name
Browse files Browse the repository at this point in the history
  • Loading branch information
asmfstatoil committed Oct 28, 2024
1 parent cbcad08 commit 2385029
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 115 deletions.
242 changes: 133 additions & 109 deletions examples/jupyter/examplesInPython.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
}
],
"source": [
"thermoSystem = jneqsim.thermo.system.SystemSrkEos(280.0,10.0)\n",
"thermoSystem = jneqsim.thermo.system.SystemSrkEos(280.0, 10.0)\n",
"thermoSystem.addComponent(\"methane\", 10.0)\n",
"thermoSystem.addComponent(\"water\", 4.0)\n",
"\n",
"thermoOps = jneqsim.thermodynamicoperations.ThermodynamicOperations(thermoSystem)\n",
"thermoOps.TPflash()\n",
"\n",
"#thermoSystem.display()\n",
"# thermoSystem.display()\n",
"\n",
"gasEnthalpy = thermoSystem.getPhase(0).getEnthalpy()\n",
"\n",
Expand Down Expand Up @@ -101,7 +101,7 @@
}
],
"source": [
"thermoSystem = jneqsim.thermo.system.SystemSrkEos(280.0,10.0)\n",
"thermoSystem = jneqsim.thermo.system.SystemSrkEos(280.0, 10.0)\n",
"thermoSystem.addComponent(\"nitrogen\", 1.0)\n",
"thermoSystem.addComponent(\"methane\", 70.0)\n",
"thermoSystem.addComponent(\"ethane\", 4.0)\n",
Expand All @@ -112,11 +112,19 @@
"thermoOps = jneqsim.thermodynamicoperations.ThermodynamicOperations(thermoSystem)\n",
"thermoOps.calcPTphaseEnvelope()\n",
"\n",
"plt.plot(list(thermoOps.getOperation().get(\"dewT\")),list(thermoOps.getOperation().get(\"dewP\")), label=\"dew point\")\n",
"plt.plot(list(thermoOps.getOperation().get(\"bubT\")),list(thermoOps.getOperation().get(\"bubP\")), label=\"bubble point\")\n",
"plt.title('PT envelope')\n",
"plt.xlabel('Temperature [\\u00B0C]')\n",
"plt.ylabel('Pressure [bar]')\n",
"plt.plot(\n",
" list(thermoOps.getOperation().get(\"dewT\")),\n",
" list(thermoOps.getOperation().get(\"dewP\")),\n",
" label=\"dew point\",\n",
")\n",
"plt.plot(\n",
" list(thermoOps.getOperation().get(\"bubT\")),\n",
" list(thermoOps.getOperation().get(\"bubP\")),\n",
" label=\"bubble point\",\n",
")\n",
"plt.title(\"PT envelope\")\n",
"plt.xlabel(\"Temperature [\\u00B0C]\")\n",
"plt.ylabel(\"Pressure [bar]\")\n",
"plt.legend()\n",
"plt.show()"
]
Expand All @@ -142,16 +150,16 @@
}
],
"source": [
"thermoSystem = jneqsim.thermo.system.SystemSrkEos(280.0,60.0)\n",
"thermoSystem = jneqsim.thermo.system.SystemSrkEos(280.0, 60.0)\n",
"thermoSystem.addComponent(\"methane\", 90.0)\n",
"thermoSystem.addComponent(\"ethane\", 10.0)\n",
"thermoSystem.addComponent(\"propane\", 1.0)\n",
"thermoSystem.addComponent(\"water\", 4.0)\n",
"thermoSystem.setHydrateCheck(True);\n",
"thermoSystem.setHydrateCheck(True)\n",
"thermoOps = jneqsim.thermodynamicoperations.ThermodynamicOperations(thermoSystem)\n",
"thermoOps.hydrateFormationTemperature()\n",
"\n",
"print(\"Hydrate equilibrium temperature \", thermoSystem.getTemperature()-273.15, \" C\")"
"print(\"Hydrate equilibrium temperature \", thermoSystem.getTemperature() - 273.15, \" C\")"
]
},
{
Expand Down Expand Up @@ -188,25 +196,25 @@
}
],
"source": [
"thermoSystem = jneqsim.thermo.system.SystemSrkEos(280.0,60.0)\n",
"thermoSystem = jneqsim.thermo.system.SystemSrkEos(280.0, 60.0)\n",
"thermoSystem.addComponent(\"nitrogen\", 2.0)\n",
"thermoSystem.addComponent(\"CO2\", 1.0)\n",
"thermoSystem.addComponent(\"methane\", 10.0)\n",
"thermoSystem.addComponent(\"ethane\", 10.0)\n",
"thermoSystem.addComponent(\"propane\", 1.0)\n",
"thermoSystem.addTBPfraction(\"C6\", 0.428, 86.178 / 1000.0, 0.664);\n",
"thermoSystem.addTBPfraction(\"C7\", 0.626, 96.00 / 1000.0, 0.738);\n",
"thermoSystem.addTBPfraction(\"C8\", 0.609, 107.0 / 1000.0, 0.765);\n",
"thermoSystem.addTBPfraction(\"C9\", 0.309, 121.0 / 1000.0, 0.781);\n",
"thermoSystem.addPlusFraction(\"C10\", 5.137, 231.0 / 1000.0, 0.8301);\n",
"thermoSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(12);\n",
"thermoSystem.getCharacterization().characterisePlusFraction();\n",
"thermoSystem.addTBPfraction(\"C6\", 0.428, 86.178 / 1000.0, 0.664)\n",
"thermoSystem.addTBPfraction(\"C7\", 0.626, 96.00 / 1000.0, 0.738)\n",
"thermoSystem.addTBPfraction(\"C8\", 0.609, 107.0 / 1000.0, 0.765)\n",
"thermoSystem.addTBPfraction(\"C9\", 0.309, 121.0 / 1000.0, 0.781)\n",
"thermoSystem.addPlusFraction(\"C10\", 5.137, 231.0 / 1000.0, 0.8301)\n",
"thermoSystem.getCharacterization().getLumpingModel().setNumberOfLumpedComponents(12)\n",
"thermoSystem.getCharacterization().characterisePlusFraction()\n",
"thermoSystem.setMixingRule(2)\n",
"\n",
"thermoOps = jneqsim.thermodynamicoperations.ThermodynamicOperations(thermoSystem)\n",
"thermoOps.TPflash()\n",
"\n",
"#thermoSystem.display()\n",
"# thermoSystem.display()\n",
"\n",
"thermoSystem.initPhysicalProperties(\"Density\")\n",
"gasDensity = thermoSystem.getPhase(\"gas\").getDensity(\"kg/m3\")\n",
Expand All @@ -218,11 +226,19 @@
"thermoOps = jneqsim.thermodynamicoperations.ThermodynamicOperations(thermoSystem)\n",
"thermoOps.calcPTphaseEnvelope()\n",
"\n",
"plt.plot(list(thermoOps.getOperation().get(\"dewT\")),list(thermoOps.getOperation().get(\"dewP\")), label=\"dew point\")\n",
"plt.plot(list(thermoOps.getOperation().get(\"bubT\")),list(thermoOps.getOperation().get(\"bubP\")), label=\"bubble point\")\n",
"plt.title('PT envelope')\n",
"plt.xlabel('Temperature [\\u00B0C]')\n",
"plt.ylabel('Pressure [bar]')\n",
"plt.plot(\n",
" list(thermoOps.getOperation().get(\"dewT\")),\n",
" list(thermoOps.getOperation().get(\"dewP\")),\n",
" label=\"dew point\",\n",
")\n",
"plt.plot(\n",
" list(thermoOps.getOperation().get(\"bubT\")),\n",
" list(thermoOps.getOperation().get(\"bubP\")),\n",
" label=\"bubble point\",\n",
")\n",
"plt.title(\"PT envelope\")\n",
"plt.xlabel(\"Temperature [\\u00B0C]\")\n",
"plt.ylabel(\"Pressure [bar]\")\n",
"plt.legend()\n",
"plt.show()"
]
Expand Down Expand Up @@ -251,67 +267,73 @@
"source": [
"processequipment = jneqsim.processsimulation.processequipment\n",
"\n",
"testSystem = jneqsim.thermo.system.SystemSrkEos((273.15+50.0),50.00);\n",
"testSystem.addComponent(\"methane\", 900.00);\n",
"testSystem.addComponent(\"ethane\", 200.00);\n",
"testSystem.addComponent(\"n-hexane\", 200.0);\n",
"testSystem.addComponent(\"n-nonane\", 200.0);\n",
"testSystem.addComponent(\"nC10\", 20.0);\n",
"testSystem.addComponent(\"nC13\", 10.0);\n",
"testSystem.setMixingRule(2);\n",
"\n",
"stream_1 = processequipment.stream.Stream(\"Stream1\", testSystem);\n",
" \n",
"mixerHP = processequipment.mixer.StaticMixer(\"Mixer HP\");\n",
"mixerHP.addStream(stream_1);\n",
" \n",
"separator = processequipment.separator.Separator(\"Separator 1\", mixerHP.getOutStream());\n",
" \n",
"LP_valve = processequipment.valve.ThrottlingValve(\"LPventil\", separator.getLiquidOutStream());\n",
"LP_valve.setOutletPressure(5.0);\n",
" \n",
"LPseparator = processequipment.separator.Separator(\"Separator 1\", LP_valve.getOutStream());\n",
" \n",
"LPcompressor = processequipment.compressor.Compressor(LPseparator.getGasOutStream());\n",
"LPcompressor.setOutletPressure(50.0);\n",
" \n",
"heaterLP = processequipment.heatExchanger.Heater(LPcompressor.getOutStream());\n",
"heaterLP.setOutTemperature(270.25);\n",
" \n",
"stream_2 = processequipment.stream.Stream(\"cooled gas\",heaterLP.getOutStream());\n",
" \n",
"gasScrubber = processequipment.separator.GasScrubberSimple(\"Scrubber\", stream_2);\n",
"testSystem = jneqsim.thermo.system.SystemSrkEos((273.15 + 50.0), 50.00)\n",
"testSystem.addComponent(\"methane\", 900.00)\n",
"testSystem.addComponent(\"ethane\", 200.00)\n",
"testSystem.addComponent(\"n-hexane\", 200.0)\n",
"testSystem.addComponent(\"n-nonane\", 200.0)\n",
"testSystem.addComponent(\"nC10\", 20.0)\n",
"testSystem.addComponent(\"nC13\", 10.0)\n",
"testSystem.setMixingRule(2)\n",
"\n",
"stream_1 = processequipment.stream.Stream(\"Stream1\", testSystem)\n",
"\n",
"mixerHP = processequipment.mixer.StaticMixer(\"Mixer HP\")\n",
"mixerHP.addStream(stream_1)\n",
"\n",
"separator = processequipment.separator.Separator(\"Separator 1\", mixerHP.getOutStream())\n",
"\n",
"LP_valve = processequipment.valve.ThrottlingValve(\n",
" \"LPventil\", separator.getLiquidOutStream()\n",
")\n",
"LP_valve.setOutletPressure(5.0)\n",
"\n",
"LPseparator = processequipment.separator.Separator(\n",
" \"Separator 1\", LP_valve.getOutStream()\n",
")\n",
"\n",
"LPcompressor = processequipment.compressor.Compressor(LPseparator.getGasOutStream())\n",
"LPcompressor.setOutletPressure(50.0)\n",
"\n",
"heaterLP = processequipment.heatexchanger.Heater(LPcompressor.getOutStream())\n",
"heaterLP.setOutTemperature(270.25)\n",
"\n",
"stream_2 = processequipment.stream.Stream(\"cooled gas\", heaterLP.getOutStream())\n",
"\n",
"gasScrubber = processequipment.separator.GasScrubberSimple(\"Scrubber\", stream_2)\n",
"gasScrubber.setInletStream(stream_2)\n",
" \n",
"stream_3 = processequipment.stream.Stream(\"liq from scrubber gas\",gasScrubber.getLiquidOutStream());\n",
" \n",
"mixerHP.addStream(stream_3);\n",
" \n",
"mixer = processequipment.mixer.StaticMixer(\"Mixer export\");\n",
"mixer.addStream(separator.getGasOutStream());\n",
"mixer.addStream(gasScrubber.getGasOutStream());\n",
" \n",
"HPcompressor = processequipment.compressor.Compressor(mixer.getOutStream());\n",
"HPcompressor.setOutletPressure(200.0);\n",
" \n",
"operations = jneqsim.processsimulation.processsystem.ProcessSystem();\n",
"operations.add(stream_1);\n",
"operations.add(mixerHP);\n",
"operations.add(separator);\n",
"operations.add(LP_valve);\n",
"operations.add(LPseparator);\n",
"operations.add(LPcompressor);\n",
"operations.add(heaterLP);\n",
"operations.add(stream_2);\n",
"operations.add(gasScrubber);\n",
"operations.add(stream_3);\n",
"operations.add(mixer);\n",
"operations.add(HPcompressor);\n",
" \n",
"operations.run();\n",
"\n",
"print(\"LP compressor power \", LPcompressor.getPower()/1000.0, \" kW\")\n",
"print(\"HP compressor power \", HPcompressor.getPower()/1000.0, \" kW\")"
"\n",
"stream_3 = processequipment.stream.Stream(\n",
" \"liq from scrubber gas\", gasScrubber.getLiquidOutStream()\n",
")\n",
"\n",
"mixerHP.addStream(stream_3)\n",
"\n",
"mixer = processequipment.mixer.StaticMixer(\"Mixer export\")\n",
"mixer.addStream(separator.getGasOutStream())\n",
"mixer.addStream(gasScrubber.getGasOutStream())\n",
"\n",
"HPcompressor = processequipment.compressor.Compressor(mixer.getOutStream())\n",
"HPcompressor.setOutletPressure(200.0)\n",
"\n",
"operations = jneqsim.processsimulation.processsystem.ProcessSystem()\n",
"operations.add(stream_1)\n",
"operations.add(mixerHP)\n",
"operations.add(separator)\n",
"operations.add(LP_valve)\n",
"operations.add(LPseparator)\n",
"operations.add(LPcompressor)\n",
"operations.add(heaterLP)\n",
"operations.add(stream_2)\n",
"operations.add(gasScrubber)\n",
"operations.add(stream_3)\n",
"operations.add(mixer)\n",
"operations.add(HPcompressor)\n",
"\n",
"operations.run()\n",
"\n",
"print(\"LP compressor power \", LPcompressor.getPower() / 1000.0, \" kW\")\n",
"print(\"HP compressor power \", HPcompressor.getPower() / 1000.0, \" kW\")"
]
},
{
Expand Down Expand Up @@ -351,37 +373,39 @@
}
],
"source": [
"thermoSystem = jneqsim.thermo.system.SystemSrkEos(280.0,10.0)\n",
"thermoSystem = jneqsim.thermo.system.SystemSrkEos(280.0, 10.0)\n",
"thermoSystem.addComponent(\"methane\", 10.0)\n",
"thermoSystem.addComponent(\"ethane\", 4.0)\n",
"\n",
"thermoOps = jneqsim.thermodynamicoperations.ThermodynamicOperations(thermoSystem)\n",
"thermoOps.TPflash()\n",
"\n",
"\n",
"def enthalpy(P):\n",
" thermoSystem.setPressure(P)\n",
" thermoSystem.init(3)\n",
" return thermoSystem.getEnthalpy(\"kJ/kg\")\n",
"\n",
"\n",
"def entropy(P):\n",
" thermoSystem.setPressure(P)\n",
" thermoSystem.init(3)\n",
" return thermoSystem.getEntropy(\"kJ/kgK\")\n",
"\n",
"\n",
"pressure = np.arange(1.0, 200.0, 5.0)\n",
"enthalpy = [enthalpy(P) for P in pressure]\n",
"entropy = [entropy(P) for P in pressure]\n",
"\n",
"plt.subplot(2, 1, 1)\n",
"plt.plot(pressure, enthalpy)\n",
"plt.xlabel('Pressure [bara]')\n",
"plt.ylabel('Enthalpy [kJ/kg]')\n",
"plt.xlabel(\"Pressure [bara]\")\n",
"plt.ylabel(\"Enthalpy [kJ/kg]\")\n",
"\n",
"plt.subplot(2, 1, 2)\n",
"plt.plot(pressure, entropy)\n",
"plt.xlabel('Pressure [bara]')\n",
"plt.ylabel('Entropy [kJ/kgK]')\n",
" "
"plt.xlabel(\"Pressure [bara]\")\n",
"plt.ylabel(\"Entropy [kJ/kgK]\")"
]
},
{
Expand All @@ -406,10 +430,10 @@
}
],
"source": [
"fluid1 = fluid('srk')\n",
"fluid1.addComponent('methane',10.0)\n",
"fluid1.addComponent('n-heptane',2.0)\n",
"fluid1.addComponent('water',3.0)\n",
"fluid1 = fluid(\"srk\")\n",
"fluid1.addComponent(\"methane\", 10.0)\n",
"fluid1.addComponent(\"n-heptane\", 2.0)\n",
"fluid1.addComponent(\"water\", 3.0)\n",
"fluid1.setMixingRule(2)\n",
"fluid1.setMultiPhaseCheck(True)\n",
"TPflash(fluid1)\n",
Expand All @@ -422,13 +446,13 @@
"metadata": {},
"outputs": [],
"source": [
"fluid1 = fluid('srk')\n",
"fluid1.addComponent('methane',10.0)\n",
"fluid1.addComponent('n-heptane',2.0)\n",
"fluid1 = fluid(\"srk\")\n",
"fluid1.addComponent(\"methane\", 10.0)\n",
"fluid1.addComponent(\"n-heptane\", 2.0)\n",
"fluid1.setMixingRule(2)\n",
"TPflash(fluid1)\n",
"\n",
"print('density ',fluid1.getPhase('gas').getDensity(),' kg/m3')"
"print(\"density \", fluid1.getPhase(\"gas\").getDensity(), \" kg/m3\")"
]
},
{
Expand All @@ -449,27 +473,27 @@
}
],
"source": [
"fluid1 = fluid('srk')\n",
"fluid1.addComponent('n-heptane',49.39)\n",
"#fluid1.addComponent('methane',50.61)\n",
"fluid1 = fluid(\"srk\")\n",
"fluid1.addComponent(\"n-heptane\", 49.39)\n",
"# fluid1.addComponent('methane',50.61)\n",
"fluid1.setMixingRule(2)\n",
"fluid1.setTemperature(267.12)\n",
"fluid1.setPressure(17.91)\n",
"#fluid1.useVolumeCorrection(True)\n",
"# fluid1.useVolumeCorrection(True)\n",
"TPflash(fluid1)\n",
"fluid1.initPhysicalProperties()\n",
"\n",
"print('density ',fluid1.getPhase('oil').getDensity(),' kg/m3')\n",
"print('conductivity ',fluid1.getPhase('oil').getConductivity())\n",
"fluid1.getPhase(0).getPhysicalProperties().setConductivityModel(\"PFCT\");\n",
"print(\"density \", fluid1.getPhase(\"oil\").getDensity(), \" kg/m3\")\n",
"print(\"conductivity \", fluid1.getPhase(\"oil\").getConductivity())\n",
"fluid1.getPhase(0).getPhysicalProperties().setConductivityModel(\"PFCT\")\n",
"fluid1.initPhysicalProperties()\n",
"print('conductivity ',fluid1.getPhase('oil').getConductivity())"
"print(\"conductivity \", fluid1.getPhase(\"oil\").getConductivity())"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "neqsim",
"language": "python",
"name": "python3"
},
Expand All @@ -483,7 +507,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 2385029

Please sign in to comment.