Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixex2 #312

Merged
merged 6 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"ms-python.pylint",
"ms-python.black-formatter",
"ms-python.flake8",
"ms-python.pylint"
"ms-python.pylint",
"GitHub.copilot",
"GitHub.copilot-chat"
]
}
},
Expand Down
16 changes: 16 additions & 0 deletions examples/CO2deprezzurizing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# -*- coding: utf-8 -*-
"""
This script demonstrates the process of CO2 depressurization using the NeqSim library.

The script performs the following steps:
1. Creates a fluid object using the SRK equation of state.
2. Adds 100 moles of CO2 to the fluid.
3. Sets the initial temperature to -25°C and pressure to 18 bara.
4. Enables multi-phase and solid-phase checks for CO2.
5. Performs a temperature-pressure (TP) flash calculation.
6. Calculates the bubble point temperature.
7. Prints the fluid properties before depressurization.
8. Initializes the fluid properties and calculates the enthalpy.
9. Sets the pressure to 1 bara and performs a pressure-enthalpy (PH) flash calculation.
10. Prints the fluid properties after depressurization.

The script also includes commented-out lines for performing dew point and solid phase flash calculations.

Created on Tue Jun 23 10:37:26 2020

@author: ESOL
Expand Down
47 changes: 42 additions & 5 deletions examples/CarnotCycle.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# -*- coding: utf-8 -*-
"""
This script simulates a Carnot cycle using the neqsim library for thermodynamic calculations.

The Carnot cycle consists of four main processes:
1. Isothermal Expansion (1-2): Heat is transferred reversibly from a high-temperature reservoir at constant temperature.
2. Isentropic Expansion (2-3): Reversible adiabatic expansion of the gas, resulting in work output.
3. Isothermal Compression (3-4): Heat is transferred reversibly to a low-temperature reservoir at constant temperature.
4. Adiabatic Reversible Compression (4-1): The gas is compressed adiabatically and reversibly.

The script performs the following steps:
1. Initializes a fluid at thermodynamic equilibrium with specified components and conditions.
2. Simulates the isothermal expansion process and calculates the state properties.
3. Simulates the isentropic expansion process and calculates the state properties.
4. Simulates the isothermal compression process and calculates the state properties.
5. Simulates the adiabatic reversible compression process and calculates the state properties.
6. Calculates the Carnot efficiency based on the heat transferred during the cycle.
7. Plots the pressure-volume (PV) and temperature-entropy (TS) diagrams for the Carnot cycle.

Variables:
- P1: Initial pressure in bara.
- T_hot: High temperature in Celsius.
- T_cold: Low temperature in Celsius.
- fluid_1: Thermodynamic fluid object.
- T1, T2, T3, T4, T5: Temperatures at different states in Celsius.
- P2, P3, P4, P5: Pressures at different states in bara.
- H1, H2, H3, H4, H5: Enthalpies at different states in kJ/kg.
- U1, U2, U3, U4, U5: Internal energies at different states in kJ/kg.
- S1, S2, S3, S4, S5: Entropies at different states in kJ/kgK.
- V1, V2, V3, V4, V5: Volumes at different states in m3.
- dS: Change in entropy between states 1 and 2 in kJ/kgK.
- QH: Heat added during the isothermal expansion in kJ.
- QC: Heat rejected during the isothermal compression in kJ.
- efficiency: Calculated Carnot efficiency.
- efficiency2: Theoretical Carnot efficiency.

Plots:
- Pressure vs. Volume (PV) diagram.
- Temperature vs. Entropy (TS) diagram.
Created on Thu Jan 2 15:49:07 2020

@author: esol
Expand All @@ -19,7 +56,7 @@
fluid_1.setTemperature(T_hot, "C")
fluid_1.setPressure(P1, "bara")
TPflash(fluid_1)
fluid_1.display()
printFrame(fluid_1)
T1 = fluid_1.getTemperature("C")
H1 = fluid_1.getEnthalpy("kJ/kg")
U1 = fluid_1.getInternalEnergy("kJ/kg")
Expand All @@ -30,7 +67,7 @@
# 1-2: Isothermal Expansion. Heat is transferred reversibly from high temperature reservoir at constant temperature TH (isothermal heat addition or absorption).
V2 = V1 * 1.5
TVflash(fluid_1, V2, "m3")
fluid_1.display()
printFrame(fluid_1)
T2 = fluid_1.getTemperature("C")
P2 = fluid_1.getPressure("bara")
H2 = fluid_1.getEnthalpy("kJ/kg")
Expand All @@ -40,7 +77,7 @@
# 2-3: Isentropic (reversible adiabatic) expansion of the gas (isentropic work output).
fluid_1.setTemperature(T_cold, "C")
TSflash(fluid_1, S2, "kJ/kgK")
fluid_1.display()
printFrame(fluid_1)

T3 = fluid_1.getTemperature("C")
P3 = fluid_1.getPressure()
Expand All @@ -59,7 +96,7 @@
S4 = fluid_1.getEntropy("kJ/kgK")
V4 = fluid_1.getVolume("m3")

fluid_1.display()
printFrame(fluid_1)
# 4-1 Adiabatic reversible compression.

VSflash(fluid_1, V1, S4, "m3", "kJ/kgK")
Expand All @@ -69,7 +106,7 @@
U5 = fluid_1.getInternalEnergy("kJ/kg")
S5 = fluid_1.getEntropy("kJ/kgK")
V5 = fluid_1.getVolume("m3")
fluid_1.display()
printFrame(fluid_1)

dS = S2 - S1
QH = (T_hot + 273.15) * dS
Expand Down
1 change: 1 addition & 0 deletions examples/compressorCalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Created on Thu Jun 4 10:52:50 2020


@author: ESOL
"""
import pandas as pd
Expand Down
167 changes: 114 additions & 53 deletions examples/jupyter/examplesInPython.ipynb

Large diffs are not rendered by default.

81 changes: 39 additions & 42 deletions examples/jupyter/readEclipseE300format.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -36,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -47,7 +47,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -85,8 +85,8 @@
" <th>0</th>\n",
" <td></td>\n",
" <td>total</td>\n",
" <td>gas</td>\n",
" <td>oil</td>\n",
" <td>GAS</td>\n",
" <td>OIL</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td></td>\n",
Expand All @@ -95,8 +95,8 @@
" <th>1</th>\n",
" <td>nitrogen</td>\n",
" <td>1.328E-3</td>\n",
" <td>1.37375E-3</td>\n",
" <td>2.27017E-6</td>\n",
" <td>1.37208E-3</td>\n",
" <td>2.10134E-6</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>[mole fraction]</td>\n",
Expand All @@ -105,8 +105,8 @@
" <th>2</th>\n",
" <td>CO2</td>\n",
" <td>3.25865E-2</td>\n",
" <td>3.36916E-2</td>\n",
" <td>5.65258E-4</td>\n",
" <td>3.36515E-2</td>\n",
" <td>5.53463E-4</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>[mole fraction]</td>\n",
Expand All @@ -115,8 +115,8 @@
" <th>3</th>\n",
" <td>methane</td>\n",
" <td>8.39723E-1</td>\n",
" <td>8.68521E-1</td>\n",
" <td>5.27666E-3</td>\n",
" <td>8.67475E-1</td>\n",
" <td>5.02947E-3</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>[mole fraction]</td>\n",
Expand All @@ -125,8 +125,8 @@
" <th>4</th>\n",
" <td>ethane</td>\n",
" <td>4.83544E-2</td>\n",
" <td>4.99564E-2</td>\n",
" <td>1.93729E-3</td>\n",
" <td>4.98992E-2</td>\n",
" <td>1.89264E-3</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>[mole fraction]</td>\n",
Expand Down Expand Up @@ -198,11 +198,11 @@
],
"text/plain": [
" 0 1 2 3 4 5 6\n",
"0 total gas oil \n",
"1 nitrogen 1.328E-3 1.37375E-3 2.27017E-6 [mole fraction]\n",
"2 CO2 3.25865E-2 3.36916E-2 5.65258E-4 [mole fraction]\n",
"3 methane 8.39723E-1 8.68521E-1 5.27666E-3 [mole fraction]\n",
"4 ethane 4.83544E-2 4.99564E-2 1.93729E-3 [mole fraction]\n",
"0 total GAS OIL \n",
"1 nitrogen 1.328E-3 1.37208E-3 2.10134E-6 [mole fraction]\n",
"2 CO2 3.25865E-2 3.36515E-2 5.53463E-4 [mole fraction]\n",
"3 methane 8.39723E-1 8.67475E-1 5.02947E-3 [mole fraction]\n",
"4 ethane 4.83544E-2 4.98992E-2 1.89264E-3 [mole fraction]\n",
".. ... ... ... ... .. .. ...\n",
"59 Stream -\n",
"60 \n",
Expand All @@ -213,7 +213,7 @@
"[64 rows x 7 columns]"
]
},
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -232,7 +232,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -241,7 +241,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -279,8 +279,8 @@
" <th>0</th>\n",
" <td></td>\n",
" <td>total</td>\n",
" <td>gas</td>\n",
" <td>oil</td>\n",
" <td>GAS</td>\n",
" <td>OIL</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td></td>\n",
Expand All @@ -289,8 +289,8 @@
" <th>1</th>\n",
" <td>nitrogen</td>\n",
" <td>8.49998E-4</td>\n",
" <td>8.70757E-4</td>\n",
" <td>1.39448E-6</td>\n",
" <td>8.70763E-4</td>\n",
" <td>1.36793E-6</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>[mole fraction]</td>\n",
Expand All @@ -299,8 +299,8 @@
" <th>2</th>\n",
" <td>CO2</td>\n",
" <td>3.26669E-2</td>\n",
" <td>3.34524E-2</td>\n",
" <td>5.57794E-4</td>\n",
" <td>3.34527E-2</td>\n",
" <td>5.54883E-4</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>[mole fraction]</td>\n",
Expand All @@ -309,8 +309,8 @@
" <th>3</th>\n",
" <td>methane</td>\n",
" <td>8.62505E-1</td>\n",
" <td>8.83475E-1</td>\n",
" <td>5.27028E-3</td>\n",
" <td>8.83482E-1</td>\n",
" <td>5.20781E-3</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>[mole fraction]</td>\n",
Expand All @@ -319,8 +319,8 @@
" <th>4</th>\n",
" <td>ethane</td>\n",
" <td>4.28819E-2</td>\n",
" <td>4.38895E-2</td>\n",
" <td>1.68985E-3</td>\n",
" <td>4.389E-2</td>\n",
" <td>1.68005E-3</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>[mole fraction]</td>\n",
Expand Down Expand Up @@ -392,11 +392,11 @@
],
"text/plain": [
" 0 1 2 3 4 5 6\n",
"0 total gas oil \n",
"1 nitrogen 8.49998E-4 8.70757E-4 1.39448E-6 [mole fraction]\n",
"2 CO2 3.26669E-2 3.34524E-2 5.57794E-4 [mole fraction]\n",
"3 methane 8.62505E-1 8.83475E-1 5.27028E-3 [mole fraction]\n",
"4 ethane 4.28819E-2 4.38895E-2 1.68985E-3 [mole fraction]\n",
"0 total GAS OIL \n",
"1 nitrogen 8.49998E-4 8.70763E-4 1.36793E-6 [mole fraction]\n",
"2 CO2 3.26669E-2 3.34527E-2 5.54883E-4 [mole fraction]\n",
"3 methane 8.62505E-1 8.83482E-1 5.20781E-3 [mole fraction]\n",
"4 ethane 4.28819E-2 4.389E-2 1.68005E-3 [mole fraction]\n",
".. ... ... ... ... .. .. ...\n",
"59 Stream -\n",
"60 \n",
Expand All @@ -407,7 +407,7 @@
"[64 rows x 7 columns]"
]
},
"execution_count": 9,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -419,11 +419,8 @@
}
],
"metadata": {
"interpreter": {
"hash": "a5df7bd4ca0d6bb9986d9d69faf4f6c25893f82bf7982e9868ee8495bd8c927f"
},
"kernelspec": {
"display_name": "Python 3.7.9 64-bit ('base': conda)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -437,7 +434,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.10.16"
},
"orig_nbformat": 4
},
Expand Down
Loading
Loading