Skip to content

Commit 52400b4

Browse files
committed
update precommit
1 parent 0d59c43 commit 52400b4

File tree

290 files changed

+24851
-7438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+24851
-7438
lines changed

.github/workflows/generate-stubs.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ on:
1414
jobs:
1515
generate-stubs:
1616
runs-on: ubuntu-latest
17-
17+
1818
steps:
1919
- uses: actions/checkout@v4
20-
20+
2121
- name: Set up Python
2222
uses: actions/setup-python@v5
2323
with:
2424
python-version: '3.11'
25-
25+
2626
- name: Set up Java
2727
uses: actions/setup-java@v4
2828
with:
2929
distribution: 'temurin'
3030
java-version: '17'
31-
31+
3232
- name: Install dependencies
3333
run: |
3434
pip install poetry
3535
poetry install --with dev
36-
36+
3737
- name: Generate stubs
3838
run: |
3939
poetry run python scripts/generate_stubs.py
40-
40+
4141
- name: Commit updated stubs
4242
uses: stefanzweifel/git-auto-commit-action@v5
4343
with:

examples/beggsBrillPipeline.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@
3434
multiphase_fluid.setTotalFlowRate(100000.0, "kg/hr")
3535

3636
# Create inlet stream
37-
inlet_stream = jneqsim.process.equipment.stream.Stream("Pipeline Inlet", multiphase_fluid)
37+
inlet_stream = jneqsim.process.equipment.stream.Stream(
38+
"Pipeline Inlet", multiphase_fluid
39+
)
3840

3941
# Create Beggs and Brill pipeline
4042
# This pipeline goes uphill with significant elevation change
41-
pipe = jneqsim.process.equipment.pipeline.PipeBeggsAndBrills("Multiphase Pipeline", inlet_stream)
43+
pipe = jneqsim.process.equipment.pipeline.PipeBeggsAndBrills(
44+
"Multiphase Pipeline", inlet_stream
45+
)
4246

4347
# Set pipeline geometry
4448
pipe.setLength(10000.0) # 10 km length

examples/ejectorProcess.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Ejector Process Simulation Example
44
55
This example demonstrates using an ejector (steam/gas jet) in NeqSim.
6-
Ejectors are used in vacuum systems, refrigeration cycles, and
6+
Ejectors are used in vacuum systems, refrigeration cycles, and
77
for mixing/boosting low-pressure gas with a high-pressure motive stream.
88
99
The ejector calculation uses a quasi one-dimensional formulation combining
@@ -37,10 +37,14 @@
3737

3838
# Create streams
3939
motive_stream = jneqsim.process.equipment.stream.Stream("Motive Stream", motive_fluid)
40-
suction_stream = jneqsim.process.equipment.stream.Stream("Suction Stream", suction_fluid)
40+
suction_stream = jneqsim.process.equipment.stream.Stream(
41+
"Suction Stream", suction_fluid
42+
)
4143

4244
# Create ejector
43-
ejector = jneqsim.process.equipment.ejector.Ejector("Gas Ejector", motive_stream, suction_stream)
45+
ejector = jneqsim.process.equipment.ejector.Ejector(
46+
"Gas Ejector", motive_stream, suction_stream
47+
)
4448

4549
# Create process system and run
4650
process = jneqsim.process.processmodel.ProcessSystem()
@@ -75,7 +79,9 @@
7579
print(f" Flow rate: {outlet_flow:.0f} kg/hr")
7680

7781
# Get entrainment ratio (mass of suction per mass of motive)
78-
entrainment_ratio = suction_fluid.getFlowRate("kg/hr") / motive_fluid.getFlowRate("kg/hr")
82+
entrainment_ratio = suction_fluid.getFlowRate("kg/hr") / motive_fluid.getFlowRate(
83+
"kg/hr"
84+
)
7985
print(f"\nEntrainment Ratio: {entrainment_ratio:.3f}")
8086
print(f"Compression Ratio: {outlet_pressure / suction_stream.getPressure('bara'):.2f}")
8187
print("=" * 60)

examples/equationOfState.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
print("\n2. COMPARING EoS FOR NATURAL GAS")
5454
print("-" * 40)
5555

56+
5657
# Define composition
5758
def create_natural_gas(eos_name):
5859
"""Create a natural gas mixture with specified EoS."""
@@ -68,6 +69,7 @@ def create_natural_gas(eos_name):
6869
gas.setMixingRule("classic")
6970
return gas
7071

72+
7173
# Conditions
7274
temp_c = 25.0
7375
pressure_bara = 100.0
@@ -85,16 +87,16 @@ def create_natural_gas(eos_name):
8587
TPflash(gas)
8688
gas.initThermoProperties()
8789
gas.initPhysicalProperties()
88-
90+
8991
z = gas.getZ()
9092
rho = gas.getDensity("kg/m3")
9193
cp = gas.getCp("J/molK")
92-
94+
9395
if gas.hasPhaseType("gas"):
9496
sos = gas.getPhase("gas").getSoundSpeed()
9597
else:
9698
sos = gas.getPhase(0).getSoundSpeed()
97-
99+
98100
print(f"{eos:11} | {z:9.5f} | {rho:9.2f} | {cp:9.2f} | {sos:8.1f}")
99101
except Exception as e:
100102
print(f"{eos:11} | Error: {e}")
@@ -106,6 +108,7 @@ def create_natural_gas(eos_name):
106108
print("-" * 40)
107109
print("CPA handles hydrogen bonding (association) in water and alcohols")
108110

111+
109112
def create_wet_gas(eos_name):
110113
"""Create a wet gas mixture with specified EoS."""
111114
if eos_name == "cpa":
@@ -114,13 +117,14 @@ def create_wet_gas(eos_name):
114117
else:
115118
gas = fluid(eos_name)
116119
gas.setMixingRule("classic")
117-
120+
118121
gas.addComponent("methane", 90.0, "mol%")
119122
gas.addComponent("ethane", 5.0, "mol%")
120123
gas.addComponent("water", 5.0, "mol%")
121124
gas.setMultiPhaseCheck(True)
122125
return gas
123126

127+
124128
print(f"\nConditions: T = 25°C, P = 50 bara")
125129
print("Wet natural gas with 5 mol% water")
126130
print("\nEoS | # Phases | Gas Density | Water in Gas Phase")
@@ -134,9 +138,9 @@ def create_wet_gas(eos_name):
134138
gas.setPressure(50.0, "bara")
135139
TPflash(gas)
136140
gas.initThermoProperties()
137-
141+
138142
n_phases = gas.getNumberOfPhases()
139-
143+
140144
if gas.hasPhaseType("gas"):
141145
gas_phase = gas.getPhase("gas")
142146
rho = gas_phase.getDensity("kg/m3")
@@ -146,7 +150,7 @@ def create_wet_gas(eos_name):
146150
else:
147151
rho = gas.getPhase(0).getDensity("kg/m3")
148152
water_in_gas = 0.0
149-
153+
150154
print(f"{eos:6} | {n_phases:8} | {rho:11.2f} | {water_in_gas:.6f}")
151155
except Exception as e:
152156
print(f"{eos:6} | Error: {e}")
@@ -167,7 +171,7 @@ def create_wet_gas(eos_name):
167171
heptane.setPressure(1.01325, "bara")
168172
TPflash(heptane)
169173
heptane.initThermoProperties()
170-
174+
171175
rho = heptane.getDensity("kg/m3")
172176
print(f"{eos.upper()}: {rho:.1f} kg/m³")
173177

@@ -193,7 +197,7 @@ def create_wet_gas(eos_name):
193197
co2.setPressure(80.0, "bara")
194198
TPflash(co2)
195199
co2.initThermoProperties()
196-
200+
197201
rho = co2.getDensity("kg/m3")
198202
z = co2.getZ()
199203
print(f"{eos:13} | {rho:15.2f} | {z:.5f}")
@@ -205,7 +209,8 @@ def create_wet_gas(eos_name):
205209
# =============================================================================
206210
print("\n6. EOS-CG FOR CO2 AND COMBUSTION GASES")
207211
print("-" * 40)
208-
print("""
212+
print(
213+
"""
209214
EOS-CG (Equation of State for Combustion Gases) is based on GERG-2008
210215
but optimized for CO2-rich mixtures and combustion product gases.
211216
@@ -217,7 +222,8 @@ def create_wet_gas(eos_name):
217222
- Blue/green hydrogen with CO2
218223
219224
Components: CO2, N2, O2, Ar, H2O, CO, H2, H2S, SO2, CH4
220-
""")
225+
"""
226+
)
221227

222228
# Create a typical flue gas / CCS mixture
223229
print("Example: CO2-rich CCS mixture")
@@ -239,7 +245,7 @@ def create_wet_gas(eos_name):
239245
ccs_gas.setPressure(100.0, "bara")
240246
TPflash(ccs_gas)
241247
ccs_gas.initThermoProperties()
242-
248+
243249
rho = ccs_gas.getDensity("kg/m3")
244250
z = ccs_gas.getZ()
245251
print(f"{eos:13} | {rho:15.2f} | {z:.5f}")
@@ -254,7 +260,8 @@ def create_wet_gas(eos_name):
254260
# =============================================================================
255261
print("\n7. GUIDELINES FOR EoS SELECTION")
256262
print("-" * 40)
257-
print("""
263+
print(
264+
"""
258265
Application | Recommended EoS
259266
-------------------------------------|----------------------
260267
Natural gas properties | GERG-2008 (most accurate)
@@ -279,5 +286,6 @@ def create_wet_gas(eos_name):
279286
Gas hydrates | CPA with hydrate model
280287
|
281288
Electrolyte solutions (brine) | Electrolyte-CPA
282-
""")
289+
"""
290+
)
283291
print("=" * 70)

examples/equipmentFactory.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,18 @@
9292
# List all available equipment types
9393
print("\n4. Available equipment types (partial list):")
9494
equipment_types = [
95-
"Stream", "Compressor", "Pump", "Separator", "HeatExchanger",
96-
"ThrottlingValve", "Mixer", "Splitter", "Cooler", "Heater",
97-
"Expander", "Pipeline"
95+
"Stream",
96+
"Compressor",
97+
"Pump",
98+
"Separator",
99+
"HeatExchanger",
100+
"ThrottlingValve",
101+
"Mixer",
102+
"Splitter",
103+
"Cooler",
104+
"Heater",
105+
"Expander",
106+
"Pipeline",
98107
]
99108
for eq_type in equipment_types:
100109
print(f" - {eq_type}")

examples/flareSystem.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Flare System Simulation Example
44
55
This example demonstrates using the Flare unit operation in NeqSim.
6-
A flare is used to safely combust emergency relief gases, typically
6+
A flare is used to safely combust emergency relief gases, typically
77
from pressure safety valves (PSV) or blowdown systems.
88
99
Features demonstrated:
@@ -82,9 +82,9 @@
8282
print(f" Mass utilization: {capacity_check.getMassUtilization() * 100:.1f}%")
8383
else:
8484
print(f"\n✓ Flare is within design capacity")
85-
if not float('nan') == capacity_check.getHeatUtilization():
85+
if not float("nan") == capacity_check.getHeatUtilization():
8686
print(f" Heat utilization: {capacity_check.getHeatUtilization() * 100:.1f}%")
87-
if not float('nan') == capacity_check.getMassUtilization():
87+
if not float("nan") == capacity_check.getMassUtilization():
8888
print(f" Mass utilization: {capacity_check.getMassUtilization() * 100:.1f}%")
8989

9090
print("=" * 60)

examples/flashCalculations.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,18 @@
7676
if natural_gas.hasPhaseType("gas"):
7777
gas_phase = natural_gas.getPhase("gas")
7878
print(f" Gas phase:")
79-
print(f" - Mole fraction: {natural_gas.getMoleFraction(natural_gas.getPhaseNumberOfPhase('gas')):.4f}")
79+
print(
80+
f" - Mole fraction: {natural_gas.getMoleFraction(natural_gas.getPhaseNumberOfPhase('gas')):.4f}"
81+
)
8082
print(f" - Density: {gas_phase.getDensity('kg/m3'):.2f} kg/m³")
8183
print(f" - Z-factor: {gas_phase.getZ():.4f}")
8284

8385
if natural_gas.hasPhaseType("oil"):
8486
oil_phase = natural_gas.getPhase("oil")
8587
print(f" Liquid phase:")
86-
print(f" - Mole fraction: {natural_gas.getMoleFraction(natural_gas.getPhaseNumberOfPhase('oil')):.4f}")
88+
print(
89+
f" - Mole fraction: {natural_gas.getMoleFraction(natural_gas.getPhaseNumberOfPhase('oil')):.4f}"
90+
)
8791
print(f" - Density: {oil_phase.getDensity('kg/m3'):.2f} kg/m³")
8892

8993
# =============================================================================
@@ -182,7 +186,8 @@
182186
print("\n" + "=" * 70)
183187
print("FLASH CALCULATION SUMMARY")
184188
print("=" * 70)
185-
print("""
189+
print(
190+
"""
186191
Flash Type | Given | Find | Application
187192
-----------|----------------|----------------|---------------------------
188193
TPflash | T, P | Phases, comp. | General equilibrium
@@ -191,5 +196,6 @@
191196
TVflash | T, V | P, phases | Closed vessels
192197
VHflash | V, H | T, P, phases | Adiabatic closed systems
193198
VUflash | V, U | T, P, phases | Isolated systems
194-
""")
199+
"""
200+
)
195201
print("=" * 70)

examples/fluidCreation.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
gas = fluid("srk") # Soave-Redlich-Kwong EoS
3636

3737
# Add components one by one
38-
gas.addComponent("methane", 1.0) # Default: mole fraction
38+
gas.addComponent("methane", 1.0) # Default: mole fraction
3939
gas.addComponent("ethane", 0.1)
4040
gas.addComponent("propane", 0.05)
4141
gas.setMixingRule("classic")
@@ -92,10 +92,18 @@
9292

9393
# Define composition in a DataFrame
9494
composition_data = {
95-
'ComponentName': ['nitrogen', 'CO2', 'methane', 'ethane', 'propane',
96-
'i-butane', 'n-butane', 'i-pentane', 'n-pentane'],
97-
'MolarComposition[-]': [0.02, 0.01, 0.85, 0.05, 0.03,
98-
0.01, 0.015, 0.005, 0.01]
95+
"ComponentName": [
96+
"nitrogen",
97+
"CO2",
98+
"methane",
99+
"ethane",
100+
"propane",
101+
"i-butane",
102+
"n-butane",
103+
"i-pentane",
104+
"n-pentane",
105+
],
106+
"MolarComposition[-]": [0.02, 0.01, 0.85, 0.05, 0.03, 0.01, 0.015, 0.005, 0.01],
99107
}
100108
df = pd.DataFrame(composition_data)
101109

@@ -218,8 +226,12 @@
218226
cloned.setTemperature(100.0, "C")
219227
cloned.setPressure(100.0, "bara")
220228

221-
print(f"Original fluid: T = {original.getTemperature('C'):.1f}°C, P = {original.getPressure('bara'):.1f} bara")
222-
print(f"Cloned fluid: T = {cloned.getTemperature('C'):.1f}°C, P = {cloned.getPressure('bara'):.1f} bara")
229+
print(
230+
f"Original fluid: T = {original.getTemperature('C'):.1f}°C, P = {original.getPressure('bara'):.1f} bara"
231+
)
232+
print(
233+
f"Cloned fluid: T = {cloned.getTemperature('C'):.1f}°C, P = {cloned.getPressure('bara'):.1f} bara"
234+
)
223235
print("(Changes to clone don't affect original)")
224236

225237
# =============================================================================
@@ -257,7 +269,8 @@
257269
# =============================================================================
258270
print("\n9. COMMONLY USED COMPONENTS")
259271
print("-" * 40)
260-
print("""
272+
print(
273+
"""
261274
Category | Component Names
262275
-------------------|------------------------------------------------
263276
Light gases | nitrogen, oxygen, argon, helium, hydrogen, H2S
@@ -272,7 +285,8 @@
272285
273286
Note: For components not in database, use addTBPfraction() or
274287
addPlusFraction() with MW and density.
275-
""")
288+
"""
289+
)
276290

277291
# =============================================================================
278292
# 10. ELECTROLYTE FLUIDS

0 commit comments

Comments
 (0)