Created
May 11, 2017 06:33
-
-
Save idontgetoutmuch/ee05df4433949d85bdb2e043039ab37a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| oneStepH98 :: Double -> (V2 Double, V2 Double) -> (V2 Double, V2 Double) | |
| oneStepH98 h prev = (qNew, pNew) | |
| where | |
| h2 = h / 2 | |
| hs = pure h | |
| h2s = pure h2 | |
| p2 = psPrev - h2s * nablaQ qsPrev | |
| qNew = qsPrev + hs * nablaP p2 | |
| pNew = p2 - h2s * nablaQ qNew | |
| qsPrev = P.fst prev | |
| psPrev = P.snd prev | |
| nablaQ qs = V2 (q1 / r) (q2 / r) | |
| where | |
| q1 = qs ^. L._x | |
| q2 = qs ^. L._y | |
| r = (q1 ^ 2 + q2 ^ 2) ** (3/2) | |
| nablaP ps = ps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function oneStep2(h :: Float64, prev :: ((Float64, Float64), (Float64, Float64))) :: ((Float64, Float64), (Float64, Float64)) | |
| hs = (h, h) | |
| h2 = h / 2 | |
| h2s = (h2, h2) | |
| qsPrev = prev[1] | |
| psPrev = prev[2] | |
| function nablaQ(qs) | |
| q1 = qs[1] | |
| q2 = qs[2] | |
| r = (q1^2 + q2^2) ^ (3/2) | |
| return (q1 / r, q2 / r) | |
| end | |
| function nablaP(ps) | |
| return ps | |
| end | |
| p2 = psPrev - h2s * nablaQ(qsPrev) | |
| qNew = qsPrev + hs * nablaP(p2) | |
| pNew = p2 - h2s * nablaQ(qNew) | |
| return (qNew, pNew) | |
| end |
idontgetoutmuch
commented
May 11, 2017
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment