Skip to content

Added integration of new model in tutorial #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 7, 2023
Merged

Added integration of new model in tutorial #185

merged 13 commits into from
Apr 7, 2023

Conversation

piluc
Copy link
Collaborator

@piluc piluc commented Apr 5, 2023

No description provided.

@piluc piluc requested review from natema and paulobruno as code owners April 5, 2023 08:41
Copy link
Member

@natema natema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piluc thanks for the great tutorial! I have just some comments regarding some parts.

gettables() = copy(_tables)
getranges() = copy(_ranges)
```
Note that the function `gettables` is exactly the one that has been used above while updating a model with modern data.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find where the function gettables has been previously used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is used in the code presented within the tutorial section titled "Modifying an interpolation table".

```
Observe that if the model contains multiple systems and/or multiple subsystems, then the ODE systems returned by all the subsystems have to be composed by using the function `compose` (which also asks for the connections between the variables declared and used in different subsystems). An example of a scenario using multiple systems and subsystems is defined in the file `scenarios.jl` included in the directory `world2` within the `World` model directory.

Finally, the model can be solved and simulated by using the `solve` and the `plotvariables` functions that we already used above. In particular, the file `plots.jl` (we assume that also this file is contained in the directory `nonrenewablestock`) does it in order to reproduce Figure 3.9 of the chapter of the above mentioned book.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that "above" here refers to a previous page in the documentation, so I would not say "used above".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"above" refers to a previous paragraph in the same tutorial page. "solve" has been used in the paragraph titled "Solving the ODE system", while "plotvariables" has been use in the paragraph titled "Plotting the evolution of the model".


fig_3_9(; kwargs...) = plotvariables(nrs_run_solution(), (t, 0, 200), _variables_nrs(); title="Simulation output showing stocks and flows", showaxis=false, showlegend=true, kwargs...)
```
Note that, for performance reasons, the definition of the function `nrs_run_solution` starts by checking whether the solution of the model is already available: in this case, nothing is done.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have issue #120 regarding a cleaner approach using closures instead of defining global variables. We can keep the current approach until that issue gets solved by a PR, but we should then remember to update the tutorial.


```
include("Duggan/Duggan.jl")
Main.Duggan.NonRenewableStock.fig_3_9()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need Main?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, yes. But I am not a Julia expert...

Comment on lines +289 to +290
using WorldDynamics
using ModelingToolkit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be a very naive question, since we are currently doing that in the models we implemented, but... do we need to re-include these two modules, which are already included in Duggan.jl.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know...

@aurorarossi aurorarossi merged commit 10213a9 into dev Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants