Acausality and time execution / Acausality lost after generating c code?

5 posts / 0 new
Last post
Hassen
Offline
Joined: 2010-03-22
Acausality and time execution / Acausality lost after generating c code?

Hi all,

I want to know is there are any link between the acausality of a model and its time execution.

In another word, if we took 2 models describing the same system one with acausal modeling and the other with causal modeling. If we execute the 2 models, will they have the same execution time?

As i know, when generating c code of a modelica model, acausality is lost. So did acausality is a good thing only for "modelica users" in the phase of modeling?

Any idea, suggestion, remark...? i am taker.

Best Regards,
Hassen

jakesson
Offline
Joined: 2009-03-14
Hi Hassen,   In some cases a

Hi Hassen,
 
In some cases a Modelica tool can transform an acausal model into a causal equivalent. Typically this is done by first performing the Block Lower Transformation (BLT) to get an ordering and grouping of equations. Each group of equations is referred to as blocks and corresponds to systems of equations which may be acausal. In some cases, e.g., scalar equations which can be trivially solved, blocks may be transformed into causal assignment statements. However, in the general case, iterative methods (such as Newtons method) is needed to solve a sequence of acausal equation systems. 
 
Regarding execution time, I am not sure what you mean by executing a model, i.e., do you mean evaluation of the right hand side of a DAE or ODE, simulation, or optimization? 
 
The question about if acausality is lost when generating C code depends on how the code is generated. JModelica.org supports generation of C code in the form of a DAE, in which case the model is still acausal. Also, we are about add a BLT algorithm, which will then be used to provide and ODE interface. In the latter case, the model will appear causal to an algorithm, although acausal equation systems are solved internally to compute the derivatives.
 
Hope this helps.
 
Best
/Johan

Hassen
Offline
Joined: 2010-03-22
Thank you for answering. I

Thank you for answering.

I know that when doing BLT transformation, an acausal model will be a partially acausal model ( if functions contains 2 or more variables, they keep their acausality).

I am interested within the time execution of models. I mean time needed to simulate a model. And I would know if coding in acausal manner can , for example, accelerate the execution time of the simulation.

I think that the advanatage of acausality is only when modeling. But i don't think that acausality have an influence on the performance of the simulation (time execution, rapidity..).

A last question : What about implementing the FMI in Jmodelica?

Thank you in advance.

Best Regards,
Hassen

jakesson
Offline
Joined: 2009-03-14
Hi Hassen,   Just a minor

Hi Hassen,
 
Just a minor point about acauality: it is still possible for a scalar equation to be acausal, e.g., 0.5*x=sin(x).
 
In general, acausality will not improve simulation speed, but rather make it slower, since iterative methods then typically need to be used to solve implicit equation systems. I would say that given an acausal model, if you can apply symbolic transformations (manually or automatic) to make it more causal then the odds are good that your simulation will be faster.
 
About FMI. JModelica.org already supports export of XML model metadata files as specified by FMI and we plan to add support for the FMI C API during 2010.
 
Best
/Johan

Hassen
Offline
Joined: 2010-03-22
Thank you for answering. I

Thank you for answering.

I think that inline integration is the last solution to make the generated C code "faster".

Regards,
Hassen

Login or register to post comments