jejjohnson / jejjohnson/spectraldiffx

Extend Chebyshev operators: 3D support, integration, quadrature, and physics operators

Open
#28 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Overview

Extend Chebyshev support to match Fourier operator capabilities. Currently only 1D/2D grids and derivatives are available.

## Missing Features

| Feature | Status | Snippet Has? |
|---------|--------|-------------|
| 3D Chebyshev derivatives | NOT SUPPORTED (only 1D/2D) | Yes |
| Integration matrix | NOT SUPPORTED | Yes |
| Clenshaw-Curtis quadrature weights | NOT SUPPORTED | Yes |
| `integrate()` method | NOT SUPPORTED | Yes |
| Jacobian operator | NOT SUPPORTED | Yes |
| Biharmonic operator | NOT SUPPORTED | Yes |
| Hyperviscosity | NOT SUPPORTED | Yes |
| Velocity from streamfunction | NOT SUPPORTED | Yes |
| Vorticity from velocity | NOT SUPPORTED | Yes |
| Vector Laplacian | NOT SUPPORTED | Yes |

## Reference Implementation

**Source:** `jej_vc_snippets/derivatives/spectral_chebychev.py`

Uses the stable Weideman-Reddy formulation for differentiation matrix construction. Integration is via Clenshaw-Curtis quadrature weights computed from the Chebyshev nodes.

## Proposed API

```python
class ChebyshevGrid3D(eqx.Module):
"""3D Chebyshev grid on [a1,b1] × [a2,b2] × [a3,b3]."""
...

class ChebyshevDerivative3D(eqx.Module):
"""3D Chebyshev differentiation operator."""
...

# Extensions to existing classes:
class ChebyshevDerivative1D(eqx.Module):
# Existing: derivative

# NEW:
def integrate(self, f: Float[Array, "N"]) -> float:
"""Clenshaw-Curtis quadrature integration."""

@property
def quadrature_weights(self) -> Float[Array, "N"]:
"""Clenshaw-Curtis weights."""

class ChebyshevDerivative2D(eqx.Module):
# NEW:
def jacobian(self, f, g): ...
def biharmonic(self, f): ...
def velocity_from_streamfunction(self, psi): ...
def vorticity_from_velocity(self, u, v): ...
```

## Target Modules

- `spectraldiffx/_src/chebyshev/grid.py` (add `ChebyshevGrid3D`)
- `spectraldiffx/_src/chebyshev/operators.py` (add 3D derivatives, integration, physics ops)

## Acceptance Criteria

- [ ] `ChebyshevGrid3D` and `ChebyshevDerivative3D`
- [ ] Integration matrix and `integrate()` method (1D, 2D)
- [ ] Clenshaw-Curtis quadrature weights
- [ ] Jacobian, biharmonic, hyperviscosity (2D, 3D)
- [ ] Velocity/streamfunction/vorticity conversions (2D, 3D)
- [ ] Vector Laplacian
- [ ] Tests for all new operators

## Priority

**MEDIUM** — extends Chebyshev to match Fourier capabilities.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.