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: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
ProcessBasedModelling.jl is an extension to [ModelingToolkit.jl](https://docs.sciml.ai/ModelingToolkit/stable/) (MTK) for building a model of equations using symbolic expressions.
10
10
It is an alternative framework to MTK's [native component-based modelling](https://docs.sciml.ai/ModelingToolkit/stable/tutorials/acausal_components/), but, instead of components, there are "processes".
11
11
This approach is useful in the modelling of physical/biological/whatever systems, where each variable corresponds to a particular physical concept or observable and there are few (or none) duplicate variables to make the definition of MTK "factories" worthwhile.
12
-
On the other hand, there plenty of different physical representations, or _processes_ to represent a given physical concept.
12
+
On the other hand, there plenty of different physical representations, or _processes_ to represent a given physical concept in equation form.
13
13
In many scientific fields this approach parallels the modelling reasoning of the researcher more closely than the "components" approach.
14
14
15
15
Beyond this reasoning style, the biggest strength of ProcessBasedModelling.jl is the **informative errors and automation** it provides regarding incorrect/incomplete equations. When building the MTK model via ProcessBasedModelling.jl the user provides a vector of "processes": equations or custom types that have a well defined and single left-hand-side variable.
@@ -22,7 +22,7 @@ This allows ProcessBasedModelling.jl to:
22
22
- Else, throw an informative error saying exactly which originally provided variable introduced this new "process-less" variable.
23
23
3. Throw an informative error if a variable has two processes assigned to it (by mistake).
24
24
25
-
In our experience, and as we also highlight explicitly in the online documentation, this approach typically yields simpler, less ambiguous and more targeted warning or error messages than the native MTK one's, leading to faster identification and resolution of the problems with the composed equations.
25
+
In our experience, and as we also highlight explicitly in the online documentation, this approach typically yields simpler, less ambiguous, and more targeted warning or error messages than the native MTK one's. This leads to faster identification and resolution of the problems with the composed equations.
26
26
27
27
ProcessBasedModelling.jl is particularly suited for developing a model about a physical/biological/whatever system and being able to try various physical "rules" (couplings, feedbacks, mechanisms, ...) for a given physical observable efficiently.
28
28
This means switching arbitrarily between different processes that correspond to the same variable.
@@ -36,4 +36,4 @@ Besides the informative errors, ProcessBasedModelling.jl also
36
36
37
37
See the documentation online for details on how to use this package as well as examples highlighting its usefulness.
38
38
39
-
ProcessBasedModelling.jl development is funded by UKRI's Engineering and Physical Sciences Research Council, grant no. EP/Y01653X/1 (grant agreement for a EU Marie Sklodowska-Curie Postdoctoral Fellowship).
39
+
ProcessBasedModelling.jl development is funded by UKRI's Engineering and Physical Sciences Research Council, grant no. EP/Y01653X/1 (grant agreement for a EU Marie Sklodowska-Curie Postdoctoral Fellowship for George Datseris).
Copy file name to clipboardExpand all lines: docs/src/index.md
+28-8Lines changed: 28 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,10 +14,12 @@ ProcessBasedModelling
14
14
15
15
In ProcessBasedModelling.jl, each variable is governed by a "process".
16
16
Conceptually this is just an equation that _defines_ the given variable.
17
-
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 (or, simply if you want to utilize the conveniences of predefined processes).
18
-
In either case, the variable and the expression are both _symbolic expressions_ created via ModellingToolkit.jl (more specifically, via Symbolics.jl).
17
+
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 (or, simply if you want to utilize the conveniences of predefined processes).
18
+
In either case, the `variable` and the `expression` are both _symbolic expressions_ created via ModellingToolkit.jl.
19
19
20
-
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.
20
+
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`. `processes_to_mtkmodel` also defines what quantifies as a "process" in more specificity.
21
+
Then `processes_to_mtkmodel` ensures that all variables in the relational graph of your equations have a defining equation, or throws informative errors/warnings otherwise.
22
+
It also provides some useful automation, see the example below.
21
23
22
24
## Example
23
25
@@ -60,8 +62,13 @@ equations(model)
60
62
61
63
All good. Now, if we missed the process for one variable (because of our own error/sloppyness/very-large-codebase), MTK will throw an error when we try to _structurally simplify_ the model (a step necessary before solving the ODE problem):
62
64
63
-
```julia
65
+
```@example MAIN
66
+
# no errors:
64
67
model = ODESystem(eqs[1:2], t; name = :example)
68
+
```
69
+
70
+
```julia
71
+
# here is the error
65
72
model =structural_simplify(model)
66
73
```
67
74
```
@@ -92,7 +99,7 @@ Here is what the user defines to make the same system of equations via **PBM**:
Differential(t)(x) ~ 0.1*y, # defines x, introduces y; normal `Equation`
97
104
y ~ z - x, # defines y; normal `Equation`
98
105
]
@@ -108,15 +115,15 @@ equations(model)
108
115
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.
109
116
110
117
Now, in contrast to before, if we "forgot" a process, **PBM** will react accordingly.
111
-
For example, if we forgot the 2nd process, then the construction will error informatively,
118
+
For example, if we forgot the process for ``x``, then the construction will error informatively,
112
119
telling us exactly which variable is missing, and because of which processes it is missing:
113
120
```julia
114
121
model =processes_to_mtkmodel(processes[[1, 3]])
115
122
```
116
123
```
117
124
ERROR: ArgumentError: Variable x(t) was introduced in process of variable z(t).
118
125
However, a process for x(t) was not provided,
119
-
there is no default process for x(t), and (t)x doesn't have a default value.
126
+
there is no default process for x(t), and x(t) doesn't have a default value.
120
127
Please provide a process for variable x(t).
121
128
```
122
129
@@ -154,6 +161,10 @@ equations(model)
154
161
155
162
does not throw any warnings as it obtained a process for ``y`` from the given default processes.
156
163
164
+
!!! note "Default processes example"
165
+
The default process infrastructure of **PBM** is arguably its most powerful quality when it comes to building field-specific libraries. Its usefulness is illustrated in the derivative package [ConceptualClimateModels.jl](https://github.com/JuliaDynamics/ConceptualClimateModels.jl).
166
+
167
+
157
168
## Special handling of timescales
158
169
159
170
In dynamical systems modelling the timescale associated with a process is a special parameter. That is why, if a timescale is given for either the [`TimeDerivative`](@ref) or [`ExpRelaxation`](@ref) processes, it is converted to a named `@parameter` by default:
@@ -173,9 +184,18 @@ equations(model)
173
184
parameters(model)
174
185
```
175
186
187
+
Note the automatically created parameters ``\tau_x, \tau_z``.
176
188
This special handling is also why each process can declare a timescale via the [`ProcessBasedModelling.timescale`](@ref) function that one can optionally extend
177
189
(although in our experience the default behaviour covers almost all cases).
178
190
191
+
If you do not want this automation, you can opt out in two ways:
192
+
193
+
- Provide your own created parameter as the third argument in e.g., `ExpRelaxation`
194
+
- Wrap the numeric value into [`LiteralParameter`](@ref). This will insert the numeric literal into the equation.
195
+
196
+
See the section on [automatic parameters](@ref auto_params) for more related automation,
197
+
such as the macro [`@convert_to_parameters`](@ref) which can be particularly useful
0 commit comments