Skip to content

Commit 45178b7

Browse files
doc improvements
1 parent 36d2b5c commit 45178b7

File tree

11 files changed

+148
-38
lines changed

11 files changed

+148
-38
lines changed

docs/src/systems/AbstractSystem.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ 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

44+
Below are the possible calculation and generation functions:
45+
46+
```@docs
47+
calculate_tgrad
48+
calculate_grad
49+
calculate_jacobian
50+
calculate_factorized_W
51+
calculate_hessian
52+
generate_jacobian
53+
generate_grad
54+
generate_tgrad
55+
generate_factorized_W
56+
generate_hessian
57+
```
58+
4459
## Problem Constructors
4560

4661
At the end, the system types have `DEProblem` constructors, like `ODEProblem`,

docs/src/systems/NonlinearSystem.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ NonlinearSystem
1414

1515
## Transformations
1616

17-
## Function Calculation and Generation
17+
## Applicable Calculation and Generation Functions
1818

19-
```@docs
19+
```julia
2020
calculate_jacobian
2121
generate_jacobian
2222
```

docs/src/systems/ODESystem.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ ODESystem
1919
ode_order_lowering
2020
```
2121

22-
## Function Calculation and Generation
22+
## Applicable Calculation and Generation Functions
2323

24-
```@docs
24+
```julia
2525
calculate_jacobian
2626
calculate_tgrad
2727
calculate_factorized_W
2828
generate_jacobian
2929
generate_tgrad
3030
generate_factorized_W
31-
ODEFunction
3231
```
3332

3433
## Problem Constructors
3534

3635
```@docs
36+
ODEFunction
3737
ODEProblem
3838
```

docs/src/systems/OptimizationSystem.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ OptimizationSystem
1414

1515
## Transformations
1616

17-
## Function Calculation and Generation
17+
## Applicable Calculation and Generation Functions
1818

19-
```@docs
19+
```julia
2020
calculate_grad
2121
calculate_hes
2222
generate_grad

docs/src/systems/SDESystem.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ SDESystem
1515

1616
## Transformations
1717

18-
## Function Calculation and Generation
18+
## Applicable Calculation and Generation Functions
1919

20-
```@docs
21-
calculate_jacobian(sys::ModelingToolkit.AbstractODESystem)
22-
calculate_tgrad(sys::ModelingToolkit.AbstractODESystem)
23-
calculate_factorized_W(sys::ModelingToolkit.AbstractODESystem, simplify)
20+
```julia
21+
calculate_jacobian
22+
calculate_tgrad
23+
calculate_factorized_W
2424
generate_jacobian
2525
generate_tgrad
2626
generate_factorized_W
27-
SDEFunction
2827
```
2928

3029
## Problem Constructors
3130

3231
```@docs
32+
SDEFunction
3333
SDEProblem
3434
```

src/ModelingToolkit.jl

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,6 @@ Base.one(::Type{<:Expression}) = Constant(1)
3535
"""
3636
$(TYPEDSIGNATURES)
3737
38-
Calculate the jacobian matrix of a system.
39-
40-
Returns a matrix of [`Expression`](@ref) instances. The result from the first
41-
call will be cached in the system object.
42-
"""
43-
function calculate_jacobian end
44-
45-
"""
46-
$(TYPEDSIGNATURES)
47-
48-
Generate a function to calculate the Jacobian of the system.
49-
"""
50-
function generate_jacobian end
51-
52-
"""
53-
$(TYPEDSIGNATURES)
54-
55-
Generate a function to evaluate the system's equations.
56-
"""
57-
function generate_function end
58-
59-
"""
60-
$(TYPEDSIGNATURES)
61-
6238
Get the set of independent variables for the given system.
6339
"""
6440
function independent_variables end

src/simplify.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ function simplify_constants(O::Operation, shorten_tree)
99
end
1010
end
1111
simplify_constants(x, shorten_tree) = x
12+
13+
"""
14+
simplify_constants(x::Operation)
15+
16+
Simplifies the constants within an expression, for example removing equations
17+
multiplied by a zero and summing constant values.
18+
"""
1219
simplify_constants(x) = simplify_constants(x, true)
1320

1421
Base.isone(x::Operation) = x.op == one || x.op == Constant && isone(x.args)

src/systems/abstractsystem.jl

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,100 @@
1+
"""
2+
calculate_tgrad(sys::AbstractSystem)
3+
4+
Calculate the time gradient of a system.
5+
6+
Returns a vector of [`Expression`](@ref) instances. The result from the first
7+
call will be cached in the system object.
8+
"""
9+
function calculate_tgrad end
10+
11+
"""
12+
calculate_grad(sys::AbstractSystem)
13+
14+
Calculate the gradient of a scalar system.
15+
16+
Returns a vector of [`Expression`](@ref) instances. The result from the first
17+
call will be cached in the system object.
18+
"""
19+
function calculate_grad end
20+
21+
"""
22+
calculate_jacobian(sys::AbstractSystem)
23+
24+
Calculate the jacobian matrix of a system.
25+
26+
Returns a matrix of [`Expression`](@ref) instances. The result from the first
27+
call will be cached in the system object.
28+
"""
29+
function calculate_jacobian end
30+
31+
"""
32+
calculate_factorized_W(sys::AbstractSystem)
33+
34+
Calculate the factorized W-matrix of a system.
35+
36+
Returns a matrix of [`Expression`](@ref) instances. The result from the first
37+
call will be cached in the system object.
38+
"""
39+
function calculate_factorized_W end
40+
41+
"""
42+
calculate_hessian(sys::AbstractSystem)
43+
44+
Calculate the hessian matrix of a scalar system.
45+
46+
Returns a matrix of [`Expression`](@ref) instances. The result from the first
47+
call will be cached in the system object.
48+
"""
49+
function calculate_hessian end
50+
51+
"""
52+
generate_tgrad(sys::AbstractSystem, dvs = states(sys), ps = parameters(sys), expression = Val{true}; kwargs...)
53+
54+
Generates a function for the time gradient of a system. Extra arguments control
55+
the arguments to the internal [`build_function`](@ref) call.
56+
"""
57+
function generate_tgrad end
58+
59+
"""
60+
generate_grad(sys::AbstractSystem, dvs = states(sys), ps = parameters(sys), expression = Val{true}; kwargs...)
61+
62+
Generates a function for the gradient of a system. Extra arguments control
63+
the arguments to the internal [`build_function`](@ref) call.
64+
"""
65+
function generate_grad end
66+
67+
"""
68+
generate_jacobian(sys::AbstractSystem, dvs = states(sys), ps = parameters(sys), expression = Val{true}; sparse = false, kwargs...)
69+
70+
Generates a function for the jacobian matrix matrix of a system. Extra arguments control
71+
the arguments to the internal [`build_function`](@ref) call.
72+
"""
73+
function generate_jacobian end
74+
75+
"""
76+
generate_factorized_W(sys::AbstractSystem, dvs = states(sys), ps = parameters(sys), expression = Val{true}; sparse = false, kwargs...)
77+
78+
Generates a function for the factorized W-matrix matrix of a system. Extra arguments control
79+
the arguments to the internal [`build_function`](@ref) call.
80+
"""
81+
function generate_factorized_W end
82+
83+
"""
84+
generate_hessian(sys::AbstractSystem, dvs = states(sys), ps = parameters(sys), expression = Val{true}; sparse = false, kwargs...)
85+
86+
Generates a function for the hessian matrix matrix of a system. Extra arguments control
87+
the arguments to the internal [`build_function`](@ref) call.
88+
"""
89+
function generate_hessian end
90+
91+
"""
92+
generate_function(sys::AbstractSystem, dvs = states(sys), ps = parameters(sys), expression = Val{true}; kwargs...)
93+
94+
Generate a function to evaluate the system's equations.
95+
"""
96+
function generate_function end
97+
198
function Base.getproperty(sys::AbstractSystem, name::Symbol)
299
if name fieldnames(typeof(sys))
3100
return getfield(sys,name)

src/systems/diffeqs/sdesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function rename(sys::SDESystem,name)
151151
end
152152

153153
"""
154-
$(TYPEDEF)
154+
$(SIGNATURES)
155155
156156
Generates an SDEProblem from an SDESystem and allows for automatically
157157
symbolically calculating numerical enhancements.

src/utils.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ end
8181
is_singleton(e) = false
8282
is_singleton(e::Operation) = e.op isa Variable
8383

84+
"""
85+
get_variables(O::Operation)
86+
87+
Returns the variables in the Operation
88+
"""
8489
get_variables(e::Constant, vars = Operation[]) = vars
8590
function get_variables(e::Operation, vars = Operation[])
8691
if is_singleton(e)
@@ -92,6 +97,11 @@ function get_variables(e::Operation, vars = Operation[])
9297
end
9398

9499
# variable substitution
100+
"""
101+
substitute_expr!(expr::Operation, s::Pair{Operation, Operation})
102+
103+
Performs the substitution `Operation => Operation` on the `expr` Operation.
104+
"""
95105
substitute_expr!(expr::Constant, s::Pair{Operation, Operation}) = nothing
96106
function substitute_expr!(expr::Operation, s::Pair{Operation, Operation})
97107
if !is_singleton(expr)

0 commit comments

Comments
 (0)