Elliptic-curl Problem#
Let \(\Omega \subset \mathbb{R}^d\) be an open Liptschitz bounded set, and we look for the solution of the following problem
where \(\mathbf{f} \in \mathbf{L}^2(\Omega)\), \(\mu \in L^\infty(\Omega)\) and there exists \(\mu_0 > 0\) such that \(\mu \geq \mu_0\) almost everywhere.
The Variational Formulation#
We take the Hilbert space \(V := \mathbf{H}\_0(\mbox{curl}, \Omega)\), in which case the variational formulation writes
Find \(\mathbf{u} \in V\) such that
where
We recall that in \(\mathbf{H}_0(\mbox{curl}, \Omega)\), the bilinear form \(a\) is equivalent to the inner product and is therefor continuous and coercive. Hence, our abstract theory applies and there exists a unique solution to the problem.
Warning
This NB needs to be fixed
Formal Model#
from sympde.expr import BilinearForm, LinearForm, integral
from sympde.expr import find, EssentialBC
from sympde.topology import VectorFunctionSpace, Cube, element_of
from sympde.calculus import curl, dot, grad, div
from sympde.core import Constant
from sympy import pi, sin, cos, Tuple
mu = Constant('mu', is_real=True)
domain = Cube()
V = VectorFunctionSpace('V', domain, kind='Hcurl')
x,y,z = domain.coordinates
u,v = [element_of(V, name=i) for i in ['u', 'v']]
# bilinear form
a = BilinearForm((u,v), integral(domain, dot(curl(v), curl(u)) + mu * dot(u,v)))
# linear form
f1 = sin(pi*x)*sin(pi*y)*sin(pi*z)
f2 = sin(pi*x)*sin(pi*y)*sin(pi*z)
f3 = sin(pi*x)*sin(pi*y)*sin(pi*z)
f = Tuple(f1, f2, f3)
l = LinearForm(v, integral(domain, dot(f,v)))
# Dirichlet boundary conditions
bc = [EssentialBC(u, 0, domain.boundary)]
# Variational problem
equation = find(u, forall=v, lhs=a(u, v), rhs=l(v), bc=bc)
Discretization#
We shall need the discretize function from PsyDAC.
from psydac.api.discretization import discretize
degree = [2,2,2]
ncells = [8,8,8]
# Create computational domain from topological domain
domain_h = discretize(domain, ncells=ncells, comm=None)
# Create discrete spline space
Vh = discretize(V, domain_h, degree=degree)
# Discretize equation
equation_h = discretize(equation, domain_h, [Vh, Vh])
Solving the PDE#
#uh = equation_h.solve()
Computing the error norm#
When the analytical solution is available, you might be interested in computing the \(L^2\) norm or \(H^1_0\) semi-norm. SymPDE allows you to do so, by creating the Norm object. In this example, the analytical solution is given by
Computing the \(L^2\) norm#
#u = element_of(V, name='u')
# create the formal Norm object
#l2norm = Norm(u - ue, domain, kind='l2')
# discretize the norm
#l2norm_h = discretize(l2norm, domain_h, Vh)
# assemble the norm
#l2_error = l2norm_h.assemble(u=uh)
# print the result
#print(l2_error)
Computing the \(H^1\) semi-norm#
# create the formal Norm object
#h1norm = SemiNorm(u - ue, domain, kind='h1')
# discretize the norm
#h1norm_h = discretize(h1norm, domain_h, Vh)
# assemble the norm
#h1_error = h1norm_h.assemble(u=uh)
# print the result
#print(h1_error)
Computing the \(H^1\) norm#
# create the formal Norm object
#h1norm = Norm(u - ue, domain, kind='h1')
# discretize the norm
#h1norm_h = discretize(h1norm, domain_h, Vh)
# assemble the norm
#h1_error = h1norm_h.assemble(u=uh)
# print the result
#print(h1_error)