예제 #1
0
def test_TPflash1():
    fluid1 = fluid("srk")  # create a fluid using the SRK-EoS
    fluid1.setTemperature(28.15, "C")
    fluid1.setPressure(100.0, "bara")
    fluid1.addComponent("nitrogen", 1.0, "mol/sec")
    fluid1.addComponent("CO2", 2.3, "mol/sec")
    fluid1.addComponent("methane", 80.0, "mol/sec")
    fluid1.addComponent("ethane", 6.0, "mol/sec")
    fluid1.addComponent("propane", 3.0, "mol/sec")
    fluid1.addComponent("i-butane", 1.0, "mol/sec")
    fluid1.addComponent("n-butane", 1.0, "mol/sec")
    fluid1.addComponent("i-pentane", 0.4, "mol/sec")
    fluid1.addComponent("n-pentane", 0.2, "mol/sec")
    fluid1.addComponent("n-hexane", 0.1, "mol/sec")
    fluid1.setMixingRule("classic")  # classic will use binary kij
    fluid1.setMultiPhaseCheck(
        True)  #True if more than two phases could be present
    fluidcomposition = [
        0.01, 0.02, 0.9, 0.1, 0.03, 0.02, 0.01, 0.01, 0.01, 0.003
    ]
    fluidComposition(fluid1, fluidcomposition)
    fluid1.setPressure(101.0, "bara")
    fluid1.setTemperature(22.3, "C")
    TPflash(fluid1)
    fluid1.initThermoProperties()
    fluid1.initPhysicalProperties()
    assert fluid1.getViscosity('kg/msec') == 1.574354015664789e-05
예제 #2
0
fluid1.setMixingRule("classic")  # classic will use binary kij
fluid1.setMultiPhaseCheck(True)  #True if more than two phases could be present
fluid1.useVolumeCorrection(True)  # True if volume translation should be used
"""
Set a new fluid composition, temperature and pressure (fluid composition will 
be normalized), and calculate nubmber of phases and composition at 
equilibrium (TPflash). Thermodynamic properties (enthalpies, densities, 
entropy, etc.) are calculated using initThermoProperties(). Physical properties
 (viscosities, thermal conductivities etc.) are calculated using 
 initPhysicalProperties()
"""
numbComp = fluid1.getPhase(0).getNumberOfComponents()
fluidcomposition = [0.01] * numbComp
fluidcomposition[2] = 0.9
fluidComposition(fluid1, fluidcomposition)
fluid1.setPressure(101.0, "bara")
fluid1.setTemperature(22.3, "C")
TPflash(fluid1)
fluid1.initProperties()
#fluid1.display()
"""
Print results (number of phases at equilibrium and density). 
For how to read more properties see: propertiesOfNaturalGas.py
"""
print("number of phases ", fluid1.getNumberOfPhases())
print("fluid density ", fluid1.getDensity("kg/m3"), " kg/m3")
print("gas density ", fluid1.getPhase("gas").getDensity("kg/m3"), " kg/m3")
print("oil density ", fluid1.getPhase("oil").getDensity("kg/m3"), " kg/m3")
print("aqueous density ",
      fluid1.getPhase("aqueous").getDensity("kg/m3"), " kg/m3")
예제 #3
0

separator1.getMechanicalDesign().calcDesign();
separartorInnerDiameter = separator1.getMechanicalDesign().getInnerDiameter();
Ks = 0.1;
import math 
Vtmax = Ks * math.sqrt((separator1.getThermoSystem().getPhase('oil').getDensity()-separator1.getThermoSystem().getPhase('gas').getDensity())/separator1.getThermoSystem().getPhase('gas').getDensity());
diameter = math.sqrt(separator1.getThermoSystem().getFlowRate("m3/sec")/Vtmax/3.14*4.0);
separator1.getMechanicalDesign().displayResults();


coolerDuty = cooler1.getEnergyInput()
print("cooler duty "+ str(cooler1.getEnergyInput()/1.0e6) + " MW")
#phaseenvelope(scrubber1.getThermoSystem(), plot=True)


#calulates enthalpy of water between 10 and 30 C
fluid2 = fluid("srk")  # create a fluid using the SRK-EoS
fluid2.addComponent("water", 1.0)
fluid2.setTemperature(10.0, "C")
fluid2.setPressure(30.0, "bara")
TPflash(fluid2)
fluid2.initThermoProperties()
enthalpy1 = fluid2.getEnthalpy("J/mol")
fluid2.setTemperature(30.0, "C")
fluid2.initThermoProperties()
enthalpy2 = fluid2.getEnthalpy("J/mol")

flowratewater = coolerDuty/(enthalpy1-enthalpy2)*fluid2.getMolarMass()*3600/1000.0

print("cooling water rate " + str(flowratewater) + " m3/hr")
예제 #4
0
def calcProperties(frame):
    gascondensateFluid.setTemperature(frame[0], "K")
    gascondensateFluid.setPressure(frame[1], "bara")
    try:
        TPflash(gascondensateFluid)
        gascondensateFluid.initProperties()
    except:
        print('error in calculation properties....continue')
        return None
    #Reporting some properties of the total fluid
    frame['molarmass[kg/mol]'] = gascondensateFluid.getMolarMass('kg/mol')
    frame['enthalpy[J/mol]'] = gascondensateFluid.getEnthalpy("J/mol")
    #Reporting some properties of the gas phase (NaN will be reported if the phase is not present)
    if gascondensateFluid.hasPhaseType("gas"):
        phaseNumber = gascondensateFluid.getPhaseNumberOfPhase("gas")
        frame['gasmolfraction[mol/mol]'] = gascondensateFluid.getMoleFraction(
            phaseNumber)
        frame[
            'gasvolumefraction[mol/mol]'] = gascondensateFluid.getCorrectedVolumeFraction(
                phaseNumber)
        frame['gasthermalconductivity[W/mK]'] = gascondensateFluid.getPhase(
            phaseNumber).getThermalConductivity("W/mK")
        frame['gasZ[-]'] = gascondensateFluid.getPhase(phaseNumber).getZ()
        frame['gasmolarMass[kg/mol]'] = gascondensateFluid.getPhase(
            phaseNumber).getZ()
        frame['gasenthalpy[kg/mol]'] = gascondensateFluid.getPhase(
            phaseNumber).getEnthalpy("J/mol")
        frame['gasviscosity[kg/msec]'] = gascondensateFluid.getViscosity(
            "kg/msec")
    #Reporting some properties of the oil phase (NaN will be reported if the phase is not present)
    if gascondensateFluid.hasPhaseType("oil"):
        phaseNumber = gascondensateFluid.getPhaseNumberOfPhase("oil")
        frame['oilmolfraction[mol/mol]'] = gascondensateFluid.getMoleFraction(
            phaseNumber)
        frame[
            'oilvolumefraction[mol/mol]'] = gascondensateFluid.getCorrectedVolumeFraction(
                phaseNumber)
        frame['oilthermalconductivity[W/mK]'] = gascondensateFluid.getPhase(
            phaseNumber).getThermalConductivity("W/mK")
        frame['oilZ[-]'] = gascondensateFluid.getPhase(phaseNumber).getZ()
        frame['oilmolarMass[kg/mol]'] = gascondensateFluid.getPhase(
            phaseNumber).getZ()
        frame['oilenthalpy[kg/mol]'] = gascondensateFluid.getPhase(
            phaseNumber).getEnthalpy("J/mol")
        frame['oilviscosity[kg/msec]'] = gascondensateFluid.getViscosity(
            "kg/msec")
        frame['oilmolfraction[mol/mol]'] = gascondensateFluid.getMoleFraction(
            phaseNumber)
        frame[
            'oilvolumefraction[mol/mol]'] = gascondensateFluid.getCorrectedVolumeFraction(
                phaseNumber)
        frame['oilthermalconductivity[W/mK]'] = gascondensateFluid.getPhase(
            phaseNumber).getThermalConductivity("W/mK")
        frame['oilZ[-]'] = gascondensateFluid.getPhase(phaseNumber).getZ()
        frame['oilmolarMass[kg/mol]'] = gascondensateFluid.getPhase(
            phaseNumber).getZ()
        frame['oilenthalpy[kg/mol]'] = gascondensateFluid.getPhase(
            phaseNumber).getEnthalpy("J/mol")
        frame['oilviscosity[kg/msec]'] = gascondensateFluid.getViscosity(
            "kg/msec")
    return frame
예제 #5
0
from neqsim.thermo import fluid_df, TPflash, phaseenvelope,printFrame,dewt
import pandas as pd


naturalgas = {'ComponentName':  ["nitrogen", "CO2", "methane", "ethane", "propane", "i-butane", "n-butane","i-pentane", "n-pentane","2-m-C5", "3-m-C5", "n-hexane", "benzene", "c-hexane", "n-heptane", "toluene", "c-C7", "n-octane", "m-Xylene", "c-C8", "n-nonane", "m-Xylene","nC10","nC11","nC12"], 
       'MolarComposition[-]':  [1.192,0.5102,95.3303,2.1102,0.3217,0.1278,0.0846,0.0694,0.0340,0.0335,0.0109,0.0181,0.0017,0.0661,0.0207,0.0045,0.0530,0.0061,0.0033,0.000103,0.0032, 0.00354, 0.00597,0.0000597,0.000001]
} 


naturalgasdf = pd.DataFrame(naturalgas) 
print("Natural Gas Fluid:\n")
print(naturalgasdf.head(30).to_string())

naturalgasFluid = fluid_df(naturalgasdf).setModel("UMR-PRU-EoS")
naturalgasFluid.autoSelectMixingRule()
TPflash(naturalgasFluid)
printFrame(naturalgasFluid)

gasPhaseEnvelope = phaseenvelope(naturalgasFluid,True)
cricobar = gasPhaseEnvelope.get("cricondenbar")
print("cricoP ",  cricobar[1], "  [bara] ", " cricoT ", cricobar[0], " °C")



naturalgasFluid.setTemperature(-10.0, "C")
naturalgasFluid.setPressure(21.0, "bara")
TPflash(naturalgasFluid)
printFrame(naturalgasFluid)


naturalgasFluid.setPressure(21.0, "bara")
예제 #6
0
# -*- coding: utf-8 -*-
"""
The current python script demonstrates simple ways of creating fluids in neqsim
@author: esol
"""
from neqsim.thermo import fluid, fluid_df, addOilFractions, printFrame, dataFrame, fluidcreator, createfluid, createfluid2, TPflash, phaseenvelope
import pandas as pd
# Start by creating a fluid in neqsim uing a predifined fluid (dry gas, rich gas, light oil, black oil)
#Set temperature and pressure and do a TPflash. Show results in a dataframe.
fluidcreator.setHasWater(False)
fluid1 = createfluid('dry gas')
fluid1.setPressure(10.0, "bara")
fluid1.setTemperature(22.3, "C")
TPflash(fluid1)
print('results of TPflash for fluid 1')
printFrame(fluid1)

#Calculate and display the phase envelope of various fluid types
fluid1 = createfluid('black oil')
print('phase envelope for black oil')
phaseenvelope(fluid1, True)

fluid2 = createfluid('dry gas')
print('phase envelope for fluid 2')
phaseenvelope(fluid2, True)

fluid3 = createfluid('rich gas')
print('phase envelope for fluid 3')
phaseenvelope(fluid3, True)

#Demonstration of a simple way of generating a fluid when component names and comosition are given as list
예제 #7
0
Created on Wed Jun  3 23:45:38 2020

@author: ESOL
"""

from neqsim.thermo import fluid, fluid_df, addOilFractions, printFrame, dataFrame, fluidcreator, createfluid, createfluid2, TPflash, phaseenvelope
import pandas as pd

reservoirfluid = fluid('Electrolyte-CPA-EoS')
reservoirfluid.addComponent("H2S", 0.12)
reservoirfluid.addComponent("nitrogen", 1.0)
reservoirfluid.addComponent("methane", 70.0)
reservoirfluid.addComponent("ethane", 4.3)
reservoirfluid.addComponent("propane", 1.2)
reservoirfluid.addComponent("nC10", 1.2)
reservoirfluid.addComponent("water", 5.0, "kg/sec")
reservoirfluid.addComponent("Na+", 0.010)
reservoirfluid.addComponent("Cl-", 0.01)
reservoirfluid.addComponent("OH-", 0.0001)

reservoirfluid.chemicalReactionInit()
reservoirfluid.setMultiPhaseCheck(True)
reservoirfluid.setMixingRule(10)

reservoirfluid.setTotalFlowRate(1.0, "MSm3/day")
reservoirfluid.setTemperature(55.0, "C")
reservoirfluid.setPressure(15.0, "bara")

TPflash(reservoirfluid)
printFrame(reservoirfluid)