Switching Modelica Blocks

Minoru Yubuchi_21420
Minoru Yubuchi_21420 New Altair Community Member
edited October 2020 in Community Q&A

Dear Experts,

 

I would like to know how to switch two Modelica blocks based on a situation of the simulation.

 

For example, please assume two SpringDamper blocks, A and B are contained in an Actibvate model which are applied at the same location. SpringDamper block (A or B)used in the simulation is decided based on situation of simulation and might be changed during the simulation.

 

I created a model (attached) where MoCustomComponent based on Spring is used. In the model, spring constant of the Spring block can be switched during simulation but Spring block cannot be switched in this way?

 

Are there any ways to switch Modelica blocks?

 

Regards,

Minoru Yubuchi

Unable to find an attachment - read this blog

Answers

  • ChristianKehrer
    ChristianKehrer Altair Community Member
    edited June 2019

    Dear Yubuchi-san,

     

    as far as I understood, it is not possible to switch between two different Modelica components during a running simulation, because that would require a new compilation to create a new set of equations (before the simulation you could use the include diagram block, but that is not your question, right?).

     

    One option (maybe, not the smartest implementation;) could be to use both Modelica components in parallel and switch between their outputs depending on a specific condition.

    I attached a very simple example for that.

     

    Does that help?

     

    Best regards

    Christian

    Unable to find an attachment - read this blog

  • RoKet
    RoKet
    Altair Employee
    edited June 2019

    Hi Christian,

     

    I fully agree to your explanations.

     

    An additional question: You mentioned the include diagram block (a very interesting and powerful element!). Can I use it with Modelica ports or is it limited to Activate signals? Many of my models have super models with Modelica content and Modelica ports, It would be very helpful if I could exchange a super models by another one by changing a configuration parameter.

     

    Thanks,
    Ronald

  • Minoru Yubuchi_21420
    Minoru Yubuchi_21420 New Altair Community Member
    edited June 2019

    Christian,

     

    Thank you so much! Your advice is very useful for me.

     

    Thanks,

    Minoru Yubuchi