Opened 18 years ago

Last modified 14 years ago

#87 closed defect (fixed)

lower_statement_input_outputs finished yet

Reported by: ms6ep Owned by: ms6ep
Priority: critical Milestone:
Component: Simulation Code Generation Version: 1.4.0
Keywords: Cc: ms6ep, haklu

Description

See comments.

Change History (4)

comment:1 by ms6ep, 18 years ago

I get the above error message when I attempt to compile the following model.
It's coming from DAELow.mo:3916. Sorry, the model is kind of long. I assume
the error message should actually read "lower_statement_input_outputs not
finished yet". Is there a workaround?


type LitresPerHour = Real(final quantity="LitresPerHour",final unit="l.h-1");
type TemperatureChange = Real(final quantity="TemperatureChange", final
unit="degC.h-1");
type InverseHour = Real(final quantity="InverseHour",final unit="h-1");
type CoolingPower = Real(final quantity="CoolingPower",final unit="degC.m3.h-1");

model MilkingModel

import Modelica.SIunits.Conversions.NonSIunits;
NonSIunits.Volume_litre V(start = 0) "Milk Volume";
LitresPerHour dV(start = 0) "Change in Milk Volume";
parameter Integer i = 4 "Number of milking periods";
parameter NonSIunits.Time_hour H[i] = {20, 30, 45, 55}

"Start time of ith milking period";

parameter NonSIunits.Time_hour MD[i] = {2, 2, 2, 2}

"Duration of ith milking period";

parameter NonSIunits.Volume_litre Vp[i] = {500,500,500,500}

"Volume of ith milking period";

parameter NonSIunits.Volume_litre Vavg = 5000 * Nb / 305

"Mean milking volume";

parameter NonSIunits.Volume_litre Vtank = 100 * ceil(2.2 * Vavg / 100);
parameter Integer Nb = 30 "Herd size in number of cows";

equation

der(V) = dV;
dV = if time >= H[1] and time <= (H[1] + MD[1]) then

Vp[1] / MD[1] else

if time >= H[2] and time <= (H[2] + MD[2]) then

Vp[2] / MD[2] else

if time >= H[3] and time <= (H[3] + MD[3]) then

Vp[3] / MD[3] else

if time >= H[4] and time <= (H[4] + MD[4]) then

Vp[4] / MD[4] else

0;

end MilkingModel;

model MilkTemperature

extends MilkingModel;
import Modelica.SIunits.Conversions.NonSIunits;
import Modelica.Constants;
NonSIunits.Temperature_degC T(start = thetaInf, fixed = true)

"Temperature in tank";

TemperatureChange dT(start = 0) "Change in temperature";
TemperatureChange Tadd(start = 0)

"Variation in temperature due to fresh milk";

TemperatureChange Tloss(start = 0)

"Variation in temperature due to temperature loss";

discrete TemperatureChange Tcool(start = 0)

"Variation in temperature due to cooling";

NonSIunits.Temperature_degC TExt "Eternal temperature at time T";
parameter NonSIunits.Temperature_degC T0 = 30

"Temperature of milk entering bulk tank";

parameter InverseHour k = 0.01 * Vtank "Temperature loss constant";
parameter NonSIunits.Temperature_degC TExtMean = 18

"Mean external temperature";

parameter NonSIunits.Temperature_degC vTExt = 2

"External temperature variation";

parameter CoolingPower cool = -1000 * k "Cooling power constant (l)";
parameter NonSIunits.Temperature_degC thetaInf = 3

"Lower limit of tank thermostat";

parameter NonSIunits.Temperature_degC thetaSup = 4

"Upper limit of tank thermostat";

equation

der(T) = dT;
dT = Tadd + Tloss + Tcool;
if (V + dV > 0) then

Tadd = (V * T + T0 * dV) / (V + dV) - T;

else

Tadd = 0;

end if;
if (V > 0) then

Tloss = k * (TExt - T) / V;

else

Tloss = 0;

end if;
TExt = TExtMean + vTExt * cos(2.0 * Constants.pi * (time - 14.0) / 24.0);

algorithm

when ((T > thetaSup) and (V > 0)) then

Tcool := cool / V;

elsewhen ( T < thetaInf) then

Tcool := 0;

end when;

end MilkTemperature;

model ListeriaGrowth

import Modelica.SIunits.Conversions.NonSIunits;
extends MilkTemperature;
parameter Integer j = 4 "Number of contamination periods";
InverseHour MuMax[j] "Specific growth rate of contamination j";
Real Phi[j] "Secondard growth model of bacteria";
NonSIunits.Time_hour lambda[j] "Lag time at temperature T";
Real y[j] "Decimal logarithm of bacterial concentration";
parameter InverseHour MuOpt[j] "Highest MuMax[j] value achievable";
parameter NonSIunits.Temperature_degC Tmax[j] "Maximum temperature of growth";
parameter NonSIunits.Temperature_degC Tmin[j] "Minimum temperature of growth";
parameter NonSIunits.Temperature_degC Topt[j] "Optimum temperature of growth";
parameter Real K[j] "Lag time and temperature constant";
parameter Real y0[j] "Logarithm of initial inoculum concentrations";
parameter Real yMax[j] "Logarithm of maximum concentration available";

equation

for x in 1:j loop

MuMax[x] = MuOpt[x] * Phi[x];
if T > Tmax[x] or T < Tmin[x] then

Phi[x] = 0;

else

Phi[x] = ((T - Tmax[x]) * (T - Tmin[x]) 2.0) /

((Topt[x] - Tmin[x]) * ((Topt[x] - Tmin[x])*(T - Topt[x]) -

(Topt[x] - Tmax[x])*(Topt[x] + Tmin[x] - 2 * T)));
end if;
lambda[x] * MuMax[x] = K[x];
der(y[x]) = (if time <= lambda[x] then 0 else

MuMax[x] * (1 - exp(y[x] - yMax[x])));

end for;

initial equation

for x in 1:j loop

y[x] = y0[x];

end for;

end ListeriaGrowth;

comment:2 by Peter Aronsson, 18 years ago

When clauses in algorithms is not implemented yet. However, we have now a better
error message for this. Also, workaround is to use when clauses in algorithms
instead.

comment:3 by Peter Aronsson, 18 years ago

Håkan, Here is a testcase for when-algorithms.

comment:4 by Martin Sjölund, 14 years ago

This reported issue has been fixed. The simulation now reports:
{{{$ ./ListeriaGrowth
ERROR: Division by zero in partial equation: K[4] / MuMax[4] because MuMax[4] == 0.}}}

Note: See TracTickets for help on using tickets.