dymola - Debug Modelica code -


i wonder if there way "debug" modelica code, mean debugging code line line , can see how variables change, things that?

i know modelica code translated c, want know if there's possibility somehow, if there is, believe it's gonna great improvement of simulation environments. thanks.

hy

this question , comes lot. first, let's step second.

the idea of debugging "line line" comes imperative programming languages. "imperative" mean program sequence of instructions carried out in specified order.

when debugs java or python, "line line" approach makes sense because statements fundamental way behavior represented. "line line" approach extended modeling formalisms block diagrams (e.g. simulink) because, while graphical, imperative (i.e. constitute steps carried out in specified order).

but modelica not imperative language. there no notion of steps, statements or instructions. instead, have omnipresent equations. thinking linearly debugging doesn't work in modelica. true think debugging c code generated modelica, typically not useful because bears partial resemblance equations.

so how debug modelica code? well, debugging modelica code debugging modelica equations. normally, modelica models composed of components. equations generated when components connected automatically generated lets stipulate modelica compiler generates correctly. what's left equations in component models.

the simplest way approach test each component individually (or @ least in smallest possible models). trying debug modelica components throwing them in big model listening orchestra , trying figure out 1 instrument out of tune. fact these equations in modelica tend form simultaneous systems of equations means errors, when occur, can propagate number of variables.

so best bet go through , create tests each individual component , verify behavior of component. experience when this, can track down , eliminate bugs pretty easily.

update: shouldn't need add outputs other people's component models debug them. output can created @ level, e.g.

model systemmodel   someoneelsescomponent a;   someotherguyscomponent b; end systemmodel;  model systemmodel_debug   extends systemmodel;   output real somenestedsignalfroma = a.somesubsystem.somesubcomponent.somesignal;   output real someothernestedsignalfromb = b.anothersubsystem.anothersignal; end systemmodel_debug; 

of course, becomes impractical if have multiple instantiations of signal component. in cases, admit easier modify underlying model. if make models replaceable, can use same trick above (extends model, add bunch of custom outputs , redeclare model in place of original).


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -