Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6798801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:46:25+00:00 2026-05-26T18:46:25+00:00

Can anyone give me a hint what algebraic loop means — and how I

  • 0

Can anyone give me a hint what “algebraic loop” means — and how I am supposed to cope with this situation by adding “pre”-operators? I’m seriously not getting it…

Error: Failed to generate code for an algebraic loop
involving when equations or algorithms with when parts.
Unknowns:
  pump.Hb_flow
  pump.medium.d
  pump.medium.h
  pump.medium.state.melting
  pump.medium.state.T
  pump.V_flow
  pump.V_flow_single
  pump.W_single

Equations:
  algorithm 
    when Modelica.SIunits.Conversions.to_degC(pump.medium.state.T) < 13.9 then
      pump.medium.state.melting := true;
    elsewhen Modelica.SIunits.Conversions.to_degC(pump.medium.state.T) > 32.8       then
      pump.medium.state.melting := false;
    end when;
  // [removed set of equations that contained no "when"]

You may be able to cut the loop 
by putting 'pre' around some of the references to
unknown continuous time variables in when parts or when conditions.

Thanks in advance,
best regards

TIMO.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:46:26+00:00Added an answer on May 26, 2026 at 6:46 pm

    This problem is, in general, because the equations within the when clause impact the conditional statement that triggers them.

    The thing that you need to understand with Modelica is that a solver will evaluate equations using “candidate solutions” as part of the simulation process. These are not necessarily the solution it will eventually choose, but it nevertheless needs to evaluate them as it approaches the eventual solution.

    How is this related? Well in your case I see that you are changing the value of a “melting” variable. But if that value then influences the medium temperature (which triggered the change in the value of “melting”) then the tool will detect an inconsistency in the system of equations. A tool might be able to iterate to find a consistent candidate solution, but Dymola just “punts” and says it doesn’t support such situations.

    Now, the important thing to understand here is that basically this is usually all irrelevant. Why? Because for the most part user’s really don’t want the default semantics of when clauses in such cases. What most users want is to treat the condition in the when clause as a “cause” and the equations inside the when clause as an “effect”. In this sense, they are sequential and the effect should not turn around and affect the cause (although the White Stripes wrote a great song about such situations ;-)).

    The general pattern here is to isolate the condition and then add a “pre” operator around it in the when clause. If the original model looked like this:

    model Test
    ...
    equation
      when x>12.5 then
        // equations involving y
      end when;
      // equations coupling x to y
    end Test;
    

    You just need to refactor the model into something like this:

    model Test2
    ...
      Boolean cond;
    equation
      cond = x>12.5;
      when pre(cond) then
        // equations involving y
      end when;
      // equations coupling x to y
    end Test;
    

    The essential thing here is that the equations involving y only come after the condition is true. The ‘pre’ in this case basically says that if, at current time minus some epsilon, the value of condition was true then (in response) the equations in the when clause kick in.

    Such situations can lead to a condition called “chattering” where the value of the condition flips for every “epsilon” of time that passes, but this means that the problem is not well posed.

    I hope this makes some sense. I admit that in complex cases, it can be hard to detect exactly where the algebraic loops exist (although Dymola tries to give you some diagnostics). Also, in some cases you do want the default behavior of Modelica so you don’t always want to add gratuitous ‘pre’ qualifiers.

    Let me know if you have any questions on this explanation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone give me any hint on how I can open a new window
Can anyone give a hint how to set separate connect and read timeouts when
Can anyone give me a hint how to add ContextMenu to Data Grid Column
Can anyone give me a complete list of string manipulation function in Microsoft SQL
Can anyone give me pointers to good books or web sites that teach how
Can anyone give me details of runtime error 3734 in Access vba. For reference
Can anyone give a concise set of real-world considerations that would drive the choice
Can anyone give me a scenario where they think busy cursors are justified? I
Can anyone give me an idea how can we show or embed a YouTube
Can anyone give an idea of how should I implement undo/redo of cutting/copying/pasting of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.