usnistgov / REFPROP-wrappers

Wrappers around NIST REFPROP for languages such as Python, MATLAB, etc.
190 stars 128 forks source link

.NET Wrapper Sample proj. Error: "SATT err 121] Temperature input is greater than the critical or mascondenthem temperature..... #603

Open bhbooton opened 2 months ago

bhbooton commented 2 months ago

Description

In the sample application "RefProp_cs_Examples the third tab functionality is not working. No matter what numbers you enter the result will include an error message "Error: SATT err 121] Temperature input is greater than the critical or mascondenthem temperature...."

Steps to Reproduce

  1. Open the RerProp_cs_Examples.sln in Visual Studio.
  2. Hit F5 to run the application.
  3. Go to EX-MIX-FORTRAN > t:378 Mixture: R401A (Really it doesn't matter) > Calc
  4. In the Grid boxes the last column shows the error.

Versions

REFPROP Version: 1.0.0.0 Operating System and Version: Windows 10, Visual Studio 2022
Access Method: .NET Wrapper (RefProp_cs_Examples.sln) SampleDocErrorMessage.docx

Additional Information

If possible, please post examples and/or screenshots of the issue.

bhbooton commented 1 month ago

When can I expect to hear back on this?

ianhbell commented 1 month ago

The wrappers are community provided and supported so we (at NIST) only serve as moderators, aside from the wrappers that we actively support (Python and Excel)

henningjp commented 1 month ago

@bhbooton - I'm going to preface this with the fact that I know absolutely nothing about CS or .NET. However, the C# is close enough to C++ to figure out what's going on here.

The Calc button is assigned to button5_Click on line 1998 of Form1.Designer.cs.

In Form1.cs (in the button5_Click routine) on lines 292-293, :

292            double t = Convert.ToDouble(textBox_t_3rdTab.Text);
293            double tk = (t - 32) * 5.0 / 9.0 + 273.15;

On line 292, temperature t is being converted from the text box on the third tab to a double. Then on line 293, this temperature looks like it is being converted from °F to K, even though the label on the panel says that the text box should be entered in K.

The critical temperature for R454B is 351.254 K. (You can figure this out from the GUI or the Excel wrapper.) The values you tried to use in your attached document, if we assume it is being treated as °F, yield temperatures in Kelvin [K] that are greater than Tcrit. This is exactly what the error message says.

                t = 283 °F = 412.594 K

This is exactly the T value shown in the error message, which is above the critical Temperature of 351.254 K as noted.

I would suggest either,

  1. Change the label on the temperature entry field to °F

    1999            // 
    2000            // label17
    2001            // 
    2002            this.label17.AutoSize = true;
    2003            this.label17.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    2004            this.label17.Location = new System.Drawing.Point(110, 83);
    2005            this.label17.Name = "label17";
    2006            this.label17.Size = new System.Drawing.Size(15, 15);
    2007            this.label17.TabIndex = 95;
    2008            this.label17.Text = "°F";            //   <====  Change the label here to F
    2009            this.label17.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  2. Or, comment out line 293 in Form1.cs so that the temperature is left in K.

    292            double t = Convert.ToDouble(textBox_t_3rdTab.Text);
    293            double tk = t;                             // (t - 32) * 5.0 / 9.0 + 273.15;

Hope that helps.