Skip to main content

Overview

The coordinates module provides coordinate system definitions and transformations for spectral simulations. It includes Cartesian, spherical, polar, and S2 coordinate systems with support for curvilinear coordinates and vector transformations.

Coordinate Systems

Coordinate

Coordinate(name, cs=None)
Basic coordinate class representing a single dimension.

Parameters

  • name (str): Name of the coordinate
  • cs (CoordinateSystem, optional): Parent coordinate system

Attributes

  • dim (int): Dimension (always 1 for Coordinate)
  • curvilinear (bool): Whether coordinate is curvilinear (default: False)
  • coords (tuple): Tuple containing self

Example

import dedalus.public as d3

# Create a coordinate
x = d3.Coordinate('x')

CartesianCoordinates

CartesianCoordinates(*names, right_handed=True)
Cartesian coordinate system with arbitrary dimension.

Parameters

  • names (str): Names for each coordinate axis
  • right_handed (bool, optional): Whether 3D system is right-handed (default: True)

Attributes

  • dim (int): Number of dimensions
  • coords (tuple): Tuple of Coordinate objects
  • curvilinear (bool): Always False for Cartesian

Example

import dedalus.public as d3

# 2D Cartesian coordinates
coords = d3.CartesianCoordinates('x', 'y')

# 3D Cartesian coordinates
coords = d3.CartesianCoordinates('x', 'y', 'z')

SphericalCoordinates

SphericalCoordinates(azimuth, colatitude, radius)
Spherical coordinate system (φ, θ, r).

Parameters

  • azimuth (str): Name of azimuthal coordinate (φ)
  • colatitude (str): Name of colatitude coordinate (θ)
  • radius (str): Name of radial coordinate (r)

Attributes

  • dim (int): Always 3
  • curvilinear (bool): Always True
  • spin_ordering (tuple): Component ordering (-1, +1, 0)
  • right_handed (bool): Always False

Methods

cartesian(phi, theta, r) - Convert to Cartesian coordinates
x, y, z = SphericalCoordinates.cartesian(phi, theta, r)
# x = r * sin(θ) * cos(φ)
# y = r * sin(θ) * sin(φ)  
# z = r * cos(θ)

Example

import dedalus.public as d3
import numpy as np

# Create spherical coordinates
coords = d3.SphericalCoordinates('phi', 'theta', 'r')

# Use in a domain
basis = d3.SphereBasis(coords, (32, 64), radius=1)

S2Coordinates

S2Coordinates(azimuth, colatitude)
Coordinate system on the 2-sphere (azimuth, colatitude).

Parameters

  • azimuth (str): Name of azimuthal coordinate
  • colatitude (str): Name of colatitude coordinate

Attributes

  • dim (int): Always 2
  • curvilinear (bool): Always True
  • spin_ordering (tuple): Component ordering (-1, +1)

Example

import dedalus.public as d3

coords = d3.S2Coordinates('phi', 'theta')

PolarCoordinates

PolarCoordinates(azimuth, radius)
Polar coordinate system in 2D (azimuth, radius).

Parameters

  • azimuth (str): Name of azimuthal coordinate
  • radius (str): Name of radial coordinate

Attributes

  • dim (int): Always 2
  • curvilinear (bool): Always True
  • spin_ordering (tuple): Component ordering (-1, +1)

Methods

cartesian(phi, r) - Convert to Cartesian coordinates
x, y = PolarCoordinates.cartesian(phi, r)
# x = r * cos(φ)
# y = r * sin(φ)

Example

import dedalus.public as d3

coords = d3.PolarCoordinates('phi', 'r')
basis = d3.DiskBasis(coords, (32, 64), radius=1)

DirectProduct

DirectProduct(*coordsystems, right_handed=None)
Direct product of coordinate systems.

Parameters

  • coordsystems: Coordinate system objects to combine
  • right_handed (bool, optional): For 3D systems, whether right-handed

Attributes

  • dim (int): Sum of component system dimensions
  • coords (tuple): Flattened tuple of all coordinates
  • coordsystems (tuple): Component coordinate systems

Example

import dedalus.public as d3

# Combine Cartesian and radial
cart = d3.CartesianCoordinates('x', 'y')
radial = d3.Coordinate('z')
coords = d3.DirectProduct(cart, radial)

See Also

  • Basis - Spectral bases on coordinate systems
  • Field - Fields defined on coordinate systems
  • Operators - Differential operators in various coordinate systems

Build docs developers (and LLMs) love