Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Division by zero at time=0

Division by zero at time=0

Hi

I am building a model containing 4 different components connected to each other, and I have some problem with division by zero at time=0.

I have manage to solve a couple of errors of this kind but when I put on more components, another error of this kind will appear.

I have tried to give some start values for the variable that become zero using the following code.

Code:

parameter Real START = 1 * 10 ^ (-6);

Real evapMass(start = START);

Or

Code:

Real evapMass(start = START, fixed = true);

I have also tried to force the variable to be non-zero by writing, including other variables as well:

Code:

if time > 0 then

    evapMass = waterUse / 60;
  else
    evapMass = START;
  end if;

I have tried to go to the bottom with this by following and controlling every superior variable that is included in this variable and make sure that they are non-zero at time=0.

The error message from the last simulation:

Code:

C:/Users/ninawe/AppData/Local/Temp/OpenModelica/OMEdit/Evap_kyln.Examples.EvaporativeCooler.exe -port=2066 -logFormat=xml -w -lv=LOG_STATS

assert        | debug     | division by zero at time 0, (a=-1e-006) / (b=0), where divisor b expression is: if time > 0.0 then 0.01666666666666667 else 0.0 Debug more
Process crashed
Simulation process exited with code -1

Now to the question:
I might of course have missed something in my model that will cause this error but is there other ways to get rid of the “division by zero” errors in the initialization process, others than those I already have tried, or does someone have any tips on how to get around it?

Re: Division by zero at time=0

I discovered something in the debugger.
There are four components in my model:

    dropVelocity
    X
    evaporation
    gasTemp


A picture from the debugger window.
https://dl.dropboxusercontent.com/u/22026291/debugger.PNG

Does anyone know what the variable evaporgastionemp1.evapMass marked with red and gren in the picture above means? EvapMass don´t exist in such component. I am confused about this and don´t really know what it means.

Re: Division by zero at time=0

The red/green is the diff from the substitution evaporation to gastemp. Probably from a connection. If the component did not exist in one of them: is it an expandable connection? You might be able to tell some from instantiateModel and looking at the flat Modelica code.

Re: Division by zero at time=0

Thanks for the reply.
No, it is not an expandable connection.
I manage somehow to solve the problem but I am not quite sure what I really did to solve it. With a little help from Dymola I manage to locate where the problem might have meen located and then I took away some of the start values and also some of the if-statements I described above and now it works just fine current/smile

Re: Division by zero at time=0

It appears that START has been evaluated to zero, causing your if else expression to evaluate to zero and cause the divide by zero.

There are 0 guests and 0 other users also viewing this topic
You are here: