Skip to content

Commit

Permalink
fix typos & avoid running SampledData for now
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianM-C committed Oct 20, 2024
1 parent 2ee5ecd commit 95c24d8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/src/tutorials/input_component.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function MassSpringDamper(; name)
D(x) ~ dx
D(dx) ~ ddx]
ODESystem(eqs, t, [], []; name, systems = [input])
ODESystem(eqs, t; name, systems = [input])
end
function MassSpringDamperSystem(data, time; name)
Expand Down Expand Up @@ -122,7 +122,7 @@ function MassSpringDamperSystem(data, time; name)
connect(src.input, clk.output)
]
ODESystem(eqs, t, [], []; name, systems = [src, clk, model])
ODESystem(eqs, t; name, systems = [src, clk, model])
end
function generate_data()
Expand Down Expand Up @@ -217,7 +217,7 @@ Additional code could be added to resolve this issue, for example by using a `Re

To resolve the issues presented above, the `ModelingToolkitStandardLibrary.Blocks.SampledData` component can be used which allows for a resusable `ODESystem` and self contained data which ensures a solution which remains valid for it's lifetime. Now it's possible to also parallelize the call to `solve()`.

```@example sampled_data_component
```julia
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
using ModelingToolkitStandardLibrary.Blocks
Expand Down Expand Up @@ -246,14 +246,14 @@ time = 0:dt:0.1
data1 = sin.(2 * pi * time * 100)
data2 = cos.(2 * pi * time * 50)

prob = ODEProblem(sys, [], (0, time[end]); tofloat = false, use_union=true)
prob = ODEProblem(sys, [], (0, time[end]); split=false, tofloat = false, use_union=true)
defs = ModelingToolkit.defaults(sys)

function get_prob(data)
defs[s.src.buffer] = Parameter(data, dt)
# ensure p is a uniform type of Vector{Parameter{Float64}} (converting from Vector{Any})
p = Parameter.(ModelingToolkit.varmap_to_vars(defs, parameters(sys); tofloat = false))
remake(prob; p)
remake(prob; p, build_initializeprob=false)
end

prob1 = get_prob(data1)
Expand Down

0 comments on commit 95c24d8

Please sign in to comment.