dg-solvax 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,182 @@
1
+ Metadata-Version: 2.4
2
+ Name: dg-solvax
3
+ Version: 0.1.1
4
+ Summary: Discontinuous Galerkin and Riemann solver in JAX for (systems of) partial differential equations
5
+ Author: David A. Reiss
6
+ Author-email: David A. Reiss <dav.reiss@t-online.de>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
17
+ Classifier: Topic :: Scientific/Engineering :: Physics
18
+ Requires-Dist: diffrax>=0.7.2
19
+ Requires-Dist: jax>=0.11.1
20
+ Requires-Dist: pydantic>=2.13.5
21
+ Requires-Dist: sympy>=1.14.0
22
+ Requires-Python: >=3.12
23
+ Description-Content-Type: text/markdown
24
+
25
+ # `dg-solvax`: Discontinuous Galerkin and Riemann solver in JAX for (systems of) partial differential equations
26
+
27
+ [![CI](https://github.com/D-A-Reiss/dg-solvax/actions/workflows/ci.yml/badge.svg)](https://github.com/D-A-Reiss/dg-solvax/actions/workflows/ci.yml)
28
+ [![docs](https://github.com/D-A-Reiss/dg-solvax/actions/workflows/docs.yml/badge.svg)](https://d-a-reiss.github.io/dg-solvax/)
29
+
30
+ The core functionality of this package is to numerically solve initial-boundary-value problems for (systems of) linear partial differential equations (PDEs) with constant coefficients of the following form:
31
+ $$ \frac{\partial y}{\partial t} = \sum_{\gamma=1}^{N_x} A_\gamma \frac{\partial y}{\partial x_\gamma} + B y, $$
32
+
33
+ where $y = y(x, t)$ is the $N_y$-dimensional vector field to be determined by solving the PDEs, $t$ usually denotes the time, $N_x$ the number of spatial dimensions, $x_\gamma$ the components of $x$, and $A$ as well as $B$ are $N_y \times N_y$ matrices, independent of $t$ and $x$.
34
+ Supplied initial conditions are projected onto the basis exactly via symbolic integration; boundary conditions need to be supplied as reflection and transmission coefficients.
35
+
36
+ Remarks:
37
+
38
+ - Your higher-order PDE may be converted to this form like a second-order ordinary differential equation (ODE) may be converted to a system of first-order ODEs.
39
+
40
+ - Currently, only $N_x = 1$ is supported, which may change in the future, see "Potential features in the future" below.
41
+
42
+ - For the mathematics behind the discontinuous Galerkin and the Riemann solver, see the documentation page ["Mathematical background"](https://d-a-reiss.github.io/dg-solvax/mathematical-background).
43
+
44
+ - For a wider context of this work see my [GitHub pages](https://d-a-reiss.github.io/projects/dg-solvax).
45
+
46
+ The main entrypoint to use the core functionality of `dg-solvax` as explained above is the method `partialdiffeqsolve` of the class `DiscontinuousGalerkinSolver`, see "Quickstart" and "Documentation" below.
47
+
48
+
49
+ ## Installation
50
+
51
+ dg-solvax requires Python >= 3.12 and is available on [PyPI](https://pypi.org/project/dg-solvax/):
52
+
53
+ ```sh
54
+ pip install dg-solvax
55
+ ```
56
+
57
+ or, with [uv](https://docs.astral.sh/uv/):
58
+
59
+ ```sh
60
+ uv add dg-solvax
61
+ ```
62
+
63
+ ## Quickstart
64
+
65
+ Solve a pair of linear advection equations with opposite velocities, i.e.,
66
+ $$ \frac{\partial y}{\partial t} = \begin{pmatrix}
67
+ 1 & 0 \\
68
+ 0 & -1 \\
69
+ \end{pmatrix} \frac{\partial y}{\partial x}, $$
70
+
71
+ in the domain $t \in [0, 2], x \in [0, 10]$, a block-shaped initial condition for the first component, and absorbing domain boundaries, using rectangular function for the discretized spatial domain in the discontinuous Galerkin scheme:
72
+
73
+ ```python
74
+ import jax.numpy as jnp
75
+ from diffrax import SaveAt, Tsit5
76
+ from sympy import Heaviside, Symbol, sqrt
77
+
78
+ from dg_solvax import DiscontinuousGalerkinSolver
79
+
80
+ x = Symbol("x")
81
+ cell_size = 1.0
82
+ num_spatial_cells = 10
83
+
84
+ solver = DiscontinuousGalerkinSolver(
85
+ spatial_domain_boundaries=(0.0, num_spatial_cells * cell_size),
86
+ num_spatial_cells=num_spatial_cells,
87
+ orthonormal_spatial_functions=[1 / sqrt(cell_size)],
88
+ )
89
+
90
+ solution, ys = solver.partialdiffeqsolve(
91
+ diffeq_solver=Tsit5(),
92
+ t0=jnp.array(0.0),
93
+ t1=jnp.array(2.0),
94
+ dt0=jnp.array(0.25),
95
+ yt0=[Heaviside(x - 2.0) - Heaviside(x - 3.0), 0 * x],
96
+ yx0=jnp.array([[0.0, 0.0]]),
97
+ yx1=jnp.array([[0.0, 0.0]]),
98
+ spatial_derivative_operator=jnp.array([[1.0, 0.0], [0.0, -1.0]]),
99
+ no_derivative_operator=jnp.zeros((2, 2)),
100
+ saveat_t=SaveAt(ts=[0.0, 1.0, 2.0]),
101
+ saveat_x=jnp.linspace(0.0, 10.0, 101),
102
+ )
103
+ # ys has shape (num_saveat_t, num_saveat_x, num_components)
104
+ ```
105
+
106
+ where more details on the arguments can be found in the [API reference]([...](https://d-a-reiss.github.io/dg-solvax/reference)).
107
+
108
+ See the [examples directory](https://github.com/D-A-Reiss/dg-solvax/tree/main/examples) for complete runnable scripts, including a reflecting domain boundary and config-driven experiments, and the [benchmarks directory](https://github.com/D-A-Reiss/dg-solvax/tree/main/benchmarks) for performance benchmarks.
109
+
110
+
111
+ ## Documentation
112
+
113
+ The [documentation](https://d-a-reiss.github.io/dg-solvax/) is autogenerated from the Google-style docstrings in the source code using [mkdocstrings](https://mkdocstrings.github.io/) and [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/), and is rebuilt automatically on every push to `main`. I've tried to write the source code itself as self-explanatory as I could (the core parts were completely written by me, not AI), but haven't had the time to also write the docstrings myself, which were generated by AI.
114
+
115
+ To build and preview the docs locally:
116
+
117
+ ```sh
118
+ uv run --group docs mkdocs serve
119
+ ```
120
+
121
+ For a static build into `site/`, use `uv run --group docs mkdocs build` instead.
122
+
123
+
124
+ ## Potential features in the future
125
+
126
+ Potential features to be implemented in the future include:
127
+
128
+ - support for $N_x = 2$ and $N_x = 3$ spatial dimensions
129
+
130
+ Feel free to suggest further features via GitHub issues!
131
+
132
+
133
+ ## Development
134
+
135
+ To run the CI checks (formatting, linting, tests, secret scanning) automatically on every commit, install the pre-commit hook:
136
+
137
+ ```sh
138
+ uv sync
139
+ uv run pre-commit install
140
+ ```
141
+
142
+ The secret scanning hook requires the gitleaks binary, e.g. installed via Homebrew:
143
+
144
+ ```sh
145
+ brew install gitleaks
146
+ ```
147
+
148
+ To run all checks on demand, use `uv run pre-commit run --all-files`.
149
+
150
+ See [CONTRIBUTING.md](https://github.com/D-A-Reiss/dg-solvax/blob/main/CONTRIBUTING.md) for more details on the development setup.
151
+
152
+
153
+ ## Related work
154
+
155
+ The following is an incomplete list of important work related to `dg-solvax`:
156
+
157
+ - [Diffrax](https://docs.kidger.site/diffrax/): JAX-based library of numerical ODE/SDE solvers with `diffeqsolve` and multiple adjoint modes; the direct time-integration dependency of `dg-solvax`.
158
+
159
+ - [Trixi.jl](https://github.com/trixi-framework/Trixi.jl): Julia framework for adaptive high-order discontinuous Galerkin simulations of hyperbolic conservation laws with entropy-stable fluxes and shock capturing; the closest DG counterpart in another ecosystem.
160
+
161
+ - [JAX-Fluids](https://github.com/tumaer/JAXFLUIDS): Fully differentiable 3D compressible finite-volume CFD solver in JAX with high-order WENO/TENO reconstruction and Riemann solvers (HLL, HLLC, Roe).
162
+
163
+ - [JAX-DIPS](https://github.com/JAX-DIPS/JAX-DIPS): Differentiable interfacial PDE solver in JAX with level-set interfaces and neural bootstrapping.
164
+
165
+ - [JAX-FEM](https://github.com/deepmodeling/jax-fem): Differentiable GPU-accelerated finite element package in pure JAX for inverse design.
166
+
167
+ - [PyFR](https://www.pyfr.org): Open-source Python+C flux-reconstruction (arbitrary-order DG-type) solver for scale-resolving simulations across CPUs, GPUs, and TPUs.
168
+
169
+ - [ExaDG](https://github.com/exadg/exadg): High-performance matrix-free high-order DG solver for (in)compressible flow and coupled multiphysics, built on `deal.II`.
170
+
171
+ - [deal.II](https://www.dealii.org): Widely used C++ finite-element library with extensive DG support; the foundation under `ExaDG`.
172
+
173
+ - [Firedrake](https://www.firedrakeproject.org): Automated finite-element PDE solution from UFL expressions with PETSc solvers, including HDG methods.
174
+
175
+ - [Clawpack](https://www.clawpack.org): Finite-volume package for hyperbolic PDEs with high-resolution Godunov methods and a rich library of Riemann solvers (PyClaw for Python).
176
+
177
+
178
+ ## Acknowledgements
179
+
180
+ Parts of this work were done during the 10% of my work time as employee of [TNG Technology Consulting GmbH](https://www.tngtech.com/), during which I'm free to pursue whatever software project I want.
181
+
182
+ Parts of this work were generated with AI models hosted by TNG. For how to get access to them when you're not an employee of TNG, check out https://trustedtokens.eu/. All AI-generated parts have been reviewed by me.
@@ -0,0 +1,158 @@
1
+ # `dg-solvax`: Discontinuous Galerkin and Riemann solver in JAX for (systems of) partial differential equations
2
+
3
+ [![CI](https://github.com/D-A-Reiss/dg-solvax/actions/workflows/ci.yml/badge.svg)](https://github.com/D-A-Reiss/dg-solvax/actions/workflows/ci.yml)
4
+ [![docs](https://github.com/D-A-Reiss/dg-solvax/actions/workflows/docs.yml/badge.svg)](https://d-a-reiss.github.io/dg-solvax/)
5
+
6
+ The core functionality of this package is to numerically solve initial-boundary-value problems for (systems of) linear partial differential equations (PDEs) with constant coefficients of the following form:
7
+ $$ \frac{\partial y}{\partial t} = \sum_{\gamma=1}^{N_x} A_\gamma \frac{\partial y}{\partial x_\gamma} + B y, $$
8
+
9
+ where $y = y(x, t)$ is the $N_y$-dimensional vector field to be determined by solving the PDEs, $t$ usually denotes the time, $N_x$ the number of spatial dimensions, $x_\gamma$ the components of $x$, and $A$ as well as $B$ are $N_y \times N_y$ matrices, independent of $t$ and $x$.
10
+ Supplied initial conditions are projected onto the basis exactly via symbolic integration; boundary conditions need to be supplied as reflection and transmission coefficients.
11
+
12
+ Remarks:
13
+
14
+ - Your higher-order PDE may be converted to this form like a second-order ordinary differential equation (ODE) may be converted to a system of first-order ODEs.
15
+
16
+ - Currently, only $N_x = 1$ is supported, which may change in the future, see "Potential features in the future" below.
17
+
18
+ - For the mathematics behind the discontinuous Galerkin and the Riemann solver, see the documentation page ["Mathematical background"](https://d-a-reiss.github.io/dg-solvax/mathematical-background).
19
+
20
+ - For a wider context of this work see my [GitHub pages](https://d-a-reiss.github.io/projects/dg-solvax).
21
+
22
+ The main entrypoint to use the core functionality of `dg-solvax` as explained above is the method `partialdiffeqsolve` of the class `DiscontinuousGalerkinSolver`, see "Quickstart" and "Documentation" below.
23
+
24
+
25
+ ## Installation
26
+
27
+ dg-solvax requires Python >= 3.12 and is available on [PyPI](https://pypi.org/project/dg-solvax/):
28
+
29
+ ```sh
30
+ pip install dg-solvax
31
+ ```
32
+
33
+ or, with [uv](https://docs.astral.sh/uv/):
34
+
35
+ ```sh
36
+ uv add dg-solvax
37
+ ```
38
+
39
+ ## Quickstart
40
+
41
+ Solve a pair of linear advection equations with opposite velocities, i.e.,
42
+ $$ \frac{\partial y}{\partial t} = \begin{pmatrix}
43
+ 1 & 0 \\
44
+ 0 & -1 \\
45
+ \end{pmatrix} \frac{\partial y}{\partial x}, $$
46
+
47
+ in the domain $t \in [0, 2], x \in [0, 10]$, a block-shaped initial condition for the first component, and absorbing domain boundaries, using rectangular function for the discretized spatial domain in the discontinuous Galerkin scheme:
48
+
49
+ ```python
50
+ import jax.numpy as jnp
51
+ from diffrax import SaveAt, Tsit5
52
+ from sympy import Heaviside, Symbol, sqrt
53
+
54
+ from dg_solvax import DiscontinuousGalerkinSolver
55
+
56
+ x = Symbol("x")
57
+ cell_size = 1.0
58
+ num_spatial_cells = 10
59
+
60
+ solver = DiscontinuousGalerkinSolver(
61
+ spatial_domain_boundaries=(0.0, num_spatial_cells * cell_size),
62
+ num_spatial_cells=num_spatial_cells,
63
+ orthonormal_spatial_functions=[1 / sqrt(cell_size)],
64
+ )
65
+
66
+ solution, ys = solver.partialdiffeqsolve(
67
+ diffeq_solver=Tsit5(),
68
+ t0=jnp.array(0.0),
69
+ t1=jnp.array(2.0),
70
+ dt0=jnp.array(0.25),
71
+ yt0=[Heaviside(x - 2.0) - Heaviside(x - 3.0), 0 * x],
72
+ yx0=jnp.array([[0.0, 0.0]]),
73
+ yx1=jnp.array([[0.0, 0.0]]),
74
+ spatial_derivative_operator=jnp.array([[1.0, 0.0], [0.0, -1.0]]),
75
+ no_derivative_operator=jnp.zeros((2, 2)),
76
+ saveat_t=SaveAt(ts=[0.0, 1.0, 2.0]),
77
+ saveat_x=jnp.linspace(0.0, 10.0, 101),
78
+ )
79
+ # ys has shape (num_saveat_t, num_saveat_x, num_components)
80
+ ```
81
+
82
+ where more details on the arguments can be found in the [API reference]([...](https://d-a-reiss.github.io/dg-solvax/reference)).
83
+
84
+ See the [examples directory](https://github.com/D-A-Reiss/dg-solvax/tree/main/examples) for complete runnable scripts, including a reflecting domain boundary and config-driven experiments, and the [benchmarks directory](https://github.com/D-A-Reiss/dg-solvax/tree/main/benchmarks) for performance benchmarks.
85
+
86
+
87
+ ## Documentation
88
+
89
+ The [documentation](https://d-a-reiss.github.io/dg-solvax/) is autogenerated from the Google-style docstrings in the source code using [mkdocstrings](https://mkdocstrings.github.io/) and [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/), and is rebuilt automatically on every push to `main`. I've tried to write the source code itself as self-explanatory as I could (the core parts were completely written by me, not AI), but haven't had the time to also write the docstrings myself, which were generated by AI.
90
+
91
+ To build and preview the docs locally:
92
+
93
+ ```sh
94
+ uv run --group docs mkdocs serve
95
+ ```
96
+
97
+ For a static build into `site/`, use `uv run --group docs mkdocs build` instead.
98
+
99
+
100
+ ## Potential features in the future
101
+
102
+ Potential features to be implemented in the future include:
103
+
104
+ - support for $N_x = 2$ and $N_x = 3$ spatial dimensions
105
+
106
+ Feel free to suggest further features via GitHub issues!
107
+
108
+
109
+ ## Development
110
+
111
+ To run the CI checks (formatting, linting, tests, secret scanning) automatically on every commit, install the pre-commit hook:
112
+
113
+ ```sh
114
+ uv sync
115
+ uv run pre-commit install
116
+ ```
117
+
118
+ The secret scanning hook requires the gitleaks binary, e.g. installed via Homebrew:
119
+
120
+ ```sh
121
+ brew install gitleaks
122
+ ```
123
+
124
+ To run all checks on demand, use `uv run pre-commit run --all-files`.
125
+
126
+ See [CONTRIBUTING.md](https://github.com/D-A-Reiss/dg-solvax/blob/main/CONTRIBUTING.md) for more details on the development setup.
127
+
128
+
129
+ ## Related work
130
+
131
+ The following is an incomplete list of important work related to `dg-solvax`:
132
+
133
+ - [Diffrax](https://docs.kidger.site/diffrax/): JAX-based library of numerical ODE/SDE solvers with `diffeqsolve` and multiple adjoint modes; the direct time-integration dependency of `dg-solvax`.
134
+
135
+ - [Trixi.jl](https://github.com/trixi-framework/Trixi.jl): Julia framework for adaptive high-order discontinuous Galerkin simulations of hyperbolic conservation laws with entropy-stable fluxes and shock capturing; the closest DG counterpart in another ecosystem.
136
+
137
+ - [JAX-Fluids](https://github.com/tumaer/JAXFLUIDS): Fully differentiable 3D compressible finite-volume CFD solver in JAX with high-order WENO/TENO reconstruction and Riemann solvers (HLL, HLLC, Roe).
138
+
139
+ - [JAX-DIPS](https://github.com/JAX-DIPS/JAX-DIPS): Differentiable interfacial PDE solver in JAX with level-set interfaces and neural bootstrapping.
140
+
141
+ - [JAX-FEM](https://github.com/deepmodeling/jax-fem): Differentiable GPU-accelerated finite element package in pure JAX for inverse design.
142
+
143
+ - [PyFR](https://www.pyfr.org): Open-source Python+C flux-reconstruction (arbitrary-order DG-type) solver for scale-resolving simulations across CPUs, GPUs, and TPUs.
144
+
145
+ - [ExaDG](https://github.com/exadg/exadg): High-performance matrix-free high-order DG solver for (in)compressible flow and coupled multiphysics, built on `deal.II`.
146
+
147
+ - [deal.II](https://www.dealii.org): Widely used C++ finite-element library with extensive DG support; the foundation under `ExaDG`.
148
+
149
+ - [Firedrake](https://www.firedrakeproject.org): Automated finite-element PDE solution from UFL expressions with PETSc solvers, including HDG methods.
150
+
151
+ - [Clawpack](https://www.clawpack.org): Finite-volume package for hyperbolic PDEs with high-resolution Godunov methods and a rich library of Riemann solvers (PyClaw for Python).
152
+
153
+
154
+ ## Acknowledgements
155
+
156
+ Parts of this work were done during the 10% of my work time as employee of [TNG Technology Consulting GmbH](https://www.tngtech.com/), during which I'm free to pursue whatever software project I want.
157
+
158
+ Parts of this work were generated with AI models hosted by TNG. For how to get access to them when you're not an employee of TNG, check out https://trustedtokens.eu/. All AI-generated parts have been reviewed by me.
@@ -0,0 +1,58 @@
1
+ [project]
2
+ name = "dg-solvax"
3
+ version = "0.1.1"
4
+ description = "Discontinuous Galerkin and Riemann solver in JAX for (systems of) partial differential equations"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.12"
9
+ dependencies = [
10
+ "diffrax>=0.7.2",
11
+ "jax>=0.11.1",
12
+ "pydantic>=2.13.5",
13
+ "sympy>=1.14.0",
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Science/Research",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Programming Language :: Python :: 3.14",
23
+ "Topic :: Scientific/Engineering :: Mathematics",
24
+ "Topic :: Scientific/Engineering :: Physics",
25
+ ]
26
+
27
+ [[project.authors]]
28
+ name = "David A. Reiss"
29
+ email = "dav.reiss@t-online.de"
30
+
31
+ [build-system]
32
+ requires = ["uv_build>=0.12.9,<0.13.0"]
33
+ build-backend = "uv_build"
34
+
35
+ [dependency-groups]
36
+ dev = [
37
+ "pre-commit>=4.6.2",
38
+ "pytest>=9.1.1",
39
+ "pytest-benchmark>=5.3.0",
40
+ ]
41
+ docs = [
42
+ "mkdocs-material>=9.7.7",
43
+ "mkdocstrings[python]>=1.0.6",
44
+ ]
45
+ lint = ["ruff>=0.16.6"]
46
+ utils = ["plotly>=7.0.0"]
47
+
48
+ [tool.ruff.lint]
49
+ extend-select = ["D"]
50
+
51
+ [tool.ruff.lint.pydocstyle]
52
+ convention = "google"
53
+
54
+ [tool.ruff.format]
55
+
56
+ [tool.pytest.ini_options]
57
+ testpaths = ["tests"]
58
+ pythonpath = ["."]
@@ -0,0 +1,61 @@
1
+ [project]
2
+ name = "dg-solvax"
3
+ version = "0.1.1"
4
+ description = "Discontinuous Galerkin and Riemann solver in JAX for (systems of) partial differential equations"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "David A. Reiss", email = "dav.reiss@t-online.de" }
8
+ ]
9
+ license = "Apache-2.0"
10
+ license-files = ["LICENSE"]
11
+ requires-python = ">=3.12"
12
+ dependencies = [
13
+ "diffrax>=0.7.2",
14
+ "jax>=0.11.1",
15
+ "pydantic>=2.13.5",
16
+ "sympy>=1.14.0",
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Intended Audience :: Science/Research",
21
+ "Operating System :: OS Independent",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Topic :: Scientific/Engineering :: Mathematics",
27
+ "Topic :: Scientific/Engineering :: Physics",
28
+ ]
29
+
30
+ [build-system]
31
+ requires = ["uv_build>=0.12.9,<0.13.0"]
32
+ build-backend = "uv_build"
33
+
34
+ [dependency-groups]
35
+ dev = [
36
+ "pre-commit>=4.6.2",
37
+ "pytest>=9.1.1",
38
+ "pytest-benchmark>=5.3.0",
39
+ ]
40
+ docs = [
41
+ "mkdocs-material>=9.7.7",
42
+ "mkdocstrings[python]>=1.0.6",
43
+ ]
44
+ lint = [
45
+ "ruff>=0.16.6",
46
+ ]
47
+ utils = [
48
+ "plotly>=7.0.0",
49
+ ]
50
+
51
+ [tool.ruff.lint]
52
+ extend-select = ["D"]
53
+
54
+ [tool.ruff.lint.pydocstyle]
55
+ convention = "google"
56
+
57
+ [tool.ruff.format]
58
+
59
+ [tool.pytest.ini_options]
60
+ testpaths = ["tests"]
61
+ pythonpath = ["."]