-
-
Notifications
You must be signed in to change notification settings - Fork 167
add support for rosenbrock method #709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
poonai
wants to merge
20
commits into
patrick-kidger:dev
Choose a base branch
from
poonai:poonai/ros3p
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
da76f95
add support for rosenbrock ros3p method
poonai 6552fcc
resolve commetn
poonai 236f5f7
fix doc
poonai 96c244a
minor
poonai a0af050
bring back the accuracy
poonai 3d16575
remove the skip
poonai b44e877
use tensordot
poonai 0d13fe5
organize import
poonai d45bda8
abstract rosenbrock class
poonai a2b616a
add rodas method
poonai 505f4b0
add additional rosenbrock methods
poonai 444101c
limit the rosenbrok to accept odeterm
poonai f3072f0
organize import
poonai 2504b0e
parametrize rosenbrock test
poonai acb1d79
improve doc
poonai 9923161
add nested pytree test and fix dense output in rosenbrock
poonai 95a114f
support multiterm
poonai 61df176
park rodas6p
poonai b09790a
add type hinting
poonai 0042b81
cleanup
poonai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ | |
| Euler, | ||
| EulerHeun, | ||
| ItoMilstein, | ||
| Ros3p, | ||
| StratonovichMilstein, | ||
| ) | ||
| from ._step_size_controller import ( | ||
|
|
||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,238 @@ | ||
| from collections.abc import Callable | ||
| from typing import ClassVar | ||
|
|
||
| import numpy as np | ||
|
|
||
| from diffrax._local_interpolation import RodasInterpolation | ||
|
|
||
| from .rosenbrock import AbstractRosenbrock, RosenbrockTableau | ||
|
|
||
|
|
||
| _tableau = RosenbrockTableau( | ||
| a_lower=( | ||
| np.array( | ||
| [ | ||
| 0.6358126895828704, | ||
| ] | ||
| ), | ||
| np.array([0.31242290829798824, 0.0971569310417652]), | ||
| np.array([1.3140825753299277, 1.8583084874257945, -2.1954603902496506]), | ||
| np.array( | ||
| [ | ||
| 0.42153145792835994, | ||
| 0.25386966273009, | ||
| -0.2365547905326239, | ||
| -0.010005969169959593, | ||
| ] | ||
| ), | ||
| np.array( | ||
| [ | ||
| 1.712028062121536, | ||
| 2.4456320333807953, | ||
| -3.117254839827603, | ||
| -0.04680538266310614, | ||
| 0.006400126988377645, | ||
| ] | ||
| ), | ||
| np.array( | ||
| [ | ||
| -0.9993030215739269, | ||
| -1.5559156221686088, | ||
| 3.1251564324842267, | ||
| 0.24141811637172583, | ||
| -0.023293468307707062, | ||
| 0.21193756319429014, | ||
| ], | ||
| ), | ||
| np.array( | ||
| [ | ||
| -0.003487250199264519, | ||
| -0.1299669712056423, | ||
| 1.525941760806273, | ||
| 1.1496140949123888, | ||
| -0.7043357115882416, | ||
| -1.0497034859198033, | ||
| 0.21193756319429014, | ||
| ] | ||
| ), | ||
| ), | ||
| c_lower=( | ||
| np.array([-0.6358126895828704]), | ||
| np.array([-0.4219499144476441, -0.12845036137023838]), | ||
| np.array([0.38766328985840337, -2.0150665034868993, 3.2201109377224792]), | ||
| np.array( | ||
| [ | ||
| 3.165730533008969, | ||
| 1.3574038770338352, | ||
| -2.1414486119160854, | ||
| -0.2677977215559399, | ||
| ] | ||
| ), | ||
| np.array( | ||
| [ | ||
| -2.711331083695463, | ||
| -4.001547655549404, | ||
| 6.24241127231183, | ||
| 0.28822349903483196, | ||
| -0.02969359529608471, | ||
| ] | ||
| ), | ||
| np.array( | ||
| [ | ||
| 0.9958157713746624, | ||
| 1.4259486509629664, | ||
| -1.5992146716779536, | ||
| 0.9081959785406629, | ||
| -0.6810422432805345, | ||
| -1.2616410491140935, | ||
| ] | ||
| ), | ||
| np.array( | ||
| [ | ||
| 0.12584733011227164, | ||
| 0.1802058530898342, | ||
| -0.20210253993991456, | ||
| 0.11477428094984177, | ||
| -0.08606747399894099, | ||
| 0.08161021050037465, | ||
| -0.42620522390775717, | ||
| ] | ||
| ), | ||
| ), | ||
| α=np.array( | ||
| [ | ||
| 0.0, | ||
| 0.6358126895828704, | ||
| 0.4095798393397535, | ||
| 0.9769306725060716, | ||
| 0.4288403609558664, | ||
| 0.9999999999999998, | ||
| 0.9999999999999999, | ||
| 1.0000000000000002, | ||
| ] | ||
| ), | ||
| γ=np.array( | ||
| [ | ||
| 0.21193756319429014, | ||
| -0.42387512638858027, | ||
| -0.3384627126235924, | ||
| 1.8046452872882734, | ||
| 2.325825639765069, | ||
| 9.71445146547012e-16, | ||
| 2.220446049250313e-16, | ||
| -3.3306690738754696e-16, | ||
| ] | ||
| ), | ||
| m_sol=np.array( | ||
| [ | ||
| 0.12236007991300712, | ||
| 0.050238881884191906, | ||
| 1.3238392208663585, | ||
| 1.2643883758622305, | ||
| -0.7904031855871826, | ||
| -0.9680932754194287, | ||
| -0.214267660713467, | ||
| 0.21193756319429014, | ||
| ] | ||
| ), | ||
| m_error=np.array( | ||
| [ | ||
| -0.003487250199264519, | ||
| -0.1299669712056423, | ||
| 1.525941760806273, | ||
| 1.1496140949123888, | ||
| -0.7043357115882416, | ||
| -1.0497034859198033, | ||
| 0.21193756319429014, | ||
| 0.0, | ||
| ] | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| class _Rodas5pInterpolation(RodasInterpolation): | ||
| coeff: ClassVar[np.ndarray] = np.array( | ||
| [ | ||
| [ | ||
| 0.12236007991300712, | ||
| 0.050238881884191906, | ||
| 1.3238392208663585, | ||
| 1.2643883758622305, | ||
| -0.7904031855871826, | ||
| -0.9680932754194287, | ||
| -0.214267660713467, | ||
| 0.21193756319429014, | ||
| ], | ||
| [ | ||
| -0.8232744916805133, | ||
| 0.3181483349120214, | ||
| 0.16922330104086836, | ||
| -0.049879453396320994, | ||
| 0.19831791977261218, | ||
| 0.31488148287699225, | ||
| -0.16387506167704194, | ||
| 0.036457968151382296, | ||
| ], | ||
| [ | ||
| -0.6726085201965635, | ||
| -1.3128972079520966, | ||
| 9.467244336394248, | ||
| 12.924520918142036, | ||
| -9.002714541842755, | ||
| -11.404611057341922, | ||
| -1.4210850083209667, | ||
| 1.4221510811179898, | ||
| ], | ||
| [ | ||
| 1.4025185206933914, | ||
| 0.9860299407499886, | ||
| -11.006871867857507, | ||
| -14.112585514422294, | ||
| 9.574969612795117, | ||
| 12.076626078349426, | ||
| 2.114222828697341, | ||
| -1.0349095990054304, | ||
| ], | ||
| ], | ||
| dtype=np.float64, | ||
| ) | ||
|
|
||
|
|
||
| class Rodas5p(AbstractRosenbrock): | ||
| r"""Rodas5p method. | ||
|
|
||
| 5th order Rosenbrock method for solving stiff equations. | ||
|
|
||
| ??? cite "Reference" | ||
|
|
||
| @article{Steinebach2023, | ||
| author = {Steinebach, Gerd}, | ||
| title = {Construction of Rosenbrock--Wanner method Rodas5P and numerical | ||
| benchmarks within the Julia Differential Equations package}, | ||
| journal = {BIT Numerical Mathematics}, | ||
| year = {2023}, | ||
| volume = {63}, | ||
| number = {2}, | ||
| pages = {27}, | ||
| doi = {10.1007/s10543-023-00967-x}, | ||
| url = {https://doi.org/10.1007/s10543-023-00967-x}, | ||
| issn = {1572-9125}, | ||
| date = {2023-04-17} | ||
| } | ||
|
|
||
| """ | ||
|
|
||
| tableau: ClassVar[RosenbrockTableau] = _tableau | ||
|
|
||
| interpolation_cls: ClassVar[Callable[..., _Rodas5pInterpolation]] = ( | ||
| _Rodas5pInterpolation.from_k | ||
| ) | ||
|
|
||
| rodas: ClassVar[bool] = True | ||
|
|
||
| def order(self, terms): | ||
| del terms | ||
| return 5 | ||
|
|
||
|
|
||
| Rodas5p.__init__.__doc__ = """**Arguments:** None""" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new interpolation method added for rodas class.