
5.2. IMPLEMENTATION OF EQUATIONS IN COMSOL MULTIPHYSICS 45
where J is a vector and F a scalar, but J could as well be a tensor and F a vector. A
physical interpretation of Eq. (5.7) is that the divergence of a current density J is equal
to a source density F. Most of the equations encountered in physics originate from
conservation laws and can be written on the form Eq. (5.7). To nd a weak solution we
insert the defect d(r) = r J + F from Eq. (5.7) in Eq. (5.4),
Z
h
m
r J + F
i
dr = 0; for all m: (5.8)
Utilizing r ( mJ) = mr J + J r m and Gauss's theorem, we can rewrite Eq. (5.8)
into Z
@
h
mJ n
i
dr +
Z
h
r m J + mF
i
dr = 0; for all m; (5.9)
where n is the outwards pointing surface normal. Equation (5.9) is the theoretical equation
we should have in mind when implementing bulk equation in Comsol, as exemplied in
Section 5.2.
Boundary conditions can be implemented either as Neumann conditions or Dirichlet
conditions. For Neumann conditions the current density J is assigned a xed value Jbd at
the boundary by altering the boundary integral in Eq. (5.9),
Z
@
h
m
J Jbd
i
dr = 0; for all m: (5.10)
n
For Dirichlet conditions a function M, depending on both the physical elds and the spatial
coordinates, is forced to be zero at the boundary
M(g(r); r) = 0: (5.11)
The Dirichlet condition is implemented by use of a Lagrange multiplier, which is a eld
that lives only at the boundary where the Dirichlet condition is applied. For an explanation
on how this boundary condition is coupled to the governing equation (5.9), the reader is
referred to Refs. 45, 46.
5.2 Implementation of equations in Comsol Multiphysics
In this section a practical example is given of how to implement an equation in Comsol,
following the theoretical expression Eq. (5.9). We treat the rst-order frequency-domain
equation (3.14c) governing the temperature eld T1, which is rewritten as
i!0cpT1 + i!pT0p1 = kth
0 r2T1 ) (5.12)
r (kth
0 rT1) + i!(0cpT1 pT0p1) = 0: (5.13)
Following the general divergence equation (5.7), we dene
J = kth
0 rT1; F = i!(0cpT1 pT0p1): (5.14)