Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
run: |
grep -v symengine .test-conda-env-py3.yml > .test-conda-env.yml
CONDA_ENVIRONMENT=.test-conda-env.yml
export PYTEST_ADDOPTS=${PYTEST_ADDOPTS:-"-m 'not slowtest'"}
curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/build-and-test-py-project-within-miniconda.sh
. ./build-and-test-py-project-within-miniconda.sh

Expand All @@ -89,6 +90,7 @@ jobs:
- uses: actions/checkout@v6
- name: "Main Script"
run: |
export PYTEST_ADDOPTS=${PYTEST_ADDOPTS:-"-m 'not slowtest'"}
curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/build-and-test-py-project-within-miniconda.sh
. ./build-and-test-py-project-within-miniconda.sh

Expand Down
7 changes: 6 additions & 1 deletion sumpy/e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,14 @@
[sym.Symbol(f"data{i}")
for i in range(m2l_translation_classes_dependent_ndata)]

ncoeff_src = len(self.src_expansion)
m2l_translation = self.tgt_expansion.m2l_translation

Check warning on line 323 in sumpy/e2e.py

View workflow job for this annotation

GitHub Actions / basedpyright

Type of "m2l_translation" is unknown (reportUnknownMemberType)

Check warning on line 323 in sumpy/e2e.py

View workflow job for this annotation

GitHub Actions / basedpyright

Type of "tgt_expansion" is unknown (reportUnknownMemberType)
if m2l_translation.use_preprocessing:

Check warning on line 324 in sumpy/e2e.py

View workflow job for this annotation

GitHub Actions / basedpyright

Type of "use_preprocessing" is unknown (reportUnknownMemberType)
ncoeff_src = m2l_translation.preprocess_multipole_nexprs(

Check warning on line 325 in sumpy/e2e.py

View workflow job for this annotation

GitHub Actions / basedpyright

Type of "preprocess_multipole_nexprs" is unknown (reportUnknownMemberType)
self.tgt_expansion, self.src_expansion)

Check warning on line 326 in sumpy/e2e.py

View workflow job for this annotation

GitHub Actions / basedpyright

Type of "src_expansion" is unknown (reportUnknownMemberType)

Check warning on line 326 in sumpy/e2e.py

View workflow job for this annotation

GitHub Actions / basedpyright

Type of "tgt_expansion" is unknown (reportUnknownMemberType)
else:
ncoeff_src = len(self.src_expansion)

Check warning on line 328 in sumpy/e2e.py

View workflow job for this annotation

GitHub Actions / basedpyright

Argument type is unknown   Argument corresponds to parameter "obj" in function "len" (reportUnknownArgumentType)

Check warning on line 328 in sumpy/e2e.py

View workflow job for this annotation

GitHub Actions / basedpyright

Type of "src_expansion" is unknown (reportUnknownMemberType)

src_coeff_exprs = [sym.Symbol(f"src_coeffs{i}") for i in range(ncoeff_src)]

Check warning on line 330 in sumpy/e2e.py

View workflow job for this annotation

GitHub Actions / basedpyright

Argument type is partially unknown   Argument corresponds to parameter "stop" in function "__new__"   Argument type is "Unknown | int" (reportUnknownArgumentType)

from sumpy.assignment_collection import SymbolicAssignmentCollection
sac = SymbolicAssignmentCollection()
Expand Down
75 changes: 75 additions & 0 deletions sumpy/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
.. autoclass:: LineOfCompressionKernel
:show-inheritance:
:members: mapper_method
.. autoclass:: HeatKernel
:show-inheritance:
:members: mapper_method

Derivatives
-----------
Expand Down Expand Up @@ -1119,6 +1122,76 @@
return laplacian(w)


class HeatKernel(ExpressionKernel):
r"""The Green's function for the heat equation given by
:math:`e^{-r^2/{4 \alpha t}}/\sqrt{(4 \pi \alpha t)^d}`
where :math:`d` is the number of spatial dimensions.

.. note::

This kernel cannot be used in an FMM yet and can only
be used in expansions and evaluations that occur forward
in the time dimension.
"""
heat_alpha_name: str

mapper_method: ClassVar[str] = "map_heat_kernel"

def __init__(self, spatial_dims: int, heat_alpha_name: str = "alpha"):
dim = spatial_dims + 1
d = make_sym_vector("d", dim)
t = d[-1]
r = pymbolic_real_norm_2(d[:-1])
alpha = SpatialConstant(heat_alpha_name)
expr = var("exp")(-r**2/(4 * alpha * t)) / var("sqrt")(t**(dim - 1))
scaling = 1/var("sqrt")((4*var("pi")*alpha)**(dim - 1))

super().__init__(
dim,
expression=expr,
global_scaling_const=scaling,
)

self.heat_alpha_name = heat_alpha_name

@property
@override
def is_complex_valued(self) -> bool:
return False

def update_persistent_hash(self, key_hash, key_builder):

Check warning on line 1162 in sumpy/kernel.py

View workflow job for this annotation

GitHub Actions / basedpyright

Type of parameter "key_hash" is unknown (reportUnknownParameterType)
key_hash.update(type(self).__name__.encode("utf8"))
key_builder.rec(key_hash, (self.dim, self.heat_alpha_name))

@override
def __repr__(self):
return f"HeatKnl{self.dim - 1}D"

@override
def get_args(self):
return [
KernelArgument(
loopy_arg=lp.ValueArg(self.heat_alpha_name, np.float64),
)]

def get_derivative_taker(self, dvec, rscale, sac):
"""Return a :class:`sumpy.derivative_taker.ExprDerivativeTaker` instance
that supports taking derivatives of the base kernel with respect to dvec.
"""
from sumpy.derivative_taker import ExprDerivativeTaker
return ExprDerivativeTaker(self.get_expression(dvec), dvec, rscale,

Check failure on line 1182 in sumpy/kernel.py

View workflow job for this annotation

GitHub Actions / basedpyright

Argument of type "Matrix" cannot be assigned to parameter "var_list" of type "Sequence[Symbol]" in function "__init__"   "MutableDenseMatrix" is not assignable to "Sequence[Symbol]" (reportArgumentType)
sac)

@override
def get_pde_as_diff_op(self):
from sumpy.expansion.diff_op import diff, laplacian, make_identity_diff_op
alpha = sym.Symbol(self.heat_alpha_name)
w = make_identity_diff_op(self.dim - 1, time_dependent=True)
time_diff = [0]*self.dim
time_diff[-1] = 1
return diff(w, tuple(time_diff)) - laplacian(w) * alpha


# }}}


Expand Down Expand Up @@ -1590,6 +1663,7 @@
map_elasticity_kernel = map_expression_kernel
map_line_of_compression_kernel = map_expression_kernel
map_stresslet_kernel = map_expression_kernel
map_heat_kernel = map_expression_kernel

def map_axis_target_derivative(self, kernel: AxisTargetDerivative) -> Kernel:
return type(kernel)(kernel.axis, self.rec(kernel.inner_kernel))
Expand Down Expand Up @@ -1662,6 +1736,7 @@
map_yukawa_kernel = map_expression_kernel
map_line_of_compression_kernel = map_expression_kernel
map_stresslet_kernel = map_expression_kernel
map_heat_kernel = map_expression_kernel

@override
def map_axis_target_derivative(self, kernel: AxisTargetDerivative) -> int:
Expand Down
Loading
Loading