HAPropsSI Matlab Vectors

213 views
Skip to first unread message

Forest Reider

unread,
Oct 13, 2017, 2:23:46 AM10/13/17
to coolprop-users
Hello,  I am new to CoolProp and using Matlab. I need some humid air properties and therefore making use of HAPropsSI.

For example: 

% calculate enthalpy
for i = 1:height(T)
    T.enthalpy(i) = CoolProp.HAPropsSI('H','T',T.temp(i),'R',T.humidity(i),'P',T.pressure(i));
end


However, it is very slow as the height of my table,T, increases.  Passing Matlab vectors doesn't work.  From the documentation it seems that some sort of vectorization should be possible using low level functions, but I don't quite understand how to implement it.

Could someone point to a source describing how to do this for HAPropsSI? or a simple example?

Many thanks,
Forest

Matthis Thorade

unread,
Oct 13, 2017, 4:20:46 AM10/13/17
to coolprop-users
Hi, I am not a MAtlab user, but could you try using the Matlab-Python interface as discussed here?
https://github.com/CoolProp/CoolProp/issues/1497

Ian Bell

unread,
Oct 15, 2017, 12:29:46 PM10/15/17
to coolpro...@googlegroups.com
Matthis is right. Vectorization via python is probably your best bet.  You are right, some of the calculations with HAPropsSI are quite slow, but I doubt you will see a massive improvement with vectorization.  Your better bet is to figure out the water mole fraction or humidity ratio yourself, because that is a non iterative calculation one you know T P and one of the mole fraction or humidity ratio.

--
You received this message because you are subscribed to the Google Groups "coolprop-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-users+unsubscribe@googlegroups.com.
To post to this group, send email to coolprop-users@googlegroups.com.
Visit this group at https://groups.google.com/group/coolprop-users.
For more options, visit https://groups.google.com/d/optout.

Forest Reider

unread,
Oct 16, 2017, 2:04:22 AM10/16/17
to coolprop-users
Thanks for the input.  I can certainly write my own functions, I was just just thinking about a nice standardized, flexible library to replace custom code overhead in the future.  I will try the python via matlab approach.

Cheers


On Sunday, October 15, 2017 at 6:29:46 PM UTC+2, Ian Bell wrote:
Matthis is right. Vectorization via python is probably your best bet.  You are right, some of the calculations with HAPropsSI are quite slow, but I doubt you will see a massive improvement with vectorization.  Your better bet is to figure out the water mole fraction or humidity ratio yourself, because that is a non iterative calculation one you know T P and one of the mole fraction or humidity ratio.
On Oct 13, 2017 4:20 AM, "Matthis Thorade" <matthis...@gmail.com> wrote:
Hi, I am not a MAtlab user, but could you try using the Matlab-Python interface as discussed here?
https://github.com/CoolProp/CoolProp/issues/1497


Am Freitag, 13. Oktober 2017 08:23:46 UTC+2 schrieb Forest Reider:
Hello,  I am new to CoolProp and using Matlab. I need some humid air properties and therefore making use of HAPropsSI.

For example: 

% calculate enthalpy
for i = 1:height(T)
    T.enthalpy(i) = CoolProp.HAPropsSI('H','T',T.temp(i),'R',T.humidity(i),'P',T.pressure(i));
end


However, it is very slow as the height of my table,T, increases.  Passing Matlab vectors doesn't work.  From the documentation it seems that some sort of vectorization should be possible using low level functions, but I don't quite understand how to implement it.

Could someone point to a source describing how to do this for HAPropsSI? or a simple example?

Many thanks,
Forest

--
You received this message because you are subscribed to the Google Groups "coolprop-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-user...@googlegroups.com.
To post to this group, send email to coolpro...@googlegroups.com.

Forest Reider

unread,
Oct 16, 2017, 8:56:33 AM10/16/17
to coolprop-users
In the end I was able to try some of the recommendations.  Calling CoolProps via Python it was indeed easier to pass a vector of values, but the calculation time was not significantly reduced.  Writing my own vectorized psychrometric function in Matlab was faster (0.004s vs 9s).

Thanks for all the help.

Ian Bell

unread,
Oct 22, 2017, 11:52:34 AM10/22/17
to coolpro...@googlegroups.com
Can you please post your function?  That's an impressive speedup to say the least!

--
You received this message because you are subscribed to the Google Groups "coolprop-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-users+unsubscribe@googlegroups.com.
To post to this group, send email to coolprop-users@googlegroups.com.

Mark335

unread,
Sep 30, 2019, 2:15:19 PM9/30/19
to coolprop-users
Revitalizing this thread from the past for similar reasons.

I am trying to make property calls to HAPropsSI from Python to calculate dewpoint, specific volume, etc for calculations. Example call is below.

HAPropsSI("D", "T", 25+273.15, "P", 100*1000, "WetBulb", 18+273.15 )

This call is unreasonably slow. Making 100 calls and timing results in a 8.9 second total time for the 100 calls.

ASHRAE publishes simple equations for calculating properties and someone has posted a library called psypy which utilizes these for property calls. This returns 100 calls in 0.004 seconds total for 100 calls.

I tried as Ian suggested to calculate the Humidity Ratio using these simpler equations and then use that HumRat as an input to the dewpoint calculation of Coolprop. For 100 calls making the first call to psypy to return HumRat and then input HumRat to Coolprop resulted in 0.15 seconds total for 100 calls. 

This is a nice improvement for sure, but not super streamlined. All of these calculations were performed serially and no vector or parallel compute option was used.

I tried calculating HumRat from Coolprop and then inputting that to the dewpoint call for Coolprop with no improvements in total call time.

Has there been any other developments on this front to enable tabular backends for humid air?
Is there any other recommendation to accomplish this faster yet using something not yet discussed?

Any feedback is welcome.







On Sunday, October 22, 2017 at 8:52:34 AM UTC-7, Ian Bell wrote:
Can you please post your function?  That's an impressive speedup to say the least!
On Mon, Oct 16, 2017 at 6:56 AM, Forest Reider <forest...@gmail.com> wrote:
In the end I was able to try some of the recommendations.  Calling CoolProps via Python it was indeed easier to pass a vector of values, but the calculation time was not significantly reduced.  Writing my own vectorized psychrometric function in Matlab was faster (0.004s vs 9s).

Thanks for all the help.


On Friday, October 13, 2017 at 8:23:46 AM UTC+2, Forest Reider wrote:
Hello,  I am new to CoolProp and using Matlab. I need some humid air properties and therefore making use of HAPropsSI.

For example: 

% calculate enthalpy
for i = 1:height(T)
    T.enthalpy(i) = CoolProp.HAPropsSI('H','T',T.temp(i),'R',T.humidity(i),'P',T.pressure(i));
end


However, it is very slow as the height of my table,T, increases.  Passing Matlab vectors doesn't work.  From the documentation it seems that some sort of vectorization should be possible using low level functions, but I don't quite understand how to implement it.

Could someone point to a source describing how to do this for HAPropsSI? or a simple example?

Many thanks,
Forest

--
You received this message because you are subscribed to the Google Groups "coolprop-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coolpro...@googlegroups.com.
To post to this group, send email to coolpro...@googlegroups.com.

Ian Bell

unread,
Sep 30, 2019, 10:48:27 PM9/30/19
to coolpro...@googlegroups.com
Wet bulb will always be very slow due to the nested iterations that are required.  There's not too much to be done about that.  The values from the ASHRAE  curves are much less accurate than this model, but if that accuracy is acceptable for you, by all means use that.  Or better yet, propose a means to get better computational speed out of this model.  I have some ideas, but no time to implement them.

To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coolprop-users/2f6b63d1-44c0-43dc-8149-824340478cc2%40googlegroups.com.

Mark335

unread,
Oct 1, 2019, 12:20:49 PM10/1/19
to coolprop-users
Ian,

I tried a few other options including using HumRat instead of Wetbulb and still had the slow speeds.

I would like to know what your other thoughts may be so I could try a few things out.

From your response, it seems that there are no tabular options or speedier alternatives available. Could you provide some detail why the tabular backend is not an option? As I understand it you are adding an additional dimension to the table which could make it slower than refrigerant properties. Given the desire to model full heat exchangers, obtaining accurate airside properties at speed is a real scenario.

I am happy to try things out and am open to your thoughts to see if there is anything I can do to help.

To unsubscribe from this group and stop receiving emails from it, send an email to coolpro...@googlegroups.com.

Ian Bell

unread,
Oct 2, 2019, 10:33:54 PM10/2/19
to coolpro...@googlegroups.com
The independent variables are T,p,psi_w, so how unacceptable is the speed of evaluation of properties as a function of T, p, psi_w?  The current tables in CoolProp are not suitable because psychrometry is a three-dimensional (T,p,psi_w) problem, while the tables are all two-dimensional (P,h & p,T).  If you wanted to, I think you could simplify the problem by fixing the pressure to one atmosphere and then you only have two independent variables.  But implementing all the combinations of calculations is a decidedly non-trivial matter, something I have spent way more hours on than I would like already.

When I was developing ACHP (https://github.com/CenterHighPerformanceBuildingsPurdue/ACHP), I worked quite a lot on making the psychrometry calculations faster, so I am VERY sympathetic to your request.

I'm sorry to not be able to be more help here, but others need to step up and take the reins of CoolProp now.

To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coolprop-users/c0936d65-56e3-4515-9522-5e9c82dbeebc%40googlegroups.com.

Ian Bell

unread,
Oct 7, 2019, 11:08:28 PM10/7/19
to coolprop-users
@mark335 Please reach out to Matthias Kunick (matthia...@hotmail.com ) who might have a solution for you for your speed problems.
To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-users+unsubscribe@googlegroups.com.
Message has been deleted

Forest Reider

unread,
Oct 8, 2019, 10:06:43 AM10/8/19
to coolprop-users
For me Ian's point about accuracy and lookup tables is right on. It depends on what you need. For me the Ashrae equations were acceptable (and easy to speed up with vectors), and I had a limited domain for which lookup tables were easy to create for iterative solutions.
Reply all
Reply to author
Forward
0 new messages