CoolProp  6.6.1dev
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 #ifndef __cplusplus
63 # if defined(__STDC_VERSION__)
64 # if (__STDC_VERSION__ >= 199901L)
65 # include <stdbool.h>
66 # endif
67 # endif
68 #endif
69 
70 // Hack for PowerPC compilation to only use extern "C"
71 #if defined(__powerpc__) || defined(EXTERNC)
72 # undef EXPORT_CODE
73 # define EXPORT_CODE extern "C"
74 #endif
75 
76 #if defined(__powerpc__)
77 // From https://rowley.zendesk.com/entries/46176--Undefined-reference-to-assert-error-message
78 // The __assert function is an error handler function that is invoked when an assertion fails.
79 // If you are writing a program that uses the assert macro then you must supply you own __assert error handler function. For example
80 inline void __assert(const char* error) {
81  while (1)
82  ;
83 }
84 #endif
85 
92 EXPORT_CODE double CONVENTION Props1SI(const char* FluidName, const char* Output);
93 
100 EXPORT_CODE void CONVENTION Props1SImulti(const char* Outputs, char* backend, const char* FluidNames, const double* fractions,
101  const long length_fractions, double* result, long* resdim1);
108 EXPORT_CODE double CONVENTION PropsSI(const char* Output, const char* Name1, double Prop1, const char* Name2, double Prop2, const char* Ref);
131 EXPORT_CODE void CONVENTION PropsSImulti(const char* Outputs, const char* Name1, double* Prop1, const long size_Prop1, const char* Name2,
132  double* Prop2, const long size_Prop2, char* backend, const char* FluidNames, const double* fractions,
133  const long length_fractions, double* result, long* resdim1, long* resdim2);
140 EXPORT_CODE long CONVENTION PhaseSI(const char* Name1, double Prop1, const char* Name2, double Prop2, const char* Ref, char* phase, int n);
141 
150 EXPORT_CODE long CONVENTION get_global_param_string(const char* param, char* Output, int n);
158 EXPORT_CODE long CONVENTION get_parameter_information_string(const char* key, char* Output, int n);
165 EXPORT_CODE long CONVENTION get_fluid_param_string(const char* fluid, const char* param, char* Output, int n);
171 EXPORT_CODE void CONVENTION set_config_string(const char* key, const char* val);
177 EXPORT_CODE void CONVENTION set_config_double(const char* key, const double val);
183 EXPORT_CODE void CONVENTION set_config_bool(const char* key, const bool val);
195 EXPORT_CODE void CONVENTION set_departure_functions(const char* string_data, long* errcode, char* message_buffer, const long buffer_length);
201 EXPORT_CODE int CONVENTION set_reference_stateS(const char* Ref, const char* reference_state);
207 EXPORT_CODE int CONVENTION set_reference_stateD(const char* Ref, double T, double rhomolar, double hmolar0, double smolar0);
214 EXPORT_CODE void CONVENTION propssi_(const char* Output, const char* Name1, const double* Prop1, const char* Name2, const double* Prop2,
215  const char* Ref, double* output);
216 
218 EXPORT_CODE double CONVENTION F2K(double T_F);
220 EXPORT_CODE double CONVENTION K2F(double T_K);
225 EXPORT_CODE long CONVENTION get_param_index(const char* param);
230 EXPORT_CODE long CONVENTION get_input_pair_index(const char* param);
233 EXPORT_CODE long CONVENTION redirect_stdout(const char* file);
234 
235 // ---------------------------------
236 // Getter and setter for debug level
237 // ---------------------------------
238 
244 EXPORT_CODE void CONVENTION set_debug_level(int level);
245 
246 /* \brief Extract a value from the saturation ancillary
247  *
248  * @param fluid_name The name of the fluid to be used - HelmholtzEOS backend only
249  * @param output The desired output variable ("P" for instance for pressure)
250  * @param Q The quality, 0 or 1
251  * @param input The input variable ("T")
252  * @param value The input value
253  */
254 EXPORT_CODE double CONVENTION saturation_ancillary(const char* fluid_name, const char* output, int Q, const char* input, double value);
255 
256 // ---------------------------------
257 // Humid Air Properties
258 // ---------------------------------
259 
265 EXPORT_CODE double CONVENTION HAPropsSI(const char* Output, const char* Name1, double Prop1, const char* Name2, double Prop2, const char* Name3,
266  double Prop3);
267 
275 EXPORT_CODE double CONVENTION cair_sat(double T);
276 
282 EXPORT_CODE void CONVENTION hapropssi_(const char* Output, const char* Name1, const double* Prop1, const char* Name2, const double* Prop2,
283  const char* Name3, const double* Prop3, double* output);
284 
292 EXPORT_CODE double CONVENTION HAProps(const char* Output, const char* Name1, double Prop1, const char* Name2, double Prop2, const char* Name3,
293  double Prop3);
294 
302 EXPORT_CODE void CONVENTION haprops_(const char* Output, const char* Name1, const double* Prop1, const char* Name2, const double* Prop2,
303  const char* Name3, const double* Prop3, double* output);
304 
305 // ---------------------------------
306 // Low-level access
307 // ---------------------------------
308 
318 EXPORT_CODE long CONVENTION AbstractState_factory(const char* backend, const char* fluids, long* errcode, char* message_buffer,
319  const long buffer_length);
329 EXPORT_CODE void CONVENTION AbstractState_fluid_names(const long handle, char* fluids, long* errcode, char* message_buffer, const long buffer_length);
338 EXPORT_CODE void CONVENTION AbstractState_free(const long handle, long* errcode, char* message_buffer, const long buffer_length);
349 EXPORT_CODE void CONVENTION AbstractState_set_fractions(const long handle, const double* fractions, const long N, long* errcode, char* message_buffer,
350  const long buffer_length);
362 EXPORT_CODE void CONVENTION AbstractState_get_mole_fractions(const long handle, double* fractions, const long maxN, long* N, long* errcode,
363  char* message_buffer, const long buffer_length);
376 EXPORT_CODE void CONVENTION AbstractState_get_mole_fractions_satState(const long handle, const char* saturated_state, double* fractions,
377  const long maxN, long* N, long* errcode, char* message_buffer,
378  const long buffer_length);
388 EXPORT_CODE double CONVENTION AbstractState_get_fugacity(const long handle, const long i, long* errcode, char* message_buffer,
389  const long buffer_length);
399 EXPORT_CODE double CONVENTION AbstractState_get_fugacity_coefficient(const long handle, const long i, long* errcode, char* message_buffer,
400  const long buffer_length);
412 EXPORT_CODE void CONVENTION AbstractState_update(const long handle, const long input_pair, const double value1, const double value2, long* errcode,
413  char* message_buffer, const long buffer_length);
423 EXPORT_CODE void CONVENTION AbstractState_specify_phase(const long handle, const char* phase, long* errcode, char* message_buffer,
424  const long buffer_length);
433 EXPORT_CODE void CONVENTION AbstractState_unspecify_phase(const long handle, long* errcode, char* message_buffer, const long buffer_length);
443 EXPORT_CODE double CONVENTION AbstractState_keyed_output(const long handle, const long param, long* errcode, char* message_buffer,
444  const long buffer_length);
445 
456 EXPORT_CODE double CONVENTION AbstractState_first_saturation_deriv(const long handle, const long Of, const long Wrt, long* errcode,
457  char* message_buffer, const long buffer_length);
458 
470 EXPORT_CODE double CONVENTION AbstractState_first_partial_deriv(const long handle, const long Of, const long Wrt, const long Constant, long* errcode,
471  char* message_buffer, const long buffer_length);
472 
487 EXPORT_CODE double CONVENTION AbstractState_second_two_phase_deriv(const long handle, const long Of1, const long Wrt1, const long Constant1,
488  const long Wrt2, const long Constant2, long* errcode, char* message_buffer,
489  const long buffer_length);
504 EXPORT_CODE double CONVENTION AbstractState_second_partial_deriv(const long handle, const long Of1, const long Wrt1, const long Constant1,
505  const long Wrt2, const long Constant2, long* errcode, char* message_buffer,
506  const long buffer_length);
507 
523 EXPORT_CODE double CONVENTION AbstractState_first_two_phase_deriv_splined(const long handle, const long Of, const long Wrt, const long Constant,
524  const double x_end,long* errcode, char* message_buffer, const long buffer_length);
537 EXPORT_CODE double CONVENTION AbstractState_first_two_phase_deriv(const long handle, const long Of, const long Wrt, const long Constant,
538  long* errcode, char* message_buffer, const long buffer_length);
559 EXPORT_CODE void CONVENTION AbstractState_update_and_common_out(const long handle, const long input_pair, const double* value1, const double* value2,
560  const long length, double* T, double* p, double* rhomolar, double* hmolar,
561  double* smolar, long* errcode, char* message_buffer, const long buffer_length);
562 
580 EXPORT_CODE void CONVENTION AbstractState_update_and_1_out(const long handle, const long input_pair, const double* value1, const double* value2,
581  const long length, const long output, double* out, long* errcode, char* message_buffer,
582  const long buffer_length);
583 
605 EXPORT_CODE void CONVENTION AbstractState_update_and_5_out(const long handle, const long input_pair, const double* value1, const double* value2,
606  const long length, long* outputs, double* out1, double* out2, double* out3, double* out4,
607  double* out5, long* errcode, char* message_buffer, const long buffer_length);
608 
621 EXPORT_CODE void CONVENTION AbstractState_set_binary_interaction_double(const long handle, const long i, const long j, const char* parameter,
622  const double value, long* errcode, char* message_buffer,
623  const long buffer_length);
624 
638 EXPORT_CODE void CONVENTION AbstractState_set_cubic_alpha_C(const long handle, const long i, const char* parameter, const double c1, const double c2,
639  const double c3, long* errcode, char* message_buffer, const long buffer_length);
640 
652 EXPORT_CODE void CONVENTION AbstractState_set_fluid_parameter_double(const long handle, const long i, const char* parameter, const double value,
653  long* errcode, char* message_buffer, const long buffer_length);
654 
666 EXPORT_CODE void CONVENTION AbstractState_build_phase_envelope(const long handle, const char* level, long* errcode, char* message_buffer,
667  const long buffer_length);
668 
686 EXPORT_CODE void CONVENTION AbstractState_get_phase_envelope_data(const long handle, const long length, double* T, double* p, double* rhomolar_vap,
687  double* rhomolar_liq, double* x, double* y, long* errcode, char* message_buffer,
688  const long buffer_length);
689 
710 EXPORT_CODE void CONVENTION AbstractState_get_phase_envelope_data_checkedMemory(const long handle, const long length, const long maxComponents, double* T,
711  double* p, double* rhomolar_vap, double* rhomolar_liq, double* x, double* y,
712  long* actual_length, long* actual_components, long* errcode, char* message_buffer,
713  const long buffer_length);
714 
723 EXPORT_CODE void CONVENTION AbstractState_build_spinodal(const long handle, long* errcode, char* message_buffer, const long buffer_length);
724 
739 EXPORT_CODE void CONVENTION AbstractState_get_spinodal_data(const long handle, const long length, double* tau, double* delta, double* M1,
740  long* errcode, char* message_buffer, const long buffer_length);
741 
757 EXPORT_CODE void CONVENTION AbstractState_all_critical_points(const long handle, const long length, double* T, double* p, double* rhomolar,
758  long* stable, long* errcode, char* message_buffer, const long buffer_length);
769 EXPORT_CODE double CONVENTION AbstractState_keyed_output_satState(const long handle, const char* saturated_state, const long param, long* errcode,
770  char* message_buffer, const long buffer_length);
780 EXPORT_CODE void CONVENTION AbstractState_backend_name(const long handle, char* backend, long* errcode, char* message_buffer,
781  const long buffer_length);
782 
786 EXPORT_CODE void CONVENTION AbstractState_fluid_param_string(const long handle, const char* param, char* return_buffer,
787  const long return_buffer_length, long* errcode, char* message_buffer,
788  const long buffer_length);
789 
793 EXPORT_CODE int CONVENTION AbstractState_phase(const long handle, long* errcode, char* message_buffer, const long buffer_length);
794 
798 EXPORT_CODE double CONVENTION AbstractState_saturated_liquid_keyed_output(const long handle, const long param, long* errcode, char* message_buffer,
799  const long buffer_length);
800 
804 EXPORT_CODE double CONVENTION AbstractState_saturated_vapor_keyed_output(const long handle, const long param, long* errcode, char* message_buffer,
805  const long buffer_length);
806 
814 EXPORT_CODE void CONVENTION add_fluids_as_JSON(const char* backend, const char* fluidstring, long* errcode, char* message_buffer,
815  const long buffer_length);
816 
820 EXPORT_CODE int CONVENTION C_is_valid_fluid_string(const char* fluidName);
821 
825 EXPORT_CODE int CONVENTION C_extract_backend(const char* fluid_string, char* backend, const long backend_length, char* fluid,
826  const long fluid_length);
827 
828 // *************************************************************************************
829 // *************************************************************************************
830 // ***************************** DEPRECATED *******************************************
831 // *************************************************************************************
832 // *************************************************************************************
833 
838 EXPORT_CODE double CONVENTION PropsS(const char* Output, const char* Name1, double Prop1, const char* Name2, double Prop2, const char* Ref);
842 EXPORT_CODE double CONVENTION Props(const char* Output, const char Name1, double Prop1, const char Name2, double Prop2, const char* Ref);
846 EXPORT_CODE double CONVENTION Props1(const char* FluidName, const char* Output);
847 
848 #endif