Plot Pressure- enthalpy (P-H) diagram
이전 댓글 표시
Dear All,
How can I plot a PH (pressue- enthalpy) diagram using coolprop library through matlab for 'R134a'?
Regards
댓글 수: 1
Sulaymon Eshkabilov
2023년 8월 14일
Have checked these links:
답변 (1개)
Karan Singh
2023년 8월 23일
편집: Karan Singh
2023년 8월 23일
Hi Hussein, as you would have tried and seen the “CoolProp” library. First install this library.
So we can try via python in MATLAB. Here are the detailed steps for the same.
- Install python from Welcome to Python.org according to your os I have used the Python 3.9.1.
- Open MATLAB and add python by using the following commands:
pyversion C:\Users\<user>\AppData\Local\Programs\Python\Python39\python.exe
Check the Python version to ensure it's set up correctly.
pyversion
Now, Python is integrated into your MATLAB environment. Proceed to install "CoolProp."
- To install "CoolProp," execute the following MATLAB command:
[v,e]=pyversion; system([e, ' -m pip install --user -U CoolProp'])
2. Now that "CoolProp" is installed, you can set the parameter values and write the rest of the code.
% Define pressure and enthalpy ranges
pressure = linspace(0, 2e6, 100); % Pressure range in Pa
enthalpy = linspace(0, 3000e3, 100); % Enthalpy range in J/kg
% Calculate specific volume
v = zeros(length(pressure), length(enthalpy));
for i = 1:length(pressure)
for j = 1:length(enthalpy)
v(i, j) = CoolProp.PropsSI('D', 'P', pressure(i), 'H', enthalpy(j), 'R134a');
end
end
% Plot the PH diagram
figure;
contourf(enthalpy, pressure, v, 'LineStyle', 'none');
colorbar;
xlabel('Enthalpy (J/kg)');
ylabel('Pressure (Pa)');
title('R134a Pressure-Enthalpy (PH) Diagram');
This would plot the required result, please note that using "CoolProp" through the Python interface in MATLAB may have some performance implications due to the inter-language communication overhead.
카테고리
도움말 센터 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!