Plot Pressure- enthalpy (P-H) diagram
Ältere Kommentare anzeigen
Dear All,
How can I plot a PH (pressue- enthalpy) diagram using coolprop library through matlab for 'R134a'?
Regards
1 Kommentar
Sulaymon Eshkabilov
am 14 Aug. 2023
Have checked these links:
Antworten (1)
Karan Singh
am 23 Aug. 2023
Bearbeitet: Karan Singh
am 23 Aug. 2023
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.
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!