Opened 10 years ago

Closed 10 years ago

#2853 closed defect (fixed)

Annex60 model fails after new lookup

Reported by: Martin Sjölund Owned by: Adrian Pop
Priority: high Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: Cc:

Description

Annex60.Utilities.Psychrometrics.Functions.BaseClasses.Examples.DewPointTemperatureDerivativeCheck_amb in the following model fails after the changes to the front-end. Note that DewPointTemperatureDerivativeCheck_amb works fine.

package Modelica

  package Math

    function exp
      input Real u;
      output Real y;
      external "builtin" y = exp(u);
    end exp;

    function log
      input Real u;
      output Real y;
      external "builtin" y = log(u);
    end log;
  end Math;

  package SIunits
    type Pressure = Real(final quantity = "Pressure", final unit = "Pa", displayUnit = "bar");
    type ThermodynamicTemperature = Real(final quantity = "ThermodynamicTemperature", final unit = "K", min = 0.0, start = 288.15, nominal = 300, displayUnit = "degC");
    type Temperature = ThermodynamicTemperature;
  end SIunits;
end Modelica;

package Annex60
  package Utilities
    package Psychrometrics
      package Functions
        function pW_TDewPoi_amb
          extends Annex60.Utilities.Psychrometrics.Functions.BaseClasses.pW_TDewPoi_amb;
          input Modelica.SIunits.Temperature T;
          output Modelica.SIunits.Pressure p_w(displayUnit = "Pa", min = 100);
        algorithm
          p_w := Modelica.Math.exp(a1 + a2 * T);
        end pW_TDewPoi_amb;

        package BaseClasses
          package Examples
            model DewPointTemperatureDerivativeCheck_amb
              Real x;
              Real y;
              parameter Real uniCon(unit = "K/s") = 1;
            initial equation
              y = x;
            equation
              x = Annex60.Utilities.Psychrometrics.Functions.pW_TDewPoi_amb(T = time * uniCon);
              der(y) = der(x);
              assert(abs(x - y) < 1E-2, "Model has an error");
            end DewPointTemperatureDerivativeCheck_amb;
          end Examples;

          function der_pW_TDewPoi_amb
            extends Annex60.Utilities.Psychrometrics.Functions.BaseClasses.pW_TDewPoi_amb;
            input Modelica.SIunits.Temperature T;
            input Real dT;
            output Real dp_w;
          algorithm
            dp_w := a2 * Modelica.Math.exp(a1 + a2 * T) * dT;
          end der_pW_TDewPoi_amb;

          partial function pW_TDewPoi_amb
          protected
            constant Modelica.SIunits.Temperature T1 = 283.15;
            constant Modelica.SIunits.Temperature T2 = 293.15;
            constant Modelica.SIunits.Pressure p1 = 1227.97;
            constant Modelica.SIunits.Pressure p2 = 2338.76;
            constant Real a1 = (Modelica.Math.log(p2) - Modelica.Math.log(p1) * T2 / T1) / (1 - T2 / T1);
            constant Real a2(unit = "1/K") = (Modelica.Math.log(p1) - a1) / T1;
          end pW_TDewPoi_amb;
        end BaseClasses;
      end Functions;
    end Psychrometrics;
  end Utilities;
end Annex60;

model DewPointTemperatureDerivativeCheck_amb
  extends Annex60.Utilities.Psychrometrics.Functions.BaseClasses.Examples.DewPointTemperatureDerivativeCheck_amb;
  annotation(__Dymola_Commands(file = "modelica://Annex60/Resources/Scripts/Dymola/Utilities/Psychrometrics/Functions/BaseClasses/Examples/DewPointTemperatureDerivativeCheck_amb.mos"), experiment(StartTime = 273.15, StopTime = 323.15));
end DewPointTemperatureDerivativeCheck_amb;

Change History (3)

comment:1 by Martin Sjölund, 10 years ago

Got any fixes for this?

comment:2 by Adrian Pop, 10 years ago

I think I know what the problem is but haven't got time to fix it. I'll have a look today.

comment:3 by Adrian Pop, 10 years ago

Resolution: fixed
Status: newclosed

Fixed in r22672.

Note: See TracTickets for help on using tickets.