Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help



Boundary Conditions

Topic: advanced.pde.boundary_conditions

Boundary conditions (BCs) specify constraints on the PDE solution at domain boundaries. They determine eigenvalues and influence solution behavior. Covers Dirichlet, Neumann, Robin, and periodic boundary conditions with implementation details and eigenvalue computation.

Mathematical Definition

Dirichlet (Fixed Value):

Neumann (Fixed Derivative):

Robin (Mixed):

Periodic:

Eigenvalues (1D Dirichlet):

Eigenvalues (1D Neumann):

Boundary Conditions

Types of Boundary Conditions

Boundary conditions (BCs) specify constraints on the PDE solution at domain boundaries. They determine eigenvalues and influence solution behavior.

Dirichlet Boundary Conditions (Fixed Value)

Definition: Function value specified on boundary

Physical examples:

  • Fixed temperature (heat equation): rod end held at 0°C
  • Fixed position (wave equation): string end clamped at zero displacement
  • Fixed potential (Laplace equation): conductor maintained at constant voltage

MathHook support: ✅ FULLY SUPPORTED

Eigenvalues (1D, homogeneous Dirichlet):

Neumann Boundary Conditions (Fixed Derivative)

Definition: Normal derivative specified on boundary

Physical examples:

  • Insulated boundary (heat): no heat flux ()
  • Free end (wave): no force constraint
  • Flux specified (Laplace): given charge density

MathHook support: ⚠️ NOT YET IMPLEMENTED (Phase 2)

Eigenvalues (1D, homogeneous Neumann ):

Note: is allowed (constant mode)!

Eigenfunctions:

Robin (Mixed) Boundary Conditions

Definition: Linear combination of function and derivative

Physical examples:

  • Convective cooling (heat): (Newton's law)
  • Elastic support (wave): restoring force proportional to displacement

MathHook support: ⚠️ NOT YET IMPLEMENTED (Phase 2)

Eigenvalues: Transcendental equation (no closed form for general )

Periodic Boundary Conditions

Definition: Function and derivatives match at endpoints

Physical examples:

  • Circular domain (heat on ring)
  • Periodic structures (wave in periodic medium)

MathHook support: ⚠️ NOT YET IMPLEMENTED (Phase 2)

Eigenvalues:

Eigenfunctions: Both and modes

Boundary Condition Implementation

BoundaryCondition Type

The MathHook implementation uses an enum type for different boundary conditions:

#![allow(unused)]
fn main() {
pub enum BoundaryCondition {
    Dirichlet {
        value: Expression,
        location: BoundaryLocation,
    },
    Neumann {  // ⚠️ NOT YET FUNCTIONAL
        derivative: Expression,
        location: BoundaryLocation,
    },
    Robin {    // ⚠️ NOT YET FUNCTIONAL
        alpha: Expression,
        beta: Expression,
        value: Expression,
        location: BoundaryLocation,
    },
}

pub enum BoundaryLocation {
    Simple {
        variable: Symbol,
        value: Expression,
    },
    // Future: Curved boundaries, multi-dimensional faces
}
}

Current Limitations

Only Dirichlet BCs work in the current implementation.

Workaround for Neumann: Transform to Dirichlet problem (if possible).

Example: Insulated ends

Cannot directly solve, but eigenvalues are known: use cosine modes manually.

Eigenvalue Computation

Dirichlet: Sine Modes

For :

Solution:

MathHook implementation (common/eigenvalues.rs):

#![allow(unused)]
fn main() {
pub fn compute_dirichlet_1d_eigenvalues(
    boundary_conditions: &[BoundaryCondition],
    spatial_var: &Symbol,
    max_terms: usize,
) -> Result<Vec<Expression>, PDEError> {
    let L = extract_domain_length(boundary_conditions, spatial_var)?;

    let eigenvalues: Vec<_> = (1..=max_terms)
        .map(|n| {
            let n_expr = Expression::integer(n as i64);
            let pi = Expression::pi();
            // λₙ = (nπ/L)²
            Expression::pow(
                expr!(n_expr * pi * (L.clone() ^ -1)),
                Expression::integer(2),
            )
        })
        .collect();

    Ok(eigenvalues)
}
}

Wave Equation: Same Eigenvalues, Different Interpretation

For wave equation :

Eigenvalues: (same as heat!)

But: Temporal part is oscillatory, not decaying:

where

Non-Homogeneous Boundary Conditions

Problem

Heat equation with , (non-zero constants).

Cannot directly use separation of variables (BCs not homogeneous).

Solution Strategy

Step 1: Find steady-state satisfying BCs:

Step 2: Define

Step 3: satisfies homogeneous BCs:

Step 4: Solve for using MathHook

Step 5: Recover

MathHook does NOT automate this currently (manual transformation needed).

Time-Dependent Boundary Conditions

Problem

Heat equation with (time-varying).

Cannot use simple separation of variables.

Solution: Duhamel's Principle

Break into sequence of instantaneous problems and superpose.

⚠️ NOT SUPPORTED in MathHook (Phase 2).

Multi-Dimensional Boundary Conditions

2D Rectangle

For Laplace equation on :

Four edges, each with BC:

  • Left ():
  • Right ():
  • Bottom ():
  • Top ():

Strategy: Decompose into four sub-problems (one non-homogeneous edge each), solve each, superpose.

MathHook currently: Handles all four edges but doesn't automate decomposition.

Examples

Homogeneous Dirichlet Boundary Condition

Fixed value at both boundaries (u=0), commonly used for heat equation with fixed temperatures

Rust
#![allow(unused)]
fn main() {
let x = symbol!(x);

// Homogeneous: u(0,t) = 0
let bc_left = BoundaryCondition::dirichlet(
    expr!(0),
    BoundaryLocation::Simple { variable: x.clone(), value: expr!(0) },
);

// Homogeneous: u(L,t) = 0
let bc_right = BoundaryCondition::dirichlet(
    expr!(0),
    BoundaryLocation::Simple { variable: x, value: expr!(1) },
);

}
Python
x = symbol('x')

# Homogeneous: u(0,t) = 0
bc_left = BoundaryCondition.dirichlet(
    expr(0),
    BoundaryLocation.Simple(variable=x, value=expr(0))
)

# Homogeneous: u(L,t) = 0
bc_right = BoundaryCondition.dirichlet(
    expr(0),
    BoundaryLocation.Simple(variable=x, value=expr(1))
)

JavaScript
const x = symbol('x');

// Homogeneous: u(0,t) = 0
const bcLeft = BoundaryCondition.dirichlet(
    expr(0),
    BoundaryLocation.Simple({ variable: x, value: expr(0) })
);

// Homogeneous: u(L,t) = 0
const bcRight = BoundaryCondition.dirichlet(
    expr(0),
    BoundaryLocation.Simple({ variable: x, value: expr(1) })
);

Non-Homogeneous Dirichlet Boundary Condition

Fixed non-zero value at boundary, common in heat transfer with maintained temperatures

Rust
#![allow(unused)]
fn main() {
let x = symbol!(x);

// u(0,t) = 0
let bc_left = BoundaryCondition::dirichlet(
    expr!(0),
    BoundaryLocation::Simple { variable: x.clone(), value: expr!(0) },
);

// Non-homogeneous: u(L,t) = 100
let bc_right = BoundaryCondition::dirichlet(
    expr!(100),
    BoundaryLocation::Simple { variable: x, value: expr!(1) },
);

}
Python
x = symbol('x')

# u(0,t) = 0
bc_left = BoundaryCondition.dirichlet(
    expr(0),
    BoundaryLocation.Simple(variable=x, value=expr(0))
)

# Non-homogeneous: u(L,t) = 100
bc_right = BoundaryCondition.dirichlet(
    expr(100),
    BoundaryLocation.Simple(variable=x, value=expr(1))
)

JavaScript
const x = symbol('x');

// u(0,t) = 0
const bcLeft = BoundaryCondition.dirichlet(
    expr(0),
    BoundaryLocation.Simple({ variable: x, value: expr(0) })
);

// Non-homogeneous: u(L,t) = 100
const bcRight = BoundaryCondition.dirichlet(
    expr(100),
    BoundaryLocation.Simple({ variable: x, value: expr(1) })
);

Performance

Time Complexity: O(n)

API Reference

  • Rust: mathhook_core::pde::boundary::BoundaryCondition
  • Python: mathhook.pde.boundary.BoundaryCondition
  • JavaScript: mathhook.pde.boundary.BoundaryCondition

See Also