Skip to content

Commit 96f0b94

Browse files
authored
Update docs (#416)
1 parent 3112fb1 commit 96f0b94

13 files changed

+57
-57
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](http://mtk.sciml.ai/stable/)
77
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](http://mtk.sciml.ai/dev/)
88

9-
ModelingToolkit.jl is a modeling framework for high performance symbolic-numeric computation
9+
ModelingToolkit.jl is a modeling framework for high-performance symbolic-numeric computation
1010
in scientific computing and scientific machine learning.
1111
It allows for users to give a high-level description of a model for
1212
symbolic preprocessing to analyze and enhance the model. ModelingToolkit can
@@ -18,11 +18,11 @@ to the model to make it easier for numerical solvers to handle.
1818
For information on using the package,
1919
[see the stable documentation](https://mtk.sciml.ai/stable/). Use the
2020
[in-development documentation](https://mtk.sciml.ai/dev/) for the version of
21-
the documentation which contains the un-released features.
21+
the documentation which contains the unreleased features.
2222

23-
## High Level Examples
23+
## High-Level Examples
2424

25-
First let's define a second order riff on the Lorenz equations, symbolically
25+
First, let's define a second order riff on the Lorenz equations, symbolically
2626
lower it to a first order system, symbolically generate the Jacobian function
2727
for the numerical integrator, and solve it.
2828

@@ -59,8 +59,8 @@ using Plots; plot(sol,vars=(x,y))
5959

6060
This automatically will have generated fast Jacobian functions, making
6161
it more optimized than directly building a function. In addition, we can then
62-
use ModelingToolkit to compose multiple ODE subsystems. Now let's define two
63-
interacting Lorenz equations and simulate the resulting Differential-Algebriac
62+
use ModelingToolkit to compose multiple ODE subsystems. Now, let's define two
63+
interacting Lorenz equations and simulate the resulting Differential-Algebraic
6464
Equation (DAE):
6565

6666
```julia

docs/src/IR.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
ModelingToolkit IR, which falls under the `Expression` abstract type, mirrors
44
the Julia AST but allows for easy mathematical manipulation by itself following
5-
mathematical semantics. The base of the IR is the `Variable` type which defines
5+
mathematical semantics. The base of the IR is the `Variable` type, which defines
66
a symbolic variable. These variables are combined using `Operation`s, which are
77
registered functions applied to the various variables. These `Operation`s then
88
perform automatic tracing, so normal mathematical functions applied to an `Operation`
99
generate a new `Operation`. For example, `op1 = x+y` is one `Operation` and
10-
`op2 = 2z` is another, and so `op1*op2` is another `Operation`. Then at the top,
10+
`op2 = 2z` is another, and so `op1*op2` is another `Operation`. Then, at the top,
1111
an `Equation`, normally written as `op1 ~ op2`, defines the symbolic equality
1212
between two operations.
1313

@@ -24,7 +24,7 @@ Equation
2424
### Function Registration
2525

2626
The ModelingToolkit graph only allowed for registered Julia functions for the
27-
operations. All other functions are automatically traced down to registred
27+
operations. All other functions are automatically traced down to registered
2828
functions. By default, ModelingToolkit.jl pre-registers the common functions
2929
utilized in the AD package ruleset [DiffRules.jl](https://github.com/JuliaDiff/DiffRules.jl)
3030
and pre-defines their derivatives. However, the user can utilize the `@register`
@@ -36,8 +36,8 @@ macro to add their function to allowed functions of the computation graph.
3636

3737
### Derivatives and Differentials
3838

39-
A `Differential(op)` is a partial derivative with respect to the operation `op`
40-
which can then be applied to some other operations. For example `D=Differential(t)`
39+
A `Differential(op)` is a partial derivative with respect to the operation `op`,
40+
which can then be applied to some other operations. For example, `D=Differential(t)`
4141
is what would commonly be referred to as `d/dt`, which can then be applied to
4242
other operations using its function call, so `D(x+y)` is `d(x+y)/dt`.
4343

@@ -55,7 +55,7 @@ ModelingToolkit.jacobian
5555
ModelingToolkit.hessian
5656
```
5757

58-
Note that generation of sparse matrices simply follows from the Julian semantics
58+
Note that the generation of sparse matrices simply follows from the Julia semantics
5959
imbued on the IR, so `sparse(jac)` changes a dense Jacobian to a sparse Jacobian
6060
matrix.
6161

@@ -64,7 +64,7 @@ matrix.
6464
There is a large amount of derivatives pre-defined by
6565
[DiffRules.jl](https://github.com/JuliaDiff/DiffRules.jl). Note that `Expression`
6666
types are defined as `<:Real`, and thus any functions which allow the use of real
67-
numbers can automatically be traced by the derivative mechanism. Thus for example:
67+
numbers can automatically be traced by the derivative mechanism. Thus, for example:
6868

6969
```julia
7070
f(x,y,z) = x^2 + sin(x+y) - z
@@ -86,7 +86,7 @@ ModelingToolkit.derivative(::typeof(my_function), args::NTuple{N,Any}, ::Val{i})
8686
```
8787

8888
where `i` means that it's the derivative of the `i`th argument. `args` is the
89-
array of arguments, so for example if your function is `f(x,t)` then `args = [x,t]`.
89+
array of arguments, so, for example, if your function is `f(x,t)`, then `args = [x,t]`.
9090
You should return an `Operation` for the derivative of your function.
9191

9292
For example, `sin(t)`'s derivative (by `t`) is given by the following:
@@ -102,7 +102,7 @@ types. Most of the functionality comes by the `Expression` type obeying the
102102
standard mathematical semantics. For example, if one has `A` a matrix of
103103
`Expression`, then `A^2` calculates the `Expression`s for the squared matrix.
104104
In that sense, it is encouraged that one uses standard Julia for performing a
105-
lot of the manipulation on the IR, as for example calculating the sparse form
105+
lot of the manipulation on the IR, as, for example, calculating the sparse form
106106
of the matrix via `sparse(A)` is valid, legible, and easily understandable
107107
to all Julia programmers.
108108

@@ -124,7 +124,7 @@ like those for differential equation solvers and optimization libraries.
124124

125125
Additionally, the core compilation process of ModelingToolkit IR is `build_function`.
126126
`build_function` takes an operation or an `AbstractArray` of operations and
127-
generates a compile-able version of the model for numerical solvers.
127+
generates a compilable version of the model for numerical solvers.
128128

129129
```@docs
130130
build_function

docs/src/highlevel.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# High Level API
22

3-
The high level API allows modelers to interactively build models in a symbolic
3+
The high-level API allows modelers to interactively build models in a symbolic
44
manner. It is designed as a semi-DSL for easily building large complex models
5-
and manipulating the models to generate optimal forms for utilizing in numerical
5+
and manipulating the models to generate optimal forms to be used in numerical
66
methods.
77

88
## Examples
99

1010
### Example 1: Symbolically Building an ODEProblem for DifferentialEquations.jl
1111

12-
Let's build an ODE. First we define some variables. In a differential equation
12+
Let's build an ODE. First, we define some variables. In a differential equation
1313
system, we need to differentiate between our (dependent) variables
14-
and parameters. Therefore we label them as follows:
14+
and parameters. Therefore, we label them as follows:
1515

1616
```julia
1717
using ModelingToolkit
@@ -73,7 +73,7 @@ connections = [0 ~ lorenz1.x + lorenz2.y + sin(α*γ)]
7373
connected = ODESystem(connections,[α],[γ],systems=[lorenz1,lorenz2])
7474
```
7575

76-
which is now a differential-algebraic equation (DAE) of 7 variables which has
76+
which is now a differential-algebraic equation (DAE) of 7 variables, which has
7777
two independent Lorenz systems and an algebraic equation that determines `α`
7878
such that an implicit constraint holds. We can then define the resulting
7979
`ODEProblem` and send it over to DifferentialEquations.jl.
@@ -169,7 +169,7 @@ which gives:
169169
end)
170170
```
171171

172-
Now we can call `nlsolve` by enclosing our parameters into the functions:
172+
Now, we can call `nlsolve` by enclosing our parameters into the functions:
173173

174174
```julia
175175
using NLsolve
@@ -184,9 +184,9 @@ generate the function, i.e.:
184184
nlsys_func = generate_function(ns, [x,y,z], [σ,ρ,β], expression=Val{false})[2]
185185
```
186186

187-
which uses GeneralizedGenerated.jl to build a same world-age function on the fly without eval.
187+
which uses GeneralizedGenerated.jl to build the same world-age function on the fly without eval.
188188

189-
## High Level API Documentation
189+
## High-Level API Documentation
190190

191191
```@docs
192192
@parameters
@@ -195,14 +195,14 @@ which uses GeneralizedGenerated.jl to build a same world-age function on the fly
195195
Base.:~(::Expression, ::Expression)
196196
```
197197

198-
## Additional High Level Explanations and Tips
198+
## Additional High-Level Explanations and Tips
199199

200200
### The Auto-Detecting System Constructors
201201

202-
For the high level interface, the system constructors such as `ODESystem` have
203-
high level constructors which just take in the required equations and automatically
202+
For the high-level interface, the system constructors, such as `ODESystem`, have
203+
high-level constructors, which just take in the required equations and automatically
204204
parse the expressions to figure out the states and parameters of the system.
205-
The following high level constructors exist:
205+
The following high-level constructors exist:
206206

207207
```julia
208208
ODESystem(eqs)
@@ -211,7 +211,7 @@ NonlinearSystem(eqs)
211211

212212
### Direct Tracing
213213

214-
Because the ModelingToolkit `Expression` types obey Julia-semantics, one can
214+
Because the ModelingToolkit `Expression` types obey Julia semantics, one can
215215
directly transform existing Julia functions into ModelingToolkit symbolic
216216
representations of the function by simply inputting the symbolic values into
217217
the function and using what is returned. For example, let's take the following
@@ -282,7 +282,7 @@ multithreadedjac = eval(ModelingToolkit.build_function(vec(jac),u,multithread=tr
282282
### modelingtoolkitize
283283

284284
For some `DEProblem` types, automatic tracing functionality is already included
285-
via the `modelingtoolkitize` function. Take for example the Robertson ODE
285+
via the `modelingtoolkitize` function. Take, for example, the Robertson ODE
286286
defined as an `ODEProblem` for DifferentialEquations.jl:
287287

288288
```julia
@@ -299,7 +299,7 @@ prob = ODEProblem(rober,[1.0,0.0,0.0],(0.0,1e5),(0.04,3e7,1e4))
299299
```
300300

301301
If we want to get a symbolic representation, we can simply call `modelingtoolkitize`
302-
on the `prob` which will return an `ODESystem`:
302+
on the `prob`, which will return an `ODESystem`:
303303

304304
```julia
305305
sys = modelingtoolkitize(prob)

docs/src/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ModelingToolkit.jl
22

3-
ModelingToolkit.jl is a modeling language for high performance
4-
symbolic-numeric computation in scientific computing and scientific machine learning.
3+
ModelingToolkit.jl is a modeling language for high-performance
4+
symbolic-numeric computation in scientific computing and scientific machine learning.
55
It allows for users to give a high-level description of a model for
66
symbolic preprocessing to analyze and enhance the model. ModelingToolkit can
77
automatically generate fast functions for model components like Jacobians
@@ -20,10 +20,10 @@ ModelingToolkit has 3 layers:
2020
ModelingToolkit models directly from Julia code.
2121
2. The `AbstractSystem` level. This is the level where content-dependent functionality
2222
is added, where models such an ordinary differential equation are represented.
23-
At the system level there are *transformations* which take one system to
23+
At the system level, there are *transformations* which take one system to
2424
another, and *targets* which output code for numerical solvers.
2525
3. The IR level, also referred to as the direct level. At this level, one
26-
directly acts on arrays of `Equation`, `Operation` and `Variable` types to
26+
directly acts on arrays of `Equation`, `Operation`, and `Variable` types to
2727
generate functions.
2828

2929
Each level above is built on the level below, giving more context to allow for

docs/src/systems/AbstractSystem.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Each `AbstractSystem` has lists of variables in context, such as distinguishing
1313
parameters vs states. In addition, an `AbstractSystem` also can hold other
1414
`AbstractSystem` types. Direct accessing of the values, such as `sys.states`,
1515
gives the immediate list, while the accessor functions `states(sys)` gives the
16-
total set which includes that of all systems held inside.
16+
total set, which includes that of all systems held inside.
1717

1818
The values which are common to all `AbstractSystem`s are:
1919

@@ -25,9 +25,9 @@ The values which are common to all `AbstractSystem`s are:
2525
## Transformations
2626

2727
Transformations are functions which send a valid `AbstractSystem` definition to
28-
another `AbstractSystem`. These are passes like optimizations (ex: Block-Lower
29-
Triangle transformations) or changes to the representation which allow for
30-
alternative numerical methods to be utilized on the model (ex: DAE index reduction).
28+
another `AbstractSystem`. These are passes, like optimizations (e.g., Block-Lower
29+
Triangle transformations), or changes to the representation, which allow for
30+
alternative numerical methods to be utilized on the model (e.g., DAE index reduction).
3131

3232
## Function Calculation and Generation
3333

@@ -36,8 +36,8 @@ quantities to enhance the numerical methods applied to the resulting system.
3636
The calculations, like `calculate_jacobian`, generate ModelingToolkit IR for
3737
the Jacobian of the system, while the generations, like `generate_jacobian`,
3838
generate compiled output for the numerical solvers by applying `build_function`
39-
to the generated code. Additionally, many systems have function type outputs
40-
which cobble together the generation functionality for a system, for example
39+
to the generated code. Additionally, many systems have function-type outputs,
40+
which cobble together the generation functionality for a system, for example,
4141
`ODEFunction` can be used to generate a DifferentialEquations-based `ODEFunction`
4242
with compiled version of the ODE itself, the Jacobian, the mass matrix, etc.
4343

@@ -63,6 +63,6 @@ which allow for directly generating the problem types required for numerical
6363
methods. The first argument is always the `AbstractSystem`, and the proceeding
6464
arguments match the argument order of their original constructors. Whenever an
6565
array would normally be provided, such as `u0` the initial condition of an
66-
`ODEProblem`, it is instead replaced with a variable map, i.e. an array of
67-
pairs `var=>value` which allows the user to designate the values without having
66+
`ODEProblem`, it is instead replaced with a variable map, i.e., an array of
67+
pairs `var=>value`, which allows the user to designate the values without having
6868
to know the order that ModelingToolkit is internally using.

docs/src/systems/ReactionSystem.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ReactionSystem
22

3-
A `ReactionSystem` represents a system of chemical reactions. Conversions are provided to generate corresponding chemical reaction ODE models, chemical Langevin equation SDE models, and stochastic chemical kinetics jump process models. As a simple example, the code below creates a SIR model, and solves the corresponding ODE, SDE and jump process models.
3+
A `ReactionSystem` represents a system of chemical reactions. Conversions are provided to generate corresponding chemical reaction ODE models, chemical Langevin equation SDE models, and stochastic chemical kinetics jump process models. As a simple example, the code below creates a SIR model, and solves the corresponding ODE, SDE, and jump process models.
44

55
```julia
66
using ModelingToolkit, OrdinaryDiffEq, StochasticDiffEq, DiffEqJump
@@ -56,4 +56,4 @@ ismassaction
5656

5757
```@docs
5858
Base.convert
59-
```
59+
```

src/build_function.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ struct DistributedForm <: ParallelForm end
1414
1515
Generates a numerically-usable function from a ModelingToolkit `Expression`.
1616
If the `Expression` is an `Operation`, the generated function is a function
17-
with a scalar output, otherwise if it's an `AbstractArray{Operation}` the output
17+
with a scalar output, otherwise if it's an `AbstractArray{Operation}`, the output
1818
is two functions, one for out-of-place AbstractArray output and a second which
1919
is a mutating function. The outputted functions match the given argument order,
20-
i.e. f(u,p,args...) for the out-of-place and scalar functions and
20+
i.e., f(u,p,args...) for the out-of-place and scalar functions and
2121
`f!(du,u,p,args..)` for the in-place version.
2222
2323
```julia
@@ -38,7 +38,7 @@ Arguments:
3838
- `expression`: Whether to generate code or whether to generate the compiled form.
3939
By default, `expression = Val{true}`, which means that the code for the
4040
function is returned. If `Val{false}`, then the returned value is a compiled
41-
Julia function which utilizes GeneralizedGenerated.jl in order to world-age
41+
Julia function, which utilizes GeneralizedGenerated.jl in order to world-age
4242
free.
4343
4444
Keyword Arguments:

src/differentials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ julia> ModelingToolkit.derivative(sin(x), 1)
7676
cos(x())
7777
```
7878
79-
Note that the function does not recurse into the operation's arguments, i.e. the
79+
Note that the function does not recurse into the operation's arguments, i.e., the
8080
chain rule is not applied:
8181
8282
```jldoctest label1

src/equations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ An equality relationship between two expressions.
77
$(FIELDS)
88
"""
99
struct Equation
10-
"""The expression on the left hand side of the equation."""
10+
"""The expression on the left-hand side of the equation."""
1111
lhs::Expression
12-
"""The expression on the right hand side of the equation."""
12+
"""The expression on the right-hand side of the equation."""
1313
rhs::Expression
1414
end
1515
Base.:(==)(a::Equation, b::Equation) = isequal((a.lhs, a.rhs), (b.lhs, b.rhs))

src/function_registration.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
$(SIGNATURES)
44
5-
Registers a function call as a primative for the `Operation` graph of the
5+
Registers a function call as a primitive for the `Operation` graph of the
66
ModelingToolkit IR. Example:
77
88
```julia

src/latexify_recipes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
env --> :align
44
cdot --> false
55

6-
# Convert both the left and right hand side to expressions of basic types
6+
# Convert both the left- and right-hand sides to expressions of basic types
77
# that latexify can deal with.
88

99
rhs = getfield.(eqs, :rhs)

src/operations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Base.isequal(::Operation, ::Constant ) = false
5555
Base.isequal(::Constant , ::Operation) = false
5656

5757
# provide iszero for Operations to help sparse addition and multiplication
58-
# e.g. we want to tell the sparse library that iszero(zero(Operation) + zero(Operation)) == true
58+
# e.g., we want to tell the sparse library that iszero(zero(Operation) + zero(Operation)) == true
5959
Base.iszero(x::Operation) = (_x = simplify(x); _x isa Constant && iszero(_x.value))
6060

6161
Base.show(io::IO, O::Operation) = print(io, convert(Expr, O))

src/variables.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ as equal.
2525
$(FIELDS)
2626
2727
For example, the following code defines an independent variable `t`, a parameter
28-
`α`, a function parameter `σ`, a variable `x` which depends on `t`, a variable
29-
`y` with no dependents, a variable `z` which depends on `t`, `α`, and `x(t)`
30-
and a parameters `β₁` and `β₂`.
28+
`α`, a function parameter `σ`, a variable `x`, which depends on `t`, a variable
29+
`y` with no dependents, a variable `z`, which depends on `t`, `α`, and `x(t)`
30+
and parameters `β₁` and `β₂`.
3131
3232
3333
```julia

0 commit comments

Comments
 (0)