Skip to content

Equations, operators, and spaces

The scalar API accepts linear differential operators and tagged boundary conditions. The symbolic interfaces compile SymPy expressions into these numerical problems.

SymbolicSystem declares coupled scalar stationary fields. SymbolicStokes is the specialized constant-viscosity momentum compiler with prescribed velocity boundaries. Both models expose named symbolic fields for their PDE expressions; those same fields can key the approximation spaces used by the solver.

rbflab.SymbolicScalar

A single scalar field in Cartesian 2D or 3D.

Build equations with SymPy Eq/diff and compile using stationary/evolution. Pass transient=True for a field depending on time. The resulting objects are ordinary LinearPDE/EvolutionPDE instances accepted by existing methods.

data(expression, *, parameters=None)

Compile field-independent spatial data for interpolation or initial values.

operator(expression, *, parameters=None)

Compile a homogeneous spatial expression for low-level numerical use.

stationary(equation, *, boundary, parameters=None)

Compile one linear stationary scalar equation and boundary list.

equation is a SymPy equality or zero residual in the declared field. boundary supplies tagged equations; parameters replace symbolic constants before coefficient extraction. Returns a LinearPDE accepted by global, LHI, or RBF-FD assembly.

evolution(equation, *, initial, boundary, parameters=None)

Compile a first-order-in-time linear scalar evolution problem.

The nonzero time-derivative coefficient is normalized to one. initial is a field expression at start_time. Spatial and boundary functionals remain fixed; forcing and boundary values may depend on time. Returns EvolutionPDE.

rbflab.SymbolicSystem

Named scalar fields, one stationary equation slot per field, in 2D/3D.

A boundary row replaces the equation with the same slot at boundary sites. Interior equations are retained in every slot. LHI pressure constraints use the specified equation slot for an explicit compatibility multiplier.

rbflab.LinearPDE dataclass

Stationary scalar problem operator(u) = rhs with boundary rows.

Call solve(cloud, method) or assemble with a selected numerical method to inspect the matrix before solving.

solve(cloud, method)

Assemble and solve using a selected scalar discretization.

rbflab.BoundaryCondition dataclass

A linear boundary row attached to a cloud label or boundary selection.

Parameters:

Name Type Description Default
on object

Boundary label or selection understood by the cloud.

required
operator object

Boundary functional applied to the unknown.

required
rhs object

Prescribed scalar values or a callable evaluated at boundary points.

required

rbflab.Dirichlet(value=0.0, on='boundary')

Create a value boundary condition u = value on a label.

rbflab.Identity(dimension=2)

Return the value functional in the selected spatial dimension.

rbflab.Derivative(axis, dimension=2)

Return a first Cartesian derivative operator.

Parameters:

Name Type Description Default
axis int

Zero-based coordinate axis.

required
dimension int

Number of spatial coordinates.

2

rbflab.Laplacian(dimension=2)

Return the sum of second Cartesian derivatives.

rbflab.NormalDerivative dataclass

Outward normal derivative, bound to a supplied geometric normal.

The normal vector is data at a boundary point, not a quantity to differentiate. At a corner, boundary tag priority determines which normal applies to the enforced row.

rbflab.Robin dataclass

Boundary functional alpha*u + beta*normal_derivative(u).

The geometric unit normal is supplied when the functional is bound to a boundary point.

rbflab.SpatialOperator dataclass

Sum a_alpha(x) D^alpha, bound at physical evaluation/source points.

Compose/differentiate expressions in SymPy before compiling; binding freezes the resulting coefficient values and never differentiates them a second time.

Spaces also describe explicit local trials through .representers(source) and .translates(points). See functional approximation.

Polynomial augmentation is selected independently on each space. The default polynomial_degree=None omits polynomial columns; an explicit None does the same. An integer requests exactly that total degree, including degrees below a kernel's conventional CPD minimum. Such a choice may make the augmented system singular or less accurate; RBFLAB reports diagnostics but does not reject the degree solely for being below that minimum. Use polynomial_degree="auto" to select the kernel minimum. This controls basis construction, not approximation quality or stability.

For example, constant-only solenoidal velocity polynomials and no pressure polynomial tail can be selected independently:

import rbflab as rbf

model = rbf.SymbolicStokes(2)
u, p = model.fields
equation = -model.laplacian(u) + model.gradient(p)
space = rbf.MixedSpace({
    u: rbf.DivergenceFreeSpace(rbf.PHS(5), polynomial_degree=0),
    p: rbf.PressureSpace(rbf.PHS(5), polynomial_degree=None),
})
method = rbf.GlobalCollocation(spaces=space)

SymbolicSystem works the same way for scalar fields: unpack model.fields, use those symbols in its stationary equations, and use them as keys in a MixedSpace. SymbolicStokes fields retain vector velocity and scalar pressure roles. The same fields also describe local linear spatial functionals:

samples = {
    "momentum": rbf.Samples(points, operator=-nu * rbf.laplacian(u)
                            + rbf.gradient(p)),
    "pressure_gradient": rbf.Samples(points, operator=rbf.gradient(p)),
}
trial = space.representers(samples)
approximation = rbf.LocalApproximation(
    trial=trial, operators={"momentum": -nu * rbf.laplacian(u)
                            + rbf.gradient(p)},
)

These local operators are linear spatial functionals. Use the symbolic model compiler for nonlinear or time-dependent PDE expressions; the local functional API does not compile those PDEs.

This space choice is supported by Python assembly and the C++ MPFR global backend. For C++ MPFR, pass backend=rbf.CppGlobalBackend(...) and precision=rbf.Precision(global_digits=...) to GlobalCollocation. The pressure space is modulo additive constants, so None means no additional pressure polynomial columns; the pressure constant remains omitted as the gauge mode. These options do not imply a general stability guarantee.

rbflab.ScalarSpace dataclass

Scalar radial approximation space with optional polynomials.

Parameters:

Name Type Description Default
kernel object

Scalar radial kernel or bound symbolic kernel.

required
polynomial_degree object

Degree, None, or "auto" for the kernel minimum.

None

representers(source)

Construct trial functions by applying source functionals to the kernel.

Value samples give ordinary kernel translates. Derivative samples give the corresponding source-argument derivatives. The same sample groups can be fitted to obtain Hermite interpolation.

translates(points)

Construct ordinary kernel translates at explicit trial centers.

rbflab.DivergenceFreeSpace dataclass

Bases: ScalarSpace

Velocity space generated by (Hessian - I*Laplacian) of phi.

Every kernel column has zero analytic divergence. Polynomial columns are restricted to a solenoidal nullspace. The space changes the trial basis; it is not an extra discrete divergence constraint.

rbflab.PressureSpace dataclass

Bases: ScalarSpace

Pressure modulo additive constants.

This space omits an independent constant polynomial or gauge row. In LocalApproximation, source, trial and target functionals must annihilate constants. Use ScalarSpace for absolute pressure observations or evaluation and impose any global reference in the assembled equations. Specialized Stokes methods retain their documented pressure output rules.

rbflab.MixedSpace dataclass

Named direct sum of scalar and divergence-free approximation spaces.

Field names describe layout only, not PDE roles. Mixed local construction currently uses matching Hermite representers with explicit FieldOperator samples. A scalar factor retains its constant. A quotient PressureSpace factor omits constant polynomials and only admits observations and targets that annihilate its additive constant.

fields property

Original symbolic fields, or named expressions for string-keyed spaces.

field_spaces property

Field-to-space mapping retaining the user's original declaration keys.

representers(source)

Apply whole mixed sample functionals to the block kernel.

rbflab.FieldOperator dataclass

A rectangular differential block for each named field.

FieldOperator({'u': [[Lap, 0], [0, Lap]], 'p': [[Dx], [Dy]]}) has two outputs. Blocks share a row count; their columns are the field components. Only literal zero is accepted in place of an operator. Spatial dimensions and field widths are validated when bound.

requires_normals property

Whether an unbound scalar entry needs a surface normal.

at_point(point, normal=None)

Bind spatially varying scalar entries without selecting a field.

scalar_rows(fields)

Normalize to scalar rows indexed by field and component.

rbflab.Stencil dataclass

A fixed nearest-site selection shared by multiple sample groups.

Stencil(points, size=37) selects physical sites before groups intersect them with their own points and apply target exclusion. No observations or unknowns are introduced by this geometric object. Coordinates match exactly; missing/excluded sites are not replaced. Selection uses the same nearest-neighbor convention as Samples(size=...). This fixed selection does not grow under a quality stencil policy.

Alternatively, pass indices=memberships instead of size: one sequence of distinct point indices per target. Explicit ordering is preserved.

select(target, row=0)

Return nearest physical-site indices, ordered by distance and index.

rbflab.SharedStencil = Stencil module-attribute

Stencil is the canonical fixed geometric selector. SharedStencil remains an alias for compatibility. Use Stencil(points, size=37) to select a shared set of physical sites, or Stencil(points, indices=memberships) for explicit physical-site index rows (one row per target). Samples(indices=...) remains available for explicit group-local memberships.

rbflab.laplacian(expression)

Apply the Laplacian componentwise to a scalar or vector field expression.

rbflab.gradient(expression)

Map a scalar field expression to its spatial gradient in 2D or 3D.

rbflab.vector(*components)

Stack scalar field expressions into an ordered vector of outputs.

Output length is independent of spatial dimension. Each component must be a scalar expression; use indexing to extract vector components.

rbflab.derivative(expression, axis, order=1)

Differentiate a scalar/vector expression along a zero-based Cartesian axis.

Order is a nonnegative integer. Nest calls for mixed derivatives. Spatial dimension and axis bounds are checked when bound to geometry.

rbflab.dx(expression, order=1)

Differentiate a field expression along coordinate 0 (x).

rbflab.dy(expression, order=1)

Differentiate a field expression along coordinate 1 (y).

rbflab.dz(expression, order=1)

Differentiate a field expression along coordinate 2 (z); requires 3D.

u, p = space.fields returns field expressions in the MixedSpace insertion order. Write -nu * laplacian(u) + gradient(p) and pass it directly to Samples(operator=...) or LocalApproximation.operators. Geometry supplies the spatial dimension (2 or 3). Scalar and vector output shapes must agree under addition. Coefficients are finite real constants; nonlinear products and tensor-valued gradients are not supported. Expressions compile to the existing FieldOperator blocks, whose explicit syntax remains available.

For direct local approximation, PressureSpace admits only constant-invariant source, trial and target functionals, such as pressure derivatives. It never inserts a constant polynomial, including when the requested degree is None. Absolute nodal pressure data or value targets use ScalarSpace; any global gauge belongs to the assembled equations. This resolves the earlier local-engine behavior that silently added a constant and accepted absolute observations.

rbflab.EvolutionPDE dataclass

u_t + operator(u) = rhs(points,t); initial(points) is at start_time.

Spatial coefficients and boundary operators are fixed. Boundary values may depend on time. Extended callbacks use TimeData and PrecisionData.

rbflab.SymbolicStokes

Declare coupled velocity and pressure fields for Stokes momentum.

Accepts one vector velocity and one scalar pressure in Cartesian 2D or 3D. Supply only the momentum vector equation: the selected DivergenceFreeSpace handles incompressibility. The general stationary SymbolicSystem branch remains available for other coupled PDEs.

stationary(equations, *, boundary, parameters=None)

Compile steady momentum rows and tagged velocity boundary data.

Divergence is represented by the chosen velocity space, not by another symbolic equation. Returns SpaceStokesProblem.

evolution(equations, *, initial, boundary, parameters=None)

Compile unsteady momentum with initial velocity only.

initial maps the declared velocity field to a vector expression. No initial pressure is required because pressure is a constraint variable, determined modulo its gauge.

rbflab.CenterGroup dataclass

A named set of LHI data functionals.

points: Nx2/Nx3 coordinates. Solution points must map to cloud interior DOFs. role: solution, pde, boundary, or data. Only solution values are unknown. operator/data: PDE defaults to the problem operator/forcing. Boundary/data groups must supply both; solution uses Identity and has no data. size: nearest-neighbor count after target filtering; None selects all. indices: explicit per-target rows of group-local indices, preserving order. Mutually exclusive with size/policy. One row per interior target. target: allow, exclude, or require geometrical coincidence with target. policy: independent neighbor-selection policy (not a separate kernel scale). normals: optional normals to bind normal-dependent boundary functionals.

Independent groups currently support stationary scalar Python LHI only.