FEMpy is a pure-Python finite element method differential equation solver.

Basic Usage

To solve a Poisson equation on a 1D interval with Dirichlet boundary conditions:

import numpy as np
from FEMpy import Interval1D, IntervalBasis1D, BoundaryConditions, Poisson1D

def dirichlet_funct(x):
   if x == 0:
      return 1
   elif x == 1:
      return 2

coefficient_funct = lambda x: 1
source_funct = lambda x: 4*x

mesh = Interval1D(left=0, right=1, h=1/4, basis_type='linear')
basis = IntervalBasis1D('linear')

bcs = BoundaryConditions(mesh, boundary_types=('dirichlet', 'dirichlet'), dirichlet_fun=dirichlet_funct)
poisson_eq = Poisson(mesh, test_basis=basis, trial_basis=basis, boundary_conditions=bcs)
poisson_eq.solve(coeff_fun=coefficient_funct, source_fun=source_funct)

A more complete example is available in the quickstart tutorial.