SciMLTutorials.jl: Tutorials for Scientific Machine Learning and Differential Equations
SciMLTutorials.jl holds PDFs, webpages, and interactive Jupyter notebooks showing how to utilize the software in the SciML Scientific Machine Learning ecosystem. This set of tutorials was made to complement the documentation and the devdocs by providing practical examples of the concepts. For more details, please consult the docs.
Interactive Notebooks
To run the tutorials interactively via Jupyter notebooks, install the package and open the tutorials like:
using Pkg
pkg"add https://github.com/SciML/SciMLTutorials.jl"
using SciMLTutorials
SciMLTutorials.open_notebooks()
Video Tutorial
Table of Contents
- Introduction
- Exercise Sheets
- Modeling Examples
- Advanced ODE Features
- Model Inference
- Type Handling
- DiffEqUncertainty
- Advanced
- Perturbation Theory
Contributing
First of all, make sure that your current directory is SciMLTutorials
. All of the files are generated from the Weave.jl files in the tutorials
folder. To run the generation process, do for example:
using Pkg, SciMLTutorials
cd(joinpath(dirname(pathof(SciMLTutorials)), ".."))
Pkg.pkg"activate ."
Pkg.pkg"instantiate"
SciMLTutorials.weave_file("introduction","01-ode_introduction.jmd")
To generate all of the notebooks, do:
SciMLTutorials.weave_all()
If you add new tutorials which require new packages, simply updating your local environment will change the project and manifest files. When this occurs, the updated environment files should be included in the PR.
problem with animation
Sorry for bothering you with this but I am trying to put together a notebook that animates the solution to the diffusion equation. The code below works well for plotting slices but the animation seems to go on and on and never make an animation.
Any suggestions as to what I'm doing wrong?
Needless to say, I am happy to share the notebook in case anyone might find it helpful.
Enumerate tutorials and rebuild
This PR is the continuation of #61. In a first step, I have enumerated all the tutorial files in
tutorials/
,html/
,notebook/
,pdf/
,script/
as suggested in #60. The second commit rebuilds all the tutorials that could be built without unintendedWeave.jl
warnings/errors.The following tutorials could not be built without errors, so I will add them in seperate commits to this PR, and we can figure out what to do:
introduction/05-formatting_plots
models/03-diffeqbio_I_introduction
models/04-diffeqbio_II_networkproperties
models/06-pendulum_bayesian_interface
models/07-outer_solar_system
ode_extras/ModelingToolkit
type_handling/01-number_types
type_handling/03-unitful
Plot solutions in notebook about number with uncertainties
The latest version of
Measurements.jl
supportsPlots.jl
and I took the occasion to update the related tutorial to show this feature (actually, I decided to implement this feature exactly for this tutorial).Only problem is that it doesn't seem to be possible to simply do
plot(sol)
, I get some errors. Any idea why?Example Radioactive Decay (Numbers with uncertainties) not working in Julia 1.0
Source: http://nbviewer.jupyter.org/github/JuliaDiffEq/DiffEqTutorials.jl/blob/master/PhysicalModels/NumberUncertainties.ipynb
If I execute
in Julia 1.0 I get:
Tutorial - Heat Equation Finite Element Method
Hi,
the code in the heat equation tutorial gives the following error for me:
Running Julia v0.6.1 with DifferentialEquations v3.0.2
Add more dependencies to DiffEqTutorials?
On a fresh julia-1.1.0 install, I followed the "Getting started guide" for DifferentialEquations:
So far I've needed to add IJulia, MatrixFactorizations, DiffEqParamEstim, Plots, Optim ... and perhaps a few more to come (haven't gone through the tutorial yet).
I am somewhat perplexed since I see these requirements listed here: https://github.com/JuliaDiffEq/DiffEqTutorials.jl/blob/master/Project.toml
Is that
pkg"add ..."
special in the sense it doesn't pull the dependencies?Update most if not all notebooks
@ChrisRackauckas Can you or someone please update most if not all notebooks in DiffEqTutorials to run smoothly on current Julia v1.0.1 and DifferentialEquations v5.3.1. For a fruitful dissemination of Julia DiffEq, it is important that this collection of notebooks runs flawlessly.
DiffEqBiological packages outdated
The tutorials https://tutorials.sciml.ai/html/models/03-diffeqbio_I_introduction.html and following are outdated. They still refer to DiffEqBiological instead of Catalyst. On my system, I started to fix the tutorials and I came across several issues, some of which I could fix. I will try to create a comprehensive list of errors if you are interested in keeping these tutorials. In my opinion this would make sense, because the examples in the Catalyst docs are by far not as detailed.
updated kepler problem tutorial
qdot
andpdot
.u
andv
inODEProblem
andDynamicalODEProblem
. Moreover, I guess, the order was changed at some time of these problems' existence. I have updated the plotting functions with the current state of things.u
andv
variables noted in the declaration off1
andf2
.ExtraFEMFeatures/Heat Equation
I am very new to Julia and going through some of the neat tutorials people have put together.
I installed Julia 0.6.0 on Ubunbu by downloading the generic version, as requested.
When I run the Heat Equation example the first line seems to go okay but the second has a MethodError, suggesting a method might be too new.
To be able to use this example should I use the most recent (bleeding edge) version? I am happy to do that but wanted to check to see if this is what is necessary.
MethodError: no method matching setcharheight(::Float64) The applicable method may be too new: running in world age 24141, while current world is 24142. Closest candidates are: setcharheight(::Real) at /home/fpoulin/.julia/v0.6/GR/src/GR.jl:1010 (method too new to be called from this world context.)
Rebuild tutorials automatically
First draft, I expect some things to be broken.
Here's what's supposed to happen:
setup
job chooses a random folder and file, then emits a job config for that tutorial.rebuild
GitLab CI job reads this generated job config and executes it, by:!rebuild <folder>/<file>
, in which case the same process happens but without the random selectionSciML Tutorial attempts to simultaneously use keywords vars and idxs in Plot, which is not supported.
When I try to plot the first 250 trajectories, according to the SciML tutorial:
https://github.com/SciML/SciMLTutorials.jl/blob/e8c8c3e51703fd08b874abbbc7b52ed895d0cb6f/tutorials/DiffEqUncertainty/01-expectation_introduction.jmd#L48
I get this error:
Double Pendulum example lacks explanations
The double pendulum example has a certain mismatch between the code and the explanations surrounding it: https://tutorials.sciml.ai/html/models/01-classical_physics.html
It firstly lists the underlying equations but then provides the some code without any context while also introducing additional variables (i.e. m1, m2). This ODE function needs some context, currently no equations or additional information are provided:
The initial equations block only makes sense in the next subchapter (Poincaré section).
as for code readable, I have a little suggestion
eg. lorenz
modify to :
better or worse?
SciMLTutorial does not install on Apple Silicon macOS system
I am not able to install SciMLTutorial.jl on an Apple Silicon macOS system. It gets stuck in a loop.
This is the part that loops again and again:
automatic differentiation not working in advanced examples?
I'm trying to find an example of how to use automatic differentiation in more complex ODE rather than those vanilla examples in the tutorials. Simple ODEs are quite easy to figure out, but I always have the trouble with the
Dual Number
error in complex ODE models. Seems my ODE functions are always not generic enough. And I'd like to learn how to make it work.I was trying to modify the Beeler-Reuter Model (the CPU version) in the advanced tutorial, as the original code doesn't work with
autodiff=true
since it only acceptsFloat
. I finally manage to make it work, but I have many problems that I don't understand. Here is the modified working code:The main changes are :
struct BeelerReuterCpu
parametric.(f::BeelerReuterCpu)(du, u, p, t)
function, when callingupdate_gates_cpu
andlaplacian
functions, the aruguments are converted to the type ofu
, likeeltype(u).(f.Δu)
.I made these changes otherwise I get the
Dual Number
errorMy questions are:
update_gates_cpu
andlaplacian
but notupdate_du_cpu
inside(f::BeelerReuterCpu)(du, u, p, t)
?BeelerReuterCpu
to make the type consistent betweenu
and the fields inBeelerReuterCpu
. I assume that's necessary for theDual Number
to work, but obviously that's not enough. I suppose that's because thestruct
is not created dynamically? Is there a way to do that.DiffEqBase.dualcache
is needed to avoid theDual Number
error when using cache. The cache example given there was very straightforward. But I wonder what exactly is considered as cache. Does it include any intermediary calculation variables?I hope there could be an example of complex ODE with automatic differentiation. All the complex ODE examples in the tutorials and benchmarks only accept
Float
and therefore doesn't work for automatic differentiation. Thanks!