- Index
- » Users
- » guil_pierre
- » Profile
Posts
Posts
Hi every one,
I am new to Modelica and openModelica.
Thank you for the help you'll give to this post.
We have defined a connector as follows :
connector ZPin
discrete Real value;
end ZPin;
A ZPin variable is declared in a model :
model my_model
// Some variables / parameters declarations ....
ZPin var_zpin(value(start = 0));
...
equation
...
// no equation involving var_zpin ...
...
end my_model;
I want to generate C or XML files from my model using the OM compiler.
If variable "var_zpin.value" is not involved in any equation, the compiler will exit with an error :
the model contains more variables than equations and any discrete variable (like ZPin variable in a way)
must be involved in at least one equation.
Unless "my_model.var_zpin.value" is connected to another value in a larger model
declaring a my_model object (i just realize this connection is an equation involving "var_zpin.value" after all).
The problem is that i'd like not to be forced to create a connection with this variable or a new equation involving this variable :
How can i do so that OM compiler does not take into account this variable when it counts the number
of variables and compare it to the number of equations ?
Already tried solutions :
- Adding a dummy equation involving "var_zpin.value" (var_zpin.value = 0
changes the C files generated in a not suitable way for us.
- Replacing
ZPin var_zpin(value(start = 0));
with
input discrete real var_zpin(...);
does not work : the OM compiler does not like it.
Hi every one,
First, thank you for the attention and help you'll give to this post.
Quickly :
-----------
- I'm using OMC 1.9.1.beta.1 compiler
- I want to generate C files from *.mo files
To do this :
- I generate a flattened model *.mof from *.mo files
- I try to generate some C files from the *.mof, but i have a compiling error.
This error occurs in the first line of the *.mof declaring a parameter :
parameter Real someModel.param1(fixed = false);
OMC compiler rejects the dot (".")
More precisely :
----------------------
- I have a master model (in "master_model.mo") declaring submodels :
model master_model
subModel1 instance1() ;
subModel2 instance2() ;
....
equation
<Some equations...>
end master_model;
- I generate a "master_model.mof" with the command :
/some_path/omc +showErrorMessages +d=failtrace +d=disableSingleFlowEq master_model.mo subModel1.mo subModel2.mo ....
No problem to get this "master_model.mof"
- I try to generate C file from "master_model.mof" with the command :
/some_path/omc +simCodeTarget=C +showErrorMessages +g=Modelica +d=initialization +d=failtrace master_model.mof
and i get a compiling error :
{"[/a_path.../master_model.mof:2:26-2:26:writable] Error: Missing token: SEMICOLON", "SYNTAX", "Error", "2"}
When i look at master_model.mof, here is what i see :
class master_model
parameter Real subModel1.param1(fixed = false); // Error on this first line because of the dot
parameter Real subModel1.param2(fixed = false);
<some other declarations....>
equations
<some equations....>
end master_model;
The dot on line 2 is rejected.
What did i do wrong ?
The presence of this dot at this place in this file seems illogical
since a declaration should be done with a variable or paramater name without dot,
as in most language.
Besides, since OMC compiler created the *.mof, this file should have the right
syntax and be usable to create C files with the same OMC compiler.
Hi every one,
First, thank you for the attention and help you'll give to this post.
My problem is the following one :
How can modify the openModelica compiler to add a function that dumps
variables into an xml file in a certain way ?
I have already modified some source files of the OM compiler and
obtained an xml file, but i'm not
satisfied with the results (see further).
More precisely, i have a "a_model.mo" file that contains the definition
of a connector objet PwPin and a class "a_model". This class "a_model"
contains the declaration of a PwPin as well as declaration of parameters,
real variables, etc, used in the equation section of the model.
The purpose is to generate an xml file that gives, for each variable
or object, its structure :
- if it's a simple (or classic) variable, like paramater or real
variable, then it is pointed in the xml file as a "terminal" ;
- if it's a more complex instance, like a PwPin, then it is pointed
in the xml file as a "struct" and its components are displayed.
Here is an idea of the "a_model.mo" i've got and the xml file i want to
build :
// ----------------------------------------------
// a_model.mo
// ----------------------------------------------
...
connector PwPin
Real vr;
Real vi;
flow Real ir;
flow Real ii;
end PwPin;
...
class a_model
// Declaration of parameters, real variables (like var_1), ...
...
Real var_1;
...
// Declaration of a PwPin
PwPin var_2(vr(start=ur0),vi(start=ui0), ir(start=-ir0), ii(start=-ii0));
equation
...
end a_model;
// ----------------------------------------------
// The xml file
// ----------------------------------------------
<model>
<name>a_model</name>
<elements>
<terminal>
<name>var_1</name>
<id>var_1</id>
<flow value="false"/>
</terminal>
<struct>
<name>var_2</name>
<subnodes>
<terminal>
<name>vr</name>
<id>var_2.vr</id>
<flow value="false"/>
</terminal>
<terminal>
Same thing for var_2.vi, because it's a real var too.
</terminal>
<terminal>
<name>ir</name>
<id>var_2.ir</id>
<flow value="true"/>
</terminal>
<terminal>
Same thing for var_2.ii, because it's a flow too.
</terminal>
</subnodes>
</struct>
</elements>
</model>
Here i explain a try i gave to my problem, reading it is not absolutly
necessary.
To do this, i took a look in the source files of the OM compiler
(1.9.1.BETA.1) and tried the following (not satisfying) solution :
- I followed the example of function "dumpXMLDAE" in "CevalScript.mo",
to create a new "dumpXMLDAE_2" function in the same file (this
function no longer calls "XMLDump.dumpBackendDAE" but calls the
new XMLDumpDynamo.dumpBackendDAE2Dynamo).
- I built the OM compiler with the above modified source files and
obtained a new executable.
- I wrote a small *.mos script that calls this new "dumpXMLDAE_2"
function :
loadModel(Modelica);
loadFile("a_model.mo");
dumpXMLDAE_2(a_model,"flat",false,true,false,false,false,false,false,false,false,"flat-a_model");
- I run the *.mos with the new OM compiler executable.
Doing like this, il seems impossible to keep the components of a PwPin
(vr, vi, ir, ii) all together in the xml file, they are split
into 2 parts : vr and vi appear in the "ordered variables" of the xml
file, and ir and ii appear in the "known variables" part.
How can i do to avoid the splitting into "ordered variables"
and "known variables" ?
But mainly, how can i do to give my xml file the structure
displayed above ?
- Index
- » Users
- » guil_pierre
- » Profile