diff --git a/.devcontainer/requirements.txt b/.devcontainer/requirements.txt index 5e89b6e..d3fe9f1 100644 --- a/.devcontainer/requirements.txt +++ b/.devcontainer/requirements.txt @@ -1,3 +1,4 @@ +jneqsim jpype1 pandas matplotlib diff --git a/.github/workflows/runtests.yml b/.github/workflows/runtests.yml index eac54ed..77a2742 100644 --- a/.github/workflows/runtests.yml +++ b/.github/workflows/runtests.yml @@ -11,7 +11,7 @@ jobs: build: strategy: matrix: - version: [3.8, 3.9, 3.12] + version: [3.9, 3.12] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index cb95bb5..19e7464 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ NeqSim Python is distributed as a pip package. End-users should install neqsim python with some additional packages by running ``` -pip install neqsim[interactive] +pip install neqsim ``` ## Getting Started diff --git a/neqsim/__init__.py b/neqsim/__init__.py index 4f3ba58..1bf5810 100644 --- a/neqsim/__init__.py +++ b/neqsim/__init__.py @@ -4,7 +4,8 @@ It uses the Jpype module for bridging python and Java. """ -from neqsim.neqsimpython import jneqsim, jpype +from jneqsim import neqsim +import jpype def methods(checkClass): @@ -26,8 +27,8 @@ def has_tabulate(): def setDatabase(connectionString): - jneqsim.util.database.NeqSimDataBase.setConnectionString(connectionString) - jneqsim.util.database.NeqSimDataBase.setCreateTemporaryTables(True) + neqsim.util.database.NeqSimDataBase.setConnectionString(connectionString) + neqsim.util.database.NeqSimDataBase.setCreateTemporaryTables(True) def save_xml(javaobject, filename): diff --git a/neqsim/lib/java11/neqsim-3.0.2.jar b/neqsim/lib/java11/neqsim-3.0.2.jar deleted file mode 100644 index 86f174b..0000000 Binary files a/neqsim/lib/java11/neqsim-3.0.2.jar and /dev/null differ diff --git a/neqsim/lib/java8/neqsim-3.0.2-Java8.jar b/neqsim/lib/java8/neqsim-3.0.2-Java8.jar deleted file mode 100644 index 4fff51d..0000000 Binary files a/neqsim/lib/java8/neqsim-3.0.2-Java8.jar and /dev/null differ diff --git a/neqsim/neqsimpython.py b/neqsim/neqsimpython.py deleted file mode 100644 index 86ecb65..0000000 --- a/neqsim/neqsimpython.py +++ /dev/null @@ -1,20 +0,0 @@ -import jpype - -if not jpype.isJVMStarted(): - # Could call jpype.getDefaultJVMPath() to get default JVM, - # but not able to get the orders to force loading a specific JVM - jpype.startJVM(convertStrings=False) - jvm_version = jpype.getJVMVersion()[0] - if jvm_version == 1 and jpype.getJVMVersion()[1] >= 8: - jpype.addClassPath("./lib/java8/*") - # elif jvm_version >= 21: - # jpype.addClassPath("./lib/java21/*") - elif jvm_version >= 11: - jpype.addClassPath("./lib/java11/*") - else: - print( - "Your version of Java is not supported. Please upgrade to Java version 8 or higher." - ) - print("See: https://github.com/equinor/neqsimpython#prerequisites") - -jneqsim = jpype.JPackage("neqsim") diff --git a/neqsim/process/measurement.py b/neqsim/process/measurement.py index 4befc7f..d5549bd 100644 --- a/neqsim/process/measurement.py +++ b/neqsim/process/measurement.py @@ -1,6 +1,4 @@ -from neqsim import jneqsim -import jpype -import jpype.imports +from jneqsim import neqsim from jpype import JImplements, JOverride @@ -10,8 +8,8 @@ @JImplements( - jneqsim.processsimulation.measurementdevice.MeasurementDeviceInterface -) # Use the fully qualified class name directly from the jneqsim package + neqsim.processsimulation.measurementdevice.MeasurementDeviceInterface +) # Use the fully qualified class name directly from the neqsim package class measurement: def __init__(self): self.name = "" diff --git a/neqsim/process/processTools.py b/neqsim/process/processTools.py index 021384b..e6a5600 100644 --- a/neqsim/process/processTools.py +++ b/neqsim/process/processTools.py @@ -1,9 +1,7 @@ -import jpype -import jpype.imports -from jpype.types import * -from neqsim.neqsimpython import jneqsim +from jpype.types import JDouble +from jneqsim import neqsim -processoperations = jneqsim.processsimulation.processsystem.ProcessSystem() +processoperations = neqsim.processsimulation.processsystem.ProcessSystem() def newProcess(): @@ -11,7 +9,7 @@ def newProcess(): Create a new process object """ global processoperations - processoperations = jneqsim.processsimulation.processsystem.ProcessSystem() + processoperations = neqsim.processsimulation.processsystem.ProcessSystem() def stream(name, thermoSystem, t=0, p=0): @@ -19,15 +17,13 @@ def stream(name, thermoSystem, t=0, p=0): thermoSystem.setTemperature(t) if p != 0: thermoSystem.setPressure(p) - stream = jneqsim.processsimulation.processequipment.stream.Stream( - name, thermoSystem - ) + stream = neqsim.processsimulation.processequipment.stream.Stream(name, thermoSystem) processoperations.add(stream) return stream def virtualstream(name, streamIn): - stream = jneqsim.processsimulation.processequipment.stream.VirtualStream( + stream = neqsim.processsimulation.processequipment.stream.VirtualStream( name, streamIn ) processoperations.add(stream) @@ -39,7 +35,7 @@ def neqstream(name, thermoSystem, t=0, p=0): thermoSystem.setTemperature(t) if p != 0: thermoSystem.setPressure(p) - stream = jneqsim.processsimulation.processequipment.stream.NeqStream( + stream = neqsim.processsimulation.processequipment.stream.NeqStream( name, thermoSystem ) stream.setName(name) @@ -48,8 +44,8 @@ def neqstream(name, thermoSystem, t=0, p=0): def recycle(name, stream=None): - recycle1 = jneqsim.processsimulation.processequipment.util.Recycle(name) - if not stream is None: + recycle1 = neqsim.processsimulation.processequipment.util.Recycle(name) + if stream is not None: recycle1.addStream(stream) processoperations.add(recycle1) return recycle1 @@ -57,7 +53,7 @@ def recycle(name, stream=None): def saturator(name, teststream): streamsaturator = ( - jneqsim.processsimulation.processequipment.util.StreamSaturatorUtil( + neqsim.processsimulation.processequipment.util.StreamSaturatorUtil( name, teststream ) ) @@ -67,7 +63,7 @@ def saturator(name, teststream): def glycoldehydrationlmodule(name, teststream): dehydrationlmodule = ( - jneqsim.processsimulation.processsystem.processModules.GlycolDehydrationlModule( + neqsim.processsimulation.processsystem.processModules.GlycolDehydrationlModule( name ) ) @@ -77,14 +73,14 @@ def glycoldehydrationlmodule(name, teststream): def openprocess(filename): - processoperations = jneqsim.processsimulation.processsystem.ProcessSystem.open( + processoperations = neqsim.processsimulation.processsystem.ProcessSystem.open( filename ) return processoperations def separator(name, teststream): - separator = jneqsim.processsimulation.processequipment.separator.Separator( + separator = neqsim.processsimulation.processequipment.separator.Separator( name, teststream ) separator.setName(name) @@ -93,7 +89,7 @@ def separator(name, teststream): def GORfitter(name, teststream): - GORfitter1 = jneqsim.processsimulation.processequipment.util.GORfitter( + GORfitter1 = neqsim.processsimulation.processequipment.util.GORfitter( name, name, teststream ) GORfitter1.setName(name) @@ -102,7 +98,7 @@ def GORfitter(name, teststream): def simpleTEGAbsorber(name): - absorber = jneqsim.processsimulation.processequipment.absorber.SimpleTEGAbsorber( + absorber = neqsim.processsimulation.processequipment.absorber.SimpleTEGAbsorber( name ) absorber.setName(name) @@ -111,7 +107,7 @@ def simpleTEGAbsorber(name): def waterStripperColumn(name): - stripper = jneqsim.processsimulation.processequipment.absorber.WaterStripperColumn( + stripper = neqsim.processsimulation.processequipment.absorber.WaterStripperColumn( name ) stripper.setName(name) @@ -120,7 +116,7 @@ def waterStripperColumn(name): def gasscrubber(name, teststream): - separator = jneqsim.processsimulation.processequipment.separator.GasScrubber( + separator = neqsim.processsimulation.processequipment.separator.GasScrubber( name, teststream ) separator.setName(name) @@ -129,10 +125,8 @@ def gasscrubber(name, teststream): def separator3phase(name, teststream): - separator = ( - jneqsim.processsimulation.processequipment.separator.ThreePhaseSeparator( - name, teststream - ) + separator = neqsim.processsimulation.processequipment.separator.ThreePhaseSeparator( + name, teststream ) separator.setName(name) processoperations.add(separator) @@ -140,7 +134,7 @@ def separator3phase(name, teststream): def valve(name, teststream, p=1.0): - valve = jneqsim.processsimulation.processequipment.valve.ThrottlingValve( + valve = neqsim.processsimulation.processequipment.valve.ThrottlingValve( name, teststream ) valve.setOutletPressure(p) @@ -150,13 +144,13 @@ def valve(name, teststream, p=1.0): def calculator(name): - calc2 = jneqsim.processsimulation.processequipment.util.Calculator(name) + calc2 = neqsim.processsimulation.processequipment.util.Calculator(name) processoperations.add(calc2) return calc2 def setpoint(name1, unit1, name2, unit2): - setp = jneqsim.processsimulation.processequipment.util.SetPoint( + setp = neqsim.processsimulation.processequipment.util.SetPoint( name1, unit1, name2, unit2 ) processoperations.add(setp) @@ -164,13 +158,13 @@ def setpoint(name1, unit1, name2, unit2): def filters(name, teststream): - filter2 = jneqsim.processsimulation.processequipment.filter.Filter(name, teststream) + filter2 = neqsim.processsimulation.processequipment.filter.Filter(name, teststream) processoperations.add(filter2) return filter2 def compressor(name, teststream, pres=10.0): - compressor = jneqsim.processsimulation.processequipment.compressor.Compressor( + compressor = neqsim.processsimulation.processequipment.compressor.Compressor( name, teststream ) compressor.setOutletPressure(pres) @@ -213,14 +207,14 @@ def compressorStoneWallCurve(compressor, curveConditions, stoneWallflow, stoneWa def pump(name, teststream, p=1.0): - pump = jneqsim.processsimulation.processequipment.pump.Pump(name, teststream) + pump = neqsim.processsimulation.processequipment.pump.Pump(name, teststream) pump.setOutletPressure(p) processoperations.add(pump) return pump def expander(name, teststream, p): - expander = jneqsim.processsimulation.processequipment.expander.Expander( + expander = neqsim.processsimulation.processequipment.expander.Expander( name, teststream ) expander.setOutletPressure(p) @@ -230,13 +224,13 @@ def expander(name, teststream, p): def mixer(name=""): - mixer = jneqsim.processsimulation.processequipment.mixer.Mixer(name) + mixer = neqsim.processsimulation.processequipment.mixer.Mixer(name) processoperations.add(mixer) return mixer def phasemixer(name): - mixer = jneqsim.processsimulation.processequipment.mixer.StaticPhaseMixer(name) + mixer = neqsim.processsimulation.processequipment.mixer.StaticPhaseMixer(name) processoperations.add(mixer) return mixer @@ -244,7 +238,7 @@ def phasemixer(name): def nequnit( teststream, equipment="pipeline", flowpattern="stratified", numberOfNodes=100 ): - neqUn = jneqsim.processsimulation.processequipment.util.NeqSimUnit( + neqUn = neqsim.processsimulation.processequipment.util.NeqSimUnit( teststream, equipment, flowpattern ) neqUn.setNumberOfNodes(numberOfNodes) @@ -253,10 +247,8 @@ def nequnit( def compsplitter(name, teststream, splitfactors): - compSplitter = ( - jneqsim.processsimulation.processequipment.splitter.ComponentSplitter( - name, teststream - ) + compSplitter = neqsim.processsimulation.processequipment.splitter.ComponentSplitter( + name, teststream ) compSplitter.setSplitFactors(splitfactors) processoperations.add(compSplitter) @@ -264,7 +256,7 @@ def compsplitter(name, teststream, splitfactors): def splitter(name, teststream, splitfactors=[]): - splitter = jneqsim.processsimulation.processequipment.splitter.Splitter( + splitter = neqsim.processsimulation.processequipment.splitter.Splitter( name, teststream ) if len(splitfactors) > 0: @@ -275,7 +267,7 @@ def splitter(name, teststream, splitfactors=[]): def heater(name, teststream): - heater = jneqsim.processsimulation.processequipment.heatexchanger.Heater( + heater = neqsim.processsimulation.processequipment.heatexchanger.Heater( name, teststream ) heater.setName(name) @@ -290,14 +282,14 @@ def simplereservoir( oilvolume=120.0 * 1e6, watervolume=10.0e6, ): - reserv = jneqsim.processsimulation.processequipment.reservoir.SimpleReservoir(name) + reserv = neqsim.processsimulation.processequipment.reservoir.SimpleReservoir(name) reserv.setReservoirFluid(fluid, gasvolume, oilvolume, watervolume) processoperations.add(reserv) return reserv def cooler(name, teststream): - cooler = jneqsim.processsimulation.processequipment.heatexchanger.Cooler( + cooler = neqsim.processsimulation.processequipment.heatexchanger.Cooler( name, teststream ) cooler.setName(name) @@ -307,11 +299,11 @@ def cooler(name, teststream): def heatExchanger(name, stream1, stream2=None): if stream2 is None: - heater = jneqsim.processsimulation.processequipment.heatexchanger.HeatExchanger( + heater = neqsim.processsimulation.processequipment.heatexchanger.HeatExchanger( name, stream1 ) else: - heater = jneqsim.processsimulation.processequipment.heatexchanger.HeatExchanger( + heater = neqsim.processsimulation.processequipment.heatexchanger.HeatExchanger( name, stream1, stream2 ) heater.setName(name) @@ -321,7 +313,7 @@ def heatExchanger(name, stream1, stream2=None): def distillationColumn(name, trays=5, reboil=True, condenser=True): distillationColumn = ( - jneqsim.processsimulation.processequipment.distillation.DistillationColumn( + neqsim.processsimulation.processequipment.distillation.DistillationColumn( name, trays, reboil, condenser ) ) @@ -330,7 +322,7 @@ def distillationColumn(name, trays=5, reboil=True, condenser=True): def neqheater(name, teststream): - neqheater = jneqsim.processsimulation.processequipment.heatexchanger.NeqHeater( + neqheater = neqsim.processsimulation.processequipment.heatexchanger.NeqHeater( name, teststream ) processoperations.add(neqheater) @@ -338,7 +330,7 @@ def neqheater(name, teststream): def twophasepipe(name, teststream, position, diameter, height, outTemp, rough): - pipe = jneqsim.processsimulation.processequipment.pipeline.TwoPhasePipeLine( + pipe = neqsim.processsimulation.processequipment.pipeline.TwoPhasePipeLine( name, teststream ) pipe.setOutputFileName("c:/tempNew20.nc") @@ -359,7 +351,7 @@ def twophasepipe(name, teststream, position, diameter, height, outTemp, rough): def pipe(name, teststream, length, deltaElevation, diameter, rough): - pipe = jneqsim.processsimulation.processequipment.pipeline.AdiabaticPipe( + pipe = neqsim.processsimulation.processequipment.pipeline.AdiabaticPipe( name, teststream ) pipe.setDiameter(diameter) @@ -383,7 +375,7 @@ def pipeline( pipeWallHeatTransferCoefficients, numberOfNodesInLeg=50, ): - pipe = jneqsim.processsimulation.processequipment.pipeline.OnePhasePipeLine( + pipe = neqsim.processsimulation.processequipment.pipeline.OnePhasePipeLine( name, teststream ) pipe.setOutputFileName("c:/tempNew20.nc") @@ -441,7 +433,7 @@ def viewProcess(): def waterDewPointAnalyser(name, teststream): waterDewPointAnalyser = ( - jneqsim.processsimulation.measurementdevice.WaterDewPointAnalyser(teststream) + neqsim.processsimulation.measurementdevice.WaterDewPointAnalyser(teststream) ) waterDewPointAnalyser.setName(name) processoperations.add(waterDewPointAnalyser) @@ -449,7 +441,7 @@ def waterDewPointAnalyser(name, teststream): def hydrateEquilibriumTemperatureAnalyser(name, teststream): - hydrateEquilibriumTemperatureAnalyser = jneqsim.processsimulation.measurementdevice.HydrateEquilibriumTemperatureAnalyser( + hydrateEquilibriumTemperatureAnalyser = neqsim.processsimulation.measurementdevice.HydrateEquilibriumTemperatureAnalyser( name, teststream ) hydrateEquilibriumTemperatureAnalyser.setName(name) diff --git a/neqsim/process/unitop.py b/neqsim/process/unitop.py index 66b39f6..7376885 100644 --- a/neqsim/process/unitop.py +++ b/neqsim/process/unitop.py @@ -1,6 +1,4 @@ -from neqsim import jneqsim -import jpype -import jpype.imports +from jneqsim import neqsim from jpype import JImplements, JOverride # Ensure the JVM is started and neqsim is attached @@ -9,8 +7,8 @@ @JImplements( - jneqsim.processsimulation.processequipment.ProcessEquipmentInterface -) # Use the fully qualified class name directly from the jneqsim package + neqsim.processsimulation.processequipment.ProcessEquipmentInterface +) # Use the fully qualified class name directly from the neqsim package class unitop: def __init__(self): self.name = "" diff --git a/neqsim/standards/standardTools.py b/neqsim/standards/standardTools.py index 5e325bc..1d9e745 100644 --- a/neqsim/standards/standardTools.py +++ b/neqsim/standards/standardTools.py @@ -1,4 +1,4 @@ -from neqsim.neqsimpython import jneqsim +from jneqsim import neqsim def ISO6976( @@ -8,7 +8,7 @@ def ISO6976( referencetemperaturecombustion="15", ): """numberUnit can be 'volume', 'mass', 'molar""" - iso6976 = jneqsim.standards.gasquality.Standard_ISO6976(fluid) + iso6976 = neqsim.standards.gasquality.Standard_ISO6976(fluid) iso6976.setReferenceType(numberunit) iso6976.setVolRefT(float(referencetemperaturevolume)) iso6976.setEnergyRefT(float(referencetemperaturecombustion)) diff --git a/neqsim/thermo/thermoTools.py b/neqsim/thermo/thermoTools.py index f917efa..5a48e30 100644 --- a/neqsim/thermo/thermoTools.py +++ b/neqsim/thermo/thermoTools.py @@ -2,10 +2,12 @@ from typing import List, Union import jpype import pandas -from jpype.types import * +from jpype.types import JDouble, JString from neqsim import has_matplotlib, has_tabulate -from neqsim.neqsimpython import jneqsim from neqsim.standards import ISO6976 + +# Must import this after getting all necessary methods from neqsim python package +from jneqsim import neqsim import math logger = logging.getLogger(__name__) @@ -13,55 +15,55 @@ if has_matplotlib(): import matplotlib.pyplot as plt -thermodynamicoperations = jneqsim.thermodynamicoperations.ThermodynamicOperations -fluidcreator = jneqsim.thermo.Fluid() +thermodynamicoperations = neqsim.thermodynamicoperations.ThermodynamicOperations +fluidcreator = neqsim.thermo.Fluid() fluid_type = { - "srk": jneqsim.thermo.system.SystemSrkEos, - "SRK-EoS": jneqsim.thermo.system.SystemSrkEos, - "Psrk-EoS": jneqsim.thermo.system.SystemPsrkEos, - "PSRK-EoS": jneqsim.thermo.system.SystemPsrkEos, - "RK-EoS": jneqsim.thermo.system.SystemRKEos, - "pr": jneqsim.thermo.system.SystemPrEos, - "PR-EoS": jneqsim.thermo.system.SystemPrEos, - "pr-umr": jneqsim.thermo.system.SystemUMRPRUMCEos, - "srk-s": jneqsim.thermo.system.SystemSrkSchwartzentruberEos, - "GERG-water": jneqsim.thermo.system.SystemGERGwaterEos, - "SRK-MC": jneqsim.thermo.system.SystemSrkMathiasCopeman, - "PR-MC": jneqsim.thermo.system.SystemPrMathiasCopeman, - "scrk": jneqsim.thermo.system.SystemSrkSchwartzentruberEos, - "ScRK-EoS": jneqsim.thermo.system.SystemSrkSchwartzentruberEos, - "nrtl": jneqsim.thermo.system.SystemNRTL, - "unifac": jneqsim.thermo.system.SystemUNIFAC, - "electrolyte": jneqsim.thermo.system.SystemFurstElectrolyteEos, - "Electrolyte-ScRK-EoS": jneqsim.thermo.system.SystemFurstElectrolyteEos, - "Electrolyte-CPA-EoS": jneqsim.thermo.system.SystemElectrolyteCPAstatoil, - "cpa-el": jneqsim.thermo.system.SystemElectrolyteCPA, - "cpa-s": jneqsim.thermo.system.SystemSrkCPAs, - "cpa-statoil": jneqsim.thermo.system.SystemSrkCPAstatoil, - "cpa": jneqsim.thermo.system.SystemSrkCPAstatoil, - "CPA-SRK-EoS": jneqsim.thermo.system.SystemSrkCPA, - "cpa-srk": jneqsim.thermo.system.SystemSrkCPA, - "srk-twoCoon": jneqsim.thermo.system.SystemSrkTwuCoonParamEos, - "cpa-pr": jneqsim.thermo.system.SystemPrCPA, - "CPA-PR-EoS": jneqsim.thermo.system.SystemPrCPA, - "SRK-TwuCoon-EOS": jneqsim.thermo.system.SystemSrkTwuCoonStatoilEos, + "srk": neqsim.thermo.system.SystemSrkEos, + "SRK-EoS": neqsim.thermo.system.SystemSrkEos, + "Psrk-EoS": neqsim.thermo.system.SystemPsrkEos, + "PSRK-EoS": neqsim.thermo.system.SystemPsrkEos, + "RK-EoS": neqsim.thermo.system.SystemRKEos, + "pr": neqsim.thermo.system.SystemPrEos, + "PR-EoS": neqsim.thermo.system.SystemPrEos, + "pr-umr": neqsim.thermo.system.SystemUMRPRUMCEos, + "srk-s": neqsim.thermo.system.SystemSrkSchwartzentruberEos, + "GERG-water": neqsim.thermo.system.SystemGERGwaterEos, + "SRK-MC": neqsim.thermo.system.SystemSrkMathiasCopeman, + "PR-MC": neqsim.thermo.system.SystemPrMathiasCopeman, + "scrk": neqsim.thermo.system.SystemSrkSchwartzentruberEos, + "ScRK-EoS": neqsim.thermo.system.SystemSrkSchwartzentruberEos, + "nrtl": neqsim.thermo.system.SystemNRTL, + "unifac": neqsim.thermo.system.SystemUNIFAC, + "electrolyte": neqsim.thermo.system.SystemFurstElectrolyteEos, + "Electrolyte-ScRK-EoS": neqsim.thermo.system.SystemFurstElectrolyteEos, + "Electrolyte-CPA-EoS": neqsim.thermo.system.SystemElectrolyteCPAstatoil, + "cpa-el": neqsim.thermo.system.SystemElectrolyteCPA, + "cpa-s": neqsim.thermo.system.SystemSrkCPAs, + "cpa-statoil": neqsim.thermo.system.SystemSrkCPAstatoil, + "cpa": neqsim.thermo.system.SystemSrkCPAstatoil, + "CPA-SRK-EoS": neqsim.thermo.system.SystemSrkCPA, + "cpa-srk": neqsim.thermo.system.SystemSrkCPA, + "srk-twoCoon": neqsim.thermo.system.SystemSrkTwuCoonParamEos, + "cpa-pr": neqsim.thermo.system.SystemPrCPA, + "CPA-PR-EoS": neqsim.thermo.system.SystemPrCPA, + "SRK-TwuCoon-EOS": neqsim.thermo.system.SystemSrkTwuCoonStatoilEos, } def fluid(name="srk", temperature=298.15, pressure=1.01325): - fluid_function = fluid_type.get(name, jneqsim.thermo.system.SystemSrkEos) + fluid_function = fluid_type.get(name, neqsim.thermo.system.SystemSrkEos) return fluid_function(temperature, pressure) def readEclipseFluid(filename, wellName=""): - jneqsim.thermo.util.readwrite.EclipseFluidReadWrite.pseudoName = wellName - fluid1 = jneqsim.thermo.util.readwrite.EclipseFluidReadWrite.read(filename) + neqsim.thermo.util.readwrite.EclipseFluidReadWrite.pseudoName = wellName + fluid1 = neqsim.thermo.util.readwrite.EclipseFluidReadWrite.read(filename) return fluid1 def setEclipseComposition(fluid, filename, wellName=""): - jneqsim.thermo.util.readwrite.EclipseFluidReadWrite.pseudoName = wellName - jneqsim.thermo.util.readwrite.EclipseFluidReadWrite.setComposition(fluid, filename) + neqsim.thermo.util.readwrite.EclipseFluidReadWrite.pseudoName = wellName + neqsim.thermo.util.readwrite.EclipseFluidReadWrite.setComposition(fluid, filename) def addFluids(fluids): @@ -170,7 +172,7 @@ def tunewaxmodel(fluid, experimentaldata, maxiterations=5): presList = experimentaldata["pressure"] expList = [[x * 100.0 for x in experimentaldata["experiment"]]] - waxsim = jneqsim.pvtsimulation.simulation.WaxFractionSim(fluid) + waxsim = neqsim.pvtsimulation.simulation.WaxFractionSim(fluid) waxsim.setTemperaturesAndPressures(JDouble[:](tempList), JDouble[:](presList)) waxsim.setExperimentalData(JDouble[:, :](expList)) waxsim.getOptimizer().setNumberOfTuningParameters(3) @@ -210,7 +212,7 @@ def dataFrame(system): def calcproperties(gascondensateFluid, inputDict): - properties = jneqsim.util.generator.PropertyGenerator( + properties = neqsim.util.generator.PropertyGenerator( gascondensateFluid, JDouble[:](inputDict["temperature"]), JDouble[:](inputDict["pressure"]), @@ -290,7 +292,7 @@ def fluidflashproperties( "if system is not specified, components and fractions must be specified." ) - system = jneqsim.thermo.system.SystemSrkEos(273.15, 1.01325) + system = neqsim.thermo.system.SystemSrkEos(273.15, 1.01325) if not isinstance(components, list): components = [components] @@ -304,7 +306,7 @@ def fluidflashproperties( system.setTotalNumberOfMoles(1) system.setMolarComposition(fractions) - thermoOps = jneqsim.thermodynamicoperations.ThermodynamicOperations(system) + thermoOps = neqsim.thermodynamicoperations.ThermodynamicOperations(system) if isinstance(spec1, pandas.Series): spec1 = spec1.to_list() @@ -361,7 +363,7 @@ def separatortest(fluid, pressure, temperature, GOR=None, Bo=None, display=False Bo = [] length = len(pressure) - sepSim = jneqsim.pvtsimulation.simulation.SeparatorTest(fluid) + sepSim = neqsim.pvtsimulation.simulation.SeparatorTest(fluid) sepSim.setSeparatorConditions(JDouble[:](temperature), JDouble[:](pressure)) sepSim.runCalc() for i in range(0, length): @@ -410,7 +412,7 @@ def CVD( cummulativemolepercdepleted = [] length = len(pressure) - cvdSim = jneqsim.pvtsimulation.simulation.ConstantVolumeDepletion(fluid) + cvdSim = neqsim.pvtsimulation.simulation.ConstantVolumeDepletion(fluid) cvdSim.setPressures(JDouble[:](pressure)) cvdSim.setTemperature(temperature) cvdSim.runCalc() @@ -454,7 +456,7 @@ def viscositysim( if aqueousviscosity is None: aqueousviscosity = [] length = len(pressure) - cmeSim = jneqsim.pvtsimulation.simulation.ViscositySim(fluid) + cmeSim = neqsim.pvtsimulation.simulation.ViscositySim(fluid) cmeSim.setTemperaturesAndPressures(JDouble[:](temperature), JDouble[:](pressure)) cmeSim.runCalc() for i in range(0, length): @@ -516,7 +518,7 @@ def CME( viscosity = [] length = len(pressure) - cvdSim = jneqsim.pvtsimulation.simulation.ConstantMassExpansion(fluid) + cvdSim = neqsim.pvtsimulation.simulation.ConstantMassExpansion(fluid) cvdSim.setTemperaturesAndPressures(JDouble[:](temperature), JDouble[:](pressure)) cvdSim.runCalc() saturationPressure = cvdSim.getSaturationPressure() @@ -588,7 +590,7 @@ def difflib( gasgravity = [] length = len(pressure) - cvdSim = jneqsim.pvtsimulation.simulation.DifferentialLiberation(fluid) + cvdSim = neqsim.pvtsimulation.simulation.DifferentialLiberation(fluid) cvdSim.setPressures(JDouble[:](pressure)) cvdSim.setTemperature(temperature) cvdSim.runCalc() @@ -627,7 +629,7 @@ def GOR(fluid, pressure, temperature, GORdata=None, Bo=None, display=False): Bo = [] length = len(pressure) - jGOR = jneqsim.pvtsimulation.simulation.GOR(fluid) + jGOR = neqsim.pvtsimulation.simulation.GOR(fluid) jGOR.setTemperaturesAndPressures(JDouble[:](temperature), JDouble[:](pressure)) jGOR.runCalc() for i in range(0, length): @@ -647,7 +649,7 @@ def GOR(fluid, pressure, temperature, GORdata=None, Bo=None, display=False): def saturationpressure(fluid, temperature=-1.0): if temperature > 0: fluid.setTemperature(temperature) - cvdSim = jneqsim.pvtsimulation.simulation.SaturationPressure(fluid) + cvdSim = neqsim.pvtsimulation.simulation.SaturationPressure(fluid) cvdSim.run() return cvdSim.getSaturationPressure() @@ -667,7 +669,7 @@ def swellingtest( if relativeoilvolume is None: relativeoilvolume = [] length2 = len(cummulativeMolePercentGasInjected) - cvdSim = jneqsim.pvtsimulation.simulation.SwellingTest(fluid) + cvdSim = neqsim.pvtsimulation.simulation.SwellingTest(fluid) cvdSim.setInjectionGas(fluid2) cvdSim.setTemperature(temperature) cvdSim.setCummulativeMolePercentGasInjected( @@ -799,7 +801,7 @@ def TPflash(testSystem, temperature=None, tUnit=None, pressure=None, pUnit=None) if pUnit is None: pUnit = "bara" testSystem.setPressure(pressure, pUnit) - testFlash = thermodynamicoperations(testSystem) + testFlash = neqsim.thermodynamicoperations.ThermodynamicOperations(testSystem) testFlash.TPflash() testSystem.init(3) @@ -913,7 +915,7 @@ def hydp(testSystem): def addfluids(fluid1, fluid2): - return jneqsim.thermo.system.SystemInterface.addFluids(fluid1, fluid2) + return neqsim.thermo.system.SystemInterface.addFluids(fluid1, fluid2) def hydt(testSystem, type=1): @@ -1140,7 +1142,7 @@ def entropy(thermoSystem, t=0, p=0): def densityGERG2008(phase): - GERG2008 = jneqsim.thermo.util.GERG.NeqSimGERG2008() + GERG2008 = neqsim.thermo.util.GERG.NeqSimGERG2008() return GERG2008.getDensity(phase) diff --git a/pyproject.toml b/pyproject.toml index b25aa4c..5960b7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,8 +9,9 @@ repository = "https://github.com/Equinor/neqsimpython" classifiers = ["Operating System :: OS Independent"] [tool.poetry.dependencies] -python = "^3.8" -JPype1 = "^1.5.0" +python = "^3.9,<4.0" +jneqsim = "^3.0.2" + numpy = [ { version = "^1.24.4", markers = "python_version == '3.8'" }, { version = "^1.25.2", markers = "python_version > '3.8'" }, diff --git a/tests/process/test_ProcessTools.py b/tests/process/test_ProcessTools.py index ecbf824..40d4ce4 100644 --- a/tests/process/test_ProcessTools.py +++ b/tests/process/test_ProcessTools.py @@ -20,11 +20,12 @@ valve, ) from neqsim.thermo import TPflash, fluid, printFrame, fluid_df +from neqsim.standards import ISO6976, air_fuel_ratio + from pytest import approx from jpype.types import JDouble -from neqsim import jneqsim +from jneqsim import neqsim import pandas as pd -import neqsim.standards def test_compsplitter(): @@ -198,26 +199,26 @@ def test_virtualstream(): # Example of a method using direct calls to neqsim java def testNoUseOfThermosOrProcessTools(): - fluid = jneqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00) + fluid = neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00) fluid.addComponent("methane", 0.900) fluid.addComponent("ethane", 0.100) fluid.addComponent("n-heptane", 1.00) fluid.setMixingRule(2) - stream1 = jneqsim.processsimulation.processequipment.stream.Stream("Stream1", fluid) + stream1 = neqsim.processsimulation.processequipment.stream.Stream("Stream1", fluid) stream1.setPressure(10.0, "bara") stream1.setTemperature(25.0, "C") stream1.setFlowRate(50.0, "kg/hr") - valve1 = jneqsim.processsimulation.processequipment.valve.ThrottlingValve( + valve1 = neqsim.processsimulation.processequipment.valve.ThrottlingValve( "valve_1", stream1 ) valve1.setOutletPressure(5.0, "bara") - separator1 = jneqsim.processsimulation.processequipment.separator.Separator("sep 1") + separator1 = neqsim.processsimulation.processequipment.separator.Separator("sep 1") separator1.addStream(valve1.getOutStream()) - operation = jneqsim.processsimulation.processsystem.ProcessSystem() + operation = neqsim.processsimulation.processsystem.ProcessSystem() operation.add(stream1) operation.add(valve1) operation.add(separator1) @@ -426,7 +427,7 @@ def test_gasoilprocess(): def test_AFR(): - fluid = jneqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00) + fluid = neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00) fluid.addComponent("nitrogen", 1.0) fluid.addComponent("CO2", 1.0) fluid.addComponent("methane", 92.0) @@ -472,10 +473,8 @@ def test_AFR(): afr = aconst * (32.0 + 3.76 * 28.0) / 1000.0 / molmass_hc * wtfrac_hc assert 16.2312248674 == approx(afr, abs=0.01) - assert 16.2312248674 == approx(neqsim.standards.air_fuel_ratio(fluid), abs=0.01) assert 52691.55 == approx( - neqsim.standards.ISO6976(fluid, numberunit="mass").getValue( - "SuperiorCalorificValue" - ), + ISO6976(fluid, numberunit="mass").getValue("SuperiorCalorificValue"), abs=0.01, ) + assert 16.2312248674 == approx(air_fuel_ratio(fluid), abs=0.01) diff --git a/tests/process/test_dynamic_process.py b/tests/process/test_dynamic_process.py index 307bd3a..12940ce 100644 --- a/tests/process/test_dynamic_process.py +++ b/tests/process/test_dynamic_process.py @@ -1,27 +1,30 @@ -from neqsim import jneqsim +import jneqsim +import jpype + +neqsim = jpype.JPackage("neqsim") def test_dynamic_compressor(): - testSystem2 = jneqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00) + testSystem2 = neqsim.thermo.system.SystemSrkEos((273.15 + 25.0), 10.00) testSystem2.addComponent("methane", 1.1) testSystem2.addComponent("ethane", 0.1) testSystem2.setMixingRule(2) - stream1 = jneqsim.processsimulation.processequipment.stream.Stream( + stream1 = neqsim.processsimulation.processequipment.stream.Stream( "Stream1", testSystem2 ) stream1.setFlowRate(5000.0, "kg/hr") stream1.setPressure(100.0, "bara") stream1.setTemperature(55.0, "C") - valve1 = jneqsim.processsimulation.processequipment.valve.ThrottlingValve( + valve1 = neqsim.processsimulation.processequipment.valve.ThrottlingValve( "valve_1", stream1 ) valve1.setOutletPressure(50.0) valve1.setPercentValveOpening(50) valve1.setCalculateSteadyState(False) - separator1 = jneqsim.processsimulation.processequipment.separator.Separator( + separator1 = neqsim.processsimulation.processequipment.separator.Separator( "separator_1" ) separator1.addStream(valve1.getOutletStream()) @@ -30,13 +33,13 @@ def test_dynamic_compressor(): separator1.setInternalDiameter(0.8) separator1.setLiquidLevel(0.0) - compressor1 = jneqsim.processsimulation.processequipment.compressor.Compressor( + compressor1 = neqsim.processsimulation.processequipment.compressor.Compressor( "comp1", separator1.getGasOutStream() ) compressor1.setCalculateSteadyState(False) compressor1.setOutletPressure(100.0) - separator2 = jneqsim.processsimulation.processequipment.separator.Separator( + separator2 = neqsim.processsimulation.processequipment.separator.Separator( "separator_2" ) separator2.addStream(compressor1.getOutletStream()) @@ -45,14 +48,14 @@ def test_dynamic_compressor(): separator2.setInternalDiameter(0.8) separator2.setLiquidLevel(0.0) - valve2 = jneqsim.processsimulation.processequipment.valve.ThrottlingValve( + valve2 = neqsim.processsimulation.processequipment.valve.ThrottlingValve( "valve_2", separator2.getGasOutStream() ) valve2.setOutletPressure(50.0) valve2.setPercentValveOpening(50) valve2.setCalculateSteadyState(False) - p = jneqsim.processsimulation.processsystem.ProcessSystem() + p = neqsim.processsimulation.processsystem.ProcessSystem() p.add(stream1) p.add(valve1) p.add(separator1) @@ -62,7 +65,7 @@ def test_dynamic_compressor(): p.run() compchartgenerator = ( - jneqsim.processsimulation.processequipment.compressor.CompressorChartGenerator( + neqsim.processsimulation.processequipment.compressor.CompressorChartGenerator( compressor1 ) ) diff --git a/tests/process/test_measurement.py b/tests/process/test_measurement.py index 28f5e1a..0ab1259 100644 --- a/tests/process/test_measurement.py +++ b/tests/process/test_measurement.py @@ -7,7 +7,7 @@ pumpChart, ) from neqsim.thermo import fluid -from neqsim import jneqsim +from jneqsim import neqsim from jpype import JImplements, JOverride @@ -32,16 +32,14 @@ def test_addPythonUnitOp(): fluid1.addComponent("n-hexane", 1.0, "kg/sec") fluid1.setMixingRule(2) - stream1 = jneqsim.processsimulation.processequipment.stream.Stream( - "stream1", fluid1 - ) + stream1 = neqsim.processsimulation.processequipment.stream.Stream("stream1", fluid1) stream1.setFlowRate(30000, "kg/hr") meas1 = ExampleMeasurement() meas1.setName("example measurement 1") meas1.setInputStream(stream1) - oilprocess = jneqsim.processsimulation.processsystem.ProcessSystem() + oilprocess = neqsim.processsimulation.processsystem.ProcessSystem() oilprocess.add(stream1) oilprocess.add(meas1) oilprocess.run() diff --git a/tests/process/test_unitop.py b/tests/process/test_unitop.py index 164b3d5..a84e580 100644 --- a/tests/process/test_unitop.py +++ b/tests/process/test_unitop.py @@ -7,7 +7,7 @@ pumpChart, ) from neqsim.thermo import fluid -from neqsim import jneqsim +from jneqsim import neqsim from jpype import JImplements, JOverride @@ -42,7 +42,7 @@ def test_addPythonUnitOp(): fluid1.addComponent("n-hexane", 1.0, "kg/sec") fluid1.setMixingRule(2) - stream1 = jneqsim.processsimulation.processequipment.stream.Stream( + stream1 = neqsim.processsimulation.processequipment.stream.Stream( "stream 1", fluid1 ) stream1.setFlowRate(30000, "kg/hr") @@ -51,11 +51,11 @@ def test_addPythonUnitOp(): uop.setName("example operation 1") uop.setInputStream(stream1) - stream2 = jneqsim.processsimulation.processequipment.stream.Stream( + stream2 = neqsim.processsimulation.processequipment.stream.Stream( "stream2", uop.getOutputStream() ) - oilprocess = jneqsim.processsimulation.processsystem.ProcessSystem() + oilprocess = neqsim.processsimulation.processsystem.ProcessSystem() oilprocess.add(stream1) oilprocess.add(uop) oilprocess.add(stream2) diff --git a/tests/test_NeqSim.py b/tests/test_NeqSim.py index 4e1d8ac..7ce8e7b 100644 --- a/tests/test_NeqSim.py +++ b/tests/test_NeqSim.py @@ -5,15 +5,16 @@ @author: ESOL """ import os -from neqsim.neqsimpython import jneqsim + +from jneqsim import neqsim def test_Viscosity(): - thermoSystem = jneqsim.thermo.system.SystemSrkEos(280.0, 10.0) + thermoSystem = neqsim.thermo.system.SystemSrkEos(280.0, 10.0) thermoSystem.addComponent("methane", 10.0) thermoSystem.addComponent("water", 4.0) - thermoOps = jneqsim.thermodynamicoperations.ThermodynamicOperations(thermoSystem) + thermoOps = neqsim.thermodynamicoperations.ThermodynamicOperations(thermoSystem) thermoOps.TPflash() gasEnthalpy = thermoSystem.getPhase(0).getEnthalpy() @@ -25,17 +26,16 @@ def test_Viscosity(): # def test_updateDatabase(): -# jneqsim.util.database.NeqSimDataBase.updateTable("COMP", +# neqsim.util.database.NeqSimDataBase.updateTable("COMP", # "classpath:/data/COMP.csv") def test_hasComponentDatabase(): - assert jneqsim.util.database.NeqSimDataBase.hasComponent("methane") == True + assert neqsim.util.database.NeqSimDataBase.hasComponent("methane") == True def test_fullOffshoreProcess(): import pandas as pd - import math # well stream composition (mole fractions) reservoirFluid = { diff --git a/tests/thermo/test_ThermoTools.py b/tests/thermo/test_ThermoTools.py index d0beca3..d5ced39 100644 --- a/tests/thermo/test_ThermoTools.py +++ b/tests/thermo/test_ThermoTools.py @@ -285,6 +285,7 @@ def test_fluid_df(): ] naturalgas = {"ComponentName": components, "MolarComposition[-]": composition} naturalgasFluid = fluid_df(pd.DataFrame(naturalgas)) + # todo: assert something def test_TPflash1(): @@ -442,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 @@ -531,15 +523,16 @@ def test_fluidChar(): TPflash(gascondensateFluid) assert gascondensateFluid.getNumberOfComponents() == 85 - compositon = gascondensateFluid.getMolarComposition() + composition = gascondensateFluid.getMolarComposition() # Add mud contamination - compositon[30] += compositon[30] + 0.01 + composition[30] += composition[30] + 0.01 - gascondensateFluid.setMolarComposition(compositon) + gascondensateFluid.setMolarComposition(composition) gascondensateFluid.setTemperature(25.0, "C") gascondensateFluid.setPressure(5.0, "bara") TPflash(gascondensateFluid) + # todo: assert something def test_TPflash():