7. Linking of variables

Top  Previous  Next

The calculation structure and order of a ModelSolution is defined in the section <simmodel>. This is where the SimComponents can be declared and linked with:

- Variables defined in the <variables>...</variables> section

- Variables of an object defined in the <resources>...</resources> section

- Outputs of another SimComponent

 

Once a resource object or SimComponent is defined, the variables can be accessed hierarchically by typing the name id of the object followed by a period "." and the name of the desired variable. For example:

 

    <input id="iTMMX" source="weather.TemperatureMax" /> (link the variable "TemperatureMax" from resource "weather" to a SimComponent)

 

The linkage can be specified at the attribute "rule=" or "source=". For now, the practical difference between them is that for "rules" the placeholders ${} should enclose the desired variable, whereas for source it can be defined directly. From example above:

 

rule="${weather.TemperatureMax}"

source="weather.TemperatureMax"

 

Later on you will see more details about their differences and the implications of their usage.

 

 

Tip: A short scientific documentation and the list of all constants, inputs, outputs, states and rates for all standard SimComponents of SIMPLACE is maintained at: https://simplace.net/doc/simplace_modules/. SimComponents are listed by its unique class id:

 - For example: ReferenceETPM  is class="net.simplace.sim.components.evapotran.fao56.ReferenceETPM"

 

 

 


 

Now let's practice!

 

 

Task 7.1 A variable named "LUE" is stored in the resource id="parameter" in the solution 07_LinkingVariables.sol.xml.        The SimComponent id="lintul2" uses "parameter.LUE". Now make the SimComponent id="lintul2" to read a variable with the value of LUE=3.3 instead of "parameter.LUE".

 

 Hints

  - Add new variable to the <variables>...</variables> section

  - Use new defined variable in the SimComponent "Lintul2" instead of "parameter.LUE"

  - Save and run the file

 

 Solution

  Open the 07_1_LinkingVariables_Answer.sol.xml to see how it should be done.

 

 


 

 

Task 7.2 One can even directly use a value for the resource variable, e.g. not using it either from the resource section

 or as a variable. Change the source value of cLue of "Lintul2" SimComponent to 2.9 in the simplace_modules/test/training/solution/Solution7.xml

 Think about the disadvantage of directly using the value for a variable.

 

 Hints

  - Find out where the "cLUE" is used in the "Lintul2" SimComponent and change the source value to 2.9

  - Put the new value between <input></input> tags with datatype="DOUBLE"

 

 Solution

  Open the 07_2_LinkingVariables_Answer.sol.xml to see how it should be done.

 

 

 

*ModelSolutions are found in simplace_modules\test\training\solution\1_WorkingWithSolutions