-
Notifications
You must be signed in to change notification settings - Fork 15
Add heat kernel #185
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
isuruf
wants to merge
23
commits into
inducer:main
Choose a base branch
from
isuruf:gt
base: main
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
Add heat kernel #185
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
055b8d8
Add HeatKernel
isuruf a45c315
Fix tests?
isuruf 04f8d35
Fix existing tests
isuruf 10f61f7
Fix test for dim>2
isuruf 8b9777e
Add heat kernel tests
isuruf ad6bc14
test heat equation PDE
isuruf adce9a4
fix tests
isuruf b1d68cb
Add to docs
isuruf a974590
support slow tests
isuruf 6df3254
Skip some 4D tests
isuruf a7f29e2
increase slack
isuruf 33ce473
Update docs for heat kernel
isuruf 1897656
remove incorrect comment
isuruf e2b7619
remove whitespace
isuruf c64a5c9
flip axis in test
isuruf df66f04
HeatKernel for test_translations
isuruf d6d0277
Update test for 4 dimensions (3 spatial + time)
isuruf 656c1b9
Mess around with heat toys
inducer 71c9b72
Fix docstring
isuruf 03168a5
Support FFT with M2L
isuruf bd4c155
Fix M2L with preprocessing but no FFT
isuruf 306c9f6
Fix expansion toys
isuruf fac31eb
Playing around with error models for heat
inducer 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 |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import numpy as np | ||
|
|
||
| import pyopencl as cl | ||
|
|
||
| import sumpy.toys as t | ||
| from sumpy.visualization import FieldPlotter | ||
| from sumpy.kernel import ( # noqa: F401 | ||
| YukawaKernel, | ||
| HeatKernel, | ||
| HelmholtzKernel, | ||
| LaplaceKernel) | ||
|
|
||
| try: | ||
| import matplotlib.pyplot as plt | ||
| USE_MATPLOTLIB = True | ||
| except ImportError: | ||
| USE_MATPLOTLIB = False | ||
|
|
||
|
|
||
| def main(): | ||
| from sumpy.array_context import PyOpenCLArrayContext | ||
| ctx = cl.create_some_context() | ||
| queue = cl.CommandQueue(ctx) | ||
| actx = PyOpenCLArrayContext(queue, force_device_scalars=True) | ||
|
|
||
| tctx = t.ToyContext( | ||
| actx.context, | ||
| # LaplaceKernel(2), | ||
| #YukawaKernel(2), extra_kernel_kwargs={"lam": 5}, | ||
| # HelmholtzKernel(2), extra_kernel_kwargs={"k": 0.3}, | ||
| HeatKernel(1), extra_kernel_kwargs={"alpha": 1}, | ||
| ) | ||
|
|
||
| src_size = 1 | ||
| pt_src = t.PointSources( | ||
| tctx, | ||
| np.array([ | ||
| src_size*(np.random.rand(50) - 0.5), | ||
| np.zeros(50)]), | ||
| np.random.randn(50)) | ||
|
|
||
| fp = FieldPlotter([0, 0.5], extent=np.array([8, 1])) | ||
|
|
||
| if 0 and USE_MATPLOTLIB: | ||
| t.logplot(fp, pt_src, cmap="jet", aspect=8) | ||
| plt.colorbar() | ||
| plt.show() | ||
|
|
||
|
|
||
| p = 5 | ||
| mexp = t.multipole_expand(pt_src, [0, 0], p) | ||
| diff = mexp - pt_src | ||
|
|
||
| x, t = fp.points | ||
|
|
||
| r = np.sqrt(x**2+y**2) | ||
|
|
||
| conv_factor = (src_size/r)**(p+1) | ||
|
|
||
| def logplot_fp(fp: FieldPlotter, values, **kwargs) -> None: | ||
| fp.show_scalar_in_matplotlib( | ||
| np.log10(np.abs(values + 1e-15)), **kwargs) | ||
| if USE_MATPLOTLIB: | ||
| logplot_fp(fp, diff.eval(fp.points)/conv_factor, cmap="jet", vmin=-5, vmax=0, aspect=8) | ||
| plt.colorbar() | ||
| plt.show() | ||
| 1/0 | ||
| mexp2 = t.multipole_expand(mexp, [0, 0.25]) # noqa: F841 | ||
| lexp = t.local_expand(mexp, [3, 0]) | ||
| lexp2 = t.local_expand(lexp, [3, 1], 3) | ||
|
|
||
| # diff = mexp - pt_src | ||
| # diff = mexp2 - pt_src | ||
| diff = lexp2 - pt_src | ||
|
|
||
| print(t.l_inf(diff, 1.2, center=lexp2.center)) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
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 |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ multiline-quotes = """ | |
| [tool:pytest] | ||
| markers = | ||
| mpi: test distributed FMM | ||
| slowtest: mark a test as slow | ||
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.