Hi,
I think this is a bug in OpenModelica (I will check more later).
To quickly fix this there are 2 alternatives.
The symbolic engine seems to have a problem with this expression:
p.i = C * der(p.v - n.v); in the Capacitor model.
You can rewrite that to:
1. first alternative
v = p.v -n.v;
p.i = C * der(v);
2. second alternative
p.i = C * der(p.v) - der(n.v);
In the attached model you have both alternatives.
Cheers,
Adrian Pop/
Jorge Cardona wrote:
Hi.
I was trying to work with an example, this one:
connector ElectricalPin
Modelica.SIunits.Voltage v;
flow Modelica.SIunits.Current i;
end ElectricalPin;
model Resistor
import Modelica.SIunits;
parameter SIunits.Resistance R = 300;
ElectricalPin p, n;
equation
R * p.i = p.v - n.v;
p.i + n.i = 0;
end Resistor;
model Capacitor
import Modelica.SIunits;
parameter SIunits.Capacitance C = 1e-6;
ElectricalPin p, n;
equation
p.i = C * der(p.v - n.v);
p.i + n.i = 0;
end Capacitor;
model Inductor
import Modelica.SIunits;
parameter SIunits.Inductance L = 1e-3;
ElectricalPin p, n;
equation
L * der(p.i) = p.v - n.v;
p.i + n.i = 0;
end Inductor;
model Ground
ElectricalPin ground;
equation
ground.v = 0;
end Ground;
model VoltageSource
import Modelica.SIunits;
parameter SIunits.Voltage v1=0, v2=1;
parameter SIunits.Time jump_time=1.0;
ElectricalPin p, n;
equation
p.v - n.v = if time > jump_time then v2 else v1;
p.i + n.i = 0;
end VoltageSource;
model RLC4
Resistor R1(R = 15);
Resistor R2(R = 5000);
Capacitor C1(C = 100e-6);
Inductor L1(L = 100e-3);
VoltageSource vs;
Ground g;
equation
connect(vs.n, g.ground);
connect(vs.p, L1.p);
connect(L1.n, R1.p);
connect(L1.n, R2.p);
connect(R1.n, C1.p);
connect(C1.n, g.ground);
connect(R2.n, g.ground);
end RLC4;
this is what i get on OMShell:
loadFile("prueba2.mo")
true
simulate(RLC4,stopTime=10)
record
resultFile = "Simulation failed.
Class SIunits.Resistance not found in scope Resistor while instantiating R1.R.
Error occured while flattening model RLC4
"
end record
loadModel(Modelica)
true
simulate(RLC4,stopTime=10)
record
resultFile = "Simulation failed.
Error building simulator. Buildlog: g++ -m32
-I"/home/openmodelica/dev/OpenModelica/build/include" -Wall -msse2
-mfpmath=sse -I. -o RLC4 RLC4.cpp -lsim
-L"/home/openmodelica/dev/OpenModelica/build/lib" -lc_runtime -lf2c
-lsendData
RLC4.cpp:34: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:35: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:36: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:36: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:37: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:37: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:38: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:39: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:40: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:41: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:41: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:41: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:41: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:41: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:41: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:41: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:42: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:43: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:45: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:45: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:46: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:46: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:47: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:48: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:49: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:50: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:50: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:50: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:50: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:50: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:50: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:50: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:51: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:51: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:51: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:51: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:51: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:51: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:51: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:52: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:52: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:52: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:52: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:52: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:52: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp:52: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp: In function 'char* getName(double*)':
RLC4.cpp:130: warning: deprecated conversion from string constant to 'char*'
RLC4.cpp: In function 'void residualFunc0(int*, double*, double*, int*)':
RLC4.cpp:561: error: 'der_rettype' was not declared in this scope
RLC4.cpp:561: error: expected `;' before 'tmp0'
RLC4.cpp:568: error: 'tmp0' was not declared in this scope
RLC4.cpp:568: error: 'der' was not declared in this scope
RLC4.cpp: In function 'int functionDAE_output()':
RLC4.cpp:583: warning: unused variable 'njev'
RLC4.cpp: In function 'void residualFunc2(int*, double*, double*, int*)':
RLC4.cpp:723: error: 'der_rettype' was not declared in this scope
RLC4.cpp:723: error: expected `;' before 'tmp3'
RLC4.cpp:728: error: 'tmp3' was not declared in this scope
RLC4.cpp:728: error: 'der' was not declared in this scope
RLC4.cpp: In function 'void residualFunc3(int*, double*, double*, int*)':
RLC4.cpp:739: error: 'der_rettype' was not declared in this scope
RLC4.cpp:739: error: expected `;' before 'tmp4'
RLC4.cpp:746: error: 'tmp4' was not declared in this scope
RLC4.cpp:746: error: 'der' was not declared in this scope
RLC4.cpp: In function 'int function_updateDependents()':
RLC4.cpp:810: warning: unused variable 'njev'
RLC4.cpp:826: warning: unused variable 'njev'
RLC4.cpp: In function 'void residualFunc1(int*, double*, double*, int*)':
RLC4.cpp:864: error: 'der_rettype' was not declared in this scope
RLC4.cpp:864: error: expected `;' before 'tmp2'
RLC4.cpp:869: error: 'tmp2' was not declared in this scope
RLC4.cpp:869: error: 'der' was not declared in this scope
RLC4.cpp: In function 'int functionODE()':
RLC4.cpp:894: warning: unused variable 'njev'
RLC4.cpp: In function 'int initial_residual()':
RLC4.cpp:925: error: 'der_rettype' was not declared in this scope
RLC4.cpp:925: error: expected `;' before 'tmp0'
RLC4.cpp:929: error: expected `;' before 'tmp4'
RLC4.cpp:937: error: 'tmp0' was not declared in this scope
RLC4.cpp:937: error: 'der' was not declared in this scope
RLC4.cpp:953: error: 'tmp4' was not declared in this scope
make: *** [RLC4] Error 1
Error building simulator. Buildlog: command
"/home/openmodelica/dev/OpenModelica/build/bin/Compile" not found.
Check $OPENMODELICAHOME
"
end record
Cheers,
Adrian Pop/
_____________________________________________________________________
Adrian Pop | PhD
Open Source Modelica Consortium | Technical Coordinator
Department of Computer Science | http://www.ida.liu.se/~adrpo
Linköping University | phone:+46 76 2343499/+46 13 285781
S-581 83 Linköping, Sweden | fax: +46 13 142231
OSMC & LiU/IDA/PELAB | office: 3B:478
loadModel(Modelica);
loadFile("RLC4.mo");
simulate(RLC4,stopTime=10)
connector ElectricalPin
Modelica.SIunits.Voltage v;
flow Modelica.SIunits.Current i;
end ElectricalPin;
model Resistor
import Modelica.SIunits;
parameter SIunits.Resistance R = 300;
ElectricalPin p, n;
equation
R * p.i = p.v - n.v;
p.i + n.i = 0;
end Resistor;
/* fix 1
model Capacitor
import Modelica.SIunits;
parameter SIunits.Capacitance C = 1e-6;
ElectricalPin p, n;
Modelica.SIunits.Voltage v;
equation
v = p.v - n.v;
p.i = C * der(v);
p.i + n.i = 0;
end Capacitor;
*/
/* fix 2 */
model Capacitor
import Modelica.SIunits;
parameter SIunits.Capacitance C = 1e-6;
ElectricalPin p, n;
equation
p.i = C * (der(p.v) - der(n.v));
p.i + n.i = 0;
end Capacitor;
model Inductor
import Modelica.SIunits;
parameter SIunits.Inductance L = 1e-3;
ElectricalPin p, n;
equation
L * der(p.i) = p.v - n.v;
p.i + n.i = 0;
end Inductor;
model Ground
ElectricalPin ground;
equation
ground.v = 0;
end Ground;
model VoltageSource
import Modelica.SIunits;
parameter SIunits.Voltage v1=0, v2=1;
parameter SIunits.Time jump_time=1.0;
ElectricalPin p, n;
equation
p.v - n.v = if time > jump_time then v2 else v1;
p.i + n.i = 0;
end VoltageSource;
model RLC4
Resistor R1(R = 15);
Resistor R2(R = 5000);
Capacitor C1(C = 100e-6);
Inductor L1(L = 100e-3);
VoltageSource vs;
Ground g;
equation
connect(vs.n, g.ground);
connect(vs.p, L1.p);
connect(L1.n, R1.p);
connect(L1.n, R2.p);
connect(R1.n, C1.p);
connect(C1.n, g.ground);
connect(R2.n, g.ground);
end RLC4;