Opened 11 years ago
Last modified 11 years ago
#3066 reopened defect
ExpressionSolve cant't solve cast
| Reported by: | Willi Braun | Owned by: | somebody |
|---|---|---|---|
| Priority: | high | Milestone: | Future |
| Component: | Backend | Version: | trunk |
| Keywords: | Cc: | Vitalij Ruge, Patrick Täuber |
Description
The model Modelica.Electrical.Machines.Examples.SynchronousInductionMachines.SMEE_LoadDump fails, because we can't solve for for a cast expression.
See following model:
loadString("
model Test2
parameter Real a = sin(3.14)*2;
parameter Real x = 10;
Real y;
Integer p;
equation
der(y) = y + p;
der(y) = a*sin(time);
end Test2;
");
getErrorString();
- It should be possible to fix that, or vitalij?
- The tearing module should generate an error in such situations.
Change History (8)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
The model is invalid. I will introduce better error messages when I split the simulation in continuous and discrete parts.
comment:3 by , 11 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
comment:4 by , 11 years ago
| Resolution: | invalid |
|---|---|
| Status: | closed → reopened |
I'm really not sure that this model is invalid, since let's take that model:
model A Real y; Integer p; equation //der(y) = y + p; p = integer(der(y) - y); der(y) = y; end A;
This one is clear valid it contains just a fix to Martins argument with the discrete-time expressions. So why can't we do that implicit in the compiler, since it's an equation and somehow
the kind of writing shouldn't change the semantic:
der(y) = y + p; <=> p = der(y) - y;
Okay, that perhaps a discussion for the Modelica Trac.
But the reason I reopen that the ticket again, is the following model and that has the same issue as the model above.
- In the initialization are all variables discrete-time, so that equation is valid now.
- We need to detect such situation while the tearing and that's quite easy.
- Also we could solve it that also for p and put the integer operator around the rhs.
model B Real y(start=1, fixed=true); parameter Integer p(fixed = false); initial equation der(y) = y + p^2; equation der(y) = sin(time); end B;
follow-ups: 6 8 comment:5 by , 11 years ago
What is this ticket about? I cannot see your point.
BTW: Introducing the integer-operator changes the equation fundamentally. That is not just a simple transformation. Hence, that cannot be done implicitly by the compiler.
comment:6 by , 11 years ago
Replying to lochel:
What is this ticket about? I cannot see your point.
Please check model B, which has the same issue as
Modelica.Electrical.Machines.Examples.SynchronousInductionMachines.SMEE_LoadDump
and which - in my opinion - is valid.
comment:7 by , 11 years ago
comment:8 by , 11 years ago
Replying to lochel:
What is this ticket about? I cannot see your point.
However, I changed the model B a bit and it produces the original issue now, that we all had
seen before the fix m:r8044 in Modelica.Electrical.Machines.Examples.SynchronousInductionMachines.SMEE_LoadDump.
It's a C compilation error which should catched up by the compiler with a reasonable error message, that's this ticket about.

It is an error to solve for p in any of the given equations. You need to have only discrete-time expressions in an equation if you want to solve for a discrete-time variable.