Skip to content
Snippets Groups Projects
  1. May 15, 2020
  2. May 14, 2020
  3. May 13, 2020
    • Chris Rackauckas's avatar
      fix typo · a7365281
      Chris Rackauckas authored
      a7365281
    • Chris Rackauckas's avatar
      some cleanup · 1397c59a
      Chris Rackauckas authored
      1397c59a
    • Chris Rackauckas's avatar
      fix parsing error · 2ea1db1c
      Chris Rackauckas authored
      2ea1db1c
    • Chris Rackauckas's avatar
      fix nothing sparsity case · 8044b56e
      Chris Rackauckas authored
      8044b56e
    • Chris Rackauckas's avatar
      import matrix_colors · 0b8163aa
      Chris Rackauckas authored
      0b8163aa
    • Chris Rackauckas's avatar
      always color · 9b122282
      Chris Rackauckas authored
      ```julia
      using DifferentialEquations
      const N = 32
      const xyd_brusselator = range(0,stop=1,length=N)
      brusselator_f(x, y, t) = (((x-0.3)^2 + (y-0.6)^2) <= 0.1^2) * (t >= 1.1) * 5.
      limit(a, N) = a == N+1 ? 1 : a == 0 ? N : a
      function brusselator_2d_loop(du, u, p, t)
        A, B, alpha, dx = p
        alpha = alpha/dx^2
        @inbounds for I in CartesianIndices((N, N))
          i, j = Tuple(I)
          x, y = xyd_brusselator[I[1]], xyd_brusselator[I[2]]
          ip1, im1, jp1, jm1 = limit(i+1, N), limit(i-1, N), limit(j+1, N), limit(j-1, N)
          du[i,j,1] = alpha*(u[im1,j,1] + u[ip1,j,1] + u[i,jp1,1] + u[i,jm1,1] - 4u[i,j,1]) +
                      B + u[i,j,1]^2*u[i,j,2] - (A + 1)*u[i,j,1] + brusselator_f(x, y, t)
          du[i,j,2] = alpha*(u[im1,j,2] + u[ip1,j,2] + u[i,jp1,2] + u[i,jm1,2] - 4u[i,j,2]) +
                      A*u[i,j,1] - u[i,j,1]^2*u[i,j,2]
          end
      end
      p = (3.4, 1., 10., step(xyd_brusselator))
      
      using SparsityDetection, SparseArrays
      input = rand(32,32,2)
      output = similar(input)
      sparsity_pattern = jacobian_sparsity(brusselator_2d_loop,output,input,p,0.0)
      jac_sparsity = Float64.(sparse(sparsity_pattern))
      f = ODEFunction(brusselator_2d_loop;jac_prototype=jac_sparsity)
      
      function init_brusselator_2d(xyd)
        N = length(xyd)
        u = zeros(N, N, 2)
        for I in CartesianIndices((N, N))
          x = xyd[I[1]]
          y = xyd[I[2]]
          u[I,1] = 22*(y*(1-y))^(3/2)
          u[I,2] = 27*(x*(1-x))^(3/2)
        end
        u
      end
      u0 = init_brusselator_2d(xyd_brusselator)
      prob_ode_brusselator_2d = ODEProblem(brusselator_2d_loop,
                                           u0,(0.,11.5),p)
      
      prob_ode_brusselator_2d_sparse = ODEProblem(f,
                                           u0,(0.,11.5),p)
      
      @btime solve(prob_ode_brusselator_2d_sparse,save_everystep=false)
      
      using SparseDiffTools, BenchmarkTools
      @time colorvec = matrix_colors(jac_sparsity)
      
      f = ODEFunction(brusselator_2d_loop;jac_prototype=jac_sparsity,
                                          colorvec=colorvec)
      prob_ode_brusselator_2d_sparse = ODEProblem(f,
                                           init_brusselator_2d(xyd_brusselator),
                                           (0.,11.5),p)
      @btime solve(prob_ode_brusselator_2d_sparse,save_everystep=false)
      ```
      
      3.230 s (18691 allocations: 881.07 MiB)
      10.766 s (19042 allocations: 881.07 MiB
      9b122282
    • Christopher Rackauckas's avatar
      Merge pull request #1113 from kamalojasv181/SFSDIRK_REST · 27a36f03
      Christopher Rackauckas authored
      Added SFSDIRK 4th Order 5,6,7,8 stage methods
      27a36f03
  4. May 12, 2020
  5. May 09, 2020
  6. May 08, 2020
  7. May 02, 2020
  8. May 01, 2020