Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using DiffEqOperators
- using OrdinaryDiffEq
- A = -10*speye(3)
- M = speye(3)
- num_steps = 1
- function update_A(A,u,p,t)
- global num_steps+=1
- A .= -10*speye(3)*t
- end
- L = DiffEqArrayOperator(A,1.0,update_A)
- prob = ODEProblem(L, [1.0,1.0,1.0], (0.0,1.0),mass_matrix=M)
- u = solve(prob ,ImplicitEuler(autodiff=false),
- progress=true,dt=1e-1,adaptive=false)
- num_steps
- num_steps2=1
- function update_A2(A2,u,p,t)
- global num_steps2 +=1
- end
- L2 = DiffEqArrayOperator(A,1.0,update_A2)
- prob2 = ODEProblem(L2, [1.0,1.0,1.0], (0.0,1.0),mass_matrix=M)
- num_steps2
- u = solve(prob2 ,ImplicitEuler(autodiff=false),
- dt=1e-1,adaptive=false)
- print("Took $num_steps for first run and $num_steps2 for second")
Add Comment
Please, Sign In to add comment