I have a simple script to test the curl operator in a shell basis:
# =============================================================================
# Minimal Failing Example for Dedalus v3.0.4 ShellBasis
#
# This script is designed to test the 'curl' operator. It is a mathematically
# well-posed problem (3 variables, 3 boundary conditions) but fails during
# solver build with a 'Non-square system' error, indicating a probable bug
# in the Dedalus library's handling of the curl operator in this geometry.
# =============================================================================
import numpy as np
import dedalus.public as d3
import logging
logger = logging.getLogger(__name__)
# --- Parameters ---
Nphi, Ntheta, Nr = 16, 8, 8 # Low resolution for a fast test
r_inner, r_outer = 1.0, 2.0
dtype = np.float64
# --- Setup ---
coords = d3.SphericalCoordinates('phi', 'theta', 'r')
dist = d3.Distributor(coords, dtype=dtype)
shell = d3.ShellBasis(coords, shape=(Nphi, Ntheta, Nr), radii=(r_inner, r_outer), dealias=3/2, dtype=dtype)
# --- Fields ---
B = dist.VectorField(coords, name='B', bases=shell)
# --- Problem ---
problem = d3.IVP([B], namespace=locals())
# Add the simplest possible equation that uses the curl operator.
problem.add_equation("dt(B) + curl(B) = 0")
# Add the correct number of boundary conditions (3 for a 1st-order system of 3 variables).
problem.add_equation("B(r=r_outer) = 0")
# --- Build Solver ---
try:
logger.info("Attempting to build the solver with a 'curl' operator...")
solver = problem.build_solver(d3.RK222)
logger.info("Solver built successfully.")
except Exception as e:
logger.error("Solver build FAILED.")
logger.error(f"Error Type: {type(e).__name__}")
logger.error(f"Error Message: {e}")
However, I am getting this error even though the problem is well-posed:
2025-09-16 21:58:56,007 __main__ 0/1 INFO :: Attempting to build the solver with a 'curl' operator...
2025-09-16 21:58:56,036 __main__ 0/1 ERROR :: Solver build FAILED.
2025-09-16 21:58:56,036 __main__ 0/1 ERROR :: Error Type: ValueError
2025-09-16 21:58:56,036 __main__ 0/1 ERROR :: Error Message: Non-square system: group=(0, 0, None), I=9, J=8
This seems to be an issue with how Dedalus handles the curl operator in a shell basis.