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
* fix missing tanh test
* finish docs of Process
* rename notimevar to no timeder
* discuss default lhs
* correct doc reference page
* add correct stuff in docstrings
* finish docs
* GOOD EXPORTS
* note similarity with ODESystem construction
* ignore all errors to build docs
Copy file name to clipboardExpand all lines: docs/src/index.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ In ProcessBasedModelling.jl, each variable is governed by a "process".
12
12
Conceptually this is just an equation that _defines_ the given variable.
13
13
To couple the variable with the process it is governed by, a user either defines simple equations of the form "variable = expression", or creates an instance of [`Process`](@ref) if the left-hand-side of the equation needs to be anything more complex. In either case, the variable and the expression are both _symbolic expressions_ created via ModellingToolkit.jl (more specifically, via Symbolics.jl).
14
14
15
-
Once all the processes about the physical system are collected, they are given as a `Vector` to the [`processes_to_mtkmodel`](@ref) central function. This function also defines what quantifies as a "process" in more specificity.
15
+
Once all the processes about the physical system are collected, they are given as a `Vector` to the [`processes_to_mtkmodel`](@ref) central function, similarly to how one gives a `Vector` of `Equation`s to e.g., `ModelingToolkit.ODESystem`. This function also defines what quantifies as a "process" in more specificity.
16
16
17
17
## Example
18
18
@@ -30,6 +30,7 @@ symbolically using ModelingToolkit.jl (**MTK**). We define
30
30
using ModelingToolkit
31
31
using OrdinaryDiffEq: Tsit5
32
32
33
+
@variables t # independent variable
33
34
@variables z(t) = 0.0
34
35
@variables x(t) # no default value
35
36
@variables y(t) = 0.0
@@ -38,8 +39,6 @@ ProcessBasedModelling.jl (**PBM**) strongly recommends that all defined variable
38
39
39
40
To make the equations we want, we can use MTK directly, and call
40
41
```@example MAIN
41
-
@variables t
42
-
43
42
eqs = [
44
43
Differential(t)(z) ~ x^2 - z
45
44
Differential(x) ~ 0.1y
@@ -71,28 +70,26 @@ end
71
70
72
71
Interestingly, the error is wrong. ``x`` is defined and has an equation, at least on the basis of our scientific reasoning. However ``y`` that ``x`` introduced does not have an equation. Moreover, in our experience these errors messages become increasingly less useful when a model has many equations and/or variables, as many variables get cited as "missing" from the variable map even when only one should be.
73
72
74
-
**PBM** resolves these problems and always gives accurate error messages. This is because on top of the variable map that MTK constructs automatically, **PBM** requires the user to implicitly create a map of variables to processes that govern said variables. **PBM** creates the map automatically, the only thing the user has to do is to define the equations in terms of what [`processes_to_mtkmodel`](@ref) wants (which are either [`Process`](@ref)es or `Equation`s as above).
73
+
**PBM** resolves these problems and always gives accurate error messages. This is because on top of the variable map that MTK constructs automatically, **PBM** requires the user to implicitly provide a map of variables to processes that govern said variables. **PBM** creates the map automatically, the only thing the user has to do is to define the equations in terms of what [`processes_to_mtkmodel`](@ref) wants (which are either [`Process`](@ref)es or `Equation`s as above).
75
74
Here is what the user defines to make the same system of equations:
76
75
77
76
```@example MAIN
78
77
processes = [
79
-
ExpRelaxation(z, x^2), # introduces x variable
78
+
ExpRelaxation(z, x^2), # introduces x variable
80
79
TimeDerivative(x, 0.1*y), # introduces y variable
81
-
y ~ z-x, # can be an equation because LHS is single variable
80
+
y ~ z - x, # can be an equation because LHS is single variable
82
81
]
83
82
```
84
83
85
-
Internally, all of these
86
-
87
-
which is the given to
84
+
which is then given to
88
85
```@example MAIN
89
-
model = processes_to_mtkmodel(processes)
86
+
model = processes_to_mtkmodel(processes; name = :example)
90
87
equations(model)
91
88
```
92
89
93
-
Notice that the resulting **MTK** model is not `structural_simplify`-ed, to allow composing it with other models.
90
+
Notice that the resulting **MTK** model is not `structural_simplify`-ed, to allow composing it with other models. By default `t` is taken as the independent variable.
94
91
95
-
Now, in contrast to before, if we "forgot" a process, **PBM** will react accordingly. For example, we forgot the 2nd process, then the construction will error informatively, telling us exactly which variable is missing, and because of which processes it is missing:
92
+
Now, in contrast to before, if we "forgot" a process, **PBM** will react accordingly. For example, if we forgot the 2nd process, then the construction will error informatively, telling us exactly which variable is missing, and because of which processes it is missing:
96
93
```@example MAIN
97
94
try
98
95
model = processes_to_mtkmodel(processes[[1, 3]])
@@ -101,7 +98,7 @@ catch e
101
98
end
102
99
```
103
100
104
-
If instead we "forgot" the ``y`` process, **PBM** will not error, but instead warn, and make ``y`` a named parameter:
101
+
If instead we "forgot" the ``y`` process, **PBM** will not error, but instead warn, and make ``y``equal to a named parameter:
105
102
```@example MAIN
106
103
model = processes_to_mtkmodel(processes[1:2])
107
104
equations(model)
@@ -112,6 +109,7 @@ parameters(model)
112
109
```
113
110
114
111
Lastly, [`processes_to_mtkmodel`](@ref) also allows the concept of "default" processes, that can be used for introduced "process-less" variables.
112
+
Default processes like `processes` given as a 2nd argument to [`process_to_mtkmodel`](@ref).
115
113
For example,
116
114
117
115
```@example MAIN
@@ -163,14 +161,16 @@ This API describes how you can implement your own `Process` subtype, if the [exi
0 commit comments