Giter Site home page Giter Site logo

equinor / neqsim-python Goto Github PK

View Code? Open in Web Editor NEW
55.0 10.0 14.0 1.15 GB

NeqSim is a library for calculation of fluid behavior, phase equilibrium and process simulation. This project is a Python interface to NeqSim.

Home Page: https://equinor.github.io/neqsimhome/

License: Apache License 2.0

Python 98.59% Dockerfile 1.41%
thermodynamics thermodynamic-properties oil-and-gas fluid-dynamics gas-production gas-transport pvt python oil-production fluid-properties

neqsim-python's Introduction

NeqSim Logo

Run tests Publish package

NeqSim Python

NeqSim Python is part of the NeqSim project. NeqSim Python is a Python interface to the NeqSim Java library for estimation of fluid behavior and process design for oil and gas production. NeqSim Python toolboxes (eg. thermoTools and processTools) are implemented to streamline use of neqsim in Python. Examples of use are given in jupyter workbooks.

Releases

NeqSim Python is distributed as a pip package.

End-users should install neqsim python with some additional packages by running

pip install neqsim[interactive]

Getting Started

See the NeqSim Python Wiki for how to use NeqSim Python via Python or in Jupyter notebooks. Also see examples of use of NeqSim for Gas Processing in Colab. Learn and ask questions in Discussions for use and development of NeqSim.

Prerequisites

Java version 8 or higher (Java JDK) needs to be installed. The Python package JPype is used to connect Python and Java. Read the installation requirements for Jpype. Be aware that mixing 64 bit Python with 32 bit Java and vice versa crashes on import of the jpype module. The needed Python packages are listed in the NeqSim Python dependencies page.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

Discussion forum

Questions related to neqsim can be posted in the github discussion pages.

Versioning

NeqSim use SemVer for versioning.

Licence

NeqSim is distributed under the Apache-2.0 licence.

Acknowledgments

A number of master and PhD students at NTNU have contributed to development of NeqSim. We greatly acknowledge their contributions.

neqsim-python's People

Contributors

asmfstatoil avatar dependabot[bot] avatar evensol avatar fannemel avatar jorgenengelsen avatar jsolaas avatar pre-commit-ci-lite[bot] avatar sviatose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neqsim-python's Issues

No component with name...

Dear Even Solbraa,

I updated neqsim to the last version (2.2.32 --> 2.3.1) and I am now getting an error message while running the following code:

from neqsim.thermo import fluid

gas = {"methane": 95, "nitrogen": 1, "CO2": 0.2, "ethane": 1, "propane": 0.6, "butane": 0.3, "pentane": 0.08, "hexane": 0.4, "O2": 0.05}

for key in gas.keys():
    fluid().addComponent(key, gas[key], "mol/sec")

And I get the following messages:

No component with name: butane in database
No component with name: pentane in database
No component with name: hexane in database
No component with name: O2 in database

This was not the case before the update. Any idea about that?

Thanks for your support.

python neqsim calcproperties gives error in new package version

prop = calcproperties(self.gas, temppresdict) was working in neqsim version 2.4.13

Upgraded to version 2.5.6. No the call gives error:

props = properties.calculate()
java.lang.java.lang.RuntimeException: java.lang.RuntimeException: unit not supported J/molK

Issue with ammonia in pipe function

Hello dear developers ! thanks for your wonderful work and amazing library!
I'm trying to use the pipe function in NeqSim and it's doing well but when i try to add ammonia into the stream it returns an error.
y code is as follows:
def NeqSim_calculations(q,D,df_comp,t,p1,p2,L,type):
if type == 'estimate quantity':
p1 = p198.0660.01
p2 = p298.0660.01
q = q*24/(1000000)
#Creating inlet fluid using SRK-EoS
names = list(df_comp.index.str.lower())
molefractions = list(df_comp['mol%']*0.01)
fluid1 = createfluid2(names, molefractions)
fluid1.setMixingRule('classic')
fluid1.setTemperature(t, "C")
fluid1.setPressure(p1, "bara")
fluid1.setTotalFlowRate(q, "MSm3/day")

        TPflash(fluid1)

        

        deltaElevation = 0.0
        pipeLength = L
        roughness= 0.00005
        diameter = D
        error = 10
        method = "friction theory"
        fluid1.getPhase('gas').getPhysicalProperties().setViscosityModel(method)
        fluid1.initProperties()
        while error > 0.01:
            fluid1.setTotalFlowRate(q, "MSm3/day")
            clearProcess()
            
            stream1 = stream(fluid1)
            
            pipeSimple = pipe(stream1, pipeLength, deltaElevation, diameter, roughness)
            runProcess()
            
            
            error = abs(p2 - pipeSimple.getOutStream().getFluid().getPressure('bara'))
            if p2 - pipeSimple.getOutStream().getFluid().getPressure('bara') > 0.01:
                q = q - q*0.01
            elif p2 - pipeSimple.getOutStream().getFluid().getPressure('bara') < -0.01:
                q = q + q*0.01
            else: error = error
            result = q*1000000/24
      return result

error message when i try to add "ammonia" is:
File "/home/appuser/venv/lib/python3.9/site-packages/neqsim/thermo/thermoTools.py", line 100, in createfluid2

return fluidcreator.create2(JString[:](names), JDouble[:](molefractions), unit)

java.lang.java.lang.RuntimeException: java.lang.RuntimeException: neqsim.util.exception.InvalidInputException: PhaseSrkEos:init - Input totalNumberOfMoles must be larger than zero.

i checked for the operating conditions i assumed and was fine as p1=1 bara p2= 0.6 bara, t =45 C

Could someone please guide me to add ammonia to my code? Thanks!

error: AttributeError: module 'neqsim' has no attribute 'thermodynamicOperations'

@asmfstatoil
Bug in version 2.318 ?
Trying to run Colab book:
https://colab.research.google.com/github/EvenSol/NeqSim-Colab/blob/master/notebooks/thermodynamics/Phase_envelopes_of_oil_and_gas.ipynb#scrollTo=cQnmMgSlerj7

in ()
24 fluid1.setMixingRule('classic');
25
---> 26 thermoOps = neqsim.thermodynamicOperations.ThermodynamicOperations(fluid1)
27 thermoOps.calcPTphaseEnvelope()
28

AttributeError: module 'neqsim' has no attribute 'thermodynamicOperations'

ERROR neqsim.thermo.phase.PhaseEos - Failed to solve for molarVolume within the iteration limit.

I often get this error where composition has pseudo components. Is this particularly an error due to python envelope?
The snip of example code below.

from neqsim.thermo.thermoTools import *
import matplotlib.pyplot as plt

fluid1 = fluid("srk") # create a fluid using the SRK-EoS
fluid1.setTemperature(80, "C")
fluid1.setPressure(50, "bara")
fluid1.addComponent("nitrogen", 0)
fluid1.addComponent("CO2", 1.005)
fluid1.addComponent("H2S", 0)
fluid1.addComponent("methane", 24.62)
fluid1.addComponent("ethane", 2.704)
fluid1.addComponent("propane", 2.706)
fluid1.addComponent("i-butane", 1.309)
fluid1.addComponent("n-butane", 2.031)
fluid1.addComponent("i-pentane", 2.047)
fluid1.addComponent("n-pentane", 1.49)
fluid1.addTBPfraction("C6", 3.176, 85.3/1000.0, 0.6649)
fluid1.addTBPfraction("C7", 5.331, 93.2/1000.0, 0.7266)
fluid1.addTBPfraction("C8", 7.796, 105.1/1000.0, 0.7607)
fluid1.addTBPfraction("C9", 5.179, 119.4/1000.0, 0.7812)
fluid1.addPlusFraction("C10+", 40.616, 268/1000.0, 0.865)
fluid1.setMixingRule("classic")
fluid1.setMultiPhaseCheck(True)
fluid1.useVolumeCorrection(True)
TPflash(fluid1)
fluid1.getInterphaseProperties().setInterfacialTensionModel("gas", "oil", "Parachor")
fluid1.initProperties()
fluid1.display()
thermoOps = jNeqSim.thermodynamicOperations.ThermodynamicOperations(fluid1)
thermoOps.calcPTphaseEnvelope()
plt.plot(list(thermoOps.getOperation().get("dewT2")), list(thermoOps.getOperation().get("dewP2")), label="DewPoint")
plt.plot(list(thermoOps.getOperation().get("bubT")), list(thermoOps.getOperation().get("bubP")), label="BubblePoint")
plt.show()

One should note that the class path can only be set prior starting the JVM

From Stig Oskar:
One should note that the class path can only be set prior starting the JVM. Calls to set the class path after the JVM is started are silently ignored. If a jar must be loaded after the JVM is started, it may be loaded using java.net.URLClassLoader. Classes loaded using a URLClassloader are not visible to JPype imports nor to JPackage.

import jpype

if not jpype.isJVMStarted():
jpype.startJVM(convertStrings=False)
jvmVersion = jpype.getJVMVersion()[0]
if jvmVersion <= 8:
jpype.addClassPath('./lib/libj8/')
else:
jpype.addClassPath('./lib/
')

jNeqSim = jpype.JPackage('neqsim')

Pandas support

Dear Even Solbraa,

Thank you for putting this very nice library online.
Do you have plans in the future to add support for pandas dataframes? Running the code to calculate the fluid properties for a single point (T, p) takes a few seconds - due to the connection with Java I guess - so I am a bit afraid of the time it will take to run the code on a (large) dataframe.

Best regards,

Java error: UnsupportedClassVersionError

Dear all,

I updated neqsim to the last version (2.4.0) and got the following error:

java.lang.java.lang.UnsupportedClassVersionError: java.lang.UnsupportedClassVersionError: neqsim/thermodynamicOperations/ThermodynamicOperations has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I am using the last version of the JRE (8 Update 341) on windows 10, so I'm not sure what causes this error. I have looked on the internet, and have not found a proper solution for this error so far.

I rolled back the previous versions of neqsim and found that the error appears from version 2.3.26 onwards.

Any hint will be welcome!

Thanks in advance.

Best regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.