Opened 18 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, adrpo

Description


Change History (4)

comment:1 Changed 18 years ago by Robert.Wotzlaw

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

  1. ANTLR - ANother Tool for Language Recognation Version 2.7.2, Debian Version 2.7.2 - 6
  1. SML/NJ Standard ML of New Jersey Version 110.57
  1. RML - MMC Relational Meta-Language Compiler - Meta-Modelica Compiler Version 2.3.6 - 2006-05-23
  1. GCC 3.3 - GNU Compiler Collection Version 3.3, Debian Version 3.3.5 - 13
    • gcc Version 3.3.5 GNU C - Compiler
    • g77 Version 3.3.5 GNU Fortran Compiler
    • g++ Version 3.3.5 GNU C++ - Compiler
    • gij Version 3.3.4 GNU Java bytecode interpreter
  1. Java Runtime Environment
    • Java(TM) 2 Runtime Environment Standard Edition Version build 1.4.2_05-b04
    • Java HotSpot(TM) Client VM Version build 1.4.2_05-b04, mixed mode

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

Real L;
Real Psi;
Real U;
Real i;

equation

L = (if i >= 0.0 then 2*i else 0.0);
Psi = L*i;
U = 1.0;
U = L*der(L) + i*der(L);

end BugProductRule;

In the OMShell:


loadFile("BugProductRule.mo")

true

instantiateModel(BugProductRule)

"fclass BugProductRule
Real L;
Real Psi;
Real U;
Real i;
equation

L = (if i >= 0.0 then 2*i else 0.0);
Psi = L*i;
U = 1.0;
U = L * der(i) + i * der(L);

end BugProductRule;
"

simulate(BugProductRule,startTime=0, stopTime=3.0)

record

resultFile = "BugProductRule_res.plt"

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

comment:2 Changed 18 years ago by petar

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 Changed 12 years ago by jfrenkel

  • Component set to Backend
  • Priority changed from critical to low
  • Type changed from defect to discussion
  • Version set to 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 Changed 12 years ago by cschubert

  • Resolution set to invalid
  • Status changed from assigned to 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.

Note: See TracTickets for help on using tickets.