Opened 6 years ago

Closed 6 years ago

#5232 closed defect (fixed)

Unexpanded array() in function algorithm prevents differentiation when using the NF

Reported by: Francesco Casella Owned by: Per Östlund
Priority: high Milestone: 2.0.0
Component: New Instantiation Version:
Keywords: Cc:

Description

Please check Modelica.Media.Examples.MixtureGases. The following error is reported

[OMCompiler/Compiler/BackEnd/Differentiate.mo:402:3-402:155:writable] Error:
Derivative of expression "medium1.h = Modelica.Media.Examples.MixtureGases.Medium1.h_TX(medium1.T, {0.8, 0.2}, true, Modelica.Media.Interfaces.Choices.ReferenceEnthalpy.ZeroAt0K, 0.0)" w.r.t. "time" is non-existent.

Upon inspection of the Modelica.Media.Examples.MixtureGases.Medium1.h_TX function, the algorithm when flattening with the OF is

 h := X[1] * Modelica.Media.IdealGases.Common.Functions.h_T(Modelica.Media.IdealGases.Common.DataRecord("N2", 0.0280134, 0, 309498.4543111511, 1000, {22103.71497, -381.846182, 6.08273836, -0.00853091441, 1.384646189e-005, -9.62579362e-009, 2.519705809e-012}, {710.846086, -10.76003744}, {587712.406, -2239.249073, 6.06694922, -0.00061396855, 1.491806679e-007, -1.923105485e-011, 1.061954386e-015}, {12832.10415, -15.86640027}, 296.8033869505308), T, exclEnthForm, refChoice, h_off) + X[2] * Modelica.Media.IdealGases.Common.Functions.h_T(Modelica.Media.IdealGases.Common.DataRecord("O2", 0.0319988, 0, 271263.4223783392, 1000, {-34255.6342, 484.700097, 1.119010961, 0.00429388924, -6.83630052e-007, -2.0233727e-009, 1.039040018e-012}, {-3391.45487, 18.4969947}, {-1037939.022, 2344.830282, 1.819732036, 0.001267847582, -2.188067988e-007, 2.053719572e-011, -8.193467050000001e-016}, {-16890.10929, 17.38716506}, 259.8369938872708), T, exclEnthForm, refChoice, h_off);

while the NF reports

  h := X * array(Modelica.Media.IdealGases.Common.Functions.h_T({Modelica.Media.IdealGases.Common.DataRecord("N2", 0.0280134, 0.0, 309498.4543111511, 1000.0, {22103.71497, -381.846182, 6.08273836, -0.00853091441, 1.384646189e-005, -9.62579362e-009, 2.519705809e-012}, {710.846086, -10.76003744}, {587712.406, -2239.249073, 6.06694922, -0.00061396855, 1.491806679e-007, -1.923105485e-011, 1.061954386e-015}, {12832.10415, -15.86640027}, 296.8033869505308), Modelica.Media.IdealGases.Common.DataRecord("O2", 0.0319988, 0.0, 271263.4223783392, 1000.0, {-34255.6342, 484.700097, 1.119010961, 0.00429388924, -6.83630052e-007, -2.0233727e-009, 1.039040018e-012}, {-3391.45487, 18.4969947}, {-1037939.022, 2344.830282, 1.819732036, 0.001267847582, -2.188067988e-007, 2.053719572e-011, -8.193467050000001e-016}, {-16890.10929, 17.38716506}, 259.8369938872708)}[i], T, exclEnthForm, refChoice, h_off) for i in 1:2);

I understand the fact that there is still an unexpanded array() operator probably explains the failure to differentiate the function.

Change History (1)

comment:1 by Per Östlund, 6 years ago

Resolution: fixed
Status: newclosed

Fixed in 8334fe1. The model now simulates correctly.

Note: See TracTickets for help on using tickets.