Skip to content

Calculation of thermodynamic and physical properties using NeqSim

Even Solbraa edited this page Dec 16, 2021 · 10 revisions

Examples of reading thermodynamic and physical properties can be seen in the example.

To calculate thermodynamic properties of a fluid, the init() method needs to be called first:

fluid.init(3);

The number in the method depends on the type of property that should be calculated. 1 - density and fugacity, 2- all properties from 1. + temperature and pressure derivatives + enthalpy, entropy, etc. 3. Composition derivatives of thermodynamic properties (eg. composition derivatives of fugacity coefficients)

To calculate transport properties use the method:

fluid.initPhysicalProperties();

Reading fluid properties (sum of all phases):

fluid.getNumberOfPhases(); // Mix Number of Phases fluid.getPressure("Pa"); // Mix Pressure [Pa] fluid.getTemperature("K"); // Mix Temperature [K] fluid.getMoleFractionsSum() * 100; // Mix Mole Percent 1.0 / fluid.getDensity("mol/m3"); // Mix Molar Volume [m3/mol] fluid.getDensity("kg/m3"); // Mix Density [kg/m3] fluid.getZ(); // Mix Z Factor fluid.getMolarMass() * 1000; // Mix Molecular Weight [g/mol] fluid.getEnthalpy()/fluid.getNumberOfMoles(); // Mix Enthalpy [J/mol] fluid.getEnthalpy("J/mol"); fluid.getEntropy()/fluid.getNumberOfMoles(); // Mix Entropy [J/molK] fluid.getEntropy("J/molK"); fluid.getCp("J/molK"); // Mix Heat Capacity-Cp [J/molK] fluid.getCv("J/molK");// Mix Heat Capacity-Cv [J/molK] fluid.Cp()/fluid.getCv();// Mix Kappa (Cp/Cv) fluid.getKappa();// Mix Kappa (Cp/Cv)

Reading phase properties:

fluid.getMoleFraction(phaseNumber) * 100; // Phase Mole Percent fluid.getWtFraction(phaseNumber) * 100; // Phase Weight Percent 1.0 / fluid.getPhase(phaseNumber).getDensity("mol/m3"); // Phase Molar Volume [m3/mol] fluid.getCorrectedVolumeFraction(phaseNumber) * 100;// Phase Volume Percent fluid.getPhase(phaseNumber).getDensity("kg/m3"); // Phase Density [kg/m3] fluid.getPhase(phaseNumber).getZ(); // Phase Z Factor fluid.getPhase(phaseNumber).getMolarMass() * 1000; // Phase Molecular Weight [g/mol] fluidProperties[t][k++] = fluid.getPhase(phaseNumber).getEnthalpy() / >fluid.getPhase(phaseNumber).getNumberOfMolesInPhase(); // Phase Enthalpy [J/mol] fluid.getPhase(phaseNumber).getEnthalpy("J/mol"); // Phase Enthalpy [J/mol] fluid.getPhase(phaseNumber).getEntropy() / fluid.getPhase(phaseNumber).getNumberOfMolesInPhase(); // Phase Entropy [J/molK] fluid.getPhase(phaseNumber).getEntropy("J/molK"); // Phase Entropy [J/molK] fluid.getPhase(phaseNumber).getCp() / fluid.getPhase(phaseNumber).getNumberOfMolesInPhase(); // Phase Heat Capacity-Cp [J/molK] fluid.getPhase(phaseNumber).getCp("J/molK"); // Phase Heat Capacity-Cp [J/molK] fluid.getPhase(phaseNumber).getCv() / fluid.getPhase(phaseNumber).getNumberOfMolesInPhase(); // Phase Heat Capacity-Cv [J/molK] fluid.getPhase(phaseNumber).getCv("J/molK"); // Phase Heat Capacity-Cv [J/molK] fluid.getPhase(phaseNumber).getCp() / fluid.getPhase(phaseNumber).getCv(); // Phase Kappa (Cp/Cv) fluid.getPhase(phaseNumber).getKappa(); // Phase Kappa (Cp/Cv) fluid.getPhase(phaseNumber).getJouleThomsonCoefficient() / 1e5; // Phase JT Coefficient [K/Pa] fluid.getPhase(phaseNumber).getSoundSpeed(); // Phase Velocity of Sound [m/s] fluid.getPhase(phaseNumber).getPhysicalProperties().getViscosity();// Phase Viscosity [Pa s] fluid.getPhase(phaseNumber).getViscosity("kg/msec");// Phase Viscosity [Pa s] or [kg/msec] fluid.getPhase(phaseNumber).getPhysicalProperties().getConductivity(); // Phase Thermal Conductivity [W/mK] fluid.getPhase(phaseNumber).getConductivity("W/mK"); // Phase Thermal Conductivity [W/mK]

Viscosity models

Examples from https://colab.research.google.com/github/EvenSol/NeqSim-Colab/blob/master/notebooks/thermodynamics/ViscosityOfFluids.ipynb#scrollTo=PzWrasHBWB3X

method = "friction theory" fluid1.getPhase('gas').getPhysicalProperties().setViscosityModel(method) fluid1.initProperties() print("gas viscosity ", fluid1.getViscosity('cP'), " cP ", " metod: ", method)

method = "LBC" fluid1.getPhase('gas').getPhysicalProperties().setViscosityModel(method) fluid1.initProperties() print("gas viscosity ", fluid1.getViscosity('cP'), " cP ", " metod: ", method)

method = "PFCT" fluid1.getPhase('gas').getPhysicalProperties().setViscosityModel(method) fluid1.initProperties() print("gas viscosity ", fluid1.getViscosity('cP'), " cP ", " metod: ", method)

method = "PFCT-Heavy-Oil" fluid1.getPhase('gas').getPhysicalProperties().setViscosityModel(method) fluid1.initProperties() print("gas viscosity ", fluid1.getViscosity('cP'), " cP ", " metod: ", method)

method = "polynom" fluid1.getPhase('gas').getPhysicalProperties().setViscosityModel(method) fluid1.initProperties() print("gas viscosity ", fluid1.getViscosity('cP'), " cP ", " metod: ", method)

Thermal Conductivity Models

See https://colab.research.google.com/github/EvenSol/NeqSim-Colab/blob/master/notebooks/thermodynamics/ThermalConductivityOfFluids.ipynb

fluid1 = fluid('srk') fluid1.addComponent('methane', 0.5) fluid1.addComponent('ethane', 0.5) fluid1.setTemperature(25.0, 'C') fluid1.setPressure(42.0, 'bara') TPflash(fluid1)

method = "PFCT" fluid1.getPhase('gas').getPhysicalProperties().setConductivityModel(method) fluid1.initProperties() print("gas thermal conductivity ", fluid1.getThermalConductivity('W/mK'), " W/mK ", " metod: ", method)

method = "polynom" fluid1.getPhase('gas').getPhysicalProperties().setConductivityModel(method) fluid1.initProperties() print("gas thermal conductivity ", fluid1.getThermalConductivity('W/mK'), " W/mK ", " metod: ", method)

method = "Chung" fluid1.getPhase('gas').getPhysicalProperties().setConductivityModel(method) fluid1.initProperties() print("gas thermal conductivity ", fluid1.getThermalConductivity('W/mK'), " W/mK ", " metod: ", method)

Interfacial Tension

See https://colab.research.google.com/github/EvenSol/NeqSim-Colab/blob/master/notebooks/thermodynamics/interfacialtension.ipynb

fluid1 = fluid('srk') fluid1.addComponent('methane', 0.5) fluid1.addComponent('n-heptane', 0.5) fluid1.setTemperature(25.0, 'C') fluid1.setPressure(10.0, 'bara') fluid1.setMixingRule('classic') TPflash(fluid1)

method = "Parachor" fluid1.getInterphaseProperties().setInterfacialTensionModel("gas", "oil", method); fluid1.initProperties() print("Interfacial tension ", fluid1.getInterfacialTension('gas', 'oil'), " N/m ", " metod: ", method)

method = "Linear Gradient Theory" fluid1.getInterphaseProperties().setInterfacialTensionModel("gas", "oil", method); fluid1.initProperties() print("Interfacial tension ", fluid1.getInterfacialTension('gas', 'oil'), " N/m ", " metod: ", method)

method = "Simple Gradient Theory" fluid1.getInterphaseProperties().setInterfacialTensionModel("gas", "oil", method); fluid1.initProperties() print("Interfacial tension ", fluid1.getInterfacialTension('gas', 'oil'), " N/m ", " metod: ", method)

Adsorption models

See https://colab.research.google.com/github/EvenSol/NeqSim-Colab/blob/master/notebooks/thermodynamics/Interfacialadsorption.ipynb

Diffusion Coefficients

See: https://colab.research.google.com/github/EvenSol/NeqSim-Colab/blob/master/notebooks/thermodynamics/diffusioncoefficients.ipynb

Clone this wiki locally