Compiler

How do I link external functions?


If your model needs to link external C files together with the code generated from the .M file, set an environment variable MUSEROBJS before you run MMake. For example, supposing you have files myf1.c and myf2.c which you want to link with mymodel.m, do this:

C:\>set MUSEROBJS=myf1.obj myf2.obj
# note: use the .obj extensions (not .c)
C:\>mmake mymodel.mdl
# note: mmake will compile myf1.c and myf2.c to objs
C:\>set MUSEROBJS=
# note: this unsets the environment variable


Note that mmake will take care of compiling your c-files to obj-files and link them in. In fact, it is recommended to have mmake compile your c-files, and not do it yourself.

Which arguments are valid for m2c?

Usage : m2c [options] file.m

Description: Converts a modelfile (.m) into a c source file (.c)

Options :

  • -o name : write c source to file name
  • -e name : write errors to file name
  • -s name : use name as scratch-file
  • -array : check run-time on array bound overflow
  • -fltcheck:

               Operation/Functions Valide range


-------------------------------------
x/y y: NON_ZERO
x**y x: POS
acos(x) x: UNIT_RANGE
asin(x) x: UNIT_RANGE
fmod(x,y) y: NON_ZERO
log(x) x: POS
log10(x) x: POS
pow(x,y) x: POS
sqrt(x) x: POS
exp(x) x: POS
-------------------------------------

Run time checks on
NON_ZERO: abs(x) >= eps
POS : x >= eps
UNIT_RANGE: abs(x) <= 1

The value of eps is 1.e-10 by default but can be
changed by -eps value.
  • -eps value : Change the epsilon value used by -fltcheck
  • -trace : Write every equation and integ to standard output
  • -ARRAY : check run-time on array bound overflow and use of array elements
  • -woff list : do not show warnings in list
  • -h : list these options

GUI

What is the difference between MGIM and MPlayer

MGIM is an editor and player of the MyM modelling software.
MyM Player is stripped down version of the MGIM where models and views can only be loaded and not edited.
You can distribute your models and user interfaces together with the freely distributable MPlayer to third parties.

What are the settings in the .mop file used for?

The .mop externsion for a MyM model is the option file that is automatically loaded for a model.
Thus e.g when we load casc.mdl the mgim tries to load casc.mop file.
If the file exists the settings of the mop file are used. The options can be saved from the view options dialog.

Explanation:

freeze = [0/1]wether the gym runs immediately or waits running when the the user presses the run model button
interpolation = [1/1] if the gym should let the model interpolate values that are not stored
zoom =[number] in how many steps the gym should zoom in and out
autosave =[0/1] setting to set the autosave option for views in minutes
update =[0/1] shows an update while the model i actual running; regularly the model run first completely and then displays
showtime =[0/1] to show the time on top of the top container
timendec =[number] the number of decimals to be displayed for the time
t.min =[double] the minimum time to be displayed in the model dialog
t.max=[double] the minimum time to be displayed in the model dialog
t.sample =[double] the sample of the time
t.step =[double] the step size of the time
t.error = double the error of the time
t.method =[ which method to use, RK1, RK2, etc.
RK1 1
RK2 2
RK4 3
RK5 4

Language

How do I count booleans?

Example:

boolean b[3]; 
b[1] = true; b[2] = false; b[3] = true;
integer a; a = lsum(i = 1 to 3, b[i]);

Error message: Syntax error: Not allowed to use a Boolean expression

Solution:

a = lsum(i=1 to 3,switch(b[i] ? 1 else 0));

How do I define a range for a domain variable?

You need to define the domain variable and its function before specifying the min and max of the domain, e.g.,

double x;
real f(x);
x.min = 0;
x.max = 10;

Why can’t I define real x=2/f ?

Because x=2/f is considered to be an equation. It can not be declared as input variable. Only inputvariables like real x=4; are allowed

Can I define a constant array?

The answer is NO

    Example:         const a[3] = 1, 2, 3;
Error message: Warning: Expected '='
Workaround: Define array as a real, integer, boolean or double array.

How does MyM calculate its internal time step?

The following algorithm is used internally:

  • Calculate the smallest time step tstep for all time variables: tstep_min
  • Determine a tstep such that for all time variables this tstep resembles as good as possible the predefined step per time variable, and that this step is a multiple of tstep_min.
  • The previous method is also applied to determine the tsample. Tsample is set to a value that is always >= the tstep for variables.

Simulator

Is MyM suitable for large simulation models?

Yes. because MyM compiles your model into native code, and uses optimization, MyM is able to run your models faster than models that are interpreted.