API reference
Discontinuous Galerkin and Riemann solver in JAX.
__all__ = ['DiscontinuousGalerkinSolver', 'RiemannSolver', 'SystemPartialDiffEqs', 'SystemPartialDiffEqsProblem', 'get_orthonormal_spatial_functions']
module-attribute
__version__ = metadata.version('dg-solvax')
module-attribute
DiscontinuousGalerkinSolver
Solve (systems of) partial differential equations (PDEs) via the discontinuous Galerkin method on a uniform grid.
The input vector field is represented per cell by coefficients w.r.t. orthonormal spatial basis functions.
Source code in src/dg_solvax/solvers.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | |
spatial_cell_middles = self._spatial_cell_boundaries[:-1] + self._spatial_step_size / 2
instance-attribute
__init__(spatial_domain_boundaries, num_spatial_cells, orthonormal_spatial_functions)
Initialize the grid and the orthonormal spatial basis functions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spatial_domain_boundaries
|
tuple[Position, Position]
|
Left and right boundary of the spatial domain. |
required |
num_spatial_cells
|
int
|
Number of uniform cells the spatial domain is divided into. |
required |
orthonormal_spatial_functions
|
list[ExprOfX]
|
Orthonormal SymPy expressions of a single position variable, used as per-cell basis. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a basis function depends on more than 1 free variable. |
Source code in src/dg_solvax/solvers.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
compute_coeffs_from_initial_conditions_array(yt0, *, check_whether_representable=False)
Compute the coefficients of initial conditions given as an array.
Not yet implemented.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yt0
|
Array
|
Initial conditions sampled on the spatial grid. |
required |
check_whether_representable
|
bool
|
Whether to check exact representability of the initial conditions by the basis functions. |
False
|
Returns:
| Type | Description |
|---|---|
Array
|
Per-cell basis coefficients of the initial conditions. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always, as this is not yet implemented. |
Source code in src/dg_solvax/solvers.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | |
compute_coeffs_from_initial_conditions_functions(yt0, *, check_whether_representable=False)
Compute the per-cell basis coefficients of the initial conditions.
Each component of yt0 is projected onto the orthonormal spatial
functions cell-by-cell by SymPy integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yt0
|
list[ExprOfX]
|
Initial conditions as SymPy expressions of the single
position variable |
required |
check_whether_representable
|
bool
|
Whether to check exact representability of the initial conditions by the basis functions via Parseval's identity; a UserWarning is emitted if the check fails. |
False
|
Returns:
| Type | Description |
|---|---|
Array
|
Per-cell basis coefficients with shape |
Array
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a component of |
Source code in src/dg_solvax/solvers.py
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
partialdiffeqsolve(*, diffeq_solver, t0, t1, dt0, yt0, yx0, yx1, reflection_coeffs_left_to_left=None, reflection_coeffs_right_to_right=None, transmission_coeffs_left_to_right=None, transmission_coeffs_right_to_left=None, spatial_derivative_operator, no_derivative_operator, saveat_t=_SAVEAT_T, saveat_x=None, stepsize_controller=_STEPSIZE_CONTROLLER, max_steps=None, progress_meter=_PROGRESS_METER)
Solve the PDE in time, evaluating at the requested positions.
Initial conditions may be given as SymPy expressions or coefficient arrays; time integration is delegated to diffrax.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diffeq_solver
|
AbstractSolver
|
diffrax solver used for the time integration. |
required |
t0
|
Array
|
Initial time. |
required |
t1
|
Array
|
Final time. |
required |
dt0
|
Array | None
|
Initial time step; None if the step size controller chooses the first step. |
required |
yt0
|
Array | list[ExprOfX]
|
Initial conditions, either as SymPy expressions of |
required |
yx0
|
Array | list[ExprOfT] | None
|
Exterior limit of the unknown vector field at the left
boundary of the spatial domain, as an array or as SymPy
expressions of |
required |
yx1
|
Array | list[ExprOfT] | None
|
Exterior limit of the unknown vector field at the right
boundary of the spatial domain, as an array or as SymPy
expressions of |
required |
reflection_coeffs_left_to_left
|
Array | None
|
Reflection coefficients of the right domain boundary; None for no reflection there. |
None
|
reflection_coeffs_right_to_right
|
Array | None
|
Reflection coefficients of the left domain boundary; None for no reflection there. |
None
|
transmission_coeffs_left_to_right
|
Array | None
|
Transmission coefficients of the left domain boundary; None for no transmission there. |
None
|
transmission_coeffs_right_to_left
|
Array | None
|
Transmission coefficients of the right domain boundary; None for no transmission there. |
None
|
spatial_derivative_operator
|
Array
|
Constant matrix multiplying the spatial derivative of the unknown vector field. |
required |
no_derivative_operator
|
Array
|
Constant matrix multiplying the unknown vector field. |
required |
saveat_t
|
SaveAt
|
diffrax SaveAt object specifying the times at which the solution is stored. |
_SAVEAT_T
|
saveat_x
|
SaveAtX | None
|
Positions at which the unknown vector field is evaluated; if None, self.spatial_cell_middles is used. |
None
|
stepsize_controller
|
AbstractStepSizeController
|
diffrax step size controller. |
_STEPSIZE_CONTROLLER
|
max_steps
|
int | None
|
Maximum number of steps of the time integration. |
None
|
progress_meter
|
AbstractProgressMeter
|
diffrax progress meter. |
_PROGRESS_METER
|
Returns:
| Type | Description |
|---|---|
Solution
|
The diffrax solution of the time integration and the unknown |
Array
|
vector field evaluated at the positions |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/dg_solvax/solvers.py
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | |
RiemannSolver
Solve local Riemann problems at cell and domain boundaries.
The limits of a vector field at a boundary are decomposed into the eigenvectors of the spatial derivative operator; the upwind side is selected per eigenvalue (left for positive, right for negative).
Source code in src/dg_solvax/solvers.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
compute_cell_boundary_values(spatial_derivative_operator, y_left, y_right)
staticmethod
Compute the upwind values at the cell boundaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spatial_derivative_operator
|
Array
|
Constant matrix multiplying the spatial derivative of a vector field. |
required |
y_left
|
Array
|
Limits of a vector field on the left side of the boundaries. |
required |
y_right
|
Array
|
Limits of a vector field on the right side of the boundaries. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
The upwind values of the vector field at the cell |
Array
|
boundaries. |
Source code in src/dg_solvax/solvers.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
compute_domain_boundary_values(spatial_derivative_operator, y_left, y_right, *, reflection_coeffs_left_to_left, reflection_coeffs_right_to_right, transmission_coeffs_left_to_right, transmission_coeffs_right_to_left)
staticmethod
Compute the value at a domain boundary.
The boundary is described by reflection and transmission coefficients, from which a scatter matrix is assembled and applied to the sorted-eigenvalue decomposition of the limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spatial_derivative_operator
|
Array
|
Constant matrix multiplying the spatial derivative of a vector field. |
required |
y_left
|
Array
|
Limit of a vector field on the left of the boundary. |
required |
y_right
|
Array
|
Limit of a vector field on the right of the boundary. |
required |
reflection_coeffs_left_to_left
|
Array | None
|
Reflection coefficients from the left side back to the left side, at the right domain boundary. |
required |
reflection_coeffs_right_to_right
|
Array | None
|
Reflection coefficients from the right side back to the right side, at the left domain boundary. |
required |
transmission_coeffs_left_to_right
|
Array | None
|
Transmission coefficients from the left to the right side, at the left domain boundary. |
required |
transmission_coeffs_right_to_left
|
Array | None
|
Transmission coefficients from the right to the left side, at the right domain boundary. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
The values of a vector field at the domain boundary. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If not exactly one of the two boundary coefficient pairs is given, or if the assembled scatter matrix does not match the dimension of the spatial derivative operator. |
Source code in src/dg_solvax/solvers.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
SystemPartialDiffEqs
Bases: BaseModel
A system of PDEs with constant derivative and no-derivative operators.
Source code in src/dg_solvax/utils/models.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
no_derivative_operator
instance-attribute
spatial_derivative_operator
instance-attribute
SystemPartialDiffEqsProblem
Bases: BaseModel
A PDE problem: the system with initial and boundary values.
Source code in src/dg_solvax/utils/models.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
model_config = ConfigDict(arbitrary_types_allowed=True)
class-attribute
instance-attribute
reflection_coeffs_left_to_left = None
class-attribute
instance-attribute
reflection_coeffs_right_to_right = None
class-attribute
instance-attribute
system_partial_diff_eqs
instance-attribute
transmission_coeffs_left_to_right = None
class-attribute
instance-attribute
transmission_coeffs_right_to_left = None
class-attribute
instance-attribute
vector_field_values_left_boundary
instance-attribute
vector_field_values_right_boundary
instance-attribute
vector_field_values_time_0
instance-attribute
print_partialdiffeqsolve_args()
Print the partialdiffeqsolve arguments.
Prints each of the keyword arguments returned by
provide_partialdiffeqsolve_args.
Source code in src/dg_solvax/utils/models.py
133 134 135 136 137 138 139 140 | |
provide_partialdiffeqsolve_args()
Return the keyword arguments for partialdiffeqsolve as a dict.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Keyword arguments ready to be unpacked into |
dict[str, Any]
|
|
Source code in src/dg_solvax/utils/models.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
get_orthonormal_spatial_functions(max_order, cell_size)
Return orthonormal spatial basis functions up to the given order.
The monomials up to max_order are orthonormalized over one cell of
the given size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_order
|
int
|
Highest polynomial order of the basis functions. |
required |
cell_size
|
float
|
Size of the spatial cell the basis functions are orthonormal over. |
required |
Returns:
| Type | Description |
|---|---|
list[Expr]
|
Orthonormal SymPy expressions of the position variable |
Source code in src/dg_solvax/utils/utils.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
solvers
Discontinuous Galerkin and Riemann solver on JAX.
ExprOfT = Expr
ExprOfX = Expr
Position = float
SaveAtX = Array
Time = float
DiscontinuousGalerkinSolver
Solve (systems of) partial differential equations (PDEs) via the discontinuous Galerkin method on a uniform grid.
The input vector field is represented per cell by coefficients w.r.t. orthonormal spatial basis functions.
Source code in src/dg_solvax/solvers.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | |
spatial_cell_middles = self._spatial_cell_boundaries[:-1] + self._spatial_step_size / 2
instance-attribute
__init__(spatial_domain_boundaries, num_spatial_cells, orthonormal_spatial_functions)
Initialize the grid and the orthonormal spatial basis functions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spatial_domain_boundaries
|
tuple[Position, Position]
|
Left and right boundary of the spatial domain. |
required |
num_spatial_cells
|
int
|
Number of uniform cells the spatial domain is divided into. |
required |
orthonormal_spatial_functions
|
list[ExprOfX]
|
Orthonormal SymPy expressions of a single position variable, used as per-cell basis. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a basis function depends on more than 1 free variable. |
Source code in src/dg_solvax/solvers.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
compute_coeffs_from_initial_conditions_array(yt0, *, check_whether_representable=False)
Compute the coefficients of initial conditions given as an array.
Not yet implemented.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yt0
|
Array
|
Initial conditions sampled on the spatial grid. |
required |
check_whether_representable
|
bool
|
Whether to check exact representability of the initial conditions by the basis functions. |
False
|
Returns:
| Type | Description |
|---|---|
Array
|
Per-cell basis coefficients of the initial conditions. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always, as this is not yet implemented. |
Source code in src/dg_solvax/solvers.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | |
compute_coeffs_from_initial_conditions_functions(yt0, *, check_whether_representable=False)
Compute the per-cell basis coefficients of the initial conditions.
Each component of yt0 is projected onto the orthonormal spatial
functions cell-by-cell by SymPy integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yt0
|
list[ExprOfX]
|
Initial conditions as SymPy expressions of the single
position variable |
required |
check_whether_representable
|
bool
|
Whether to check exact representability of the initial conditions by the basis functions via Parseval's identity; a UserWarning is emitted if the check fails. |
False
|
Returns:
| Type | Description |
|---|---|
Array
|
Per-cell basis coefficients with shape |
Array
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a component of |
Source code in src/dg_solvax/solvers.py
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
partialdiffeqsolve(*, diffeq_solver, t0, t1, dt0, yt0, yx0, yx1, reflection_coeffs_left_to_left=None, reflection_coeffs_right_to_right=None, transmission_coeffs_left_to_right=None, transmission_coeffs_right_to_left=None, spatial_derivative_operator, no_derivative_operator, saveat_t=_SAVEAT_T, saveat_x=None, stepsize_controller=_STEPSIZE_CONTROLLER, max_steps=None, progress_meter=_PROGRESS_METER)
Solve the PDE in time, evaluating at the requested positions.
Initial conditions may be given as SymPy expressions or coefficient arrays; time integration is delegated to diffrax.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diffeq_solver
|
AbstractSolver
|
diffrax solver used for the time integration. |
required |
t0
|
Array
|
Initial time. |
required |
t1
|
Array
|
Final time. |
required |
dt0
|
Array | None
|
Initial time step; None if the step size controller chooses the first step. |
required |
yt0
|
Array | list[ExprOfX]
|
Initial conditions, either as SymPy expressions of |
required |
yx0
|
Array | list[ExprOfT] | None
|
Exterior limit of the unknown vector field at the left
boundary of the spatial domain, as an array or as SymPy
expressions of |
required |
yx1
|
Array | list[ExprOfT] | None
|
Exterior limit of the unknown vector field at the right
boundary of the spatial domain, as an array or as SymPy
expressions of |
required |
reflection_coeffs_left_to_left
|
Array | None
|
Reflection coefficients of the right domain boundary; None for no reflection there. |
None
|
reflection_coeffs_right_to_right
|
Array | None
|
Reflection coefficients of the left domain boundary; None for no reflection there. |
None
|
transmission_coeffs_left_to_right
|
Array | None
|
Transmission coefficients of the left domain boundary; None for no transmission there. |
None
|
transmission_coeffs_right_to_left
|
Array | None
|
Transmission coefficients of the right domain boundary; None for no transmission there. |
None
|
spatial_derivative_operator
|
Array
|
Constant matrix multiplying the spatial derivative of the unknown vector field. |
required |
no_derivative_operator
|
Array
|
Constant matrix multiplying the unknown vector field. |
required |
saveat_t
|
SaveAt
|
diffrax SaveAt object specifying the times at which the solution is stored. |
_SAVEAT_T
|
saveat_x
|
SaveAtX | None
|
Positions at which the unknown vector field is evaluated; if None, self.spatial_cell_middles is used. |
None
|
stepsize_controller
|
AbstractStepSizeController
|
diffrax step size controller. |
_STEPSIZE_CONTROLLER
|
max_steps
|
int | None
|
Maximum number of steps of the time integration. |
None
|
progress_meter
|
AbstractProgressMeter
|
diffrax progress meter. |
_PROGRESS_METER
|
Returns:
| Type | Description |
|---|---|
Solution
|
The diffrax solution of the time integration and the unknown |
Array
|
vector field evaluated at the positions |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/dg_solvax/solvers.py
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | |
RiemannSolver
Solve local Riemann problems at cell and domain boundaries.
The limits of a vector field at a boundary are decomposed into the eigenvectors of the spatial derivative operator; the upwind side is selected per eigenvalue (left for positive, right for negative).
Source code in src/dg_solvax/solvers.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
compute_cell_boundary_values(spatial_derivative_operator, y_left, y_right)
staticmethod
Compute the upwind values at the cell boundaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spatial_derivative_operator
|
Array
|
Constant matrix multiplying the spatial derivative of a vector field. |
required |
y_left
|
Array
|
Limits of a vector field on the left side of the boundaries. |
required |
y_right
|
Array
|
Limits of a vector field on the right side of the boundaries. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
The upwind values of the vector field at the cell |
Array
|
boundaries. |
Source code in src/dg_solvax/solvers.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
compute_domain_boundary_values(spatial_derivative_operator, y_left, y_right, *, reflection_coeffs_left_to_left, reflection_coeffs_right_to_right, transmission_coeffs_left_to_right, transmission_coeffs_right_to_left)
staticmethod
Compute the value at a domain boundary.
The boundary is described by reflection and transmission coefficients, from which a scatter matrix is assembled and applied to the sorted-eigenvalue decomposition of the limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spatial_derivative_operator
|
Array
|
Constant matrix multiplying the spatial derivative of a vector field. |
required |
y_left
|
Array
|
Limit of a vector field on the left of the boundary. |
required |
y_right
|
Array
|
Limit of a vector field on the right of the boundary. |
required |
reflection_coeffs_left_to_left
|
Array | None
|
Reflection coefficients from the left side back to the left side, at the right domain boundary. |
required |
reflection_coeffs_right_to_right
|
Array | None
|
Reflection coefficients from the right side back to the right side, at the left domain boundary. |
required |
transmission_coeffs_left_to_right
|
Array | None
|
Transmission coefficients from the left to the right side, at the left domain boundary. |
required |
transmission_coeffs_right_to_left
|
Array | None
|
Transmission coefficients from the right to the left side, at the right domain boundary. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
The values of a vector field at the domain boundary. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If not exactly one of the two boundary coefficient pairs is given, or if the assembled scatter matrix does not match the dimension of the spatial derivative operator. |
Source code in src/dg_solvax/solvers.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
utils
Utility modules for configs, models, and other utility functions.
configs
Pydantic models for configurations describing complete numerical experiments.
BoundaryCoefficientsConfig
Bases: BaseModel
Reflection and transmission coefficients at the domain boundaries.
Source code in src/dg_solvax/utils/configs.py
45 46 47 48 49 50 51 | |
reflection_coeffs_left_to_left = None
class-attribute
instance-attribute
reflection_coeffs_right_to_right = None
class-attribute
instance-attribute
transmission_coeffs_left_to_right = None
class-attribute
instance-attribute
transmission_coeffs_right_to_left = None
class-attribute
instance-attribute
ProblemConfigBase
Bases: BaseModel
Common fields of all problem configurations.
Source code in src/dg_solvax/utils/configs.py
61 62 63 64 65 66 67 | |
model_config = ConfigDict(arbitrary_types_allowed=True)
class-attribute
instance-attribute
vector_field_values_left_boundary = None
class-attribute
instance-attribute
vector_field_values_right_boundary = None
class-attribute
instance-attribute
vector_field_values_time_0
instance-attribute
SpatialDomainConfig
Bases: BaseModel
Spatial domain: boundaries and cell size.
Source code in src/dg_solvax/utils/configs.py
14 15 16 17 18 19 20 21 22 23 24 25 26 | |
spatial_cell_size
instance-attribute
spatial_domain_boundaries
instance-attribute
TimeIntegrationConfig
Bases: BaseModel
Time integration settings: interval, step size and sampling points.
Source code in src/dg_solvax/utils/configs.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
dt0
instance-attribute
num_space_points
instance-attribute
num_time_points
instance-attribute
t0
instance-attribute
t1
instance-attribute
VisualizationConfig
Bases: BaseModel
Labels and title used for plotting.
Source code in src/dg_solvax/utils/configs.py
54 55 56 57 58 | |
component_labels
instance-attribute
title
instance-attribute
models
Pydantic models of systems of partial differential equations (PDEs) and corresponding PDE problems.
SystemPartialDiffEqs
Bases: BaseModel
A system of PDEs with constant derivative and no-derivative operators.
Source code in src/dg_solvax/utils/models.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
no_derivative_operator
instance-attribute
spatial_derivative_operator
instance-attribute
SystemPartialDiffEqsProblem
Bases: BaseModel
A PDE problem: the system with initial and boundary values.
Source code in src/dg_solvax/utils/models.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
model_config = ConfigDict(arbitrary_types_allowed=True)
class-attribute
instance-attribute
reflection_coeffs_left_to_left = None
class-attribute
instance-attribute
reflection_coeffs_right_to_right = None
class-attribute
instance-attribute
system_partial_diff_eqs
instance-attribute
transmission_coeffs_left_to_right = None
class-attribute
instance-attribute
transmission_coeffs_right_to_left = None
class-attribute
instance-attribute
vector_field_values_left_boundary
instance-attribute
vector_field_values_right_boundary
instance-attribute
vector_field_values_time_0
instance-attribute
print_partialdiffeqsolve_args()
Print the partialdiffeqsolve arguments.
Prints each of the keyword arguments returned by
provide_partialdiffeqsolve_args.
Source code in src/dg_solvax/utils/models.py
133 134 135 136 137 138 139 140 | |
provide_partialdiffeqsolve_args()
Return the keyword arguments for partialdiffeqsolve as a dict.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Keyword arguments ready to be unpacked into |
dict[str, Any]
|
|
Source code in src/dg_solvax/utils/models.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
utils
Symbolic math utilities built on SymPy and JAX.
Provides orthonormal spatial basis functions via Gram-Schmidt and the L2 function inner product over one cell.
get_orthonormal_spatial_functions(max_order, cell_size)
Return orthonormal spatial basis functions up to the given order.
The monomials up to max_order are orthonormalized over one cell of
the given size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_order
|
int
|
Highest polynomial order of the basis functions. |
required |
cell_size
|
float
|
Size of the spatial cell the basis functions are orthonormal over. |
required |
Returns:
| Type | Description |
|---|---|
list[Expr]
|
Orthonormal SymPy expressions of the position variable |
Source code in src/dg_solvax/utils/utils.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |