@@ -49,7 +49,7 @@ function friction_true()
4949 eqs = [
5050 Dt(y) ~ Fu - friction(y)
5151 ]
52- return ODESystem (eqs, t, name = :friction_true)
52+ return System (eqs, t, name = :friction_true)
5353end
5454```
5555
@@ -58,7 +58,7 @@ Now that we have defined the model, we will simulate it from 0 to 0.1 seconds.
5858``` @example friction
5959model_true = structural_simplify(friction_true())
6060prob_true = ODEProblem(model_true, [], (0, 0.1), [])
61- sol_ref = solve(prob_true, Rodas4 (); saveat = 0.001)
61+ sol_ref = solve(prob_true, Vern7 (); saveat = 0.001)
6262```
6363
6464Let's plot it.
@@ -85,7 +85,7 @@ function friction_ude(Fu)
8585 @named nn_out = RealOutputArray(nout = 1)
8686 eqs = [Dt(y) ~ Fu - nn_in.u[1]
8787 y ~ nn_out.u[1]]
88- return ODESystem (eqs, t, name = :friction, systems = [nn_in, nn_out])
88+ return System (eqs, t, name = :friction, systems = [nn_in, nn_out])
8989end
9090
9191Fu = 120.0
@@ -98,8 +98,8 @@ chain = Lux.Chain(
9898)
9999@named nn = NeuralNetworkBlock(1, 1; chain = chain, rng = StableRNG(1111))
100100
101- eqs = [connect(model.nn_in, nn.output)
102- connect(model.nn_out, nn.input)]
101+ eqs = [connect(model.nn_in.u , nn.output)
102+ connect(model.nn_out.u , nn.input)]
103103
104104ude_sys = complete(ODESystem(eqs, t, systems = [model, nn], name = :ude_sys))
105105sys = structural_simplify(ude_sys)
@@ -114,7 +114,7 @@ function loss(x, (prob, sol_ref, get_vars, get_refs, set_x))
114114 new_p = set_x(prob, x)
115115 new_prob = remake(prob, p = new_p, u0 = eltype(x).(prob.u0))
116116 ts = sol_ref.t
117- new_sol = solve(new_prob, Rodas4 (), saveat = ts, abstol = 1e-8, reltol = 1e-8)
117+ new_sol = solve(new_prob, Vern7 (), saveat = ts, abstol = 1e-8, reltol = 1e-8)
118118 loss = zero(eltype(x))
119119 for i in eachindex(new_sol.u)
120120 loss += sum(abs2.(get_vars(new_sol, i) .- get_refs(sol_ref, i)))
@@ -126,7 +126,7 @@ function loss(x, (prob, sol_ref, get_vars, get_refs, set_x))
126126 end
127127end
128128
129- of = OptimizationFunction{true} (loss, AutoForwardDiff())
129+ of = OptimizationFunction(loss, AutoForwardDiff())
130130
131131prob = ODEProblem(sys, [], (0, 0.1), [])
132132get_vars = getu(sys, [sys.friction.y])
0 commit comments