The ideas behind basic models is that logical elements of a measurement, e.g. devices, substances, can be encapsulated in abstract moduls and be instanciated for the definition of a concrete measurement scenario. Each basic model is defined in one xml file and can be parametrised so that if used parameters can be set without touching the file itself.
The frame of a basic model consist of the following few lines.
<model name="length" targetname="l">
...
</model>
The first line is used to identify the file as correct xml file, the second line tells the parser how to check the validity of the syntax in the model. Users do not have to understand these lines in detail. The interesting part follows after these two standard lines.
The model tag opens a basic model, in the example named length and the tag targetname tells the parser which influence is the main influence.
In the following subsections we omitt the xml opening lines and concentrate more on the details of the sections of interest.
In the body of a model you define your influences to the measurement by defining recursively subinfluences and quantifying them by setting parameters of their probability distributions, if neccessary. The distribution of each influence can be logged.
The following example is a really simple one. The model only consists of the main influence. It is gaussian distributed with parameters 5.0 for mu and 2.0 for sigma.
<model name="length" targetname="l">
<influence comment="result" name="l">
<distribution>
<gauss>
<mu>5.0</mu>
<sigma>2.0</sigma>
</gauss>
</distribution>
</influence>
</model>
To see what kind of distributions are support please refer to the chapter about supported distributions.
A more advanced example uses two subinfluences g1 and g2, where the main influence adds those two subinfluences using the function tag.
<model name="length" targetname="l">
<influence comment="result" name="l">
<formula>g1 + g2</formula>
<influences>
<influence name="Gauss 1" id="g1">
<distribution>
<gauss>
<mu>5.0</mu>
<sigma>2.0</sigma>
</gauss>
</distribution>
</influence>
<influence comment="Gauss 2" name="g2">
<distribution>
<gauss>
<mu>10.0</mu>
<sigma>1.0</sigma>
</gauss>
</distribution>
</influence>
</influences>
</influence>
</model>
Basic models are an abstract form of defining the dependencies of parts of a measurement with influences and distributions. Instances of basic models may need different value settings for the parameters of the distributions and one may not like to change basic models directly, but set parameters from outside, say from the part where one instanciates the basic models.
MUSE supports two different types of parametrization:
<model ...>
<influence comment="influence" name="v">
<distribution>
<gauss>
<mu parameter="#1"/>
<sigma parameter="#2"/>
</gauss>
</distribution>
</influence>
</model>
So in the model definition we define one influence named influence which is gaussian distributed. The mean and standard deviation are parametrized. That means the value (or formula!) of parameter #1 or respectively #2 will be used for the parameters of the distribution. Let us continue with the simulation file:
<simulation>
<instances>
<instance model="influence" name="v1">
<parameters>
<parameter id = "#1">time 0.1*</parameter>
<parameter id = "#2">2</parameter>
</parameters>
</instance>
</instances>
<processes>
<process name="v1">
<variable name="time"> start 10+ </variable>
<formula>time</formula>
</process>
</processes>
<calculation>
<variation name="start" from="0" to="120" step="10"/>
<measurand> v1 </measurand>
</calculation>
</simulation>
First we say, we want an instance and override the default parameters of the file. Parameter #1 will now be set to a formula, parameter #2 to a constant of 2. The variable time used in the first parameter is defined in the process section, where it uses the global variable start as another varying factor. In the end we have an influence gaussian distributed with a drifting mean with values 0, 1, 2, . . . , 10, 11, 12 and a standard deviation of 2.
The definiton of the model file using just variables, not parameters, would look like this.
<model ...>
<influence comment="influence" name="v">
<distribution>
<gauss>
<mu parameter="#1">mymu</mu>
<sigma parameter="#2">mysigma</sigma>
</gauss>
</distribution>
</influence>
</model>
In this file we use to variables mymu and mysigma that are not defined in the model file. Therefore the system expects their definitions in the simulation file.
<simulation>
<instances>
<instance model="influence" name="v1"/>
</instances>
<process>
<step name="v1">
<variable name="mymu"> start 10+ </variable>
</step>
</process>
<calculation>
<variation name="start" from="0" to="120" step="10"/>
<variable name="mysigma"> 1.5 </variable>
<measurand> v1 </measurand>
</calculation>
</simulation>
The values of mymu and mysigma will be used as defined in the simulation file. If you do not define missing variables of the models in the simulation file, the system will respond with an error message.
_Hint:___ We recommend to use parametrization, as you can define default values and for better readability of your models. A parameter is explicitly declared once in the model file and then in the simulation file, if you do not use its default value.
_Hint:___ If you take a model using variables and have not defined the named variables properly in the calcualtion section, the parser will return an error message everytime the formula is parsed.
It is possible to use basic models as influences in basic models. Like this you can define a nice hierarchy of models. See section [Recursive definition of basicmodels] for more information.
Sometimes it seems reasonable to define not a complete Initialization section as static, but only parts of it. That means, if you use an instance of a basic model for example the temperature should be kept to the same value for all calculations using this instance. You can do that by defining an influence in mode static.
<model ...>
<influence comment="concentration" name="c">
...
<influences>
<influence comment="temperature" name="t" mode="static">
...
</influence>
...
</influences>
</influence>
</model>
_Attention: If you define an influence as _static in a basic model, all subsequent influences to that one will also be defined as static.
_Attention: The keyword _static always only applies to the current instance. If you use for example two instances of a volume device with a basic model that uses static influences, they are only static for each of the volume devices.
Wiki: Distributions
Wiki: Process section
Wiki: Recursive definition of basicmodels