Skip to content

Commit 2a5928c

Browse files
committed
up
1 parent 81b34d7 commit 2a5928c

File tree

2 files changed

+73
-62
lines changed

2 files changed

+73
-62
lines changed

HISTORY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Breaking updates and feature summaries across releases
22

33
## Catalyst unreleased (master branch)
4+
5+
## Catalyst 13.6
46
- Simulation of spatial ODEs now supported. For full details, please see https://github.com/SciML/Catalyst.jl/pull/644 and upcoming documentation. Note that these methods are currently considered alpha, with the interface and approach changing even in non-breaking Catalyst releases.
57
- LatticeReactionSystem structure represents a spatial reaction network:
68
```julia
@@ -35,7 +37,6 @@ wilhelm_2009_model = @reaction_network begin
3537
k5, 0 --> X
3638
end
3739

38-
3940
using BifurcationKit
4041
bif_par = :k1
4142
u_guess = [:X => 5.0, :Y => 2.0]

docs/src/introduction_to_catalyst/catalyst_for_new_julia_users.md

Lines changed: 71 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -46,82 +46,29 @@ nothing # hide
4646

4747
This is useful to know when you e.g. declare, simulate, or plot, a Catalyst model. The first time you run a command there might be a slight delay. However, subsequent runs will be much quicker. This holds even if you make minor adjustments before the second run (such as changing simulation initial conditions).
4848

49-
## [Package management in Julia](@id catalyst_for_new_julia_users_packages)
50-
Due to its native package manager, and a registry of almost all packages of relevancy, package management in Julia is unusually easy. In principle, Catalyst can be both installed, and then imported into a session, using only:
51-
```julia
52-
using Pkg
53-
Pkg.add("Catalyst")
54-
using Catalyst
55-
```
56-
However, over the next three subsections we describe some additional considerations and useful commands. It is recommended to read and understand these at a relatively early stage. For a more detailed introduction to Julia package management, please read [the Pkg documentation](https://docs.julialang.org/en/v1/stdlib/Pkg/).
57-
58-
### [Setting up a new Julia environment](@id catalyst_for_new_julia_users_packages_environments)
59-
Whenever you run Julia, it will run in a specific *environment*. You can specify any folder on your computer as a Julia environment. If you start Julia in that folder, that environment will be used (or, this will at least be the case for most modes of running Julia). If you start Julia in a folder not corresponding to an environment, your *default* Julia environment is used. While it is possible to not worry about environments (and always use the default environment), this can lead to long-term problems as more packages are installed.
60-
61-
To activate your current folder as an environment, run the following commands:
62-
```julia
63-
using Pkg
64-
Pkg.activate(".")
65-
```
66-
This will:
67-
1. If your current folder (which can be displayed using the `pwd()` command) is not designated as a possible Julia environment, designate it as such.
68-
2. Switch your current Julia session to use the current folder's environment.
69-
70-
!!! note
71-
If you check any folder which has been designated as a Julia environment, it contains a Project.toml and a Manifest.toml file. These store all information regarding the corresponding environment. For non-advanced users, it is recommended to never touch these files directly (and instead do so using various functions from the Pkg package, the important ones which are described in the next two subsections).
49+
## [Installing and activating packages](@id catalyst_for_new_julia_users_packages_intro)
50+
Due to its native package manager (Pkg), and a registry of almost all packages of relevancy, package management in Julia is unusually easy. Here, we will briefly describe how to install and activate Catalyst (and two additional packages relevant to this tutorial).
7251

73-
### [Installing and importing packages in Julia](@id catalyst_for_new_julia_users_packages_installing)
74-
To import a Julia package into a session, you can use the `using PackageName` command (where `PackageName` is the name of the package you wish to activate). However, before you can do so, it must first be installed on your computer. Almost all relevant Julia packages are registered, and can be added through the `Pkg.add("PackageName")` command. We can thus install Catalyst through:
52+
To import a Julia package into a session, you can use the `using PackageName` command (where `PackageName` is the name of the package you wish to import). However, before you can do so, it must first be installed on your computer. This is done through the `Pkg.add("PackageName")` command:
7553
```julia
7654
using Pkg
7755
Pkg.add("Catalyst")
7856
```
79-
Here, the Julia package manager package (`Pkg`) is by default installed on your computer when Julia is installed, and can be activated directly.
80-
81-
We can now use Catalyst and its features by running:
82-
```@example ex2
83-
using Catalyst
84-
```
85-
This will only make Catalyst available for the current Julia session. If you exit Julia, you will have to run `using Catalyst` again to use its features (however, `Pkg.add("Catalyst")` does not need to be rerun). Next, we wish to install the `DifferentialEquations` and `Plots` packages (for numeric simulation of models, and plotting, respectively):
57+
Here, the Julia package manager package (`Pkg`) is by default installed on your computer when Julia is installed, and can be activated directly. Next, we also wish to install the `DifferentialEquations` and `Plots` packages (for numeric simulation of models, and plotting, respectively).
8658
```julia
8759
Pkg.add("DifferentialEquations")
8860
Pkg.add("Plots")
8961
```
90-
and also to import them into our current session:
62+
Once a package has been installed through the `Pkg.add` command, this command does not have to be repeated if we restart our Julia session. We can now import all three packages into our current session with:
9163
```@example ex2
64+
using Catalyst
9265
using DifferentialEquations
9366
using Plots
9467
```
68+
Here, if we restart Julia, these commands *do need to be rerun.
9569

96-
### [Why environments are important](@id catalyst_for_new_julia_users_packages_environment_importance)
97-
We have previously described how to set up new Julia environments, how to install Julia packages, and how to import them into a current session. Let us say that you were to restart Julia in a new folder and activate this as a separate environment. If you then try to import Catalyst through `using Catalyst` you will receive an error claiming that Catalyst was not found. The reason is that the `Pkg.add("Catalyst")` command actually carries out two separate tasks:
98-
1. If Catalyst is not already installed on your computer, install it.
99-
2. Add Catalyst as an available package to your current environment.
100-
101-
Here, while Catalyst has previously been installed on your computer, it has not been added to the new environment you created. To do so, simply run
102-
```julia
103-
using Pkg
104-
Pkg.add("Catalyst")
105-
```
106-
after which Catalyst can be imported through `using Catalyst`. You can get a list of all packages available in your current environment using:
107-
```julia
108-
Pkg.status()
109-
```
110-
111-
So, why is this required, and why cannot we simply import any package installed on our computer? The reason is that most packages depend on other packages, and these dependencies may be restricted to only specific versions of these packages. This creates complicated dependency graphs that restrict what versions of what packages are compatible with each other. When you use `Pkg.add("PackageName")`, only a specific version of that package is actually added (the latest possible version as permitted by the dependency graph). Here, Julia environments both define what packages are available *and* their respective versions (these versions are also displayed by the `Pkg.status()` command). By doing this, Julia can guarantee that the packages (and their versions) specified in an environment are compatible with each other.
112-
113-
The reason why all this is important is that it is *highly recommended* to, for each project, define a separate environment. To these, only add the required packages. General-purpose environments with a large number of packages often produce package-incompatibility issues. While these might not prevent you from installing all desired package, they often mean that you are unable to use the latest version of some packages.
114-
115-
!!! note
116-
A not-infrequent cause for reported errors with Catalyst (typically the inability to replicate code in tutorials) is package incompatibilities in large environments preventing the latest version of Catalyst from being installed. Hence, whenever an issue is encountered, it is useful to run `Pkg.status()` to check whenever the latest version of Catalyst is being used.
117-
118-
Some additional useful Pkg commands are:
119-
- `Pk.rm("PackageName")` removes a package from the current environment.
120-
- `Pkg.update(PackageName")`: updates the designated package.
70+
A more comprehensive (but still short) introduction to package management in Julia is provided at [the end of this documentation page](catalyst_for_new_julia_users_packages). It contains some useful information and is hence highly recommended reading. For a more detailed introduction to Julia package management, please read [the Pkg documentation](https://docs.julialang.org/en/v1/stdlib/Pkg/).
12171

122-
!!! note
123-
A useful feature of Julia's environment system is that enables the exact definition of what packages and versions were used to execute a script. This supports e.g. reproducibility in academic research. Here, by providing the corresponding Project.toml and Manifest.toml files, you can enable someone to reproduce the exact program just to perform some set of analyses.
124-
12572
## Simulating a basic Catalyst model
12673
Now that we have some basic familiarity with Julia, and have installed and imported the required packages, we will create and simulate a basic chemical reaction network model using Catalyst.
12774

@@ -231,6 +178,69 @@ plot(sol)
231178

232179
**Exercise:** Try simulating the model several times. Note that the epidemic doesn't always take off, but sometimes dies out without spreading through the population. Try changing the infection rate (*b*), determining how this value affects the probability that the epidemic goes through the population.
233180

181+
## [Package management in Julia](@id catalyst_for_new_julia_users_packages)
182+
We have previously introduced how to install and activate Julia packages. While this is enough to get started with Catalyst, for long-term users, there are some additional considerations for a smooth experience. These are described here.
183+
184+
### [Setting up a new Julia environment](@id catalyst_for_new_julia_users_packages_environments)
185+
Whenever you run Julia, it will run in a specific *environment*. You can specify any folder on your computer as a Julia environment. Some modes of running Julia will automatically use the environment corresponding to the folder you start Julia in. Others (or if you start Julia in a folder without an environment), will use your *default* environment. In these cases you can, during your session, switch to another environment. While it is possible to not worry about environments (and always use the default one), this can lead to long-term problems as more packages are installed.
186+
187+
To activate your current folder as an environment, run the following commands:
188+
```julia
189+
using Pkg
190+
Pkg.activate(".")
191+
```
192+
This will:
193+
1. If your current folder (which can be displayed using the `pwd()` command) is not designated as a possible Julia environment, designate it as such.
194+
2. Switch your current Julia session to use the current folder's environment.
195+
196+
!!! note
197+
If you check any folder which has been designated as a Julia environment, it contains a Project.toml and a Manifest.toml file. These store all information regarding the corresponding environment. For non-advanced users, it is recommended to never touch these files directly (and instead do so using various functions from the Pkg package, the important ones which are described in the next two subsections).
198+
199+
### [Installing and importing packages in Julia](@id catalyst_for_new_julia_users_packages_installing)
200+
Package installation and import have been described [previously](@ref catalyst_for_new_julia_users_packages_intro). However, for the sake of this extended tutorial, let us repeat the description by demonstrating how to install the [Latexify.jl](https://github.com/korsbo/Latexify.jl) package (which enables e.g. displaying Catalyst models in Latex format). First, we import the Julia Package manager ([Pkg](https://github.com/JuliaLang/Pkg.jl)) (which is required to install Julia packages):
201+
```@example ex3
202+
using Pkg
203+
```
204+
Latexify is a registered package, so it can be installed directly using:
205+
```julia
206+
Pkg.add("Latexify")
207+
```
208+
Finally, to import Latexify into our current Julia session we use:
209+
```@example ex3
210+
using Latexify
211+
```
212+
Here, `using Latexify` must be rerun whenever you restart a Julia session. However, you only need to run `Pkg.add("Latexify")` once to install it on your computer (but possibly additional times to add it to new environments, see the next section).
213+
214+
### [Why environments are important](@id catalyst_for_new_julia_users_packages_environment_importance)
215+
We have previously described how to set up new Julia environments, how to install Julia packages, and how to import them into a current session. Let us say that you were to restart Julia in a new folder and activate this as a separate environment. If you then try to import Latexify through `using Latexify` you will receive an error claiming that Latexify was not found. The reason is that the `Pkg.add("Latexify")` command actually carries out two separate tasks:
216+
1. If Latexify is not already installed on your computer, install it.
217+
2. Add Latexify as an available package to your current environment.
218+
219+
Here, while Catalyst has previously been installed on your computer, it has not been added to the new environment you created. To do so, simply run
220+
```julia
221+
using Pkg
222+
Pkg.add("Latexify")
223+
```
224+
after which Catalyst can be imported through `using Latexify`. You can get a list of all packages available in your current environment using:
225+
```julia
226+
Pkg.status()
227+
```
228+
229+
So, why is this required, and why cannot we simply import any package installed on our computer? The reason is that most packages depend on other packages, and these dependencies may be restricted to only specific versions of these packages. This creates complicated dependency graphs that restrict what versions of what packages are compatible with each other. When you use `Pkg.add("PackageName")`, only a specific version of that package is actually added (the latest possible version as permitted by the dependency graph). Here, Julia environments both define what packages are available *and* their respective versions (these versions are also displayed by the `Pkg.status()` command). By doing this, Julia can guarantee that the packages (and their versions) specified in an environment are compatible with each other.
230+
231+
The reason why all this is important is that it is *highly recommended* to, for each project, define a separate environment. To these, only add the required packages. General-purpose environments with a large number of packages often produce package-incompatibility issues. While these might not prevent you from installing all desired package, they often mean that you are unable to use the latest version of some packages.
232+
233+
!!! note
234+
A not-infrequent cause for reported errors with Catalyst (typically the inability to replicate code in tutorials) is package incompatibilities in large environments preventing the latest version of Catalyst from being installed. Hence, whenever an issue is encountered, it is useful to run `Pkg.status()` to check whenever the latest version of Catalyst is being used.
235+
236+
Some additional useful Pkg commands are:
237+
- `Pk.rm("PackageName")` removes a package from the current environment.
238+
- `Pkg.update(PackageName")`: updates the designated package.
239+
240+
!!! note
241+
A useful feature of Julia's environment system is that enables the exact definition of what packages and versions were used to execute a script. This supports e.g. reproducibility in academic research. Here, by providing the corresponding Project.toml and Manifest.toml files, you can enable someone to reproduce the exact program just to perform some set of analyses.
242+
243+
234244
---
235245
## Feedback
236246
If you are a new Julia user who has used this tutorial, and there was something you struggled with or would have liked to have explained better, please [raise an issue](https://github.com/SciML/Catalyst.jl/issues). That way, we can continue improving this tutorial.

0 commit comments

Comments
 (0)