coolprop icon indicating copy to clipboard operation
coolprop copied to clipboard

Excel - VBA: division by zero error

Open andrei-ng opened this issue 10 years ago • 4 comments

Hi,

I am trying to use coolprop in a VBA macro in Excel. Either I am not using it properly or there is something wrong in DLL file.

When I call the Props function from VBA to evaluate the enthalpy based on Pressure value and Quality value ( for "water") the Props_private function in the CoolProp.xlam returns <Division by zero>. The behavior is a bit chaotic as it can happen at almost any pressure value.

Does anybody have a suggestion or can offer an idea why this is happening ?

Thanks, Andrei

andrei-ng avatar Jul 04 '14 12:07 andrei-ng

Can you post an excel file that demonstrates this problem? With the .dll file that you are using as well? What is the exact call that you are making to CoolProp?

ibell avatar Jul 04 '14 12:07 ibell

Hi,

Attached is an excel file with some VBA code and the .dll I am using. The calls I am making as you will also see from the file are:

Tsat = Props("T", "P", temp_p, "Q", 0,"water") (where temp_P is a pressure value in 1000 kPa and 6000 kPa)

h_L = Props("H", "Q", 0, "P", temp_P, "water"

Both give the same type of error.

andrei-ng avatar Jul 04 '14 15:07 andrei-ng

Hi,

The calls I am making are: Tsat = Props("T", "P", temp_p, "Q", 0,"water")
h_L = Props("H", "Q", 0, "P", temp_P, "water") (where temp_P is a pressure value in 1000 and 6000 , assuming kPa as units to the Props function)

I run these calls in a for loop of >1000 values and the error is raised at about the 200th iteration, whichever call I invoke.

I will upload the file and .dll later, as I am new to github and I first need to discover how to do that. (Is sending them by email an option for you?)

Thank you, Andrei

andrei-ng avatar Jul 04 '14 15:07 andrei-ng

Email is ok, try ian.h.bell .at. gmail.com.

On Fri, Jul 4, 2014 at 5:10 PM, gandrein [email protected] wrote:

Hi,

The calls I am making are:

Tsat = Props("T", "P", temp_p, "Q", 0,"water")

h_L = Props("H", "Q", 0, "P", temp_P, "water") (where temp_P is a pressure value in 1000 and 6000 , assuming kPa as units to the Props function)

I run these calls in a for loop of >1000 values and the error is raised at about the 200th iteration, whichever call I invoke.

I will upload the file and .dll later, as I am new to github and I first need to discover how to do that. (Is sending them by email an option for you?)

Thank you, Andrei

— Reply to this email directly or view it on GitHub https://github.com/ibell/coolprop/issues/225#issuecomment-48054050.

ibell avatar Jul 04 '14 16:07 ibell