Skip to content
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

Integrate not working on S2 basis? #313

Open
kgb0255 opened this issue Jan 16, 2025 · 0 comments
Open

Integrate not working on S2 basis? #313

kgb0255 opened this issue Jan 16, 2025 · 0 comments

Comments

@kgb0255
Copy link

kgb0255 commented Jan 16, 2025

Hi!

I'm a new user trying to use dedalus to calculate some integrals with spherical harmonics. I was testing the following simple code snippet to see if the normalization is consistent.

In the code snippet below I attempt to integrate the square of l=2, m=0 spherical harmonics over theta and phi.

import numpy as np
import dedalus.public as d3
from scipy.special import sph_harm


Nphi, Ntheta = 256, 128
dealias = 1
dtype = np.complex128
mesh = None


coords = d3.S2Coordinates('phi', 'theta')
dist = d3.Distributor(coords, dtype=dtype, mesh=mesh)
sphere = d3.SphereBasis(coords, shape=(Nphi, Ntheta), dealias=dealias, radius=1, dtype=dtype)
phi, theta = dist.local_grids(sphere)
phigrid, thetagrid = np.meshgrid(phi[:, 0], theta[0, :], indexing='ij')


Y20 = dist.Field(name='Y20', bases=sphere)
Y20['g'] = sph_harm(0, 2, phigrid, thetagrid)[...]
Y20_sq = Y20*Y20

norm = d3.Integrate(Y20_sq, coords).evaluate()['g'] # should give 1

And I get the following error message.

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[122], line 1
----> 1 d3.Integrate(Y20_sq, coords).evaluate()['g']

File /usr/local/lib/python3.11/site-packages/dedalus/tools/dispatch.py:35, in MultiClass.__call__(cls, *args, **kw)
     32     return exception.output
     34 if len(passlist) == 0:
---> 35     raise NotImplementedError("No subclasses of {} found for the supplied arguments: {}, {}".format(cls, args, kw))
     36 elif len(passlist) > 1:
     37     raise ValueError("Degenerate subclasses of {} found for the supplied arguments {}, {}: {}".format(cls, args, kw, passlist))

NotImplementedError: No subclasses of <class 'dedalus.core.operators.Integrate'> found for the supplied arguments: (Mul(<Field 4825733392>, <Field 4825733392>), <dedalus.core.coords.S2Coordinates object at 0x11f34d450>), {}

Is the integration on 2-sphere not supported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant