diff --git a/examples/CO2deprezzurizing.py b/examples/CO2deprezzurizing.py index 79b80b54..f63fadcf 100644 --- a/examples/CO2deprezzurizing.py +++ b/examples/CO2deprezzurizing.py @@ -23,11 +23,8 @@ from neqsim.thermo import ( PHflash, - PHsolidflash, TPflash, - TPsolidflash, bubt, - dewt, fluid, printFrame, ) diff --git a/examples/H2Sdistribution.py b/examples/H2Sdistribution.py index b4fc3181..1f744683 100644 --- a/examples/H2Sdistribution.py +++ b/examples/H2Sdistribution.py @@ -5,17 +5,9 @@ @author: ESOL """ -import pandas as pd from neqsim.thermo import ( TPflash, - addOilFractions, - createfluid, - createfluid2, - dataFrame, fluid, - fluid_df, - fluidcreator, - phaseenvelope, printFrame, ) diff --git a/examples/PVTsim.py b/examples/PVTsim.py index de3682d1..17e75eca 100644 --- a/examples/PVTsim.py +++ b/examples/PVTsim.py @@ -2,14 +2,7 @@ from neqsim.thermo import ( CVD, TPflash, - addOilFractions, createfluid, - createfluid2, - dataFrame, - fluid, - fluidcreator, - phaseenvelope, - printFrame, separatortest, ) diff --git a/examples/TPflash.py b/examples/TPflash.py index 9b2b1a4a..bf1e7d80 100644 --- a/examples/TPflash.py +++ b/examples/TPflash.py @@ -11,7 +11,7 @@ @author: esol """ -from neqsim.thermo import TPflash, fluid, fluidComposition, phaseenvelope +from neqsim.thermo import TPflash, fluid, fluidComposition # Start by creating a fluid in neqsim fluid1 = fluid("srk") # create a fluid using the SRK-EoS diff --git a/examples/TPflashBenchmark.py b/examples/TPflashBenchmark.py index 59154e9b..c0823a43 100644 --- a/examples/TPflashBenchmark.py +++ b/examples/TPflashBenchmark.py @@ -1,6 +1,6 @@ import time -from neqsim.thermo import TPflash, createfluid, fluid, fluidcreator, printFrame +from neqsim.thermo import TPflash, fluid fluid1 = fluid("srk", 303.15, 35.01325) diff --git a/examples/TPflashReactive.py b/examples/TPflashReactive.py index 53086f7c..7507de5c 100644 --- a/examples/TPflashReactive.py +++ b/examples/TPflashReactive.py @@ -8,9 +8,7 @@ from neqsim.thermo import ( TPflash, fluid, - fluidComposition, ionComposition, - phaseenvelope, scaleCheck, ) diff --git a/examples/beggsBrillPipeline.py b/examples/beggsBrillPipeline.py index 27926cb4..29ad59bf 100644 --- a/examples/beggsBrillPipeline.py +++ b/examples/beggsBrillPipeline.py @@ -71,10 +71,10 @@ print("=" * 65) print("\nPipeline Geometry:") -print(f" Length: 10,000 m (10 km)") -print(f" Diameter: 0.30 m (12 inch)") -print(f" Wall roughness: 50 um") -print(f" Elevation gain: 200 m (uphill)") +print(" Length: 10,000 m (10 km)") +print(" Diameter: 0.30 m (12 inch)") +print(" Wall roughness: 50 um") +print(" Elevation gain: 200 m (uphill)") print("\nInlet Conditions:") print(f" Pressure: {inlet_stream.getPressure('bara'):.1f} bara") @@ -95,7 +95,7 @@ if outlet_fluid.hasPhaseType("gas") and outlet_fluid.hasPhaseType("oil"): gas_fraction = outlet_fluid.getPhase("gas").getBeta() liquid_fraction = 1.0 - gas_fraction - print(f"\nPhase Distribution at Outlet:") + print("\nPhase Distribution at Outlet:") print(f" Gas fraction: {gas_fraction * 100:.1f}%") print(f" Liquid fraction: {liquid_fraction * 100:.1f}%") diff --git a/examples/compressorCalc.py b/examples/compressorCalc.py index e616e535..9a418d4d 100644 --- a/examples/compressorCalc.py +++ b/examples/compressorCalc.py @@ -8,7 +8,7 @@ import pandas as pd from neqsim.process import clearProcess, compressor, compressorChart, runProcess, stream -from neqsim.thermo import fluid, fluid_df +from neqsim.thermo import fluid_df # Create a gas-condensate fluid naturalgas = { diff --git a/examples/compressorTrain.py b/examples/compressorTrain.py index 48706614..e6d4f781 100644 --- a/examples/compressorTrain.py +++ b/examples/compressorTrain.py @@ -10,10 +10,7 @@ compressor, heater, runProcess, - separator, stream, - valve, - viewProcess, ) from neqsim.thermo import fluid diff --git a/examples/createFluid.py b/examples/createFluid.py index a25b17a9..d3fdb224 100644 --- a/examples/createFluid.py +++ b/examples/createFluid.py @@ -10,8 +10,6 @@ addOilFractions, createfluid, createfluid2, - dataFrame, - fluid, fluid_df, fluidcreator, phaseenvelope, diff --git a/examples/ejectorProcess.py b/examples/ejectorProcess.py index 94f160ea..a4bb1434 100644 --- a/examples/ejectorProcess.py +++ b/examples/ejectorProcess.py @@ -66,17 +66,17 @@ print("=" * 60) print("EJECTOR SIMULATION RESULTS") print("=" * 60) -print(f"\nMotive Stream:") +print("\nMotive Stream:") print(f" Pressure: {motive_stream.getPressure('bara'):.1f} bara") print(f" Temperature: {motive_stream.getTemperature('C'):.1f} °C") print(f" Flow rate: {motive_stream.getFlowRate('kg/hr'):.0f} kg/hr") -print(f"\nSuction Stream:") +print("\nSuction Stream:") print(f" Pressure: {suction_stream.getPressure('bara'):.1f} bara") print(f" Temperature: {suction_stream.getTemperature('C'):.1f} °C") print(f" Flow rate: {suction_stream.getFlowRate('kg/hr'):.0f} kg/hr") -print(f"\nMixed Outlet Stream:") +print("\nMixed Outlet Stream:") print(f" Pressure: {outlet_pressure:.2f} bara") print(f" Temperature: {outlet_temperature:.1f} °C") print(f" Flow rate: {outlet_flow:.0f} kg/hr") diff --git a/examples/equationOfState.py b/examples/equationOfState.py index 65186323..b7d8d00d 100644 --- a/examples/equationOfState.py +++ b/examples/equationOfState.py @@ -128,7 +128,7 @@ def create_wet_gas(eos_name): return gas -print(f"\nConditions: T = 25°C, P = 50 bara") +print("\nConditions: T = 25°C, P = 50 bara") print("Wet natural gas with 5 mol% water") print("\nEoS | # Phases | Gas Density | Water in Gas Phase") print(" | | [kg/m³] | [mol fraction]") @@ -186,7 +186,7 @@ def create_wet_gas(eos_name): print("CO2 near critical point (Tc=31°C, Pc=73.8 bar)") print("Span-Wagner is the reference EoS for CO2") -print(f"\nConditions: T = 35°C, P = 80 bara (supercritical)") +print("\nConditions: T = 35°C, P = 80 bara (supercritical)") print("\nEoS | Density [kg/m³] | Z-factor") print("-" * 45) @@ -212,8 +212,7 @@ def create_wet_gas(eos_name): # ============================================================================= print("\n6. EOS-CG FOR CO2 AND COMBUSTION GASES") print("-" * 40) -print( - """ +print(""" EOS-CG (Equation of State for Combustion Gases) is based on GERG-2008 but optimized for CO2-rich mixtures and combustion product gases. @@ -225,13 +224,12 @@ def create_wet_gas(eos_name): - Blue/green hydrogen with CO2 Components: CO2, N2, O2, Ar, H2O, CO, H2, H2S, SO2, CH4 -""" -) +""") # Create a typical flue gas / CCS mixture print("Example: CO2-rich CCS mixture") print("Composition: 95% CO2, 3% N2, 1% O2, 1% Ar") -print(f"\nConditions: T = 25°C, P = 100 bara (dense phase CO2)") +print("\nConditions: T = 25°C, P = 100 bara (dense phase CO2)") print("\nEoS | Density [kg/m³] | Z-factor") print("-" * 45) @@ -263,8 +261,7 @@ def create_wet_gas(eos_name): # ============================================================================= print("\n7. GUIDELINES FOR EoS SELECTION") print("-" * 40) -print( - """ +print(""" Application | Recommended EoS -------------------------------------|---------------------- Natural gas properties | GERG-2008 (most accurate) @@ -289,6 +286,5 @@ def create_wet_gas(eos_name): Gas hydrates | CPA with hydrate model | Electrolyte solutions (brine) | Electrolyte-CPA -""" -) +""") print("=" * 70) diff --git a/examples/flareSystem.py b/examples/flareSystem.py index 7b9d5792..0b41bd7f 100644 --- a/examples/flareSystem.py +++ b/examples/flareSystem.py @@ -62,17 +62,17 @@ print("FLARE SYSTEM SIMULATION RESULTS") print("=" * 60) -print(f"\nFlare Configuration:") +print("\nFlare Configuration:") print(f" Flame height: {60.0} m") print(f" Radiant fraction: {0.20:.0%}") print(f" Tip diameter: {0.8} m") -print(f"\nOperating Conditions:") +print("\nOperating Conditions:") print(f" Inlet pressure: {flare_inlet.getPressure('bara'):.1f} bara") print(f" Inlet temperature: {flare_inlet.getTemperature('C'):.1f} °C") print(f" Mass flow rate: {flare_inlet.getFlowRate('kg/hr'):.0f} kg/hr") -print(f"\nFlare Performance:") +print("\nFlare Performance:") print(f" Heat duty: {heat_duty_mw:.2f} MW") print(f" CO2 emissions: {co2_emission:.0f} kg/hr") print(f" CO2 emissions: {co2_emission * 24 / 1000:.1f} tonnes/day") diff --git a/examples/flashCalculations.py b/examples/flashCalculations.py index 02f9b801..ff388c62 100644 --- a/examples/flashCalculations.py +++ b/examples/flashCalculations.py @@ -27,9 +27,6 @@ PHflash, PSflash, TVflash, - VHflash, - VUflash, - printFrame, ) print("=" * 70) @@ -72,13 +69,13 @@ natural_gas.initThermoProperties() natural_gas.initPhysicalProperties() -print(f"\nResults:") +print("\nResults:") print(f" Number of phases: {natural_gas.getNumberOfPhases()}") print(f" Total density: {natural_gas.getDensity('kg/m3'):.2f} kg/m³") if natural_gas.hasPhaseType("gas"): gas_phase = natural_gas.getPhase("gas") - print(f" Gas phase:") + print(" Gas phase:") print( f" - Mole fraction: {natural_gas.getMoleFraction(natural_gas.getPhaseNumberOfPhase('gas')):.4f}" ) @@ -87,7 +84,7 @@ if natural_gas.hasPhaseType("oil"): oil_phase = natural_gas.getPhase("oil") - print(f" Liquid phase:") + print(" Liquid phase:") print( f" - Mole fraction: {natural_gas.getMoleFraction(natural_gas.getPhaseNumberOfPhase('oil')):.4f}" ) @@ -120,7 +117,7 @@ natural_gas.initThermoProperties() final_temp = natural_gas.getTemperature("C") -print(f"\nAfter throttling to 20 bara:") +print("\nAfter throttling to 20 bara:") print(f" Final temperature: {final_temp:.1f}°C") print(f" Temperature drop (JT effect): {initial_temp - final_temp:.1f}°C") @@ -150,7 +147,7 @@ natural_gas.initThermoProperties() discharge_temp = natural_gas.getTemperature("C") -print(f"\nIsentropic discharge at 50 bara:") +print("\nIsentropic discharge at 50 bara:") print(f" Discharge temperature: {discharge_temp:.1f}°C") print(f" Temperature rise: {discharge_temp - initial_temp:.1f}°C") @@ -170,7 +167,7 @@ # Get current volume system_volume = natural_gas.getVolume("m3") -print(f"\nInitial state: T = 25°C, P = 50 bara") +print("\nInitial state: T = 25°C, P = 50 bara") print(f"System volume: {system_volume:.6f} m³") # Change temperature while keeping volume constant @@ -180,7 +177,7 @@ natural_gas.initThermoProperties() new_pressure = natural_gas.getPressure("bara") -print(f"\nAfter heating to 50°C at constant volume:") +print("\nAfter heating to 50°C at constant volume:") print(f" New pressure: {new_pressure:.2f} bara") # ============================================================================= @@ -189,8 +186,7 @@ print("\n" + "=" * 70) print("FLASH CALCULATION SUMMARY") print("=" * 70) -print( - """ +print(""" Flash Type | Given | Find | Application -----------|----------------|----------------|--------------------------- TPflash | T, P | Phases, comp. | General equilibrium @@ -199,6 +195,5 @@ TVflash | T, V | P, phases | Closed vessels VHflash | V, H | T, P, phases | Adiabatic closed systems VUflash | V, U | T, P, phases | Isolated systems -""" -) +""") print("=" * 70) diff --git a/examples/fluidCharacterization.py b/examples/fluidCharacterization.py index 54c1235c..bcf1d258 100644 --- a/examples/fluidCharacterization.py +++ b/examples/fluidCharacterization.py @@ -11,7 +11,7 @@ @author: esol """ -from neqsim.thermo import TPflash, fluid, fluidComposition, phaseenvelope +from neqsim.thermo import TPflash, fluid, fluidComposition # Start by creating a fluid in neqsim fluid1 = fluid("srk") # create a fluid using the SRK-EoS diff --git a/examples/fluidCreation.py b/examples/fluidCreation.py index 0b786a1d..a02879bd 100644 --- a/examples/fluidCreation.py +++ b/examples/fluidCreation.py @@ -120,7 +120,7 @@ gas_df.setPressure(50.0, "bara") TPflash(gas_df) -print(f"\nCreated fluid from DataFrame") +print("\nCreated fluid from DataFrame") print(f" Total molar flow: {gas_df.getTotalNumberOfMoles():.4f} mol") # ============================================================================= @@ -272,8 +272,7 @@ # ============================================================================= print("\n9. COMMONLY USED COMPONENTS") print("-" * 40) -print( - """ +print(""" Category | Component Names -------------------|------------------------------------------------ Light gases | nitrogen, oxygen, argon, helium, hydrogen, H2S @@ -288,8 +287,7 @@ Note: For components not in database, use addTBPfraction() or addPlusFraction() with MW and density. -""" -) +""") # ============================================================================= # 10. ELECTROLYTE FLUIDS diff --git a/examples/glycolprocess.py b/examples/glycolprocess.py index 0f156833..5b74ce29 100644 --- a/examples/glycolprocess.py +++ b/examples/glycolprocess.py @@ -11,24 +11,14 @@ heater, mixer, pump, - recycle, runProcess, separator, stream, valve, - viewProcess, ) from neqsim.thermo import ( - TPflash, - addOilFractions, - createfluid, - createfluid2, - dataFrame, fluid, fluidComposition, - fluidcreator, - phaseenvelope, - printFrame, ) # Start by creating a fluid in neqsim uing a predifined fluid (dry gas, rich gas, light oil, black oil) diff --git a/examples/heatExchanger.py b/examples/heatExchanger.py index 734ed284..57c04b2f 100644 --- a/examples/heatExchanger.py +++ b/examples/heatExchanger.py @@ -5,7 +5,6 @@ @author: esol """ -from neqsim import methods from neqsim.process import clearProcess, heatExchanger, runProcess, stream from neqsim.thermo import fluid diff --git a/examples/heatOfCombustion.py b/examples/heatOfCombustion.py index 508b8f1a..16af950d 100644 --- a/examples/heatOfCombustion.py +++ b/examples/heatOfCombustion.py @@ -6,7 +6,7 @@ """ from neqsim.standards import ISO6976 -from neqsim.thermo import TPflash, fluid, fluidComposition, phaseenvelope +from neqsim.thermo import TPflash, fluid # Start by creating a fluid in neqsim fluid1 = fluid("srk") # create a fluid using the SRK-EoS diff --git a/examples/hydrateCalculations.py b/examples/hydrateCalculations.py index 8b05cacb..33dd53dc 100644 --- a/examples/hydrateCalculations.py +++ b/examples/hydrateCalculations.py @@ -20,7 +20,7 @@ @author: NeqSim Team """ -from neqsim.thermo import fluid, TPflash +from neqsim.thermo import fluid print("=" * 70) print("GAS HYDRATE CALCULATIONS TUTORIAL") @@ -31,8 +31,7 @@ # ============================================================================= print("\n1. INTRODUCTION TO GAS HYDRATES") print("-" * 40) -print( - """ +print(""" Gas hydrates form when water and light gases (C1, C2, C3, CO2, H2S) combine under high pressure and low temperature conditions. @@ -44,8 +43,7 @@ - Temperature: Typically < 25°C - Pressure: Typically > 10-20 bara - Presence of free water -""" -) +""") # ============================================================================= # 2. HYDRATE FORMATION TEMPERATURE @@ -116,16 +114,14 @@ # ============================================================================= print("\n4. SUBCOOLING - HYDRATE RISK ASSESSMENT") print("-" * 40) -print( - """ +print(""" Subcooling (ΔT) = Hydrate formation T - Operating T Interpretation: ΔT > 0: Operating BELOW hydrate T → HIGH RISK ΔT = 0: At hydrate equilibrium → BORDERLINE ΔT < 0: Operating ABOVE hydrate T → SAFE -""" -) +""") # Example calculation gas.setPressure(100.0, "bara") @@ -228,8 +224,7 @@ # ============================================================================= print("\n7. INHIBITOR SELECTION GUIDELINES") print("-" * 40) -print( - """ +print(""" ┌─────────────────────────────────────────────────────────────────┐ │ Inhibitor Comparison │ ├────────────┬──────────────────────────────────────────────────┐ @@ -256,16 +251,14 @@ │ │ ✗ Cannot be regenerated │ │ │ → Best for: Drilling fluids, completion ops │ └────────────┴──────────────────────────────────────────────────┘ -""" -) +""") # ============================================================================= # 8. KINETIC HYDRATE INHIBITORS (KHI) # ============================================================================= print("\n8. KINETIC HYDRATE INHIBITORS (KHI)") print("-" * 40) -print( - """ +print(""" Unlike thermodynamic inhibitors (MEG, MeOH) that shift equilibrium, KHIs work by slowing hydrate formation kinetics. @@ -280,8 +273,7 @@ Note: NeqSim primarily calculates thermodynamic equilibrium. KHI effects require separate kinetic models. -""" -) +""") # ============================================================================= # 9. PRACTICAL EXAMPLE: PIPELINE HYDRATE ASSESSMENT @@ -289,16 +281,14 @@ print("\n9. PRACTICAL EXAMPLE: PIPELINE HYDRATE ASSESSMENT") print("-" * 40) -print( - """ +print(""" Scenario: Subsea pipeline from wellhead to platform - Wellhead: 150 bara, 80°C - Pipeline arrival: 80 bara, 5°C - Gas is water-saturated Question: Will hydrates form? How much MEG is needed? -""" -) +""") # Check hydrate risk pipeline_gas = fluid("cpa") @@ -316,13 +306,13 @@ hydrate_T = hydt(pipeline_gas) - 273.15 -print(f"Operating temperature: 5°C") +print("Operating temperature: 5°C") print(f"Hydrate formation temperature: {hydrate_T:.1f}°C") if 5.0 < hydrate_T: subcooling = hydrate_T - 5.0 print(f"\n⚠️ HYDRATE RISK! Subcooling = {subcooling:.1f}°C") - print(f"Recommendation: Inject MEG to reduce hydrate T below 5°C") + print("Recommendation: Inject MEG to reduce hydrate T below 5°C") else: print("\n✓ Safe from hydrates at these conditions") diff --git a/examples/jupyter/PVTexperiments.ipynb b/examples/jupyter/PVTexperiments.ipynb index 555e94ba..5dda12f8 100644 --- a/examples/jupyter/PVTexperiments.ipynb +++ b/examples/jupyter/PVTexperiments.ipynb @@ -18,7 +18,7 @@ "metadata": {}, "outputs": [], "source": [ - "from neqsim.thermo import fluid, TPflash, PHflash\n", + "from neqsim.thermo import fluid, TPflash\n", "from neqsim import jneqsim\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", @@ -440,7 +440,7 @@ "\n", "print(\"Separator Test Results:\")\n", "print(\"=\" * 50)\n", - "print(f\"\\nSeparator conditions:\")\n", + "print(\"\\nSeparator conditions:\")\n", "for i, (p, t) in enumerate(zip(sep_pressures, sep_temps)):\n", " print(f\" Stage {i+1}: {p:.1f} bara, {t}°C\")" ] @@ -458,7 +458,7 @@ " Rs_sep = sep_test.getRs()\n", " GOR_sep = sep_test.getGOR()\n", " \n", - " print(f\"\\nStock Tank Oil Properties:\")\n", + " print(\"\\nStock Tank Oil Properties:\")\n", " print(f\" Bo (Formation Volume Factor): {Bo_sep:.4f} m³/Sm³\")\n", " print(f\" Rs (Solution GOR): {Rs_sep:.1f} Sm³/Sm³\")\n", " print(f\" Total GOR: {GOR_sep:.1f} Sm³/Sm³\")\n", diff --git a/examples/jupyter/TEGdehydration.ipynb b/examples/jupyter/TEGdehydration.ipynb index cfe17c63..74faf17f 100644 --- a/examples/jupyter/TEGdehydration.ipynb +++ b/examples/jupyter/TEGdehydration.ipynb @@ -19,10 +19,7 @@ "outputs": [], "source": [ "from neqsim.thermo import fluid, TPflash, waterdewpoint\n", - "from neqsim.process import stream, separator, compressor, heater, cooler\n", - "import neqsim.jneqsim as jneqsim\n", - "import matplotlib.pyplot as plt\n", - "import pandas as pd" + "import matplotlib.pyplot as plt" ] }, { @@ -97,7 +94,7 @@ "# Calculate water dew point\n", "wdp_before = waterdewpoint(wet_gas)\n", "\n", - "print(f\"Process conditions: T = 30°C, P = 70 bara\")\n", + "print(\"Process conditions: T = 30°C, P = 70 bara\")\n", "print(f\"Water dew point of inlet gas: {wdp_before:.1f}°C\")\n", "print(f\"\\nNote: Gas will form liquid water if cooled below {wdp_before:.1f}°C\")" ] @@ -127,9 +124,9 @@ "lean_teg.setPressure(70.0, \"bara\")\n", "\n", "print(\"Lean TEG stream:\")\n", - "print(f\" TEG purity: 99 wt%\")\n", - "print(f\" Temperature: 40°C\")\n", - "print(f\" Pressure: 70 bara\")" + "print(\" TEG purity: 99 wt%\")\n", + "print(\" Temperature: 40°C\")\n", + "print(\" Pressure: 70 bara\")" ] }, { diff --git a/examples/jupyter/examplesInPython.ipynb b/examples/jupyter/examplesInPython.ipynb index 8ef32e20..21fd77cc 100644 --- a/examples/jupyter/examplesInPython.ipynb +++ b/examples/jupyter/examplesInPython.ipynb @@ -15,12 +15,9 @@ "metadata": {}, "outputs": [], "source": [ - "import neqsim\n", - "import matplotlib\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", - "from neqsim.thermo import *\n", - "import pandas as pd" + "from neqsim.thermo import *" ] }, { diff --git a/examples/jupyter/gasCompression.ipynb b/examples/jupyter/gasCompression.ipynb index cd430b1a..59343f82 100644 --- a/examples/jupyter/gasCompression.ipynb +++ b/examples/jupyter/gasCompression.ipynb @@ -19,7 +19,6 @@ "outputs": [], "source": [ "from neqsim.thermo import fluid, TPflash\n", - "from neqsim import jneqsim\n", "import matplotlib.pyplot as plt\n", "import numpy as np" ] @@ -66,8 +65,8 @@ "gas.setPressure(P_suction, \"bara\")\n", "TPflash(gas)\n", "\n", - "print(f\"Gas composition: N2=1%, CO2=0.5%, C1=90%, C2=5%, C3=2%, nC4=1%, nC5=0.5%\")\n", - "print(f\"\\nSuction conditions:\")\n", + "print(\"Gas composition: N2=1%, CO2=0.5%, C1=90%, C2=5%, C3=2%, nC4=1%, nC5=0.5%\")\n", + "print(\"\\nSuction conditions:\")\n", "print(f\" Pressure: {P_suction} bara\")\n", "print(f\" Temperature: {T_suction} °C\")\n", "print(f\" Molar mass: {gas.getMolarMass() * 1000:.2f} g/mol\")\n", @@ -117,21 +116,21 @@ "outputs": [], "source": [ "# Run the process\n", - "from neqsim.process import run, getProcess\n", + "from neqsim.process import run\n", "run()\n", "\n", "# Display results\n", "print(\"Single-Stage Compression Results:\")\n", "print(\"=\" * 50)\n", - "print(f\"\\nInlet:\")\n", + "print(\"\\nInlet:\")\n", "print(f\" Pressure: {inlet.getPressure():.1f} bara\")\n", "print(f\" Temperature: {inlet.getTemperature() - 273.15:.1f} °C\")\n", "\n", - "print(f\"\\nOutlet:\")\n", + "print(\"\\nOutlet:\")\n", "print(f\" Pressure: {comp.getOutletStream().getPressure():.1f} bara\")\n", "print(f\" Temperature: {comp.getOutletStream().getTemperature() - 273.15:.1f} °C\")\n", "\n", - "print(f\"\\nCompressor performance:\")\n", + "print(\"\\nCompressor performance:\")\n", "print(f\" Pressure ratio: {comp.getOutletStream().getPressure() / inlet.getPressure():.2f}\")\n", "print(f\" Polytropic efficiency: {comp.getPolytropicEfficiency() * 100:.1f}%\")\n", "print(f\" Polytropic head: {comp.getPolytropicHead() / 1000:.1f} kJ/kg\")\n", @@ -214,7 +213,7 @@ "metadata": {}, "outputs": [], "source": [ - "from neqsim.process import heater, separator\n", + "from neqsim.process import heater\n", "\n", "# Design two-stage compression from 30 to 200 bara\n", "P1 = 30.0 # bara\n", @@ -274,16 +273,16 @@ "print(\"Two-Stage Compression Results:\")\n", "print(\"=\" * 60)\n", "\n", - "print(f\"\\nStage 1 (LP Compressor):\")\n", + "print(\"\\nStage 1 (LP Compressor):\")\n", "print(f\" Suction: {inlet.getPressure():.1f} bara, {inlet.getTemperature() - 273.15:.1f}°C\")\n", "print(f\" Discharge: {comp1.getOutletStream().getPressure():.1f} bara, {comp1.getOutletStream().getTemperature() - 273.15:.1f}°C\")\n", "print(f\" Power: {comp1.getPower() / 1e6:.2f} MW\")\n", "\n", - "print(f\"\\nIntercooler:\")\n", + "print(\"\\nIntercooler:\")\n", "print(f\" Outlet temperature: {cooler1.getOutletStream().getTemperature() - 273.15:.1f}°C\")\n", "print(f\" Duty: {abs(cooler1.getDuty()) / 1e6:.2f} MW\")\n", "\n", - "print(f\"\\nStage 2 (HP Compressor):\")\n", + "print(\"\\nStage 2 (HP Compressor):\")\n", "print(f\" Suction: {cooler1.getOutletStream().getPressure():.1f} bara, {cooler1.getOutletStream().getTemperature() - 273.15:.1f}°C\")\n", "print(f\" Discharge: {comp2.getOutletStream().getPressure():.1f} bara, {comp2.getOutletStream().getTemperature() - 273.15:.1f}°C\")\n", "print(f\" Power: {comp2.getPower() / 1e6:.2f} MW\")\n", diff --git a/examples/jupyter/hydrateFormation.ipynb b/examples/jupyter/hydrateFormation.ipynb index e4b07ed2..f3b53b42 100644 --- a/examples/jupyter/hydrateFormation.ipynb +++ b/examples/jupyter/hydrateFormation.ipynb @@ -18,9 +18,8 @@ "metadata": {}, "outputs": [], "source": [ - "from neqsim.thermo import fluid, TPflash, hydrateequilibrium\n", - "import matplotlib.pyplot as plt\n", - "import numpy as np" + "from neqsim.thermo import fluid, hydrateequilibrium\n", + "import matplotlib.pyplot as plt" ] }, { @@ -97,7 +96,7 @@ " hydrate_T = hydrateequilibrium(gas)\n", " hydrate_temps.append(hydrate_T)\n", " print(f\"{p:15} | {hydrate_T:.1f}\")\n", - " except Exception as e:\n", + " except Exception:\n", " hydrate_temps.append(None)\n", " print(f\"{p:15} | Error\")" ] diff --git a/examples/jupyter/phaseEnvelope.ipynb b/examples/jupyter/phaseEnvelope.ipynb index 7a0d0d95..a539d23f 100644 --- a/examples/jupyter/phaseEnvelope.ipynb +++ b/examples/jupyter/phaseEnvelope.ipynb @@ -124,9 +124,9 @@ " cricondentherm_T = envelope.get(\"cricondenthermT\")[0] - 273.15\n", " cricondentherm_P = envelope.get(\"cricondenthermP\")[0]\n", " \n", - " print(f\"Cricondenbar (maximum pressure):\")\n", + " print(\"Cricondenbar (maximum pressure):\")\n", " print(f\" P = {cricondenbar_P:.2f} bara at T = {cricondenbar_T:.1f}°C\")\n", - " print(f\"\\nCricondentherm (maximum temperature):\")\n", + " print(\"\\nCricondentherm (maximum temperature):\")\n", " print(f\" T = {cricondentherm_T:.1f}°C at P = {cricondentherm_P:.2f} bara\")\n", "except Exception as e:\n", " print(f\"Could not extract critical points: {e}\")\n", diff --git a/examples/jupyter/processBuilderDemo.ipynb b/examples/jupyter/processBuilderDemo.ipynb index fcaebf9f..750312b4 100644 --- a/examples/jupyter/processBuilderDemo.ipynb +++ b/examples/jupyter/processBuilderDemo.ipynb @@ -1011,7 +1011,7 @@ " f.write(yaml_config)\n", "\n", "print(f\"Configuration saved to: {config_filename}\")\n", - "print(f\"\\nTo load and run this process later:\")\n", + "print(\"\\nTo load and run this process later:\")\n", "print(f\"\"\"\n", " import yaml\n", " from neqsim.process import ProcessBuilder\n", diff --git a/examples/jupyter/readEclipseE300format.ipynb b/examples/jupyter/readEclipseE300format.ipynb index bf9cf94c..9db3162c 100644 --- a/examples/jupyter/readEclipseE300format.ipynb +++ b/examples/jupyter/readEclipseE300format.ipynb @@ -22,9 +22,7 @@ "metadata": {}, "outputs": [], "source": [ - "import neqsim\n", - "from neqsim import thermo\n", - "from neqsim.thermo import fluid_df, readEclipseFluid,dataFrame,setEclipseComposition, TPflash, addFluids" + "from neqsim.thermo import readEclipseFluid,dataFrame,setEclipseComposition, TPflash, addFluids" ] }, { diff --git a/examples/jupyter/separatorDesign.ipynb b/examples/jupyter/separatorDesign.ipynb index 7142b22e..8ce84a51 100644 --- a/examples/jupyter/separatorDesign.ipynb +++ b/examples/jupyter/separatorDesign.ipynb @@ -20,13 +20,10 @@ "source": [ "from neqsim.thermo import fluid, TPflash\n", "from neqsim.process import (\n", - " stream, separator, separator3phase, heater, \n", - " valve, compressor, pump, mixer, splitter,\n", - " clearProcess, run, getProcess\n", + " stream, separator, separator3phase, valve, clearProcess, run\n", ")\n", "import matplotlib.pyplot as plt\n", - "import numpy as np\n", - "import pandas as pd" + "import numpy as np" ] }, { @@ -75,7 +72,7 @@ "TPflash(wellfluid)\n", "\n", "print(f\"Wellhead conditions: {P_wellhead} bara, {T_wellhead}°C\")\n", - "print(f\"Total flow rate: 50,000 kg/hr\")\n", + "print(\"Total flow rate: 50,000 kg/hr\")\n", "print(f\"Number of phases: {wellfluid.getNumberOfPhases()}\")" ] }, @@ -125,17 +122,17 @@ "print(\"Two-Phase Separator Results:\")\n", "print(\"=\" * 50)\n", "\n", - "print(f\"\\nInlet Stream:\")\n", + "print(\"\\nInlet Stream:\")\n", "print(f\" Pressure: {inlet.getPressure():.1f} bara\")\n", "print(f\" Temperature: {inlet.getTemperature() - 273.15:.1f}°C\")\n", "print(f\" Mass flow: {inlet.getFlowRate('kg/hr'):.0f} kg/hr\")\n", "\n", - "print(f\"\\nGas Outlet:\")\n", + "print(\"\\nGas Outlet:\")\n", "gas_out = sep1.getGasOutStream()\n", "print(f\" Mass flow: {gas_out.getFlowRate('kg/hr'):.0f} kg/hr\")\n", "print(f\" Molar flow: {gas_out.getFlowRate('kmol/hr'):.1f} kmol/hr\")\n", "\n", - "print(f\"\\nLiquid Outlet:\")\n", + "print(\"\\nLiquid Outlet:\")\n", "liq_out = sep1.getLiquidOutStream()\n", "print(f\" Mass flow: {liq_out.getFlowRate('kg/hr'):.0f} kg/hr\")\n", "print(f\" Molar flow: {liq_out.getFlowRate('kmol/hr'):.1f} kmol/hr\")" @@ -200,18 +197,18 @@ "print(\"Three-Phase Separator Results:\")\n", "print(\"=\" * 50)\n", "\n", - "print(f\"\\nInlet:\")\n", + "print(\"\\nInlet:\")\n", "print(f\" Total flow: {inlet_3ph.getFlowRate('kg/hr'):.0f} kg/hr\")\n", "\n", - "print(f\"\\nGas Outlet:\")\n", + "print(\"\\nGas Outlet:\")\n", "gas_3ph = sep_3phase.getGasOutStream()\n", "print(f\" Mass flow: {gas_3ph.getFlowRate('kg/hr'):.0f} kg/hr\")\n", "\n", - "print(f\"\\nOil Outlet:\")\n", + "print(\"\\nOil Outlet:\")\n", "oil_3ph = sep_3phase.getOilOutStream()\n", "print(f\" Mass flow: {oil_3ph.getFlowRate('kg/hr'):.0f} kg/hr\")\n", "\n", - "print(f\"\\nWater Outlet:\")\n", + "print(\"\\nWater Outlet:\")\n", "water_3ph = sep_3phase.getWaterOutStream()\n", "print(f\" Mass flow: {water_3ph.getFlowRate('kg/hr'):.0f} kg/hr\")" ] diff --git a/examples/jupyter/separatorEfficiency.ipynb b/examples/jupyter/separatorEfficiency.ipynb index dacc7125..e6ac6456 100644 --- a/examples/jupyter/separatorEfficiency.ipynb +++ b/examples/jupyter/separatorEfficiency.ipynb @@ -68,9 +68,9 @@ } ], "source": [ - "from neqsim.process import (clearProcess, compressor, heater, runProcess,\n", - " separator, stream, valve, viewProcess, separator3phase, cooler)\n", - "from neqsim.thermo import fluid, printFrame\n", + "from neqsim.process import (clearProcess, runProcess,\n", + " stream, separator3phase, cooler)\n", + "from neqsim.thermo import printFrame\n", "from neqsim import jneqsim\n", "\n", "factor = 1.0\n", diff --git a/examples/jupyter/simpleFlash.ipynb b/examples/jupyter/simpleFlash.ipynb index 2221046c..ae66ed34 100644 --- a/examples/jupyter/simpleFlash.ipynb +++ b/examples/jupyter/simpleFlash.ipynb @@ -13,7 +13,6 @@ "metadata": {}, "outputs": [], "source": [ - "import neqsim\n", "from neqsim.thermo.thermoTools import *\n", "from neqsim.process.processTools import *\n" ] diff --git a/examples/jupyter/wetgascompression.ipynb b/examples/jupyter/wetgascompression.ipynb index 0364cd38..15d099bf 100644 --- a/examples/jupyter/wetgascompression.ipynb +++ b/examples/jupyter/wetgascompression.ipynb @@ -214,7 +214,7 @@ } ], "source": [ - "from neqsim.process import stream, compressor, runProcess,clearProcess,GORfitter\n", + "from neqsim.process import runProcess,clearProcess,GORfitter\n", "\n", "pressure_inlet = 65.0 \n", "temperature_inlet = 35.0\n", diff --git a/examples/mechanicalDesign.py b/examples/mechanicalDesign.py index 1d1c3e40..54ea39e2 100644 --- a/examples/mechanicalDesign.py +++ b/examples/mechanicalDesign.py @@ -80,12 +80,12 @@ mech_design.calcDesign() print("\nSeparator Geometry:") -print(f" Internal diameter: 2.0 m") -print(f" Tangent length: 5.0 m") +print(" Internal diameter: 2.0 m") +print(" Tangent length: 5.0 m") # Display results if available print("\nMechanical Design Parameters:") -print(f" Max design gas flow: 500.0 m³/hr") +print(" Max design gas flow: 500.0 m³/hr") # Get capacity utilization gas_stream = separator.getGasOutStream() @@ -96,11 +96,11 @@ print(f" Capacity utilization: {capacity_utilization:.1f}%") if capacity_utilization > 100: - print(f" ⚠️ WARNING: Separator is OVER capacity!") + print(" ⚠️ WARNING: Separator is OVER capacity!") elif capacity_utilization > 80: - print(f" ⚠️ Note: Operating above 80% design capacity") + print(" ⚠️ Note: Operating above 80% design capacity") else: - print(f" ✓ Operating within design limits") + print(" ✓ Operating within design limits") # Pipeline mechanical design example print("\n" + "-" * 65) @@ -121,9 +121,9 @@ pipe_design.setMinOperationPressure(10.0) # Minimum arrival pressure print("\nPipeline Parameters:") -print(f" Length: 50 km") -print(f" Diameter: 0.5 m (20 inch)") +print(" Length: 50 km") +print(" Diameter: 0.5 m (20 inch)") print(f" Max operating P: {operating_pressure:.1f} bara") -print(f" Min operating P: 10.0 bara") +print(" Min operating P: 10.0 bara") print("=" * 65) diff --git a/examples/mineralScale.py b/examples/mineralScale.py index e3e9abf8..3f471d37 100644 --- a/examples/mineralScale.py +++ b/examples/mineralScale.py @@ -11,9 +11,7 @@ calcIonComposition, checkScalePotential, fluid, - printFluid, printFrame, - table, ) nitrogen = 1.0 # @param {type:"number"} diff --git a/examples/mineralScalePrediction.py b/examples/mineralScalePrediction.py index 52a511a6..d8096c36 100644 --- a/examples/mineralScalePrediction.py +++ b/examples/mineralScalePrediction.py @@ -32,8 +32,7 @@ # ============================================================================= print("\n1. INTRODUCTION TO MINERAL SCALE") print("-" * 40) -print( - """ +print(""" Mineral scale forms when dissolved ions precipitate as solid deposits: Type | Formula | Common Causes @@ -49,16 +48,14 @@ - Equipment damage - Increased operating costs - Production loss -""" -) +""") # ============================================================================= # 2. SATURATION INDEX CONCEPT # ============================================================================= print("\n2. SATURATION INDEX (SI)") print("-" * 40) -print( - """ +print(""" SI = log(IAP / Ksp) Where: @@ -69,8 +66,7 @@ SI > 0: Supersaturated → Scale WILL form SI = 0: At equilibrium → Borderline SI < 0: Undersaturated → Scale will NOT form -""" -) +""") # ============================================================================= # 3. CREATING FORMATION WATER @@ -124,12 +120,10 @@ print(" SO4--: 0.028 mol (2.7 g/L) ← HIGH!") print(" HCO3-: 0.002 mol (122 mg/L)") -print( - """ +print(""" ⚠️ WARNING: Mixing formation water (high Ba++) with seawater (high SO4--) causes severe BaSO4 scale! -""" -) +""") # ============================================================================= # 5. SCALE POTENTIAL CALCULATION @@ -137,7 +131,6 @@ print("\n5. SCALE POTENTIAL CALCULATION") print("-" * 40) -from neqsim.thermo import calcIonComposition, ionComposition # Calculate scale potential at reservoir conditions formation_water.setTemperature(80.0, "C") @@ -168,8 +161,7 @@ # ============================================================================= print("\n6. EFFECT OF PRESSURE DROP ON CaCO3 SCALE") print("-" * 40) -print( - """ +print(""" CaCO3 (calcite) precipitation is driven by CO2 loss: Ca++ + 2HCO3- ⇌ CaCO3↓ + H2O + CO2↑ @@ -184,8 +176,7 @@ - Wellhead chokes - First stage separator - ESPs (Electrical Submersible Pumps) -""" -) +""") print("\nPressure | Expected CaCO3 Scaling Tendency") print("---------|----------------------------------") @@ -199,8 +190,7 @@ # ============================================================================= print("\n7. BaSO4 SCALE FROM WATER MIXING") print("-" * 40) -print( - """ +print(""" Barite (BaSO4) is one of the hardest scales to remove: Ba++ (formation water) + SO4-- (seawater) → BaSO4↓ @@ -215,8 +205,7 @@ - Low-sulfate seawater injection - Scale inhibitor squeeze treatments - Careful mixing ratio control -""" -) +""") # Simulate mixing at different ratios print("\nMixing formation water with seawater:") @@ -238,8 +227,7 @@ # ============================================================================= print("\n8. SCALE INHIBITORS") print("-" * 40) -print( - """ +print(""" Scale inhibitors prevent crystal growth even when supersaturated: Type | Target Scales @@ -255,16 +243,14 @@ 3. Batch treatment (periodic) Typical dosages: 5-50 ppm based on water volume -""" -) +""") # ============================================================================= # 9. PRACTICAL SCALE ASSESSMENT WORKFLOW # ============================================================================= print("\n9. PRACTICAL SCALE ASSESSMENT WORKFLOW") print("-" * 40) -print( - """ +print(""" Step 1: Water Analysis └─ Measure: Na, K, Ca, Mg, Ba, Sr, Fe, Cl, SO4, HCO3, CO2 @@ -288,16 +274,14 @@ └─ Inhibitor selection and dosage └─ Operating condition optimization └─ Monitoring and intervention plan -""" -) +""") # ============================================================================= # 10. TEMPERATURE EFFECTS SUMMARY # ============================================================================= print("\n10. TEMPERATURE EFFECTS ON SCALE") print("-" * 40) -print( - """ +print(""" Scale Type | Solubility vs Temperature --------------|-------------------------------- CaCO3 | Decreases with increasing T @@ -316,7 +300,6 @@ | SiO2 | Increases significantly with T (Silica) | (Normal solubility) -""" -) +""") print("=" * 70) diff --git a/examples/phaseEnvelope.py b/examples/phaseEnvelope.py index 3f4fd7d7..1cffce7d 100644 --- a/examples/phaseEnvelope.py +++ b/examples/phaseEnvelope.py @@ -10,7 +10,7 @@ import matplotlib.pyplot as plt import numpy as np from neqsim.thermo.thermoTools import * -from neqsim.thermo.thermoTools import fluid, phaseenvelope +from neqsim.thermo.thermoTools import fluid time.sleep(3) eosname = "srk" # @param ["srk", "pr"] diff --git a/examples/phaseEquilibrium.py b/examples/phaseEquilibrium.py index 18a77e60..5f75fdee 100644 --- a/examples/phaseEquilibrium.py +++ b/examples/phaseEquilibrium.py @@ -52,7 +52,7 @@ oil.setTemperature(100.0, "C") bp = bubp(oil) -print(f"\nLight oil composition:") +print("\nLight oil composition:") print(" Methane: 20%, Ethane: 10%, Propane: 15%, Butane: 10%") print(" Pentane: 15%, Hexane: 10%, Heptane: 10%, Octane: 10%") print(f"\nBubble point at 100°C: {bp:.2f} bara") @@ -83,7 +83,7 @@ gas.setTemperature(20.0, "C") dp = dewp(gas) -print(f"\nRich gas composition:") +print("\nRich gas composition:") print(" Methane: 80%, Ethane: 8%, Propane: 5%, Butane: 3%") print(" Pentane: 2%, Hexane: 1.5%, Heptane: 0.5%") print(f"\nDew point at 20°C: {dp:.2f} bara") @@ -111,10 +111,10 @@ cricondentherm_T = envelope.get("cricondenthermT")[0] - 273.15 cricondentherm_P = envelope.get("cricondenthermP")[0] - print(f"\nPhase Envelope Properties:") - print(f" Cricondenbar (max pressure):") + print("\nPhase Envelope Properties:") + print(" Cricondenbar (max pressure):") print(f" P = {cricondenbar_P:.2f} bara at T = {cricondenbar_T:.1f}°C") - print(f"\n Cricondentherm (max temperature):") + print("\n Cricondentherm (max temperature):") print(f" T = {cricondentherm_T:.1f}°C at P = {cricondentherm_P:.2f} bara") except Exception as e: print(f" Could not extract cricondenbar/cricondentherm: {e}") @@ -144,15 +144,13 @@ # ============================================================================= print("\n4. RETROGRADE CONDENSATION") print("-" * 40) -print( - """ +print(""" Retrograde condensation is a unique phenomenon in gas condensate systems where REDUCING pressure causes MORE liquid to form (counterintuitive!). This occurs between the cricondentherm and critical point at pressures below the cricondenbar. It's important for gas condensate reservoirs. -""" -) +""") # Demonstrate retrograde behavior print("Demonstrating retrograde behavior with the rich gas:") @@ -220,8 +218,7 @@ # ============================================================================= print("\n6. CRICONDENBAR & CRICONDENTHERM SIGNIFICANCE") print("-" * 40) -print( - """ +print(""" ┌─────────────────────────────────────────────────────────────────┐ │ PHASE ENVELOPE │ │ │ @@ -243,7 +240,6 @@ │ ● Above cricondentherm: Heating cannot cause condensation │ │ ● Critical point: Liquid and gas become indistinguishable │ └─────────────────────────────────────────────────────────────────┘ -""" -) +""") print("=" * 70) diff --git a/examples/physicalProperties.py b/examples/physicalProperties.py index 862f821d..a6d19f6f 100644 --- a/examples/physicalProperties.py +++ b/examples/physicalProperties.py @@ -22,7 +22,7 @@ @author: NeqSim Team """ -from neqsim.thermo import fluid, TPflash, printFrame +from neqsim.thermo import fluid, TPflash print("=" * 70) print("PHYSICAL PROPERTIES CALCULATION TUTORIAL") @@ -58,7 +58,7 @@ multiphase.initThermoProperties() multiphase.initPhysicalProperties() -print(f"Conditions: T = 60°C, P = 20 bara") +print("Conditions: T = 60°C, P = 20 bara") print(f"Number of phases: {multiphase.getNumberOfPhases()}") # ============================================================================= @@ -74,7 +74,7 @@ # Phase-specific densities if multiphase.hasPhaseType("gas"): gas = multiphase.getPhase("gas") - print(f"\nGas phase:") + print("\nGas phase:") print(f" Density: {gas.getDensity('kg/m3'):.4f} kg/m³") print(f" Molar density: {gas.getDensity('mol/m3'):.2f} mol/m³") print(f" Molar volume: {1.0/gas.getDensity('mol/m3')*1e6:.2f} cm³/mol") @@ -84,7 +84,7 @@ if multiphase.hasPhaseType("oil"): oil = multiphase.getPhase("oil") - print(f"\nOil (liquid hydrocarbon) phase:") + print("\nOil (liquid hydrocarbon) phase:") print(f" Density: {oil.getDensity('kg/m3'):.2f} kg/m³") print(f" Molar density: {oil.getDensity('mol/m3'):.2f} mol/m³") # API gravity calculation @@ -95,7 +95,7 @@ if multiphase.hasPhaseType("aqueous"): aq = multiphase.getPhase("aqueous") - print(f"\nAqueous phase:") + print("\nAqueous phase:") print(f" Density: {aq.getDensity('kg/m3'):.2f} kg/m³") # ============================================================================= @@ -114,7 +114,7 @@ gas_visc = gas.getViscosity("kg/msec") gas_density = gas.getDensity("kg/m3") kinematic_visc = gas_visc / gas_density # m²/s - print(f"\nGas phase:") + print("\nGas phase:") print(f" Dynamic viscosity: {gas_visc:.6f} kg/(m·s)") print(f" Dynamic viscosity: {gas_visc*1000:.4f} cP") print(f" Kinematic viscosity: {kinematic_visc*1e6:.4f} cSt") @@ -124,7 +124,7 @@ oil_visc = oil.getViscosity("kg/msec") oil_density = oil.getDensity("kg/m3") kinematic_visc = oil_visc / oil_density - print(f"\nOil phase:") + print("\nOil phase:") print(f" Dynamic viscosity: {oil_visc:.6f} kg/(m·s)") print(f" Dynamic viscosity: {oil_visc*1000:.2f} cP") print(f" Kinematic viscosity: {kinematic_visc*1e6:.2f} cSt") @@ -132,7 +132,7 @@ if multiphase.hasPhaseType("aqueous"): aq = multiphase.getPhase("aqueous") aq_visc = aq.getViscosity("kg/msec") - print(f"\nAqueous phase:") + print("\nAqueous phase:") print(f" Dynamic viscosity: {aq_visc:.6f} kg/(m·s)") print(f" Dynamic viscosity: {aq_visc*1000:.4f} cP") @@ -168,14 +168,14 @@ Cv = multiphase.getCv("J/molK") gamma = multiphase.getKappa() # Cp/Cv ratio -print(f"Overall mixture:") +print("Overall mixture:") print(f" Cp: {Cp:.2f} J/(mol·K)") print(f" Cv: {Cv:.2f} J/(mol·K)") print(f" γ = Cp/Cv: {gamma:.4f}") if multiphase.hasPhaseType("gas"): gas = multiphase.getPhase("gas") - print(f"\nGas phase:") + print("\nGas phase:") print(f" Cp: {gas.getCp('J/molK'):.2f} J/(mol·K)") print(f" Cp: {gas.getCp('J/kgK'):.2f} J/(kg·K)") print(f" γ = Cp/Cv: {gas.getGamma():.4f}") @@ -208,12 +208,12 @@ jt = gas.getJouleThomsonCoefficient() # Convert from K/Pa to K/bar jt_per_bar = jt * 1e5 - print(f"\nGas phase:") + print("\nGas phase:") print(f" μJT: {jt_per_bar:.4f} K/bar") if jt_per_bar > 0: - print(f" → Gas cools when throttled (normal JT effect)") + print(" → Gas cools when throttled (normal JT effect)") else: - print(f" → Gas heats when throttled (inverse JT effect)") + print(" → Gas heats when throttled (inverse JT effect)") # ============================================================================= # 8. SURFACE TENSION diff --git a/examples/pipeline.py b/examples/pipeline.py index 65481dff..de0b7c0a 100644 --- a/examples/pipeline.py +++ b/examples/pipeline.py @@ -5,8 +5,7 @@ @author: esol """ -from neqsim import methods -from neqsim.process import clearProcess, pipe, pipeline, runProcess, stream +from neqsim.process import clearProcess, pipeline, runProcess, stream from neqsim.thermo import TPflash, fluid # Start by creating a fluid in neqsim diff --git a/examples/plusFluid.py b/examples/plusFluid.py index f2e572ee..89cdc5e4 100644 --- a/examples/plusFluid.py +++ b/examples/plusFluid.py @@ -8,9 +8,6 @@ from neqsim.thermo import ( TPflash, fluid, - fluidComposition, - fluidCompositionPlus, - phaseenvelope, printFrame, ) diff --git a/examples/process.py b/examples/process.py index 77fa298c..f1848463 100644 --- a/examples/process.py +++ b/examples/process.py @@ -12,7 +12,6 @@ separator, stream, valve, - viewProcess, ) from neqsim.thermo import fluid diff --git a/examples/processApproaches.py b/examples/processApproaches.py index 5261a553..79863740 100644 --- a/examples/processApproaches.py +++ b/examples/processApproaches.py @@ -23,8 +23,6 @@ separator, compressor, cooler, - valve, - # New classes (Approaches 2 & 3) ProcessContext, ProcessBuilder, newProcess, @@ -72,7 +70,7 @@ # Run the simulation runProcess() -print(f"\nResults (Approach 1):") +print("\nResults (Approach 1):") print(f" Stage 1 power: {comp1.getPower()/1e6:.3f} MW") print(f" Stage 2 power: {comp2.getPower()/1e6:.3f} MW") print(f" Total power: {(comp1.getPower() + comp2.getPower())/1e6:.3f} MW") @@ -117,7 +115,7 @@ stage1 = ctx.get("1st stage") stage2 = ctx.get("2nd stage") - print(f"\nResults (Approach 2):") + print("\nResults (Approach 2):") print(f" Stage 1 power: {stage1.getPower()/1e6:.3f} MW") print(f" Stage 2 power: {stage2.getPower()/1e6:.3f} MW") print(f" Total power: {(stage1.getPower() + stage2.getPower())/1e6:.3f} MW") @@ -161,7 +159,7 @@ comp1 = process.get("1st stage") comp2 = process.get("2nd stage") -print(f"\nResults (Approach 3):") +print("\nResults (Approach 3):") print(f" Stage 1 power: {comp1.getPower()/1e6:.3f} MW") print(f" Stage 2 power: {comp2.getPower()/1e6:.3f} MW") print(f" Total power: {(comp1.getPower() + comp2.getPower())/1e6:.3f} MW") @@ -202,7 +200,7 @@ # Run specific process my_process.run() -print(f"\nResults (Hybrid):") +print("\nResults (Hybrid):") print(f" Stage 1 power: {comp1.getPower()/1e6:.3f} MW") print(f" Stage 2 power: {comp2.getPower()/1e6:.3f} MW") print(f" Total power: {(comp1.getPower() + comp2.getPower())/1e6:.3f} MW") @@ -215,8 +213,7 @@ print("\n" + "=" * 70) print("CHOOSING AN APPROACH") print("=" * 70) -print( - """ +print(""" | Use Case | Recommended Approach | |---------------------------------|-------------------------------| | Learning / tutorials | Wrappers (global process) | @@ -228,5 +225,4 @@ | Clean declarative style | ProcessBuilder | | Mixing wrapper convenience | Hybrid (process= parameter) | with explicit control | | -""" -) +""") diff --git a/examples/processBuilderGUI.py b/examples/processBuilderGUI.py index c261e0e0..04a97763 100644 --- a/examples/processBuilderGUI.py +++ b/examples/processBuilderGUI.py @@ -229,7 +229,7 @@ def run_process(): f"**Flow:** {config['flow_rate']} {config['flow_unit']}" ) st.write("**Composition:**", config["components"]) - if st.button(f"🗑️ Remove", key=f"del_fluid_{name}"): + if st.button("🗑️ Remove", key=f"del_fluid_{name}"): del st.session_state.fluids[name] st.rerun() else: @@ -451,8 +451,7 @@ def run_process(): with st.sidebar: st.header("ℹ️ About") - st.markdown( - """ + st.markdown(""" **NeqSim Process Builder GUI** A visual tool for building and simulating @@ -473,8 +472,7 @@ def run_process(): - Valves - Heaters/Coolers - Pipes - """ - ) + """) st.divider() diff --git a/examples/process_api.py b/examples/process_api.py index 51301e47..f00ac935 100644 --- a/examples/process_api.py +++ b/examples/process_api.py @@ -44,8 +44,7 @@ from fastapi import FastAPI, HTTPException, Body from fastapi.middleware.cors import CORSMiddleware from pydantic import BaseModel, Field -from typing import Any, Dict, List, Optional, Union -import json +from typing import Any, Dict, List, Optional import traceback import logging @@ -557,7 +556,7 @@ async def run_simulation_yaml(yaml_content: str = Body(..., media_type="text/pla except ImportError: raise HTTPException(status_code=500, detail="PyYAML not installed") - except Exception as e: + except Exception: logger.error("Exception in /simulate/yaml endpoint", exc_info=True) return {"success": False, "error": "An internal error occurred"} diff --git a/examples/pumpNPSH.py b/examples/pumpNPSH.py index d7ce0734..89b3b9af 100644 --- a/examples/pumpNPSH.py +++ b/examples/pumpNPSH.py @@ -90,13 +90,13 @@ # Check for cavitation if pump.isCavitating(): - print(f" ⚠️ WARNING: CAVITATION RISK!") - print(f" Consider increasing suction pressure") - print(f" or reducing pump speed/flow") + print(" ⚠️ WARNING: CAVITATION RISK!") + print(" Consider increasing suction pressure") + print(" or reducing pump speed/flow") else: - print(f" ✓ No cavitation risk detected") + print(" ✓ No cavitation risk detected") else: - print(f" NPSHa calculation not available") - print(f" Tip: Check fluid has liquid phase at suction") + print(" NPSHa calculation not available") + print(" Tip: Check fluid has liquid phase at suction") print("=" * 60) diff --git a/examples/pvtExperimentsAdvanced.py b/examples/pvtExperimentsAdvanced.py index 7e99aca6..349ba998 100644 --- a/examples/pvtExperimentsAdvanced.py +++ b/examples/pvtExperimentsAdvanced.py @@ -251,7 +251,7 @@ base_oil.setMixingRule("classic") base_oil.setMultiPhaseCheck(True) -print(f"\nBase oil: C1/C3/C6/C10 at T = 80°C") +print("\nBase oil: C1/C3/C6/C10 at T = 80°C") print("\nCO2 Added | Swelling | Sat. Pressure") print("[mol%] | Factor | [bara]") print("-" * 40) @@ -318,8 +318,7 @@ # ============================================================================= print("\n8. PVT EXPERIMENTS SUMMARY") print("-" * 40) -print( - """ +print(""" Experiment | Purpose --------------------|---------------------------------------------- CME | Oil compressibility, relative volume, GOR @@ -328,7 +327,6 @@ Separator Test | Optimize surface separation, stock tank oil Swelling Test | EOR potential with gas injection (CO2, HC gas) Viscosity Study | Flow assurance, production optimization -""" -) +""") print("=" * 70) diff --git a/examples/safetyValve.py b/examples/safetyValve.py index 60d7a007..bbff1286 100644 --- a/examples/safetyValve.py +++ b/examples/safetyValve.py @@ -87,9 +87,9 @@ print("=" * 70) print("\nPSV Configuration:") -print(f" Set pressure: 55.0 bara") -print(f" Full open pressure: 60.5 bara") -print(f" Blowdown: 7%") +print(" Set pressure: 55.0 bara") +print(" Full open pressure: 60.5 bara") +print(" Blowdown: 7%") print(f" Reseat pressure: {55.0 * 0.93:.1f} bara") print("\nNormal Operating Conditions (50 bara):") @@ -109,12 +109,12 @@ feed_stream.setFluid(separator_gas) process.run() -print(f"\nOverpressure Conditions (58 bara inlet):") +print("\nOverpressure Conditions (58 bara inlet):") print(f" PSV status: {'CLOSED' if psv.getPercentValveOpening() < 0.1 else 'OPEN'}") print(f" PSV opening: {psv.getPercentValveOpening():.1f}%") if psv.getPercentValveOpening() > 0: - print(f"\n⚠️ PSV IS RELIEVING!") + print("\n⚠️ PSV IS RELIEVING!") print(f" Relief rate: {psv_relief.getFlowRate('kg/hr'):.0f} kg/hr") print(f" Flare duty: {flare.getHeatDuty('MW'):.2f} MW") print(f" CO2 emission: {flare.getCO2Emission('kg/hr'):.0f} kg/hr") diff --git a/examples/separationProcess.py b/examples/separationProcess.py index 7b45194a..c0a04082 100644 --- a/examples/separationProcess.py +++ b/examples/separationProcess.py @@ -7,13 +7,10 @@ from neqsim.process import ( clearProcess, - compressor, - heater, runProcess, separator, stream, valve, - viewProcess, ) from neqsim.thermo import fluid diff --git a/examples/separatorMechanicalDesign.py b/examples/separatorMechanicalDesign.py index 5a408d23..fe39be9c 100644 --- a/examples/separatorMechanicalDesign.py +++ b/examples/separatorMechanicalDesign.py @@ -10,14 +10,12 @@ compressor, heater, mixer, - recycle, runProcess, separator, stream, valve, - viewProcess, ) -from neqsim.thermo import fluid, phaseenvelope +from neqsim.thermo import fluid feedPressure = 30.0 MPpressure = 10.0 diff --git a/examples/transientSeparator.py b/examples/transientSeparator.py index e9a3ee38..c9c64d13 100644 --- a/examples/transientSeparator.py +++ b/examples/transientSeparator.py @@ -66,8 +66,8 @@ print("=" * 70) print("\nSeparator Configuration:") -print(f" Internal diameter: 2.5 m") -print(f" Length: 6.0 m") +print(" Internal diameter: 2.5 m") +print(" Length: 6.0 m") print("\nInitial Steady-State Conditions:") print(f" Feed rate: {feed_stream.getFlowRate('kg/hr'):.0f} kg/hr") @@ -83,7 +83,7 @@ time_step = 10.0 # seconds simulation_time = 120.0 # total seconds -print(f"\nTime (s) | Pressure (bara) | Gas Flow (kg/hr) | Liquid Flow (kg/hr)") +print("\nTime (s) | Pressure (bara) | Gas Flow (kg/hr) | Liquid Flow (kg/hr)") print("-" * 70) time = 0.0 diff --git a/examples/viscosityModels.py b/examples/viscosityModels.py index 8115c786..fa96c71d 100644 --- a/examples/viscosityModels.py +++ b/examples/viscosityModels.py @@ -22,7 +22,6 @@ """ from neqsim.thermo import fluid, TPflash -from neqsim import jneqsim print("=" * 70) print("OIL VISCOSITY MODELS AND TUNING TUTORIAL") @@ -33,8 +32,7 @@ # ============================================================================= print("\n1. AVAILABLE VISCOSITY MODELS") print("-" * 40) -print( - """ +print(""" Model | Keyword | Best For -------------------|--------------------|--------------------------------- LBC | "LBC" | General oil, reservoir fluids @@ -45,8 +43,7 @@ The LBC model is based on corresponding states principle using critical properties. Friction Theory links viscosity to EoS pressure terms, providing thermodynamic consistency. -""" -) +""") # ============================================================================= # 2. BASIC VISCOSITY CALCULATION @@ -69,8 +66,8 @@ oil.setPressure(100.0, "bara") TPflash(oil) -print(f"Oil composition: C1: 10%, C5: 15%, C7: 25%, C10: 30%, C16: 20%") -print(f"Conditions: T = 50°C, P = 100 bara") +print("Oil composition: C1: 10%, C5: 15%, C7: 25%, C10: 30%, C16: 20%") +print("Conditions: T = 50°C, P = 100 bara") # Compare different viscosity models print("\nViscosity with different models:") @@ -92,8 +89,7 @@ # ============================================================================= print("\n3. LBC MODEL (LOHRENZ-BRAY-CLARK)") print("-" * 40) -print( - """ +print(""" The LBC model calculates viscosity as: η = η* + η_dense / ξ_m @@ -115,8 +111,7 @@ a4 = 0.0093324 These parameters can be tuned to match laboratory viscosity data. -""" -) +""") # ============================================================================= # 4. TUNING LBC MODEL PARAMETERS @@ -171,8 +166,7 @@ print(f"Further adjusted (a2=0.10): {tuned_visc_2:.4f} cP") -print( - """ +print(""" LBC Tuning Guidelines: ---------------------- • a0 (index 0): Baseline offset - increase for higher overall viscosity @@ -180,16 +174,14 @@ • a2 (index 2): Quadratic term - significant for liquid viscosity • a3 (index 3): Cubic term - fine-tuning at high density • a4 (index 4): Quartic term - extreme density behavior -""" -) +""") # ============================================================================= # 5. FRICTION THEORY MODEL # ============================================================================= print("\n5. FRICTION THEORY MODEL") print("-" * 40) -print( - """ +print(""" Friction Theory (f-theory) links viscosity to EoS pressure terms: η = η0 + ηf @@ -205,8 +197,7 @@ ✓ Consistent with phase equilibrium calculations ✓ Better extrapolation behavior ✓ Works well for wide T/P ranges -""" -) +""") # ============================================================================= # 6. TUNING FRICTION THEORY - TBP CORRECTION FACTOR @@ -262,8 +253,7 @@ # Reset to default visc_model.setTBPviscosityCorrection(1.0) -print( - """ +print(""" Friction Theory Tuning Guidelines: ---------------------------------- • TBP Correction Factor: @@ -274,8 +264,7 @@ • Use when TBP fractions give incorrect viscosity predictions • Tune to match laboratory viscosity at one T/P condition • Model will extrapolate to other conditions -""" -) +""") # ============================================================================= # 7. ADVANCED: TUNING WITH EXPERIMENTAL DATA @@ -297,8 +286,7 @@ for pt in exp_data: print(f"{pt['T_C']:6} | {pt['P_bara']:8} | {pt['visc_cP']:.2f}") -print( - """ +print(""" Tuning Workflow: ---------------- 1. Create fluid with accurate composition @@ -313,8 +301,7 @@ For automatic optimization, use NeqSim's parameter fitting capabilities with the ViscosityFunction class in PVT simulation. -""" -) +""") # ============================================================================= # 8. MODEL COMPARISON AT DIFFERENT CONDITIONS @@ -369,8 +356,7 @@ # ============================================================================= print("\n9. HEAVY OIL CONSIDERATIONS") print("-" * 40) -print( - """ +print(""" For heavy oils (API < 20°, viscosity > 100 cP), consider: 1. Use PFCT-Heavy-Oil model: @@ -383,16 +369,14 @@ 4. Temperature sensitivity is critical - ensure accurate measurements 5. Consider using Pedersen corresponding states for very heavy systems -""" -) +""") # ============================================================================= # 10. SUMMARY # ============================================================================= print("\n10. SUMMARY: MODEL SELECTION GUIDELINES") print("-" * 40) -print( - """ +print(""" ┌────────────────────┬──────────────────────────────────────────┐ │ Oil Type │ Recommended Model & Notes │ ├────────────────────┼──────────────────────────────────────────┤ @@ -408,7 +392,6 @@ │ Extra-heavy │ Specialized correlations │ │ (API < 10°) │ May require custom viscosity data │ └────────────────────┴──────────────────────────────────────────┘ -""" -) +""") print("=" * 70) diff --git a/src/neqsim/process/measurement.py b/src/neqsim/process/measurement.py index 4220b098..f460b7f6 100644 --- a/src/neqsim/process/measurement.py +++ b/src/neqsim/process/measurement.py @@ -1,6 +1,4 @@ from neqsim import jneqsim -import jpype -import jpype.imports from jpype import JImplements, JOverride # Ensure the JVM is started and neqsim is attached diff --git a/src/neqsim/process/processTools.py b/src/neqsim/process/processTools.py index c38f90c2..c862b48b 100644 --- a/src/neqsim/process/processTools.py +++ b/src/neqsim/process/processTools.py @@ -4173,7 +4173,7 @@ def recycle(name, stream=None): Recycle: The created recycle process unit. """ recycle1 = jneqsim.process.equipment.util.Recycle(name) - if not stream is None: + if stream is not None: recycle1.addStream(stream) if not _loop_mode: processoperations.add(recycle1) diff --git a/src/neqsim/process/unitop.py b/src/neqsim/process/unitop.py index 032b8d29..26a9da3f 100644 --- a/src/neqsim/process/unitop.py +++ b/src/neqsim/process/unitop.py @@ -1,6 +1,4 @@ from neqsim import jneqsim -import jpype -import jpype.imports from jpype import JImplements, JOverride # Ensure the JVM is started and neqsim is attached diff --git a/tests/process/test_measurement.py b/tests/process/test_measurement.py index 883a6ef4..a29730a9 100644 --- a/tests/process/test_measurement.py +++ b/tests/process/test_measurement.py @@ -1,14 +1,6 @@ from neqsim.process.measurement import measurement -from neqsim.process.processTools import ( - pump, - stream, - clearProcess, - runProcess, - pumpChart, -) from neqsim.thermo import fluid from neqsim import jneqsim -from jpype import JImplements, JOverride class ExampleMeasurement(measurement): diff --git a/tests/process/test_unitop.py b/tests/process/test_unitop.py index 7fa29002..cbc8ebb5 100644 --- a/tests/process/test_unitop.py +++ b/tests/process/test_unitop.py @@ -1,14 +1,7 @@ from neqsim.process.unitop import unitop -from neqsim.process.processTools import ( - pump, - stream, - clearProcess, - runProcess, - pumpChart, -) from neqsim.thermo import fluid from neqsim import jneqsim -from jpype import JImplements, JOverride +from jpype import JOverride class ExampleCompressor(unitop): diff --git a/tests/thermo/test_ThermoTools.py b/tests/thermo/test_ThermoTools.py index fd64e1fd..cc7a2016 100644 --- a/tests/thermo/test_ThermoTools.py +++ b/tests/thermo/test_ThermoTools.py @@ -443,18 +443,9 @@ def test_addfluid(): def test_fluidChar(): - import neqsim from neqsim.thermo import ( - fluid, fluid_df, - addOilFractions, - printFrame, - dataFrame, - fluidcreator, - createfluid, - createfluid2, TPflash, - phaseenvelope, ) import pandas as pd