Elliptic1D Add Scalar Boundary Conditions#
Solves the 1D Poisson equation with Robin boundary conditions. This is the exact same problem as elliptic1D.m, with addScalarBC1D
used instead of addRobinBC
. The equation to solve is
with \(x\in[0,1]\). The boundary conditions are given by
with
This corresponds to the call to addScalarBC1D of addScalarBC1D(A,b,k,m,dx,dc,nc,v)
, where dc
, nc
, and vc
are vectors which hold the coefficients for \(a\), \(b\), and \(g\) in the above system of equations. \(a=[1,1]\), \(b=[1,1]\) and \(g=[0,2e]\). Substituting these values in gives:
The key difference is the implementation of the boundary condition operators. In elliptic1D, the RHS of the Robin operator is included on lines 26-28, yet in this example, the boundary conditions are set via the addScalarBC1D
operator.
The true solution is
This example is implemented in:
Additional MATLAB/ OCTAVE variants of this example with different boundary conditions: