Problem with two phase Fluid Tables properties for mixtures for Simscape Matlab using CoolProp
13 次查看(过去 30 天)
显示 更早的评论
Hi,
I need to generate Fluid Tables properties for a two-phase mixture in Matlab using CoolProp. Next I want to implement the properties into Simscape.
There is a function:
fluidTables = twoPhaseFluidTables(uRange,pRange,mLiquid,mVapor,n,substance,installPath)
Unfortunately I don't know how to make it work for the mixture of two different fluids.
Could I ask for some advice?
2 个评论
Yifeng Tang
2025-4-9
Following the steps on this MATLAB Answer post: https://www.mathworks.com/matlabcentral/answers/2006947-binary-mixtures-using-coolprop-in-matlab?s_tid=srchtitle, you may define a mixture in CoolProp:
try
py.CoolProp.CoolProp.apply_simple_mixing_rule('R1234yf','R32','linear')
catch
%
end
py.CoolProp.CoolProp.PropsSI('HMASS','T',300,'P',101325,'R1234yf[0.8]&R32[0.2]')
Then I was hoping to use the twoPhaseFluidTables command to get the property table, but running into error.
installPath = 'py.CoolProp.CoolProp.PropsSI';
fluidTables = twoPhaseFluidTables([200 400],[0.5 1],50,50,100,'R1234yf[0.8]&R32[0.2]',installPath)
It gave me error message that CoolProp can't get saturation properties.
CoolProp failed to return fluid properties at P = 0.5 MPa, Q = 0.
Error in twoPhaseFluidTables>@(p,q)coolpropSaturationProperties(p,q,substance,coolpropFun) (line 775)
saturationProperties = @(p, q) coolpropSaturationProperties(p, q, substance, coolpropFun);
= saturationProperties(p(j), 0);
Caused by:
Python Error: ValueError: Conformal state solver failed; error was Not able to get a solution : PropsSI("L","P",500000,"Q",0,"R1234yf[0.8]&R32[0.2]")
The error message seems to suggest it's an issue with CoolProp or this mixture I picked.
What mixture you have in mind? Maybe we can give that a try?
回答(1 个)
Yifeng Tang
2025-4-10
Hi Adam,
I think there is path forward, but it'll require some work.
The error message you and I saw was generated by the fact that CoolProp is unable to determine the critical point of this mixture. If I try to find the critical point manually using the wrapper function, I'll get a similar error
try
py.CoolProp.CoolProp.apply_simple_mixing_rule('n-Butane','Isopentane','linear');
catch
%
end
mixture = 'n-Butane[0.5]&Isopentane[0.5]';
py.CoolProp.CoolProp.PropsSI("PCRIT",'T',300,'P',101325,fluid)
Python Error: ValueError: critical point finding routine found 2 critical points : PropsSI("PCRIT","T",300,"P",101325,"n-Butane[0.5]&Isopentane[0.5]")
I can also attempt to query the internal energy at quality of 0 or 1 for different pressure, searching for the critical point, but found that the saturation line can't be computed beyond 10.1MPa for saturated liq or 3.5MPa for saturated vapor. Critical point of course needs these two pressure values to be the same :( You may try to slightly increase the pressure value in the code below and observe the error message.
py.CoolProp.CoolProp.PropsSI('UMASS','Q',0,'P',1.01e7,mixture)
py.CoolProp.CoolProp.PropsSI('UMASS','Q',1,'P',0.35e7,mixture)
As the twoPhaseFluidTables function attempts to locate the critical point, I don't see how this error can be by-passed, UNLESS we do this manually and stay below the critical point.
If your operation pressure is expected to be below 3.5MPa, I think we can generate this table manually by writing a few loops and call the wrapper function many times. 3.5MPa seems to indicate a saturation temperature around 440K. So maybe it's good enough?
py.CoolProp.CoolProp.PropsSI('T','Q',0,'P',0.35e7,mixture) % output: 440.8012
py.CoolProp.CoolProp.PropsSI('T','Q',1,'P',0.35e7,mixture) % output: 442.2485
If so, please refer to this documentation page (Manually Generate Fluid Property Tables) on how to populate this property table manually, as well we this documentation page (Two-Phase Fluid Properties (2P)) on more details of the "normalized internal energy" needed to define the table.
If you need additional assistance, please reach out to MathWorks Support or your MathWorks account team, and mention this MATLAB Answer post.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Two-Phase Fluid Library 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!