Linking REFPROP with Simulink

56 ビュー (過去 30 日間)
Mohamad Shams
Mohamad Shams 2024 年 3 月 10 日
コメント済み: Mohamad Shams 2024 年 3 月 28 日 5:27
Hi there,
I want to link REFPROP with Simulink for a two-phase fluid. I have propane as a working fluid in my thermodynamic system, and during the process, the pressure and temperature of the working fluid change. I want to import the fluid properties to Simulink, considering the changing pressure and temperature. I should import the state of the fluid, whether it is in a liquid state, gas, or supercritical, and other thermodynamic properties so that Simulink can calculate the work of turbines and compressors in the process. Is it possible, and how can I do that?

回答 (1 件)

Vandit
Vandit 2024 年 3 月 28 日 4:25
Hello Shams,
Yes, it is possible to link REFPROP with Simulink to import fluid properties, including the state of the fluid (liquid, gas, or supercritical) and other thermodynamic properties. You can follow the steps given below to integrate REFPROP with Simulink:
  • After installing REFPROP and MATLAB on your computer, verify that you can access REFPROP from MATLAB using the REFPROP MATLAB interface (refpropm). This ensures MATLAB can call REFPROP functions to calculate the properties of your fluid under various conditions.
  • Create a MATLAB function that uses 'coder.extrinsic' to call the "refpropm" function. This function should take pressure and temperature as inputs and output the desired fluid properties. The use of 'coder.extrinsic' allows you to use the "refpropm" function within Simulink, which is not directly supported for code generation. Below is a sample MATLAB function for your reference:
function [density, enthalpy, quality] = getFluidProperties(P, T)
% Declare refpropm as an extrinsic function
coder.extrinsic('refpropm');
% Call refpropm to calculate properties for the specified fluid (e.g., Propane)
[~, ~, h, ~, ~, rho, ~, ~, Q] = refpropm('TDHQS', 'T', T, 'P', P, 'Propane');
% Assign outputs
density = rho;
enthalpy = h;
quality = Q;
end
  • Open Simulink and use a MATLAB Function block to integrate the MATLAB function from Step 2, connecting inputs for pressure and temperature and outputs for fluid properties.
  • Run your model to dynamically calculate and utilize the fluid properties based on changing conditions for accurate system simulation.
For generating fluid property tables from REFPROP, you may refer to the following documentation:
Hope this helps.
  1 件のコメント
Mohamad Shams
Mohamad Shams 2024 年 3 月 28 日 5:27
Hi Vandit
Thank you so much for your complete response.
Cheers

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGas Models についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by