Skip to content

Commit 4904be8

Browse files
committed
docs(Interpolation): add docs for the macro usage
1 parent a2f6426 commit 4904be8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/src/tutorials/input_component.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,35 @@ sol = solve(prob)
7474
plot(sol)
7575
```
7676

77+
Note that in the case of the `Interpolation` block, the `data` and the `time` act like
78+
structural parameters.
79+
80+
As such, we can also build the interpolation object outside of the model
81+
82+
```@example interpolation_block
83+
my_interpolation = LinearInterpolation(df.data, df.time)
84+
85+
@mtkmodel MassSpringDamperSystem2 begin
86+
@components begin
87+
src = Interpolation(itp=my_interpolation)
88+
clk = ContinuousClock()
89+
model = MassSpringDamper()
90+
end
91+
@equations begin
92+
connect(src.input, clk.output)
93+
connect(src.output, model.input)
94+
end
95+
end;
96+
@mtkbuild sys = MassSpringDamperSystem2()
97+
98+
prob = ODEProblem(sys, [], (0, df.time[end]))
99+
sol = solve(prob, Tsit5())
100+
plot(sol)
101+
```
102+
103+
Note that the interpolation is constructed outside of the model, so we cannot use `remake` to change the
104+
data. For that usecase, see the `ParametrizedInterpolation`.
105+
77106
## `ParametrizedInterpolation` Block
78107

79108
The `ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation` component is similar to `Interpolation`, but as the name suggests, it is parametrized by the data, allowing one to change the underlying data without rebuilding the model as the data is represented via vector parameters.

0 commit comments

Comments
 (0)