Opened 19 years ago
Closed 12 years ago
#79 closed discussion (invalid)
Bug in mixed system of a single if-equation.
Reported by: | Robert.Wotzlaw | Owned by: | Robert.Wotzlaw |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | Backend | Version: | trunk |
Keywords: | Cc: | Robert.Wotzlaw, Adrian Pop |
Description
Change History (4)
comment:1 by , 19 years ago
comment:2 by , 18 years ago
This is because i should be solved from equation L = if i >= 0.0 then 2.0 * i
else 0.0;
This is a mixed system of equation(s) with only one equation. This special case
has not been implemented in OpenModelica yet.
Workaround: Introduce additional boolean variable:
class BugProductRule
Real L;
Real Psi;
Real U;
Real i;
Boolean b;
equation
b = i >= 0.0;
L = (if b then 2*i else 0.0);
Psi = L*i;
U = 1.0;
U = L*der(L) + i*der(L);
end BugProductRule;
Changed summary description to better fit problem.
comment:3 by , 12 years ago
Component: | → Backend |
---|---|
Priority: | critical → low |
Type: | defect → discussion |
Version: | → trunk |
Now the compiler report the folloing message while simulating the model.
messages = "Simulation execution failed for model: BugProductRule stdout | warning | division by zero in partial equation: -1.0 / (-L - i) because -L - i == 0: File: BugProductRule.mo Line: 13 stdout | warning | at Time=0.000000 stdout | warning | [line] 313 | [file] BugProductRule.c assert | assert | division by zero ",
Hence the model is not well defined so if you use the model with i>=0 the system
L = 2*i;
fails with a division by zero
messages = "Simulation execution failed for model: BugProductRule stdout | warning | division by zero in partial equation: -1.0 / (-L - i) because -L - i == 0: File: BugProductRule.mo Line: 18 stdout | warning | at Time=0.000000 stdout | warning | [line] 232 | [file] BugProductRule.c assert | assert | division by zero ", timeFrontend = 0.011377212544646454,
and if you use the model for i<0
L = 0;
the system is structurally singular
[BugProductRule.mo:18:5-18:28:writable] Error: Model is structurally singular, e rror found sorting equations 1: 1.0 = 0.0; for variables i(1)
I proposse to close the ticket.
comment:4 by , 12 years ago
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
This model is not well posed.
For the case i < 0 the equations become
L = 0, der(L) = 0 Psi = 0 U = 1.0 U = 0
Therefore, we have a contradiction.
In case of i >= 0, we get
L = 2*i, der(L) = 2*der(i) Psi = 2*i^2 U = 1.0 U = 4*i*der(i)
which can only be solved for der(i) if i<>0. Since no explicit start value is given, that is the value the model starts with. Thus we get at t=0
U = 1 U = 0
which again is a contradiction.
Dear Mr. Peter Aronsson,
after I tested the class BugDebCoefficient, I tried the product rule on the
class BugDebCoefficient. I build a new class based on the class
BugDebCoefficient. I named the new class BugProductRule. I changed the following
row:
old row: U = der(Psi)
new row: U = L * der(i) + i * der(L)
The result of the compiled class BugProductRule should be the same as the
class BugDebCoefficient.
But before I show You the results, I show You some additional data about my
system.
The platform and compiler
Debian Sarge Linux Knoppix Quantian with GNU GCC 3.3 and OpenModelica 1.4.1
Warnings during the compilation of OMC Vers. 1.4.1 svn 2431 and OMC 1.4.1 svn
2433 (excerpts of the make log file):
/usr/bin/rmlc -Wc, O3 -c Inst.mo
"usr/bin/rml" -Eplain Inst.mo
Inst.mo: 157.10-157.45 Warning: unused imported module: System
gcc -O3 -c O2 -fomit-frame-pointer -I"/usr/include"/plain -o Inst.o Inst.c
cp Inst.h ../Inst.h
/usr/bin/rmlc -Wc, O3 -c Lookup.mo
"usr/bin/rml" -Eplain Lookup.mo
Lookup.mo: 88.10-88.45 Warning: unused imported module: Values
gcc -O3 -c O2 -fomit-frame-pointer -I"/usr/include"/plain -o Lookup.o Lookup.c
cp Lookup.h ../Lookup.h
The BugProductRule.mo OpenModelica source code file:
class BugProductRule
equation
end BugProductRule;
In the OMShell:
true
"fclass BugProductRule
Real L;
Real Psi;
Real U;
Real i;
equation
end BugProductRule;
"
record
end record
no error.log file but an output.log file
The output.log file:
001:Error solving linear system of equations (no. 0), system is singular
002:Error solving linear system of equations (no. 1), system is singular
003:Error solving linear system of equations (no. 0), system is singular
539: "
The BugProductRule_res.plt file:
DataSet: der(L)
0, -1 until 3, -1
DataSet: L
0, 0 until 3, 0
DataSet: Psi
0, 0 until 3, 0
DataSet: i
0, 0 until 3, 0
DataSet: der(i)
0, 0 until 3, 0
DataSet: U
0, 1 until 3, 0
regards
Robert Wotzlaw