-
Notifications
You must be signed in to change notification settings - Fork 37
Proposition for release 5.2 #285
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
Merged
Changes from all commits
Commits
Show all changes
87 commits
Select commit
Hold shift + click to select a range
3ae7543
Started introducing defaults to a advection
db9c81f
Merge remote-tracking branch 'upstream/master' into problem_defaults
090af96
Removed `**kwargs` from the core problem class
edccb25
Put back the `**kwargs` :P
34fb360
Merge pull request #238 from Parallel-in-Time/master
brownbaerchen 401694f
Merge pull request #239 from brownbaerchen/problem_defaults
brownbaerchen 706533a
TL: trying solution to replace frozenclass
tlunet 5b7f535
TL: reintroduced Gauss initial solution in advectionNd (1D)
tlunet 7bbf286
TL: cleaned implementation of advectionNd
tlunet 510d969
TL: appreciating flakeheaven help on this one ;)
tlunet 7a24e72
TL: readOnly to dictionnary
tlunet c86e478
TL: better _readOnly instantiation
tlunet 1c41e0a
TL: tried to simplifiy read-only parameters
tlunet d6dfe6a
TL: moved RegisterParams and ReadOnlyError classes in proper modules
tlunet e829f9d
TL: minor correction
tlunet 3557e22
TL: other minor bug
tlunet 8be4559
TL: added datatype initializer for Problem class
tlunet 029c64b
TL: that's a new one ...
tlunet 08667eb
TL: adding metaclass for RegisterParams class
tlunet d77ea23
TL: putting ndim to property for advectionNd class
tlunet 6c989cb
TL: adding documentation
tlunet 6b70df8
Merge remote-tracking branch 'upstream/master' into v6
tlunet 2179e15
Merge pull request #252 from Parallel-in-Time/master
tlunet 3c10b63
TL: merge attribute storing and parameter registering
tlunet a0351fc
TL: documentation update
tlunet 586d2cc
Merge remote-tracking branch 'upstream/v6' into v6
tlunet d8540a7
Merge pull request #259 from Parallel-in-Time/master
tlunet 21fac8f
TL: corrected docstring
tlunet 60c9ec6
Merge remote-tracking branch 'upstream/v6' into v6
tlunet ed38531
Merge pull request #244 from tlunet/v6
brownbaerchen 25e45c5
Merge branch 'master' into v6
tlunet db20e87
Merge remote-tracking branch 'upstream/master' into v6
tlunet 847e8ca
TL: first draft for new simplified datatype classes
tlunet 3f7c6b7
TL: reorganized datatype playground, started performance tests
tlunet f6f6988
TL: labels to performance plot
tlunet b275d86
TL: switched to proper timing functions
tlunet 19e596c
Merge remote-tracking branch 'upstream/master' into v6
tlunet abf4da2
TL: switch HeatEquation_ND_FD to default parameter format
tlunet d151d80
TL: switch TestEquation_0D to new parameter format
tlunet 7afac92
TL: 51/100 pytest work
tlunet a8db607
TL: blackening
tlunet 605bccb
TL: test AC are passing
tlunet 22da733
TL: test DAE are passing
tlunet ddbe309
TL: test asympconv are passing
tlunet 5de18d4
TL: moved dtype as problem class attribute, more project tests passing
tlunet e5df699
TL: more project test are passing + black
tlunet fa54391
TL: almost all project tests passing
tlunet c8ab429
TL: blackening
tlunet 56c61fd
TL: going to tutorials
tlunet 7454cfb
cupy tests should work now
ec0539d
Merge remote-tracking branch 'upstream/v6' into v6
tlunet 320730c
Moved solver from advection and diffusion to generic parent class
129d8f3
Merge pull request #280 from brownbaerchen/v6
brownbaerchen fb7329a
Merge remote-tracking branch 'upstream/v6' into v6
tlunet 58ae1f9
TL: finished debug tutorials
tlunet 625f206
Merge remote-tracking branch 'upstream/master' into v6
tlunet 7accce1
Added work counters to generic FD problem class
11776fc
TL: forgot those tests
tlunet 4d3bd17
TL: forgot black (of course)
tlunet 02e186f
TL: some additional correction with solver_type
tlunet d1ece1e
Changed solver names to upper case
9974d97
Changed solver interface for GPU heat equation
2c5d50f
TL: reformating and testing for Logistic Equation problem
tlunet 2f946ce
TL: black ... again
tlunet ba3e4d1
TL: hack to solve dolfin/mpi4py MPI clash
tlunet f3aa24c
TL: oh holy black ...
tlunet f8f3f15
TL: finished preleminary doc for v6 + some pragma
tlunet 1a73bd5
Merge remote-tracking branch 'upstream/master' into v6
tlunet 69ad4c3
TL: forgot that ...
tlunet ff5ffdb
TL: fixed LeakySuperconductor tests
tlunet 8a216b6
TL: typo and coverage pragma
tlunet 8fe945e
TL: fixing dictionnary typo
tlunet bd134ba
TL: updated problem classes not covered by tests
tlunet 9f98a8d
TL: of course !
tlunet d47b866
TL: moving pragma cover
tlunet 2ebcf05
TL: default parameters for FastWaveSlowWave
tlunet 23e9385
TL: added docstring page in contribution guidelines
tlunet 03cd1b7
TL: replaced dolfin/mpi4py hack by a TODO
tlunet f0acf24
TL: explicitly check mpi4py imports in tests
tlunet 5ab7a12
TL: more elegant solution to solve the dolfin/mpi4py clash
tlunet ece2b63
TL: trying to fix pragma cover
tlunet fd62146
TL: forgot that ...
tlunet cec04ad
TL: another try
tlunet ea61807
TL: maybe a more elegant way
tlunet 829484e
TL: fixing previous mistake
tlunet efc0fad
TL: black, I hate you
tlunet 348606c
TL: codecov is also asking for it ...
tlunet 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
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 |
|---|---|---|
| @@ -1,7 +1,62 @@ | ||
| # Custom implementation guidelines | ||
|
|
||
| ... in construction ... | ||
| `pySDC` solves (non-)linear ODE of the form | ||
|
|
||
| $$ | ||
| \frac{du}{dt} = f(u, t), \quad u(0)=u_0, \quad t \in [0, T]. | ||
| $$ | ||
|
|
||
| where $u$ a vector or scalar, representing one or more variables. | ||
|
|
||
| The type of variable, the definition of the right-hand side $f(u,t)$ and initial solution value $u_0$ are defined in a given `Problem` class. | ||
|
|
||
| ... to be continued ... | ||
|
|
||
| ## Implementing a custom problem class | ||
|
|
||
| Any problem class inherit from the same base class, that is (currently) the `ptype` class from the module `pySDC.code.Problem`. | ||
| Each custom problem should inherit from this base class, like for the following example template : | ||
|
|
||
| - right-hand side $f(u,t)=\lambda u + ct$ with | ||
| - $\lambda$ one or more complex values (in vector form) | ||
| - $c$ one scalar value | ||
|
|
||
| ```python | ||
| import numpy as np | ||
|
|
||
| from pySDC.core.Problem import ptype | ||
| from pySDC.core.Errors import ProblemError | ||
| from pySDC.implementations.datatype_classes.mesh import mesh | ||
|
|
||
| class MyCustomProblem(ptype): | ||
| # 1) Provide datatype class as class attribute | ||
| dtype_u = mesh # -> used for u values | ||
| dtype_f = mesh # -> used for f(u,t) values | ||
|
|
||
| # 2) Define constructor | ||
| def __init__(self, lam, c): | ||
|
|
||
| # Store lambda values into a numpy array (with copy) + check | ||
| lam = np.array(lam) | ||
| if len(lam.shape) > 1: | ||
| raise ProblemError(f"lambda values must be given as 1D vector, got shape {lam.shape}") | ||
|
|
||
| # Call base constructor | ||
| super().__init__(init=(lam.size, None, lam.dtype)) | ||
|
|
||
| # Register parameters | ||
| self._makeAttributeAndRegister('lam', 'c', localVars=locals(), readOnly=True) | ||
|
|
||
| # 3) Define RHS function | ||
| def eval_f(self, u, t): | ||
| f = self.f_init # Generate new datatype to store result | ||
| f[:] = self.lam*u + self.c*t # Compute RHS value | ||
| return f | ||
| ``` | ||
|
|
||
| :bell: The `_makeAttributeAndRegister` automatically add `lam` and `c`, and register them in a list of parameters that are printed in the outputs of `pySDC`. | ||
| If you set `readOnly=True`, then those parameters cannot be changed after initializing the problem (if not specifies, use `readOnly=False`). | ||
|
|
||
| :arrow_left: [Back to Naming Conventions](./03_naming_conventions.md) --- | ||
| :arrow_up: [Contributing Summary](./../../CONTRIBUTING.md) --- | ||
| :arrow_right: [Next to a cute picture of cat](https://www.vecteezy.com/photo/2098203-silver-tabby-cat-sitting-on-green-background) | ||
| :arrow_right: [Next to Documenting Code](./05_documenting_code.md) | ||
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,93 @@ | ||
| # Documenting Code | ||
|
|
||
| When developing a new class or function, or improving current classes in `pySDC`, adding Python docstring to document the code is important, in particular : | ||
|
|
||
| - to help developer understanding how classes and functions work when reading the code | ||
| - to help user understanding how classes and functions work when reading the [documentation](https://parallel-in-time.org/pySDC/#api-documentation) | ||
|
|
||
| `pySDC` follows the [NumPy Style Python Docstring](https://numpydoc.readthedocs.io/en/latest/format.html), below is simplified example | ||
| for a class and a function : | ||
|
|
||
| > :bell: Don't document the `init` function, but rather the class itself. Also describe parameters (given to the `__init__`) and attributes (stored into the class) separately. | ||
|
|
||
| ```python | ||
| class LagrangeApproximation(object): | ||
| r""" | ||
| Class approximating any function on a given set of points using barycentric | ||
| Lagrange interpolation. | ||
|
|
||
| Let note :math:`(t_j)_{0\leq j<n}` the set of points, then any scalar | ||
| function :math:`f` can be approximated by the barycentric formula : | ||
|
|
||
| .. math:: | ||
| p(x) = | ||
| \frac{\displaystyle \sum_{j=0}^{n-1}\frac{w_j}{x-x_j}f_j} | ||
| {\displaystyle \sum_{j=0}^{n-1}\frac{w_j}{x-x_j}}, | ||
|
|
||
| where :math:`f_j=f(t_j)` and | ||
|
|
||
| .. math:: | ||
| w_j = \frac{1}{\prod_{k\neq j}(x_j-x_k)} | ||
|
|
||
| are the barycentric weights. | ||
| The theory and implementation is inspired from `this paper <http://dx.doi.org/10.1137/S0036144502417715>`_. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| points : list, tuple or np.1darray | ||
| The given interpolation points, no specific scaling, but must be | ||
| ordered in increasing order. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| points : np.1darray | ||
| The interpolating points | ||
| weights : np.1darray | ||
| The associated barycentric weights | ||
| """ | ||
|
|
||
| def __init__(self, points): | ||
| pass # Implementation ... | ||
|
|
||
| @property | ||
| def n(self): | ||
| """Number of points""" | ||
| pass # Implementation ... | ||
|
|
||
| def getInterpolationMatrix(self, times): | ||
| r""" | ||
| Compute the interpolation matrix for a given set of discrete "time" | ||
| points. | ||
|
|
||
| For instance, if we note :math:`\vec{f}` the vector containing the | ||
| :math:`f_j=f(t_j)` values, and :math:`(\tau_m)_{0\leq m<M}` | ||
| the "time" points where to interpolate. | ||
| Then :math:`I[\vec{f}]`, the vector containing the interpolated | ||
| :math:`f(\tau_m)` values, can be obtained using : | ||
|
|
||
| .. math:: | ||
| I[\vec{f}] = P_{Inter} \vec{f}, | ||
|
|
||
| where :math:`P_{Inter}` is the interpolation matrix returned by this | ||
| method. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| times : list-like or np.1darray | ||
| The discrete "time" points where to interpolate the function. | ||
|
|
||
| Returns | ||
| ------- | ||
| PInter : np.2darray(M, n) | ||
| The interpolation matrix, with :math:`M` rows (size of the **times** | ||
| parameter) and :math:`n` columns. | ||
| """ | ||
| pass # Implementation ... | ||
|
|
||
| ``` | ||
|
|
||
| A more detailed example is given [here ...](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html) | ||
|
|
||
| :arrow_left: [Back to custom implementations](./04_custom_implementations.md) --- | ||
| :arrow_up: [Contributing Summary](./../../CONTRIBUTING.md) --- | ||
| :arrow_right: [Next to a cute picture of cat](https://www.vecteezy.com/photo/2098203-silver-tabby-cat-sitting-on-green-background) |
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,75 @@ | ||
| #!/usr/bin/env python3 | ||
| # -*- coding: utf-8 -*- | ||
| """ | ||
| Description | ||
| ----------- | ||
|
|
||
| Module containing utility classe(s) from which inherit some of the pySDC base | ||
| classes. | ||
| """ | ||
| from pySDC.core.Errors import ReadOnlyError | ||
|
|
||
|
|
||
| class _MetaRegisterParams(type): | ||
| """Metaclass for RegisterParams base class""" | ||
|
|
||
| def __new__(cls, name, bases, dct): | ||
| obj = super().__new__(cls, name, bases, dct) | ||
| obj._parNamesReadOnly = set() | ||
| obj._parNames = set() | ||
| return obj | ||
|
|
||
|
|
||
| class RegisterParams(metaclass=_MetaRegisterParams): | ||
| """ | ||
| Base class to register parameters. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| params : dict (property) | ||
| Dictionary containing names and values of registered parameters. | ||
| _parNames : set of str | ||
| Names of all the registered parameters. | ||
| _parNamesReadOnly : set of str | ||
| Names of all the parameters registered as read-only. | ||
| """ | ||
|
|
||
| def _makeAttributeAndRegister(self, *names, localVars=None, readOnly=False): | ||
| """ | ||
| Register a list of attribute name as parameters of the class. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| *names : list of str | ||
| The name of the parameters to be registered (should be class attributes). | ||
| localVars : dict | ||
| Dictionary containing key=names and values=paramValues for each | ||
| parNames given in names. Can be provided, for instance, using | ||
| `locals()` built-in dictionary. MUST BE provided as soon as | ||
| names contains anything. | ||
| readOnly : bool, optional | ||
| Wether or not store the parameters as read-only attributes | ||
| """ | ||
| if len(names) > 1 and localVars is None: | ||
| raise ValueError("a dictionary must be provided in localVars with parameters values") | ||
| # Set parameters as attributes | ||
| for name in names: | ||
| try: | ||
| super().__setattr__(name, localVars[name]) | ||
| except KeyError: # pragma: no cover | ||
| raise ValueError(f'value for {name} not given in localVars') | ||
| # Register as class parameter | ||
| if readOnly: | ||
| self._parNamesReadOnly = self._parNamesReadOnly.union(names) | ||
| else: | ||
| self._parNames = self._parNames.union(names) | ||
|
|
||
| @property | ||
| def params(self): | ||
| """Dictionary containing names and values of registered parameters""" | ||
| return {name: getattr(self, name) for name in self._parNamesReadOnly.union(self._parNames)} | ||
|
|
||
| def __setattr__(self, name, value): | ||
| if name in self._parNamesReadOnly: | ||
| raise ReadOnlyError(name) | ||
| super().__setattr__(name, value) |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.