diff --git a/include/AbstractState.h b/include/AbstractState.h index 30c9bfb6..3ace7be4 100644 --- a/include/AbstractState.h +++ b/include/AbstractState.h @@ -395,6 +395,7 @@ public: ~AbstractStateWrapper(){delete this->p;}; void update(long input_pair, double Value1, double Value2){ this->p->update(input_pair,Value1,Value2); }; double keyed_output(int key) { return this->p->keyed_output(key); } + bool empty(){return (this->p == NULL);} }; } /* namespace CoolProp */ diff --git a/src/HumidAirProp.cpp b/src/HumidAirProp.cpp index 23be61f2..f233ffa3 100644 --- a/src/HumidAirProp.cpp +++ b/src/HumidAirProp.cpp @@ -16,8 +16,8 @@ #include #include -CoolProp::AbstractStateWrapper Water("HEOS", "Water"); -CoolProp::AbstractStateWrapper Air("HEOS", "Air"); +CoolProp::AbstractStateWrapper Water; +CoolProp::AbstractStateWrapper Air; namespace HumidAir { @@ -1075,6 +1075,14 @@ double HAPropsSI(const char *OutputName, const char *Input1Name, double Input1, { try { + + if (Water.empty()){ + Water = CoolProp::AbstractStateWrapper("HEOS", "Water"); + } + if (Air.empty()){ + Air = CoolProp::AbstractStateWrapper("HEOS", "Air"); + } + int In1Type, In2Type, In3Type,iT,iW,iTdp,iRH,ip,Type1,Type2; double vals[3],p,T,RH,W,Tdp,psi_w,M_ha,v_bar,h_bar,s_bar,MainInputValue,SecondaryInputValue,T_guess; double Value1,Value2,W_guess;