Local submodels can be created by simply selecting the parts of a model that will be converted to a submodel and clicking on the tab Edit → Create Submodel
. The selection will be replaced by the new submodel and the visual representation of the new submodel will be available to be edited as a new tab on the script editor. At any time, the user can make changes to the local submodel and apply those changes clicking on Apply changes / Update Submodel Properties on the model toolbar.
It is also possible to select parts of a local submodel and create another local submodel using that selection. The new local submodel will be a dependency of the previous one, but the submodel creation process is basically the same. If the selection is empty, an empty local submodel will be created. The process for updating an empty submodel is the same process used to update any local submodel.
Initially, we will learn how to create a submodel and next we will learn how to use it in a Model.
We will start with the model 5_calculate_lookup_table
located in \Guidebook_Dinamica_5\Models\creating_and_using_local_submodels
. Using this model we will answer the following question:
What is the productivity for each crop across the considered time window?
\Guidebook_Dinamica_5\Database\Tables
. Grab a Reorder Table Column and place it on the sketch to switch the order of the year and crop key columns. Connect the Load Table to Reorder Table Column. In the Functor Editor window insert the index of the column to be moved (1) and the new column index (0) and click OK.
\Guidebook_Dinamica_5\Models\creating_and_using_local_submodels
and write the file names (e.g. most_productive_year_for_crop_1.csv, most_productive_year_for_crop_2.csv and most_productive_year_for_crop_3.csv).
We can infer that 2009 was the most productive year for Crop 1 along the analyzed period, with a productivity of 80.25549 tons/ha. For the Crop 2, 2015 was the most productive year, with a productivity of 3.535804 tons/ha and 2011 was the most productive year for Crop 3, with a productivity of 3.121386 tons/ha.