You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced_usage.rst
+27-1Lines changed: 27 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,32 @@ We can substitute this function directly for the heat_loss_to_room model compone
41
41
42
42
If you want to replace a subscripted variable, you need to ensure that the output from the new function is the same as the previous one. You can check the current coordinates and dimensions of a component by using :py:data:`.get_coords(variable_name)` as it is explained in :doc:`basic usage <../basic_usage>`.
43
43
44
+
45
+
Splitting Vensim views in different files
46
+
-----------------------------------------
47
+
In order to replicate the Vensim views in translated models, the user can set the `split_modules` argument to True in the :py:func:`read_vensim` function::
The option to split the model in views is particularly interesting for large models with tens of views. Translating those models into a single file may make the resulting Python model difficult to read and maintain.
53
+
54
+
In a Vensim model with three separate views (e.g. `view_1`, `view_2` and `view_3`), setting `split_modules` to True would create the following tree inside the directory where the `.mdl` model is located:
55
+
56
+
|main-folder
57
+
|├── modules_many_views_model
58
+
|│ ├── _modules.json
59
+
|│ ├── view_1.py
60
+
|│ ├── view_2.py
61
+
|│ └── view_3.py
62
+
|├── _namespace_many_views_model.json
63
+
|├── _subscripts_dict_many_views_model.json
64
+
|├── many_views_model.py
65
+
|
66
+
|
67
+
If macros are present, they will be self-contained in files named as the macro itself. The macro inner variables will be placed inside the module that corresponds with the view in which they were defined.
68
+
69
+
44
70
Starting simulations from an end-state of another simulation
The current state of a model can be saved in a pickle file using the :py:data:`.export()`method::
@@ -68,5 +94,5 @@ the new simulation will have initial time equal to 50 with the saved values from
68
94
The changes done with *params* arguments are not ported to the new model (*model2*) object that you initialize with *final_state.pic*. If you want to keep them, you need to call run with the same *params* values as in the original model (*model1*).
69
95
70
96
.. warning::
71
-
Exported data is saved and loaded using `pickle <https://docs.python.org/3/library/pickle.html>`_, this data can be not compatible with future versions of
97
+
Exported data is saved and loaded using `pickle <https://docs.python.org/3/library/pickle.html>`_, this data can be incompatible with future versions of
72
98
*PySD* or *xarray*. In order to prevent data losses save always the source code.
0 commit comments