Skip to content

Integrate not working on S2 basis? #313

@kgb0255

Description

@kgb0255

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions