@@ -171,22 +171,29 @@ hhmodel2 = @reaction_network hhmodel2 begin
171171end
172172```
173173Finally, we extend the ` hhmodel ` with the systems defining the ion channel currents
174- ``` julia
174+ ``` @example hh1
175175for sys in (IKmodel, INamodel, ILmodel)
176176 @named hhmodel2 = extend(sys, hhmodel2)
177177end
178178hhmodel2 = complete(hhmodel2)
179179```
180- Starting from the resting state, let's again solve the system when the amplitude
181- of the stimulus is non-zero and check we get the same figure as above . Note, we
182- now run ` structural_simplify ` from ModelingToolkit as part of building the
183- ` ODEProblem ` to eliminate the algebraic equations for the currents
180+ Let's again solve the system for the resting state, and then solve with the same
181+ applied current as above (to verify we get the same figure) . Note, we now
182+ explicitly convert to an ` ODESystem ` and then run ` structural_simplify ` from
183+ ModelingToolkit to eliminate the algebraic equations for the ionic currents
184184
185185``` @example hh1
186+ osys = convert(ODESystem, hhmodel2)
187+ osys = structural_simplify(osys)
188+
186189tspan = (0.0, 50.0)
190+ u₀ = symmap_to_varmap(osys, [:V => -70, :m => 0.0, :h => 0.0, :n => 0.0,
191+ :m′ => 1.0, :n′ => 1.0, :h′ => 1.0])
192+ oprob = ODEProblem(osys, u₀, tspan)
193+ hhsssol = solve(oprob, Rosenbrock23())
194+ u_ss = unknowns(osys) .=> hhsssol(tspan[2], idxs = unknowns(osys))
187195@unpack I₀,V = hhmodel2
188- oprob = ODEProblem(hhmodel2, u_ss, tspan, [I₀ => 10.0];
189- structural_simplify = true)
196+ oprob = ODEProblem(osys, u_ss, tspan, [I₀ => 10.0])
190197sol = solve(oprob)
191198plot(sol, idxs = V, legend = :outerright)
192199```
0 commit comments