CoolProp  6.6.0
An open-source fluid property and humid air property database
CoolPropLib.h
Go to the documentation of this file.
1 
19 #ifndef COOLPROPDLL_H
20 #define COOLPROPDLL_H
21 
22 // See also http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor
23 // Copied verbatim from PlatformDetermination.h in order to have a single-include header
24 #if _WIN64
25 # define __ISWINDOWS__
26 #elif _WIN32
27 # define __ISWINDOWS__
28 #elif __APPLE__
29 # define __ISAPPLE__
30 #elif __linux || __unix || __posix
31 # define __ISLINUX__
32 #elif __powerpc__
33 # define __ISPOWERPC__
34 #else
35 # pragma error
36 #endif
37 
38 #if defined(COOLPROP_LIB)
39 # ifndef EXPORT_CODE
40 # if defined(__ISWINDOWS__)
41 # define EXPORT_CODE extern "C" __declspec(dllexport)
42 # else
43 # define EXPORT_CODE extern "C"
44 # endif
45 # endif
46 # ifndef CONVENTION
47 # if defined(__ISWINDOWS__)
48 # define CONVENTION __stdcall
49 # else
50 # define CONVENTION
51 # endif
52 # endif
53 #else
54 # ifndef EXPORT_CODE
55 # define EXPORT_CODE
56 # endif
57 # ifndef CONVENTION
58 # define CONVENTION
59 # endif
60 #endif
61 
62 // Hack for PowerPC compilation to only use extern "C"
63 #if defined(__powerpc__) || defined(EXTERNC)
64 # undef EXPORT_CODE
65 # define EXPORT_CODE extern "C"
66 #endif
67 
68 #if defined(__powerpc__)
69 // From https://rowley.zendesk.com/entries/46176--Undefined-reference-to-assert-error-message
70 // The __assert function is an error handler function that is invoked when an assertion fails.
71 // If you are writing a program that uses the assert macro then you must supply you own __assert error handler function. For example
72 inline void __assert(const char* error) {
73  while (1)
74  ;
75 }
76 #endif
77 
84 EXPORT_CODE double CONVENTION Props1SI(const char* FluidName, const char* Output);
85 
92 EXPORT_CODE void CONVENTION Props1SImulti(const char* Outputs, char* backend, const char* FluidNames, const double* fractions,
93  const long length_fractions, double* result, long* resdim1);
100 EXPORT_CODE double CONVENTION PropsSI(const char* Output, const char* Name1, double Prop1, const char* Name2, double Prop2, const char* Ref);
123 EXPORT_CODE void CONVENTION PropsSImulti(const char* Outputs, const char* Name1, double* Prop1, const long size_Prop1, const char* Name2,
124  double* Prop2, const long size_Prop2, char* backend, const char* FluidNames, const double* fractions,
125  const long length_fractions, double* result, long* resdim1, long* resdim2);
132 EXPORT_CODE long CONVENTION PhaseSI(const char* Name1, double Prop1, const char* Name2, double Prop2, const char* Ref, char* phase, int n);
133 
142 EXPORT_CODE long CONVENTION get_global_param_string(const char* param, char* Output, int n);
150 EXPORT_CODE long CONVENTION get_parameter_information_string(const char* key, char* Output, int n);
157 EXPORT_CODE long CONVENTION get_fluid_param_string(const char* fluid, const char* param, char* Output, int n);
163 EXPORT_CODE void CONVENTION set_config_string(const char* key, const char* val);
169 EXPORT_CODE void CONVENTION set_config_double(const char* key, const double val);
175 EXPORT_CODE void CONVENTION set_config_bool(const char* key, const bool val);
187 EXPORT_CODE void CONVENTION set_departure_functions(const char* string_data, long* errcode, char* message_buffer, const long buffer_length);
193 EXPORT_CODE int CONVENTION set_reference_stateS(const char* Ref, const char* reference_state);
199 EXPORT_CODE int CONVENTION set_reference_stateD(const char* Ref, double T, double rhomolar, double hmolar0, double smolar0);
206 EXPORT_CODE void CONVENTION propssi_(const char* Output, const char* Name1, const double* Prop1, const char* Name2, const double* Prop2,
207  const char* Ref, double* output);
208 
210 EXPORT_CODE double CONVENTION F2K(double T_F);
212 EXPORT_CODE double CONVENTION K2F(double T_K);
217 EXPORT_CODE long CONVENTION get_param_index(const char* param);
222 EXPORT_CODE long CONVENTION get_input_pair_index(const char* param);
225 EXPORT_CODE long CONVENTION redirect_stdout(const char* file);
226 
227 // ---------------------------------
228 // Getter and setter for debug level
229 // ---------------------------------
230 
236 EXPORT_CODE void CONVENTION set_debug_level(int level);
237 
238 /* \brief Extract a value from the saturation ancillary
239  *
240  * @param fluid_name The name of the fluid to be used - HelmholtzEOS backend only
241  * @param output The desired output variable ("P" for instance for pressure)
242  * @param Q The quality, 0 or 1
243  * @param input The input variable ("T")
244  * @param value The input value
245  */
246 EXPORT_CODE double CONVENTION saturation_ancillary(const char* fluid_name, const char* output, int Q, const char* input, double value);
247 
248 // ---------------------------------
249 // Humid Air Properties
250 // ---------------------------------
251 
257 EXPORT_CODE double CONVENTION HAPropsSI(const char* Output, const char* Name1, double Prop1, const char* Name2, double Prop2, const char* Name3,
258  double Prop3);
259 
267 EXPORT_CODE double CONVENTION cair_sat(double T);
268 
274 EXPORT_CODE void CONVENTION hapropssi_(const char* Output, const char* Name1, const double* Prop1, const char* Name2, const double* Prop2,
275  const char* Name3, const double* Prop3, double* output);
276 
284 EXPORT_CODE double CONVENTION HAProps(const char* Output, const char* Name1, double Prop1, const char* Name2, double Prop2, const char* Name3,
285  double Prop3);
286 
294 EXPORT_CODE void CONVENTION haprops_(const char* Output, const char* Name1, const double* Prop1, const char* Name2, const double* Prop2,
295  const char* Name3, const double* Prop3, double* output);
296 
297 // ---------------------------------
298 // Low-level access
299 // ---------------------------------
300 
310 EXPORT_CODE long CONVENTION AbstractState_factory(const char* backend, const char* fluids, long* errcode, char* message_buffer,
311  const long buffer_length);
321 EXPORT_CODE void CONVENTION AbstractState_fluid_names(const long handle, char* fluids, long* errcode, char* message_buffer, const long buffer_length);
330 EXPORT_CODE void CONVENTION AbstractState_free(const long handle, long* errcode, char* message_buffer, const long buffer_length);
341 EXPORT_CODE void CONVENTION AbstractState_set_fractions(const long handle, const double* fractions, const long N, long* errcode, char* message_buffer,
342  const long buffer_length);
354 EXPORT_CODE void CONVENTION AbstractState_get_mole_fractions(const long handle, double* fractions, const long maxN, long* N, long* errcode,
355  char* message_buffer, const long buffer_length);
368 EXPORT_CODE void CONVENTION AbstractState_get_mole_fractions_satState(const long handle, const char* saturated_state, double* fractions,
369  const long maxN, long* N, long* errcode, char* message_buffer,
370  const long buffer_length);
380 EXPORT_CODE double CONVENTION AbstractState_get_fugacity(const long handle, const long i, long* errcode, char* message_buffer,
381  const long buffer_length);
391 EXPORT_CODE double CONVENTION AbstractState_get_fugacity_coefficient(const long handle, const long i, long* errcode, char* message_buffer,
392  const long buffer_length);
404 EXPORT_CODE void CONVENTION AbstractState_update(const long handle, const long input_pair, const double value1, const double value2, long* errcode,
405  char* message_buffer, const long buffer_length);
415 EXPORT_CODE void CONVENTION AbstractState_specify_phase(const long handle, const char* phase, long* errcode, char* message_buffer,
416  const long buffer_length);
425 EXPORT_CODE void CONVENTION AbstractState_unspecify_phase(const long handle, long* errcode, char* message_buffer, const long buffer_length);
435 EXPORT_CODE double CONVENTION AbstractState_keyed_output(const long handle, const long param, long* errcode, char* message_buffer,
436  const long buffer_length);
437 
448 EXPORT_CODE double CONVENTION AbstractState_first_saturation_deriv(const long handle, const long Of, const long Wrt, long* errcode,
449  char* message_buffer, const long buffer_length);
450 
462 EXPORT_CODE double CONVENTION AbstractState_first_partial_deriv(const long handle, const long Of, const long Wrt, const long Constant, long* errcode,
463  char* message_buffer, const long buffer_length);
464 
479 EXPORT_CODE double CONVENTION AbstractState_second_two_phase_deriv(const long handle, const long Of1, const long Wrt1, const long Constant1,
480  const long Wrt2, const long Constant2, long* errcode, char* message_buffer,
481  const long buffer_length);
496 EXPORT_CODE double CONVENTION AbstractState_second_partial_deriv(const long handle, const long Of1, const long Wrt1, const long Constant1,
497  const long Wrt2, const long Constant2, long* errcode, char* message_buffer,
498  const long buffer_length);
499 
515 EXPORT_CODE double CONVENTION AbstractState_first_two_phase_deriv_splined(const long handle, const long Of, const long Wrt, const long Constant,
516  const double x_end,long* errcode, char* message_buffer, const long buffer_length);
529 EXPORT_CODE double CONVENTION AbstractState_first_two_phase_deriv(const long handle, const long Of, const long Wrt, const long Constant,
530  long* errcode, char* message_buffer, const long buffer_length);
551 EXPORT_CODE void CONVENTION AbstractState_update_and_common_out(const long handle, const long input_pair, const double* value1, const double* value2,
552  const long length, double* T, double* p, double* rhomolar, double* hmolar,
553  double* smolar, long* errcode, char* message_buffer, const long buffer_length);
554 
572 EXPORT_CODE void CONVENTION AbstractState_update_and_1_out(const long handle, const long input_pair, const double* value1, const double* value2,
573  const long length, const long output, double* out, long* errcode, char* message_buffer,
574  const long buffer_length);
575 
597 EXPORT_CODE void CONVENTION AbstractState_update_and_5_out(const long handle, const long input_pair, const double* value1, const double* value2,
598  const long length, long* outputs, double* out1, double* out2, double* out3, double* out4,
599  double* out5, long* errcode, char* message_buffer, const long buffer_length);
600 
613 EXPORT_CODE void CONVENTION AbstractState_set_binary_interaction_double(const long handle, const long i, const long j, const char* parameter,
614  const double value, long* errcode, char* message_buffer,
615  const long buffer_length);
616 
630 EXPORT_CODE void CONVENTION AbstractState_set_cubic_alpha_C(const long handle, const long i, const char* parameter, const double c1, const double c2,
631  const double c3, long* errcode, char* message_buffer, const long buffer_length);
632 
644 EXPORT_CODE void CONVENTION AbstractState_set_fluid_parameter_double(const long handle, const long i, const char* parameter, const double value,
645  long* errcode, char* message_buffer, const long buffer_length);
646 
658 EXPORT_CODE void CONVENTION AbstractState_build_phase_envelope(const long handle, const char* level, long* errcode, char* message_buffer,
659  const long buffer_length);
660 
678 EXPORT_CODE void CONVENTION AbstractState_get_phase_envelope_data(const long handle, const long length, double* T, double* p, double* rhomolar_vap,
679  double* rhomolar_liq, double* x, double* y, long* errcode, char* message_buffer,
680  const long buffer_length);
681 
702 EXPORT_CODE void CONVENTION AbstractState_get_phase_envelope_data_checkedMemory(const long handle, const long length, const long maxComponents, double* T,
703  double* p, double* rhomolar_vap, double* rhomolar_liq, double* x, double* y,
704  long* actual_length, long* actual_components, long* errcode, char* message_buffer,
705  const long buffer_length);
706 
715 EXPORT_CODE void CONVENTION AbstractState_build_spinodal(const long handle, long* errcode, char* message_buffer, const long buffer_length);
716 
731 EXPORT_CODE void CONVENTION AbstractState_get_spinodal_data(const long handle, const long length, double* tau, double* delta, double* M1,
732  long* errcode, char* message_buffer, const long buffer_length);
733 
749 EXPORT_CODE void CONVENTION AbstractState_all_critical_points(const long handle, const long length, double* T, double* p, double* rhomolar,
750  long* stable, long* errcode, char* message_buffer, const long buffer_length);
761 EXPORT_CODE double CONVENTION AbstractState_keyed_output_satState(const long handle, const char* saturated_state, const long param, long* errcode,
762  char* message_buffer, const long buffer_length);
772 EXPORT_CODE void CONVENTION AbstractState_backend_name(const long handle, char* backend, long* errcode, char* message_buffer,
773  const long buffer_length);
774 
778 EXPORT_CODE void CONVENTION AbstractState_fluid_param_string(const long handle, const char* param, char* return_buffer,
779  const long return_buffer_length, long* errcode, char* message_buffer,
780  const long buffer_length);
781 
785 EXPORT_CODE int CONVENTION AbstractState_phase(const long handle, long* errcode, char* message_buffer, const long buffer_length);
786 
790 EXPORT_CODE double CONVENTION AbstractState_saturated_liquid_keyed_output(const long handle, const long param, long* errcode, char* message_buffer,
791  const long buffer_length);
792 
796 EXPORT_CODE double CONVENTION AbstractState_saturated_vapor_keyed_output(const long handle, const long param, long* errcode, char* message_buffer,
797  const long buffer_length);
798 
806 EXPORT_CODE void CONVENTION add_fluids_as_JSON(const char* backend, const char* fluidstring, long* errcode, char* message_buffer,
807  const long buffer_length);
808 
812 EXPORT_CODE int CONVENTION C_is_valid_fluid_string(const char* fluidName);
813 
817 EXPORT_CODE int CONVENTION C_extract_backend(const char* fluid_string, char* backend, const long backend_length, char* fluid,
818  const long fluid_length);
819 
820 // *************************************************************************************
821 // *************************************************************************************
822 // ***************************** DEPRECATED *******************************************
823 // *************************************************************************************
824 // *************************************************************************************
825 
830 EXPORT_CODE double CONVENTION PropsS(const char* Output, const char* Name1, double Prop1, const char* Name2, double Prop2, const char* Ref);
834 EXPORT_CODE double CONVENTION Props(const char* Output, const char Name1, double Prop1, const char Name2, double Prop2, const char* Ref);
838 EXPORT_CODE double CONVENTION Props1(const char* FluidName, const char* Output);
839 
840 #endif