9. Adding outputs |
Top Previous Next |
As you may have noted, the previous solutions comprise of many resources, SimComponents and only one output file. In the output file you can save the variables, which can be of different data types or they can results from the SimComponents. The linkage works similarly as for SimComponents.
You can output variables to a file, e.g.:
<out id="Location" datatype="CHAR" rule="vLocation" />
<out id="Rain" datatype="DOUBLE" rule="weather.Rain" />
Or a results from a SimComponent:
<out id="LAI" datatype="DOUBLE" rule="Lintul2.sLAI" />
<out id="Yield" datatype="DOUBLE" rule="Lintul2.sWSO" />
<out id="HasCrop" datatype="BOOLEAN" rule="Lintul2.WithCrop" />
Tip: 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/
In contrast with SimComponents, the name of the variables can be used without the placeholders ${} in the attribute (e.g. rule="Lintul2.sWSO"). However, the placeholders can be used, for example, to execute simple calculations or units conversion:
<out id="YieldTonsHectare" datatype="DOUBLE" rule="${Lintul2.sWSO}/100" />
<out id="YieldGramSqMeter" datatype="DOUBLE" rule="Lintul2.sWSO" />
Every output entry (<out ... />) will become a column in the corresponding output interface file (interface="lintul2daily").
Now let's do some exercises!
Task 9.1 Using solution 09_AddingOutputs.sol.xml add the following variables to the end of the output file:
- TRANRF from Lintul2 SimComponent
- SeedsToLeavesBiomass from SeedsToSprouts SimComponent,
- iDoSow from Lintul2 SimComponent
Hints
- See the examples above for how to add a variable to the output file
- Make sure that you didn't misspelled the variables from the SimComponents
- Each <out id="" /> tag will be a column with the name from id="" in your output file
- All the time run the JUnit test with your solution to check the results in the output file
Solution
Open the 09_AddingOutputs_Answer.sol.xml to see how it should be done.
Task 9.2 (optional) Using solution 09_AddingOutputs.sol.xml add a MEMORY output o the outputs section with few variables that are used in this solution. e.g.:
- SeedsToSprouts.RWRT
- SeedsToSprouts.RWLV
- SeedsToSprouts.CumulatedSeedsToRootsBiomass
- Lintul2.sTSUM
This type of output is used to pass the SIMPLACE outputs via computer memory, and its useful when configuring the SIMPLACE Crop Manager GUI or using wrappers.
The interface type should be set to "MEMORY":
<interface id="diagramout" type="MEMORY">
<poolsize>20000</poolsize>
</interface>
and one more output should be added in the <outputs> section, for example:
<output id="DIAGRAM_OUT" interface="diagramout" frequence="DAILY" cachesize="10">
<header>
<out id="RWRTSeed" datatype="DOUBLE" rule="SeedsToSprouts.RWRT" />
<out id="RWLVSeed" datatype="DOUBLE" rule="SeedsToSprouts.RWLV" />
<out id="CumulatedSeedsToRootsBiomass" datatype="DOUBLE" rule="SeedsToSprouts.CumulatedSeedsToRootsBiomass" />
...
</header>
</output>
Hints
- See the explanations above how to add a MEMORY output.
Solution
Open the 09_AddingOutputs_Answer.sol.xml to see how it should be done.
*ModelSolutions are found in simplace_modules\test\training\solution\1_WorkingWithSolutions