Clear Filters
Clear Filters

GERG 2008 Equation of state calculations

43 views (last 30 days)
Hosam Ismail
Hosam Ismail on 5 Dec 2023
Answered: SOUMNATH PAUL on 20 Dec 2023
Hello all,
I'm trying to calculate the natural gas properties using the GERG 2008 eqution of state.
Is there anyway to perform this without having to write the Equation of State script?
I understand that the NIST REFPROP can be connected with matlab, but how to control the Equation of State to be used?
Thank you.

Answers (1)

SOUMNATH PAUL
SOUMNATH PAUL on 20 Dec 2023
I can understand that you are trying to calculate the natural gas properties using the GERG -2008 equation of state without writing the entire script from scratch by utilising NIST REFPROP with MATLAB.
For this, you need to follow certain steps. I am also assuming you already have REFPROP in your system.
  1. Set up MATLAB interface by copying the necessary files to your MATLAB directory.
  2. Load the GERG-2008 EOS in MATLAB, below is the code to select the equation of state in REFPROP.
% Add REFPROP path
addpath('C:\path\to\REFPROP');
% Set up REFPROP with GERG-2008
RP = py.ctREFPROP.ctREFPROP.REFPROPFunctionLibrary('C:\path\to\REFPROP');
MASS_SI = RP.GETENUMdll(int8(0), "MASS SI").iEnum;
ierr = RP.SETUPdll(int8(1), "GERG2008", "HMX.BNC", "DEF");
if ierr ~= 0
error('Error in REFPROP SETUP');
end
% Now you can calculate properties using the GERG-2008 EOS
% For example, to calculate density of methane at 100 K and 1 MPa:
T = 100; % Temperature in Kelvin
P = 1; % Pressure in MPa
z = {1.0}; % Composition (pure methane)
output = RP.REFPROPdll("", "TP", "D", MASS_SI, int8(0), int8(0), T, P, z);
density = double(output.Output(1));
After this step you can use various REFPROP functions to calculate different properties.
Kindly go through the below link to read more on GERG-2008 API :
Hope it helps!
Regards,
Soumnath

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Tags

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!