Reputation: 125
Is it possible to declare (or re-declare) components depending on the value of a time-dependent variable (as opposed to a parameter)? Conditional declaration has been discussed here numerous times (e.g., #1, #2 and #3), however in those examples, the condition depends on a parameter.
My situation is this: I have two models, NaturalConvectionHeatTransfer
and ForcedConvectionHeatTransfer
that extend from the same interface PartialHeatTransfer
. In a third model, I would like to do something like this:
model MyProblem
// stripped other declarations
input v "Velocity of fluid flow";
replaceable PartialHeatTransfer heatTransfer;
equation
if v == 0 then
// redeclare heatTransfer to be of type NaturalConvectionHeatTransfer
else
// redeclare heatTransfer to be of type ForcedConvectionHeatTransfer
end if;
end MyProblem;
A conditional declaration like Component blah if v==0;
certainly does not work if v
is not a parameter. Is there any way to achieve my goal? My guess is "no", meaning I will have to re-think the whole concept. However, perhaps someone sees an obvious solution I am missing. Any suggestion how to work around this would be appreciated.
Upvotes: 4
Views: 823
Reputation: 3523
It is not possible. You can, however, model around it by adding both heatTransfer components and switch between them using some dummy components and equations.
http://dx.doi.org/10.3384/ecp14096183 has some implementation hints on how to do it in Modelica slightly inefficiently (and how tools could optimize some of those things away).
Upvotes: 3