mod function not working

Discussion about the use of Simantics System Dynamics
Post Reply
thomas_schlotter
Posts: 4
Joined: December 19th, 2015, 12:31 pm

mod function not working

Post by thomas_schlotter » December 19th, 2015, 4:03 pm

Hi all,

I have a problem that I cannot use the mod function in my simulation model. Whe I try to start the simulation I'm getting this error message:

Simulation failed
Did not find initial state for model:
-modTest: Undefined function 'mod'


The formula is this one: mod(4, 3)

Do you know what is wrong in my model?

Thanks a lot

Thomas
Attachments
usage.PNG
Function
usage.PNG (4.08 KiB) Viewed 54783 times
failure.PNG
Failure
failure.PNG (10.66 KiB) Viewed 54783 times
Tuomas Miettinen
Site Admin
Posts: 31
Joined: March 11th, 2013, 3:14 pm

Re: mod function not working

Post by Tuomas Miettinen » December 21st, 2015, 11:26 am

Hi,

There's nothing wrong with your model, it's a bug in the tool. While waiting for a solution, you can simulate the model by using the OpenModelica solver, the solver can be switched in Window -> Preferences -> Solver. You need to have the version of the tool installed which has OpenModelica included, or you can use a custom OpenModelica installation, the installation used is selected in Window -> Preferences -> Modelica.
thomas_schlotter
Posts: 4
Joined: December 19th, 2015, 12:31 pm

Re: mod function not working

Post by thomas_schlotter » December 21st, 2015, 11:32 pm

I've used the latest version v1.9.3. But the problem still exists.
Wrote my own mod function:

Code: Select all

    input Real a;
    input Real b;
    output Real z;
algorithm
    z := a - floor(a/b)*b;
This works fine.

Thanks a lot.
Tuomas Miettinen
Site Admin
Posts: 31
Joined: March 11th, 2013, 3:14 pm

Re: mod function not working

Post by Tuomas Miettinen » December 22nd, 2015, 2:05 pm

The mod function is now working in the internal solver as well. It's available in the next nightly build (http://www.simantics.org/download/sysdyn/nightly/trunk/).
thomas_schlotter
Posts: 4
Joined: December 19th, 2015, 12:31 pm

Re: mod function not working

Post by thomas_schlotter » December 23rd, 2015, 5:41 pm

Cool. Thanks a lot.
I'll try it out with the latest version :-)
Yantis
Posts: 1
Joined: July 27th, 2017, 12:17 pm

Re: mod function not working

Post by Yantis » August 3rd, 2017, 3:19 pm

thomas_schlotter wrote:Cool. Thanks for suggesting these accountants in Tunbridge Wells a lot. With the latest version :-)
Is it working for you now Thomas?
Post Reply