Skip to content

Instantly share code, notes, and snippets.

@natschil
Last active May 21, 2018 14:46
Show Gist options
  • Save natschil/66631080443cd194fb63fd691f0290b7 to your computer and use it in GitHub Desktop.
Save natschil/66631080443cd194fb63fd691f0290b7 to your computer and use it in GitHub Desktop.
using OrdinaryDiffEq, DiffEqOperators,Sundials
n = 600
M = rand(n,n)
K = rand(n,n)
ϵ = 1e-2
p = (ϵ,M,K)
u0 = ones(n)
function compute_residual!(resid,du,u,p,t)
ϵ = p[1]
M = p[2]
K = p[3]
resid .= M*du - ϵ*K*u
end
differential_vars = [true for i in 1:size(M)[1]]
prob = DAEProblem(compute_residual!,ϵ*M\(K*u0),u0,(0.0,1.0),differential_vars=differential_vars,p)
u = solve(prob,IDA(linear_solver=:GMRES))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment