Skip to content

Poisson 2D

This example solves the classical 2D Poisson equation on the unit square and compares two ways of computing the Laplacian: automatic differentiation and finite differences.

Problem Setup

-Delta u(x,y) = 2 pi^2 sin(pi x) sin(pi y),   (x,y) in [0,1]^2,
u = 0 on the boundary

with exact solution

u(x,y) = sin(pi x) sin(pi y)

Step 1: Build a 2D Domain

The script creates a rectangular domain, samples interior points, and stores the exact solution and forcing on those points.

Step 2: Define a Reusable Solver Factory

The central idea is make_solver(...), which builds the same model twice while only changing the Laplacian scheme.

Step 3: Use a Hard Boundary Envelope

The neural field is multiplied by x(1-x)y(1-y), so homogeneous Dirichlet boundary conditions are satisfied by construction.

Step 4: Train Two Solvers

The script runs one solver with scheme="automatic_differentiation" and a second with scheme="finite_difference".

Step 5: Compare Predictions

After training, both predicted fields are evaluated on the same point cloud and compared against the exact solution.

What To Notice

  • This is a good benchmark for understanding jNO differential operator backends.
  • The same problem setup can be used to compare modeling choices without changing the PDE itself.
  • The script also contains an optional architecture-choice sweep demo using jnn.choice(...).

Script Snippet