Guest User

Untitled

a guest
May 27th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. using DiffEqOperators
  2. using OrdinaryDiffEq
  3.  
  4.  
  5. A = -10*speye(3)
  6. M = speye(3)
  7.  
  8. num_steps = 1
  9. function update_A(A,u,p,t)
  10. global num_steps+=1
  11. A .= -10*speye(3)*t
  12. end
  13.  
  14. L = DiffEqArrayOperator(A,1.0,update_A)
  15. prob = ODEProblem(L, [1.0,1.0,1.0], (0.0,1.0),mass_matrix=M)
  16. u = solve(prob ,ImplicitEuler(autodiff=false),
  17. progress=true,dt=1e-1,adaptive=false)
  18. num_steps
  19.  
  20.  
  21. num_steps2=1
  22. function update_A2(A2,u,p,t)
  23. global num_steps2 +=1
  24. end
  25. L2 = DiffEqArrayOperator(A,1.0,update_A2)
  26. prob2 = ODEProblem(L2, [1.0,1.0,1.0], (0.0,1.0),mass_matrix=M)
  27. num_steps2
  28.  
  29. u = solve(prob2 ,ImplicitEuler(autodiff=false),
  30. dt=1e-1,adaptive=false)
  31. print("Took $num_steps for first run and $num_steps2 for second")
Add Comment
Please, Sign In to add comment