Thanks Fredrik. This is very helpful.

After experimenting, I could now update the force data vector continuously with the `Ref`

approach, but seems it needs to reference a global variable rdata and dt. Is there anyway to still use the `TimeVaryingFunction`

component and somehow pass a `get_sampled_data(t; dt, rdata)`

function with `dt`

and `rdata`

set?

I also tried `SampledData`

component but got stuck at the remaking ODE problem part.

My `update_prob`

function looks like below

```
function update_prob(prob, u_last, data, dt; sys, defs)
defs[sys.driver.buffer] = Parameter(data, dt)
# ensure p is a uniform type of Vector{Parameter{Float64}} (converting from Vector{Any})
u_new = ModelingToolkit.varmap_to_vars([capacitor.v=>u_last], unknowns(sys))
p = ModelingToolkit.MTKParameters(sys, defs, u_new; tofloat = false)
remake(prob; p)
end
```

My for loop now looks like

```
sys = structural_simplify(rc_model)
defs = ModelingToolkit.defaults(sys)
prob = ODEProblem(sys_sim, [capacitor.v=>0.0], (0, tend), saveat=dt)
vc_last = 0.0
@time for n = 1:10
#dummy clock signal
vin = [vin_last; kron(kron(ones(Int(nsym/2)), [-1, 1]), ones(osr))]
prob = update_prob(prob, vc_last, vin, dt; sys, defs)
sol = solve(prob, ImplicitEuler(), adaptive=false, dt=dt)
vc_last = sol[capacitor.v][end]
vin_last = vin[end]
#plotting to see how the boundary looks like between each iteration
lines!(ax, n*tend .+ tt[2:end], sol[capacitor.v][2:end])
end
```

I get the following error

```
caused by: MethodError: no method matching Parameter(::Parameter{Float64}, ::Float64, ::Bool)
Closest candidates are:
Parameter(::SymbolicUtils.Symbolic{<:Vector}, ::Real, ::Bool)
@ ModelingToolkitStandardLibrary C:\Users\Kevin Z\.julia\packages\Symbolics\PAFGz\src\wrapper-types.jl:140
Parameter(::Vector{T}, ::T, ::Bool) where T<:Real
@ ModelingToolkitStandardLibrary C:\Users\Kevin Z\.julia\packages\ModelingToolkitStandardLibrary\OIKXb\src\Blocks\sources.jl:449
Parameter(::Symbolics.Arr{<:Any, 1}, ::Real, ::Bool)
@ ModelingToolkitStandardLibrary C:\Users\Kevin Z\.julia\packages\Symbolics\PAFGz\src\wrapper-types.jl:140
...
Stacktrace:
[1] fast_substitute(expr::SymbolicUtils.BasicSymbolic{Real}, subs::Dict{Any, Any}; operator::Type)
@ Symbolics C:\Users\Kevin Z\.julia\packages\Symbolics\PAFGz\src\variable.jl:489
[2] fast_substitute
@ C:\Users\Kevin Z\.julia\packages\Symbolics\PAFGz\src\variable.jl:473 [inlined]
[3] fixpoint_sub(x::SymbolicUtils.BasicSymbolic{Real}, dict::Dict{Any, Any}; operator::Type)
@ Symbolics C:\Users\Kevin Z\.julia\packages\Symbolics\PAFGz\src\variable.jl:429
[4] fixpoint_sub(x::SymbolicUtils.BasicSymbolic{Real}, dict::Dict{Any, Any})
@ Symbolics C:\Users\Kevin Z\.julia\packages\Symbolics\PAFGz\src\variable.jl:428
[5] (::ModelingToolkit.var"#115#126"{Dict{Any, Any}})(::Pair{Any, Any})
@ ModelingToolkit .\none:0
[6] iterate
@ .\generator.jl:47 [inlined]
[7] grow_to!(dest::Dict{…}, itr::Base.Generator{…}, st::Int64)
@ Base .\dict.jl:131
[8] grow_to!(dest::Dict{Any, Any}, itr::Base.Generator{Dict{Any, Any}, ModelingToolkit.var"#115#126"{Dict{Any, Any}}})
@ Base .\dict.jl:125
[9] dict_with_eltype
@ .\abstractdict.jl:590 [inlined]
[10] Dict(kv::Base.Generator{Dict{Any, Any}, ModelingToolkit.var"#115#126"{Dict{Any, Any}}})
@ Base .\dict.jl:109
[11] ModelingToolkit.MTKParameters(sys::ODESystem, p::Dict{Any, Any}, u0::Vector{Float64}; tofloat::Bool, use_union::Bool)
@ ModelingToolkit C:\Users\Kevin Z\.julia\packages\ModelingToolkit\IVr5X\src\systems\parameter_buffer.jl:94
[12] update_prob(prob::ODEProblem{…}, u_last::Float64, data::Vector{…}, dt::Float64; sys::ODESystem, defs::Dict{…})
@ Main c:\JuliaWS\mtk_test\mtk_test.jl:37
[13] macro expansion
@ c:\JuliaWS\mtk_test\mtk_test.jl:93 [inlined]
[14] macro expansion
@ .\timing.jl:279 [inlined]
[15] top-level scope
@ c:\JuliaWS\mtk_test\mtk_test.jl:90
Some type information was truncated. Use `show(err)` to see complete types.
```

Not sure I am regenerating the parameter maps correctly