Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Error building simulator when using inherited records

Error building simulator when using inherited records

Hi,

I came across the following error when using OMEdit / OpenModelica (r16584)
with the following model:

// -------------------------------------------------------------------------

model WithTernGas2 "Test ternary gas medium definitions"
  extends Modelica.Icons.Example;
  parameter Modelica.SIunits.MoleFraction x1=0;
  parameter Modelica.SIunits.MoleFraction x2=1;
  Modelica.SIunits.MolarMass M;
equation
  M = Media.MolarMassMoistAir(x1, x2);
end WithTernGas2;

function MolarMassMoistAir
  "Molar Mass of moist Air (ternary gas mixture)"
  parameter TernaryGas TernGas=MoistAir() "Medium definition";
  input Modelica.SIunits.MoleFraction x1 "Mole fraction of oxygen in mixture";
  input Modelica.SIunits.MoleFraction x2
    "Mole fraction of water vapor in mixture";
  output Modelica.SIunits.MolarMass M "Molar mass of gas mixture";
algorithm
  M := TernGas.Comp1.M*x1 + TernGas.Comp2.M*x2 + TernGas.Comp3.M*(1 - x1 - x2);
  assert((1 - x1 - x2) >= 0 and (1 - x1 - x2) <= 1, "Mole fraction out of bounds!");
end MolarMassMoistAir;

record MoistAir "Medium: Moist Air Definition as Ternary Gas"
  extends Modelica.Icons.Record;
   extends TernaryGas(
     Comp1=Oxygen(),
     Comp2=WaterVapor(),
     Comp3=Nitrogen());
//   extends TernaryGas(
//     Comp1(
//       M=0.032,
//       A={2122.2098,3.5302,-7.1076,-1.4542,30.6057,-83.6696,79.4375},
//       B={-0.10257E-5,0.92625E-7,-0.80657E-10,0.05113E-12,-0.01295E-15}),
//     Comp2(
//       M=0.018,
//       A={706.3032,5.1703,-6.0865,-6.6011,36.2723,-63.0965,46.2085},
//       B={-0.10718E-5,0.35248E-7,0.03575E-10,0,0}),
//     Comp3(
//       M=0.028,
//       A={432.2027,3.515,2.801,-4.1924,42.0153,-114.25,111.1019},
//       B={-0.0102E-5,0.74785E-7,-0.59037E-10,0.0323E-12,-0.00673E-15}));
end MoistAir;

record TernaryGas
  "Record containing Model Parameter used for the Ternary Gas Mixtures"
  extends Modelica.Icons.Record;
  parameter PureGas Comp1 "Component 1";
  parameter PureGas Comp2 "Component 2";
  parameter PureGas Comp3 "Component 3";
end TernaryGas;

record Oxygen "Medium: O2"
  extends Modelica.Icons.Record;
  extends PureGas(
    M=0.032,
    A={2122.2098,3.5302,-7.1076,-1.4542,30.6057,-83.6696,79.4375},
    B={-0.10257E-5,0.92625E-7,-0.80657E-10,0.05113E-12,-0.01295E-15});
end Oxygen;

record WaterVapor "Medium: H2O(g)"
  extends Modelica.Icons.Record;
  extends PureGas(
    M=0.018,
    A={706.3032,5.1703,-6.0865,-6.6011,36.2723,-63.0965,46.2085},
    B={-0.10718E-5,0.35248E-7,0.03575E-10,0,0});
end WaterVapor;

record Nitrogen "Medium: N2"
  extends Modelica.Icons.Record;
  extends PureGas(
    M=0.028,
    A={432.2027,3.515,2.801,-4.1924,42.0153,-114.25,111.1019},
    B={-0.0102E-5,0.74785E-7,-0.59037E-10,0.0323E-12,-0.00673E-15});
end Nitrogen;

record PureGas
  "Record containing Model Parameters for the used Pure Gases"
  extends Modelica.Icons.Record;
  parameter Modelica.SIunits.MolarMass M=1 "Molar Mass";
  parameter Real A[7]={1,1,1,1,1,1,1}
    "Model parameters spec. heat cap. const. pres.";
  parameter Real B[5]={1,1,1,1,1} "Model parameters dyn. viscosity";
end PureGas;

// ----------------------------------------------------------------------------

The error reads:

// ----------------------------------------------------------------------------

Translation    17:59:07        0:0-0:0    Error building simulator. Build log: gcc   -falign-functions -march=native -mfpmath=sse -fPIC   -I"/usr/include/omc" -I. -L"/home/mgroetsch/work/win/models/Libraries/PemFcSysLib/Test/GasMedDef"  -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o PemFcSysLib.Test.GasMedDef.WithTernGas2.o PemFcSysLib.Test.GasMedDef.WithTernGas2.c
In file included from PemFcSysLib.Test.GasMedDef.WithTernGas2.c:17:0:
PemFcSysLib.Test.GasMedDef.WithTernGas2_functions.c: In function 'omc_PemFcSysLib_Media_MolarMassMoistAir':
PemFcSysLib.Test.GasMedDef.WithTernGas2_functions.c:122:3: error: incompatible type for argument 1 of 'omc_PemFcSysLib_Media_TernaryGas'
PemFcSysLib.Test.GasMedDef.WithTernGas2_functions.h:113:38: note: expected 'PemFcSysLib_Media_PureGas' but argument is of type 'PemFcSysLib_Media_Oxygen'
PemFcSysLib.Test.GasMedDef.WithTernGas2_functions.c:122:3: error: incompatible type for argument 2 of 'omc_PemFcSysLib_Media_TernaryGas'
PemFcSysLib.Test.GasMedDef.WithTernGas2_functions.h:113:38: note: expected 'PemFcSysLib_Media_PureGas' but argument is of type 'PemFcSysLib_Media_WaterVapor'
PemFcSysLib.Test.GasMedDef.WithTernGas2_functions.c:122:3: error: incompatible type for argument 3 of 'omc_PemFcSysLib_Media_TernaryGas'
PemFcSysLib.Test.GasMedDef.WithTernGas2_functions.h:113:38: note: expected 'PemFcSysLib_Media_PureGas' but argument is of type 'PemFcSysLib_Media_Nitrogen'
make: *** [PemFcSysLib.Test.GasMedDef.WithTernGas2.o] Error 1

// ----------------------------------------------------------------------------

Probably, the assignment of the derived records Oxygen, WaterVapor and Nitrogen
to their base class PureGas in record MoistAir raises this error.

If the current extends declaration above in record MoistAir is substituted by
the direct and currently commented definition the error vanishes and the
simulation takes place.

Regards,
Markus.

There are 0 guests and 0 other users also viewing this topic
You are here: