Skip to main content

Crate tpt_sci_grid

Crate tpt_sci_grid 

Source
Expand description

§tpt-sci-grid

Structured finite-difference grids and stencils for the tpt-science pillar: uniform 1-D, 2-D and 3-D tensor-product grids, finite-difference stencil coefficients, and assembly of discrete PDE operators (Laplacians) on those grids.

This crate is built from scratch (no wrap target — see spec.txt). It is motivated by the compartmental-ODE / structured-grid spatial-model needs of tpt-soma and tpt-cerebrum (reaction–diffusion, cable-equation / cortical-sheet style models).

The assembled operators are returned as DMatrix / DVector from the tpt-math dense linear-algebra substrate (linalg), which is an in-house, dual-licensed (MIT OR Apache-2.0) backend with no nalgebra/faer license exposure, per the workspace policy in ADR 0007.

§Example

use tpt_sci_grid::{laplacian_1d, UniformGrid1D, Boundary};

let g = UniformGrid1D::new(11, 0.0, 1.0).unwrap();
let l = laplacian_1d(&g, Boundary::Dirichlet);
assert_eq!(l.nrows(), 11);
assert_eq!(l.ncols(), 11);

Re-exports§

pub use error::GridError;
pub use grid::Boundary;
pub use grid::UniformGrid1D;
pub use grid::UniformGrid2D;
pub use grid::UniformGrid3D;
pub use grid::linspace;
pub use operator::derivative_1d;
pub use operator::kron;
pub use operator::laplacian_1d;
pub use operator::laplacian_2d;
pub use operator::laplacian_3d;
pub use stencil::Stencil;
pub use sparse::CsrMatrix;
pub use sparse::diffuse_step;
pub use sparse::laplacian_1d_sparse;
pub use sparse::laplacian_2d_sparse;
pub use sparse::laplacian_3d_sparse;
pub use tpt_math_linalg as linalg;

Modules§

error
grid
operator
sparse
Feature-gated sparse-matrix backend for large PDE grids.
stencil

Structs§

DMatrix
Dense matrix / vector types re-exported from the tpt-math substrate so callers can consume assembled operators without a separate dependency. A dynamically-sized matrix of T, stored column-major in a contiguous Vec ((i, j) lives at i + j * nrows).
DVector
Dense matrix / vector types re-exported from the tpt-math substrate so callers can consume assembled operators without a separate dependency. A dynamically-sized column vector of T, stored as a contiguous Vec.