-
Notifications
You must be signed in to change notification settings - Fork 10
Enable general observation function for PDE, and accessing original solution (or other observable quantities) #625
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
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9b68877
code for gradient obsevation
amal-ghamdi 4a9f82b
refactor computing sol gradient
amal-ghamdi 20c9543
add helper methods for mapping solution to observed quantity
amal-ghamdi ace9a52
import helper methods for observed value
amal-ghamdi ce3c732
few updates
amal-ghamdi c3af785
update tests with the new interface of observation operator
amal-ghamdi 8443954
update documentation and classes initializers
amal-ghamdi f077242
fix method interface
amal-ghamdi 0bcb927
add test case
amal-ghamdi fc4f72e
add test data files
amal-ghamdi fe9fa34
fix typo
amal-ghamdi 6a4f3d4
Update observation map module, PDE module and how to example
amal-ghamdi cab5cfb
fix test
amal-ghamdi 90fe50d
Update cuqi/pde/_pde.py
amal-ghamdi 5d1df61
Update cuqi/pde/_pde.py
amal-ghamdi 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,7 @@ | |
| SteadyStateLinearPDE, | ||
| TimeDependentLinearPDE | ||
| ) | ||
|
|
||
| from ._observation_map import ( | ||
| FD_spatial_gradient | ||
| ) | ||
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,36 @@ | ||
| import scipy | ||
| import numpy as np | ||
| """ | ||
| This module contains observation map examples for PDE problems. The map can | ||
| be passed to the `PDE` object initializer via the `observation_map` argument. | ||
|
|
||
| For example on how to use set observation maps in time dependent PDEs, see | ||
| `demos/howtos/TimeDependentLinearPDE.py`. | ||
| """ | ||
|
|
||
| # 1. Steady State Observation Maps | ||
| # -------------------------------- | ||
|
|
||
| # 2. Time-Dependent Observation Maps | ||
| # ----------------------------------- | ||
| def FD_spatial_gradient(sol, grid, times): | ||
| """Time dependent observation map that computes the finite difference (FD) spatial gradient of a solution given at grid points (grid) and times (times). This map is supported for 1D spatial domains only. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| sol : np.ndarray | ||
| The solution array of shape (number of grid points, number of time steps). | ||
|
|
||
| grid : np.ndarray | ||
| The spatial grid points of shape (number of grid points,). | ||
|
|
||
| times : np.ndarray | ||
| The discretized time steps of shape (number of time steps,).""" | ||
|
|
||
| if len(grid.shape) != 1: | ||
| raise ValueError("FD_spatial_gradient only supports 1D spatial domains.") | ||
| observed_quantity = np.zeros((len(grid)-1, len(times))) | ||
| for i in range(observed_quantity.shape[0]): | ||
| observed_quantity[i, :] = ((sol[i, :] - sol[i+1, :])/ | ||
| (grid[i] - grid[i+1])) | ||
| return observed_quantity |
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.
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.