diff --git a/wrappers/Delphi/Project4.res b/wrappers/Delphi/Project4.res new file mode 100644 index 00000000..fcbd5375 Binary files /dev/null and b/wrappers/Delphi/Project4.res differ diff --git a/wrappers/Delphi/Project5.dpr b/wrappers/Delphi/Project5.dpr new file mode 100644 index 00000000..e6e4aaa9 --- /dev/null +++ b/wrappers/Delphi/Project5.dpr @@ -0,0 +1,14 @@ +program Project5; +{$apptype console} + +uses + cpIntf; + +var + dat: AnsiString; +begin + SetLength(dat, 1024); + get_global_param_string('FluidsList', PAnsiChar(dat), 1024); + writeln(dat); + readln; +end. \ No newline at end of file diff --git a/wrappers/Delphi/coolprop_error01.png b/wrappers/Delphi/coolprop_error01.png new file mode 100644 index 00000000..3acc0d54 Binary files /dev/null and b/wrappers/Delphi/coolprop_error01.png differ diff --git a/wrappers/Delphi/log14dec2015.txt b/wrappers/Delphi/log14dec2015.txt new file mode 100644 index 00000000..c5b7f9ea --- /dev/null +++ b/wrappers/Delphi/log14dec2015.txt @@ -0,0 +1 @@ +Some more examples. \ No newline at end of file diff --git a/wrappers/Delphi/project1.dpr b/wrappers/Delphi/project1.dpr new file mode 100644 index 00000000..6554a29d --- /dev/null +++ b/wrappers/Delphi/project1.dpr @@ -0,0 +1,20 @@ +program project1; +{$apptype console} + +uses + SysUtils, Windows, + cpIntf; + +var + h: Double; +begin + + { + Very simple example + Get the vapor enthalpy at a given pressure. + } + + h := PropsSI('H', 'P', 101e3, 'Q', 1, 'R22'); + writeln(format('h = %0.3f kJ/kg',[1e-3*h])); + readln; +end. diff --git a/wrappers/Delphi/project2.dpr b/wrappers/Delphi/project2.dpr new file mode 100644 index 00000000..b5a83f2a --- /dev/null +++ b/wrappers/Delphi/project2.dpr @@ -0,0 +1,41 @@ +program project2; +{$apptype console} + +uses + SysUtils, Windows, + cpIntf; + +var + T, h, p, D: Double; +begin + + { + This example comes from Ian Bell. + When I ran the original with Delphi, there were a few problems. + In my cpIntf interface, the fpu exceptions are disabled + and Ian's example works fine. + } + + Writeln('FLUID STATE INDEPENDENT INPUTS'); + + Writeln('TWO PHASE INPUTS (Pressure)'); + Writeln(Format('Density of saturated liquid Propane at 101325 Pa: %g kg/m^3', [PropsSI('D', 'P', 101325, 'Q', 0, 'Propane')])); + Writeln(Format('Density of saturated vapor R290 at 101325 Pa: %g kg/m^3'+ sLineBreak, [PropsSI('D', 'P', 101325, 'Q', 1, 'R290')])); + + Writeln('TWO PHASE INPUTS (Temperature)'); + Writeln(Format('Density of saturated liquid Propane at 300 K: %g kg/m^3', [PropsSI('D', 'T', 300, 'Q', 0, 'Propane')])); + Writeln(Format('Density of saturated vapor R290 at 300 K: %g kg/m^3' + sLineBreak, [PropsSI('D', 'T', 300, 'Q', 1, 'R290')])); + + Writeln('SINGLE PHASE CYCLE (Propane)'); + p := PropsSI('P', 'T', 300, 'D', 1, 'Propane'); + h := PropsSI('H', 'T', 300, 'D', 1, 'Propane'); + Writeln(Format('T,D -> P,H : 300,1 -> %g,%g', [p, h])); + T := PropsSI('T', 'P', p, 'H', h, 'Propane'); + D := PropsSI('D', 'P', p, 'H', h, 'Propane'); + Writeln(Format('P,H -> T,D : %g, %g -> %g, %g' + sLineBreak, [p, h, T, D])); + + Writeln('************ HUMID AIR PROPERTIES *************' + sLineBreak); + Writeln(Format('Humidity ratio of 50%% rel. hum. air at 300 K, 101.325 kPa: %g kg_w/kg_da', [HAPropsSI('W', 'T', 300, 'P', 101325, 'R', 0.5)])); + Writeln(Format('Relative humidity from last calculation: %g (fractional)', [HAPropsSI('R', 'T', 300, 'P', 101325, 'W', HAPropsSI('W', 'T', 300, 'P', 101325, 'R', 0.5))])); + readln; +end. diff --git a/wrappers/Delphi/project3.dpr b/wrappers/Delphi/project3.dpr new file mode 100644 index 00000000..10549d89 --- /dev/null +++ b/wrappers/Delphi/project3.dpr @@ -0,0 +1,19 @@ +program project3; +{$apptype console} + +uses + SysUtils, Windows, + cpIntf; + +var + res: AnsiString; + T: Double; +begin + SetLength(res, 1024); + get_global_param_string('FluidsList', PAnsiChar(res), 1024); + writeln(res); + + T := PropsSI('T', 'P', 4.7e6, 'H', 330e3, 'R22')-273.15; + writeln(T:6:2); + readln; +end. \ No newline at end of file diff --git a/wrappers/Delphi/project4.png b/wrappers/Delphi/project4.png new file mode 100644 index 00000000..94afac74 Binary files /dev/null and b/wrappers/Delphi/project4.png differ diff --git a/wrappers/Delphi/project6.dpr b/wrappers/Delphi/project6.dpr new file mode 100644 index 00000000..044e145c --- /dev/null +++ b/wrappers/Delphi/project6.dpr @@ -0,0 +1,32 @@ +program project6; +{$apptype console} + +{ Not using cpIntf + This is to demo the problem when the exception is not disabled. + It happens with the Delphi compiler. +} + +function PropsSI(spec: PAnsiChar; + prop1: PAnsiChar; val1: Double; + prop2: PAnsiChar; val2: Double; + ref: PAnsiChar): Double; stdcall; + external 'CoolProp.dll' name '_PropsSI@32'; + +const + MCW_EM = Word($133f); // Disable all fpu exceptions +var + Saved8087CW: Word; + p, h, t: double; +begin + Saved8087CW := Default8087CW; + Set8087CW(MCW_EM); + h := 330; + p := 4.3; // no problem + t := PropsSI('T', 'P', 1e6*p, 'H', 1e3*h, 'R22'); + writeln(t); + p := 4.4; // crash if fpu not disabled + t := PropsSI('T', 'P', 1e6*p, 'H', 1e3*h, 'R22'); + Set8087CW(Saved8087CW); + writeln(t); + readln; +end.