- Index
- » Programming
- » Modelica Language
- » Model using Enumeration does not compile
Model using Enumeration does not compile
Model using Enumeration does not compile
I have problems with enumeration version of the below test-model.
If I try to compile MyModel, it starts but get an error and aborts compilation (OMEdit v1.12.0 (64-bit)). However, if I use a simple vectorized version, compilation is successful. Is this a ticket for omc or I'm missing something?
package test
model MyModel
ModelA stage1;
Source source(q=1, cin=10);
Sink sink;
equation
connect(source.OUT, stage1.IN);
connect(stage1.OUT, sink.IN);
end MyModel;
partial model Parmodel
extends Definitions;
input pipe IN;
output pipe OUT;
parameter Real V=1;
Real c[Species];
initial equation
c = {1.0, 10.0};
end Parmodel;
model Source
extends Definitions;
output pipe OUT;
parameter Real q = 10;
parameter Real cin = 1;
equation
OUT.q = -q;
OUT.c = {cin, 2*cin};
end Source;
model Sink
input pipe IN;
end Sink;
model ModelA
extends Parmodel;
equation
der(c)={IN.q/V*(IN.c[Species.A]-c[Species.A]), IN.q/V*(IN.c[Species.B]-c[Species.B])};
OUT.c = c;
OUT.q + IN.q = 0.0;
end ModelA;
connector pipe
extends Definitions;
flow Real q;
Real c[Species];
end pipe;
type Definitions
type Species = enumeration(A, B);
end Definitions;
end test;
Re: Model using Enumeration does not compile
Connectors (like your "pipe") must have the same number of flow and state variables.
It would more or less work if you put also
flow Real q[Species]
that makes sense since, probably, there is a flow of each specific Species
Moreover, you must not extends Definitions in Pipe. You can use the type "Species" simply referring to it. Right?
- DarioMangoni
- 45 Posts
Re: Model using Enumeration does not compile
Actually, Definitions is illegal since a type must always extend from a basic type, and models are not allowed to extend from a type either (but the compiler doesn't catch that). You should make Definitions a package instead, and either use the name directly or import Definitions.Species where needed.
- perost
- 114 Posts
- Index
- » Programming
- » Modelica Language
- » Model using Enumeration does not compile