Repository navigation
Newmark beta method - #2187
Newmark beta method#2187
Conversation
|
The last remaining problem is a bit tricky. For a given DynamicalODEFunction Newmark needs to solve for a "future accelleration" by solving the problem The first issue I run into is passing down the analytical Jacobian: using OrdinaryDiffEq
function f1_harmonic(dv, v, u, p, t)
dv .= -u
end
function f2_harmonic(du, v, u, p, t)
du .= v
end
harmonic_jac_f1(J, v, u, p, t) = J[1,1] = -1.0
ff_harmonic = DynamicalODEFunction(f1_harmonic, f2_harmonic; jac = harmonic_jac_f1)
DiffEqBase.has_jac(ff_harmonic) # false
DiffEqBase.has_jac(ff_harmonic.f1) # false
ff_f1 = ODEFunction{false}(ODEFunction{false}(f1_harmonic); jac=harmonic_jac_f1!)
ff_harmonic = DynamicalODEFunction(ff_f1, f2_harmonic; jac = harmonic_jac_f1)
DiffEqBase.has_jac(ff_harmonic) # false
DiffEqBase.has_jac(ff_harmonic.f1) # false The second problem is getting the AD on track. My current strategy is to pass a helper type |
|
I think I can call this now a first prototype. I am not very sure why it manages to converge to the correct solution, but I assume the residual is just wrong up to scaling. Another problem is that the Jacobian is per construction wrong. The derivative of However, this seems to break a few assumptions taken in the code. Hence I could need some feedback on how to proceed before putting time into a design which we do not want in the library. I already think that Furthermore I cannot figure out how to integrate the W-transformation here. Any pointers? |
termi-official
left a comment
There was a problem hiding this comment.
Thanks for the feedback. I have updated the implementation to master and made the tests for linear problems (harmonic and damped oscillator) pass. However, I had to manually unroll the implementation. I left some inline comments here on Github on the code sections where I am stuck (and on which I will resume working after fixing the most pressing issues).
| uₙ₊₁ = uₙ + dt * vₙ + dt^2/2 * ((1-2β)*aₙ + 2β*aₙ₊₁) | ||
| vₙ₊₁ = vₙ + dt * ((1-γ)*aₙ + γ*aₙ₊₁) | ||
| # Compute residual | ||
| f.f1(atmp, vₙ₊₁, uₙ₊₁, p, t) | ||
| integrator.stats.nf += 1 | ||
| residual = M*(aₙ₊₁ - atmp) | ||
| # Compute jacobian | ||
| f.jac(J, vₙ₊₁, uₙ₊₁, (γ*dt, β*dt*dt), p, t) | ||
| # Solve for increment | ||
| Δaₙ₊₁ = (M-J) \ residual | ||
| aₙ₊₁ .-= Δaₙ₊₁ # Looks like I messed up the signs somewhere :') | ||
| increment_norm = integrator.opts.internalnorm(Δaₙ₊₁, t) | ||
| increment_norm < 1e-4 && break | ||
| i == 10 && error("Newton diverged. ||Δaₙ₊₁||=$increment_norm") |
There was a problem hiding this comment.
@oscardssmith I think I need some help here regarding the integration with OrdinaryDiffEqNonlinearSolve.jl .
A critical missing piece is an interface for the evaluation of the Jacobian in a suitable form (especially via ad). For now I have just bypassed this with a custom jacobian function, e.g. for the harmonic oscillator in the test
function harmonic_jac(J, v, u, weights, p, t)
J[1,1] = weights[1] * (0.0) + weights[2] * (-1.0)
J[1,2] = weights[1] * (0.0) + weights[2] * ( 0.0)
J[2,2] = weights[1] * (0.0) + weights[2] * (-1.0)
J[2,1] = weights[1] * (0.0) + weights[2] * ( 0.0)
end
because many implicit second order ODE methods requires that J = Δtₙ²β ∂fᵤ + Δtₙγ ∂fᵥ . See above for a "full" derivation.
| vₙ + dt * ((1 - γ) * aₙ + γ * aₙ₊₁), | ||
| uₙ + dt * vₙ + dt^2 / 2 * ((1 - 2β) * aₙ + 2β * aₙ₊₁) |
There was a problem hiding this comment.
ad some @.. to reduce allocations?
There was a problem hiding this comment.
This catches fire. DimensionMismatch: array could not be broadcast to match destination
|
@ChrisRackauckas any ideas on naming? Denis doesn't love |
|
Generally Second Order multistep implicit methods? |
|
Typically these methods are single step methods. So |
|
The annoying thing about |
|
This is good to go for now (minus the package name). We are missing an interface to query the manual Jacobian in SciML for further optimizations. |
|
Any suggestions or comments for the package name? I do not have a strong opinion here. I have changed it now to |
| name = "OrdinaryDiffEqNewmark" | ||
| uuid = "d204908a-63b9-11ef-18f5-cfec7123a93b" | ||
| authors = ["Dennis Ogiermann <[email protected]>"] | ||
| version = "0.0.1" |
There was a problem hiding this comment.
| version = "0.0.1" | |
| version = "0.0.1" |
What is the versioning policy for SciML repos?
| - OrdinaryDiffEqLinear | ||
| - OrdinaryDiffEqLowOrderRK | ||
| - OrdinaryDiffEqLowStorageRK | ||
| - OrdinaryDiffEqNewmark |
There was a problem hiding this comment.
The CI does not pick up the correct OrdinaryDiffEqCore version for the new package. Is there an easy fix?
Prototype to resolve #411 .
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.