Closed ora8 closed 1 year ago
Two options: 1) The CoolProp wrapper for REFPROP: http://www.coolprop.org/coolprop/wrappers/Csharp/index.html 2) https://github.com/usnistgov/REFPROP-wrappers/tree/master/wrappers/Csharp
Thanks, but the upper routine REFPROPdll is not implement by the C# Wrapper. I think that my declaration is correct. I made a mistake in calling it.
Personally, and not just because I wrote it, I prefer the interface in CoolProp.
If you wanted to add the missing high-level functions, I am sure others would appreciate it. I am not a C# user.
REFPROPddl is the only function needed in REFPROP 10. For example to get the molar mass I used this call.
var hfld = string.Empty;
var x = new double[NcMax];
var i = 0;
foreach (var item in items)
{
if (!string.IsNullOrEmpty(hfld))
hfld += "|";
hfld += item.RefPropName;
x[i] = item.Percentage / 100.0;
i++;
}
hfld += new string(' ', 10000 - hfld.Length);
/// Normalize the concentrations, there could be a difference of 0.00001
NormalizeFractions(x);
var iErr = 0L;
var q = 0.0;
var iUnits = 0L;
long iUCode = 0L;
var iMass = 1L;
var iFlag = 0L;
var a = 0.0;
var b = 0.0;
var z = new double[NcMax];
var output = new double[200];
var y = new double[NcMax];
var x3 = new double[NcMax];
var hFld_length = 10000L;
var hIn_length = 255L;
var hOut_length = 255L;
var hUnits_length = 255L;
var herr_length = 255L;
var hIn = new string(' ', 255);
var hOut = "M" + new string(' ', 254);
var hUnits = new string(' ', 255);
var herr = new string(' ', 255);
IRefProp64.REFPROPdll(ref hfld, ref hIn, ref hOut, ref iUnits, ref iMass, ref iFlag, ref a, ref b, z, output, ref hUnits, ref iUCode,
x, y, x3, ref q, ref iErr, ref herr, ref hFld_length, ref hIn_length, ref hOut_length, ref hUnits_length, ref herr_length);
if (iErr != 0L)
{
MessageBox.Show(herr, "RefProp REFPROPdll error", MessageBoxButton.OK, MessageBoxImage.Error);
return string.Empty;
}
var molarMass = output[0];
private void NormalizeFractions(double[] fractions)
{
/// Normalize the concentrations, there could a difference of 0.00001
var total = fractions.Sum();
if (total != 1.0)
{
for (var i = 0; i < fractions.Length; i++)
fractions[i] /= total;
}
}
@ora8
REFPROPdll
is NOT part of IRefProp64
.
Where did you get it? did you write/implemented it yourself?
Thanks!
RefProp64.dll is Part of Refprop. See REFPROP NIST website. RefProp.dll is the 32 Bit Version.
Hi @ora8
I think that you got this wrong.
I know that RefProp64.dll
is part of REFPROP
, but in your example you are using IRefProp64.REFPROPdll
, which is the interface
for RefProp64.dll
.
Now, if you inspect the IRefProp64
interface, you'll see that REFPROPdll
is NOT implemented there.
So you've either updated the interface code, or you have another/diff version of the interface.
I hope this. makes sense.
You are right. It is some times ago, I posted this. In the Version 10 of REFPROP there is a method REFPROPdll implemented. I tried to call this method with the posted wrapper of IRefProp64. I tested it with posted sample. It seems to work At the Moment I use Version 10 with the old API amd not with the REFPROPdll method. Perhaps You can test it if my wrapper is correct. I think it is so. If I have time I will replace the old REFProp API calls with the REFPROPdll method. My co worker is afraid that the the old API (before Version 10) will not be supported in future Releases.
Two small comments:
Has any body a working wrapper in C# for REFPROPdll. My one does not work.
The app always crashes.