" EES - CoolProp Interface This library is used to communicate with the dll of the EES - CoolProp interface (coolprop_ees.dlf) Since only one string value can be sent to the external function, the strings for the keys for the thermodynamic properties are converted to reference numbers Ian Bell Thermodynamics Laboratory University of Liege It is based on the EES-FluidProp wrapper developed by Sylvain Quoilin, University of Liège January 2013 " " Check that the units are SI units " function CoolProp_Assert_SI_units(dummy) if ((unitsystem('K') <> 1) OR (unitsystem('Pa') <> 1) OR (unitsystem('j') <> 1) OR (unitsystem('Mass') <> 1)) then call error('PropsSI and PropsSIZ routines in CoolProp can only work with K,Pa,J,mass set of units. Please update your Unit System definition') endif CoolProp_Assert_SI_units = dummy end function CoolProp_Assert_kSI_units(dummy) if ((unitsystem('K') <> 1) OR (unitsystem('KPa') <> 1) OR (unitsystem('kj') <> 1) OR (unitsystem('Mass') <> 1)) then call error('coolprop routine in CoolProp can only work with K,kPa,kJ,mass set of units. Please update your Unit System definition') endif CoolProp_Assert_kSI_units = dummy end function CoolProp_Assert_cpsi_units(dummy) if ((unitsystem('C') <> 1) OR (unitsystem('Pa') <> 1) OR (unitsystem('j') <> 1) OR (unitsystem('Mass') <> 1)) then call error('coolpropsi routine can only work with C,Pa,J,mass set of units. Please update your Unit System definition') endif CoolProp_Assert_cpsi_units = dummy end " This function can take in " function PropsSIZ(output$,input1$,input1val,input2$, input2val, fluid$, N, Z[1..N]) err = CoolProp_Assert_SI_units(9999999) "This function is not work in older version 9.487 EES, need revised f$ = fluid$||'~'||output$||'~'||input1$||'~'||input2$ " str1$ = CONCAT$(fluid$,'~') str2$ = CONCAT$(output$,'~') str3$ = CONCAT$(input1$,'~') str4$ = CONCAT$(str1$, str2$) str5$ = CONCAT$(str3$, input2$) f$ = CONCAT$(str4$, str5$) if (StringLen(f$) > 254) then call error('fluid string length headed to COOLPROP_EES C++ function is too long, sorry') endif " This is ugly, but it seems the only way " if (N=1) then val = COOLPROP_EES(f$,input1val,input2val,Z[1]) else if (N=2) then val = COOLPROP_EES(f$,input1val,input2val,Z[1],Z[2]) else if (N=3) then val = COOLPROP_EES(f$,input1val,input2val,Z[1],Z[2],Z[3]) else s$ = CONCAT$('Too many components, max is 3 currently, you have', String$(N)) "edited by NBC" call error(s$) val = 47 endif endif endif PropsSIZ = val end function PropsSI(output$,input1$,input1val,input2$, input2val, fluid$) err = CoolProp_Assert_SI_units(9999999) "This function is not work in older version 9.487 EES, need revised f$ = fluid$||'~'||output$||'~'||input1$||'~'||input2$||'~'||'SI' " str1$ = CONCAT$(fluid$,'~') str2$ = CONCAT$(output$,'~') str3$ = CONCAT$(input1$,'~') str4$ = CONCAT$(input2$,'~') str5$ = CONCAT$(str1$, str2$) str6$ = CONCAT$(str3$, str4$) str7$ = CONCAT$(str5$, str6$) f$ = CONCAT$(str7$, 'SI') if (StringLen(f$) > 254) then call error('fluid string length headed to COOLPROP_EES C++ function is too long, sorry') endif PropsSI = COOLPROP_EES(f$,input1val,input2val) end function coolprop(output$,input1$,input1val,input2$,input2val,fluid$) "This function is not work in older version 9.487 EES, need revised f$ = fluid$||'~'||output$||'~'||input1$||'~'||input2$||'~'||'kSI' " str1$ = CONCAT$(fluid$,'~') str2$ = CONCAT$(output$,'~') str3$ = CONCAT$(input1$,'~') str4$ = CONCAT$(input2$,'~') str5$ = CONCAT$(str1$, str2$) str6$ = CONCAT$(str3$, str4$) str7$ = CONCAT$(str5$, str6$) f$ = CONCAT$(str7$, 'kSI') err = CoolProp_Assert_SI_units(9999999) if (StringLen(f$) > 254) then call error('fluid string length headed to COOLPROP_EES C++ function is too long, sorry') endif coolprop = COOLPROP_EES(f$,input1val,input2val) end " This is the function that Sylvain Quoilin constructed to use an almost-SI set of units (C instead of K, different order of parameters) It is no longer supported nor should be used, but it is included here for backwards compatibility " function coolpropsi(output$,fluid$,input1$,input1val,input2$,input2val) "Format the first input with the right synthax and units for CoolProp:" if lowercase$(input1$)='t' then input1val = input1val + 273.15 in1$='T' else if lowercase$(input1$)='p' then input1val = input1val/ 1000 in1$='P' else if lowercase$(input1$)='rho' then in1$='D' else if lowercase$(input1$)='h' then input1val = input1val/ 1000 in1$='H' else if lowercase$(input1$)='s' then input1val = input1val/1000 in1$='S' else if lowercase$(input1$)='u' then input1val = input1val/ 1000 in1$='U' else if lowercase$(input1$)='x' then in1$='Q' else CALL ERROR('Invalid input key1: XXX$',input1$) endif endif endif endif endif endif endif "Format the second input with the right synthax and units for CoolProp:" if lowercase$(input2$)='t' then input2val = input2val + 273.15 in2$='T' else if lowercase$(input2$)='p' then input2val = input2val/ 1000 in2$='P' else if lowercase$(input2$)='rho' then in2$='D' else if lowercase$(input2$)='h' then input2val = input2val/ 1000 in2$='H' else if lowercase$(input2$)='s' then input2val = input2val/1000 in2$='S' else if lowercase$(input2$)='u' then input2val = input2val/ 1000 in2$='U' else if lowercase$(input2$)='x' then in2$='Q' else CALL ERROR('Invalid input key2: XXX$',input2$) endif endif endif endif endif endif endif "Format the output with the right units" if lowercase$(output$)='t' then a=1 b = -273.15 out$='T' else if lowercase$(output$)='p' then a=1000 b = 0 out$='P' else if lowercase$(output$)='rho' then a=1 b =0 out$='D' else if lowercase$(output$)='h' then a=1000 b =0 out$='H' else if lowercase$(output$)='s' then a=1000 b =0 out$='S' else if lowercase$(output$)='u' then a=1000 b =0 out$='U' else if lowercase$(output$)='x' then a=1 b =0 out$='Q' else if lowercase$(output$)='cv' then a=1000 b =0 out$='O' else if lowercase$(output$)='cp' then a=1000 b =0 out$='C' else if lowercase$(output$)='mu' then a=1 b =0 out$='V' else if lowercase$(output$)='k' then a=1000 b =0 out$='L' else if lowercase$(output$)='tcrit' then a=1 b = - 273.15 out$='Tcrit' else if lowercase$(output$)='pcrit' then a=1000 b =0 out$='pcrit' else if lowercase$(output$)='tmin' then a=1 b = - 273.15 out$='Tmin' else CALL ERROR('Invalid output key: XXX$',output$) endif endif endif endif endif endif endif endif endif endif endif endif endif endif " Need revised f$ = fluid$||'~'||output$||'~'||input1$||'~'||input2$||'~'||'SI' " str1$ = CONCAT$(fluid$,'~') str2$ = CONCAT$(output$,'~') str3$ = CONCAT$(input1$,'~') str4$ = CONCAT$(input2$,'~') str5$ = CONCAT$(str1$, str2$) str6$ = CONCAT$(str3$, str4$) str7$ = CONCAT$(str5$, str6$) f$ = CONCAT$(str7$, 'SI') err = CoolProp_Assert_cpsi_units(9999999) coolpropsi = COOLPROP_EES(f6$,input1val,input2val) coolpropsi = a*coolpropsi + b