Skip to content

Commit 20d1ed4

Browse files
committed
Expand doc strings
1 parent 06343f0 commit 20d1ed4

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

src/runtime.jl

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ module Intrinsics
44
Scope, GenScope, ddt, epsilon
55

66
"""
7-
variable([name])
7+
variable([scope])
88
99
This intrinsic introduces a variable into the system of equations.
10-
It is an intrinsic so it gets replaced by DAECompiler in the optimization pass.
10+
Optionally takes a `scope` that may be used to symbolically refer to this variable
11+
in solution objects. The passed `scope` never affects the semantics of the system.
12+
If two variables are given the same `scope`, they remain semantically separate
13+
(but a warning is generated and they cannot be accessed symbolically in solution objects).
14+
15+
Variables are not guaranteed to become part "states", i.e. of the integrator state
16+
given to the numerical integrator. DAECompiler will automatically generate appropriate
17+
accessors to re-constitute eliminated variables from the integrator state using the
18+
equations of the system.
1119
"""
1220
function variable end
1321

@@ -28,10 +36,15 @@ module Intrinsics
2836
function observed! end
2937

3038
"""
31-
equation!(val, [name])
39+
equation!(val, [scope])
3240
33-
This intrinsic marks an equation. Specifically, once the system is lowered to an SSA form,
34-
equation! constrains the value of a given SSA variable to zero.
41+
This intrinsic marks an equation. The system of equations is considered satisfied when all
42+
`val`s passed to all `equation`s are equal to zero (up to tolerance).
43+
44+
Like all intrinsics, the `scope` argument is non-semantic and two `equation!` calls with
45+
the same `scope` will introduce separate equations. To build up one equation from multiple
46+
pieces, see the lower-level `equation` (no `!`) intrinsic. Note that `equation!(val, scope)`
47+
is equivalent to and implemented as `equation(scope)(val)`. It is provided for convenience.
3548
"""
3649
function equation! end
3750

@@ -115,10 +128,12 @@ module Intrinsics
115128
end
116129

117130
"""
118-
ddt
131+
ddt(x)
119132
120-
Exposes DAECompiler's demand-driven AD capabilities to user code. The return
121-
value of the function is `d/dt` of its argument.
133+
This intrinsic takes the total derivative of its argument with respect to the systems
134+
independent variable (i.e. `sim_time()`). There are no special semantic restrictions
135+
on `x`, although any expression that contributes to it must be AD-able (e.g. have registered
136+
ChainRules).
122137
"""
123138
function ddt end
124139

src/transform/dae_finish.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,17 @@ function dae_factory_gen(interp, ci::CodeInstance, key)
627627
return ir_factory
628628
end
629629

630+
"""
631+
dae_factory(f)
632+
633+
Given Julia function `f` compatible with DAECompiler's model representation, return a `DAEFunction`
634+
suitable for use with DAEProblem. The DAEFunction will be specific to the parameterization of `f`.
635+
To obtain a new parameterization, re-run this function. The runtime complexity of this function is
636+
at most equivalent to one ordinary evaluation of `f`, but this function may have significant
637+
compile-time cost (cached as usual for Julia code).
638+
"""
639+
function dae_factory end
640+
630641
function refresh()
631642
@eval function dae_factory(f)
632643
$(Expr(:meta, :generated_only))

0 commit comments

Comments
 (0)