Opened 11 years ago

Closed 10 years ago

#2658 closed defect (fixed)

Wrong C code generated in ThermoPower example case

Reported by: Francesco Casella Owned by: Adrian Pop
Priority: high Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: Cc:

Description

The ThermoPower.Examples.BraytonCycle.OpenLoopSimulator model fails because the C code contains an undeclared identifier ‘$Pplant$PPressDrop2$Pgas$Pstate$PX$lB5$rB’

However, if the Plant.PressDrop2 component is removed and the compressor outlet is directly connected to the combustion chamber, the model gets compiled and simulates.

I haven't been able to understand what's wrong: the PressDrop model is fine (it is used in the very same Plan model without problems), and also the medium model should be fine, as it is yet another ideal gas model taken from Modelica.Media, and should be fundamentally not different from the one used in PressDrop1.

Attached you can find a Save Total file which contains both cases (the one in the library that fails, and the modified one that runs, named ThermoPower.Examples.BraytonCycle.OpenLoopSimulator).

Please help!

Attachments (1)

BraytonCycleTotal.mo (419.2 KB ) - added by Francesco Casella 11 years ago.
Save Total file

Download all attachments as: .zip

Change History (4)

by Francesco Casella, 11 years ago

Attachment: BraytonCycleTotal.mo added

Save Total file

comment:1 by Adrian Pop, 11 years ago

This is a case of the bug (#2604) same type different component and different redeclares:

   T c1(redeclare package Medium = Media.FlueGas);
   T c2(redeclare package Medium = Media.Air);

If you change the code like this:

        package G1 = Gas;
        G1.PressDrop PressDrop1(
          redeclare package Medium = Media.FlueGas,
          FFtype=ThermoPower.Choices.PressDrop.FFtypes.OpPoint,
          wnom=102,
          rhonom=2,
          dpnom=26000,
          pstart=811000,
          Tstart=1370)
                    annotation (Placement(transformation(
              origin={0,8},
              extent={{-10,-10},{10,10}},
              rotation=270)));
        package G2 = Gas;
        G2.PressDrop PressDrop2(
          pstart=8.3e5,
          FFtype=ThermoPower.Choices.PressDrop.FFtypes.OpPoint,
          A=1,
          redeclare package Medium = Media.Air,
          dpnom=0.19e5,
          wnom=100,
          rhonom=4.7,
          Tstart=600) annotation (Placement(transformation(
              origin={-104,10},
              extent={{-10,-10},{10,10}},
              rotation=90)));

Then you can simulate the model:

record SimulationResult
    resultFile = "ThermoPower.Examples.BraytonCycle.OpenLoopSimulator_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1000.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'ThermoPower.Examples.BraytonCycle.OpenLoopSimulator', options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
    messages = "",
    timeFrontend = 9.120325330943549,
    timeBackend = 0.6625850167300298,
    timeSimCode = 0.3318439526293017,
    timeTemplates = 0.8013703534324663,
    timeCompile = 4.402345668746949,
    timeSimulation = 0.9040802641081193,
    timeTotal = 16.22345291493631
end SimulationResult;

A fix is on the way, I'm working now on pushing my local changes in svn.

comment:2 by Francesco Casella, 11 years ago

Note that I had already reported this problem in #2562. If Adrian's fixes solve this issue, #2562 can also be closed.

comment:3 by Francesco Casella, 10 years ago

Resolution: fixed
Status: newclosed

Fixed by the new Inst module.

Note: See TracTickets for help on using tickets.