-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Context
Currently, z_plus_rhs() and z_minus_rhs() compute the Laplacian twice:
- Perpendicular Laplacian:
laplacian(z, kx, ky, kz=None)for Poisson bracket - Full 3D Laplacian:
laplacian(z, kx, ky, kz)for dissipation
Potential Optimization
The perpendicular Laplacian is a subset of the full Laplacian:
∇²⊥z = -(kx² + ky²)|z|²
∇²z = -(kx² + ky² + kz²)|z|²
We could compute the full Laplacian once and extract the perpendicular part.
Current Performance Impact
- Low priority: Laplacian computation is cheap (just array multiplication)
- Current approach prioritizes code clarity
- No bottleneck identified in profiling yet
When to Optimize
Only if profiling shows Laplacian computation is a significant fraction (>5%) of runtime.
Implementation Notes
If optimizing:
- Add
separate_laplacians: bool = Trueparameter - When
False, compute full Laplacian and derive perpendicular part - Benchmark to verify actual speedup
- Keep current implementation as fallback for clarity
Related
- PR feat: Implement Alfvén dynamics with Elsasser variables (Issue #6) #40 (original implementation)
- Code review comment Step 2: Core Spectral Infrastructure #2 about performance optimization
Labels
enhancement, performance, optimization
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request