Opened 6 years ago

Closed 6 years ago

#5017 closed defect (fixed)

Issue with package constants, start attribute sizes and inheritance in 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 ThermoPower.Test.GasComponents.TestCC.err. The following error is reported:

[ThermoPower 3.1/Gas.mo:2834:12-2834:39:writable] Notification: From here:
[OMCompiler/build/lib/omlibrary/Modelica 3.2.2/Media/package.mo:4478:7-4479:50:writable]
Error: Type mismatch in binding 
start = CombustionChamber1.Xstart[1:5],
expected subtype of Real[4], got type Real[5].

The offending code in Gas.mo reads

Exhaust.BaseProperties fluegas(
   p(start=pstart),
   T(start=Tstart),
   Xi(start=Xstart[1:Exhaust.nXi]));

The Exhaust medium package is defined as

package FlueGas "flue gas"
  extends Modelica.Media.IdealGases.Common.MixtureGasNasa(
    mediumName="FlueGas",
    data={Modelica.Media.IdealGases.Common.SingleGasesData.O2,
          Modelica.Media.IdealGases.Common.SingleGasesData.Ar,
          Modelica.Media.IdealGases.Common.SingleGasesData.H2O,
          Modelica.Media.IdealGases.Common.SingleGasesData.CO2,
          Modelica.Media.IdealGases.Common.SingleGasesData.N2},
    fluidConstants={
          Modelica.Media.IdealGases.Common.FluidData.O2,
          Modelica.Media.IdealGases.Common.FluidData.Ar,
          Modelica.Media.IdealGases.Common.FluidData.H2O,
          Modelica.Media.IdealGases.Common.FluidData.CO2,
          Modelica.Media.IdealGases.Common.FluidData.N2},
    substanceNames={"Oxygen","Argon","Water","Carbondioxide","Nitrogen"},
    reference_X={0.23,0.02,0.01,0.04,0.7},
    referenceChoice=Modelica.Media.Interfaces.Choices.ReferenceEnthalpy.ZeroAt25C);
end FlueGas;

In turn, MixtureGasNasa

extends Modelica.Media.Interfaces.PartialMixtureMedium(
     reducedX = false,
     ...

and PartialMixtureMedium ultimately exends PartialMedium, which contains

partial package PartialMedium
  constant Boolean reducedX=true;
  constant Integer nXi=if fixedX then 0 
                   else if reducedX then nS - 1 else nS;
  replaceable partial model BaseProperties
    InputMassFraction[nXi] Xi(start=reference_X[1:nXi])
    ...
  end BaseProperties;
  ...

Summing up, the Exhaust medium package has reducedX = false, hence nXi = nX = 5; hence the dimension of the start attributee of CombustionChamber1.fluegas.Xi[nXi],which instantiates Exhaust.BaseProperties should be 5, not 4.

Change History (3)

comment:1 by Francesco Casella, 6 years ago

The compilation now fails slightly later with a similar error:

[Modelica 3.2.2/Media/IdealGases/Common/package.mo:649:5-649:19:writable]
Error: Type mismatch for positional argument 2 in ThermoPower.Test.GasComponents.TestCC.SinkP1.Medium.h_TX(X=Wcompressor.gas.X).
The argument has type:
  Real[4]
expected type:
  Real[5]

Probably the same issue as #5078

comment:2 by Francesco Casella, 6 years ago

This problem is now resolved, the model fails for other reasons

comment:3 by Francesco Casella, 6 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.