In Partial Differential Equation Toolbox™, use a function handle to specify these electromagnetic parameters when they
depend on the coordinates and, for a harmonic analysis, on the frequency:
Relative permittivity of the material
Relative permeability of the material
Conductivity of the material
Charge density as source (can depend on space only)
Current density as source (can depend on space only)
Magnetization (can depend on space only)
Voltage on the boundary (can depend on space only)
Magnetic potential on the boundary (can depend on space only)
Electric field on the boundary (can depend on space only)
Magnetic field on the boundary (can depend on space only)
Surface current density on the boundary (can depend on space only)
For example, use function handles to specify the relative permittivity, charge density, and
voltage on the boundary for emagmodel
.
The function must be of the form:
The solver computes and populates the data in the location
and
state
structure arrays and passes this data to your function. You can
define your function so that its output depends on this data. You can use any names in place of
location
and state
.
If you call electromagneticBC
with Vectorized
set to
"on"
, then location
can contain several evaluation
points. If you do not set Vectorized
or set Vectorized
to
"off"
, then the solver passes just one evaluation point in each
call.
location
— A structure array containing these fields:
location.x
— The x-coordinate of the point
or points
location.y
— The y-coordinate of the point
or points
location.z
— For a 3-D or an axisymmetric geometry, the
z-coordinate of the point or points
location.r
— For an axisymmetric geometry, the
r-coordinate of the point or points
Furthermore, for boundary conditions, the solver passes this data in the
location
structure:
location.nx
— The x-component of
the normal vector at the evaluation point or points
location.ny
— The y-component of
the normal vector at the evaluation point or points
location.nz
— For a 3-D or an axisymmetric geometry, the
z-component of the normal vector at the evaluation point or
points
location.nr
— For an axisymmetric geometry, the
r-component of the normal vector at the evaluation point or
points
state
— A structure array containing this field for a harmonic
electromagnetic problem:
Relative permittivity, relative permeability, and conductivity get this data from the
solver:
location.x
, location.y
,
location.z
, location.r
state.frequency
for a harmonic analysis
Subdomain ID
Charge density, current density, magnetization, surface current density on the boundary, and
electric or magnetic field on the boundary get this data from the solver:
Voltage or magnetic potential on the boundary get these data from the solver:
location.x
, location.y
,
location.z
, location.r
location.nx
, location.ny
,
location.nz
, location.nr
When you solve an electrostatic, magnetostatic, or DC conduction problem, the output
returned by the function handle must be of the following size. Here, Np =
numel(location.x)
is the number of points.
1
-by-Np
if a function specifies the nonconstant
relative permittivity, relative permeability, or charge density. For the charge density, the
output can also be Np
-by-1
.
1
-by-Np
for a 2-D model and
3
-by-Np
for a 3-D model if a function specifies the
nonconstant current density and magnetic potential on the boundary. For the current density,
the output can also be Np
-by-1
or
Np
-by-3
.
2
-by-Np
for a 2-D model and
3
-by-Np
for a 3-D model if a function specifies the
nonconstant magnetization or surface current density on the boundary.
When you solve a harmonic problem, the output returned by the function handle must be of the
following size. Here, Np = numel(location.x)
is the number of points.
1
-by-Np
if a function specifies the nonconstant
relative permittivity, relative permeability, and conductivity.
2
-by-Np
for a 2-D problem and
3
-by-Np
for a 3-D problem if a function specifies
the nonconstant electric or magnetic field.
2
-by-Np
or
Np
-by-2
for a 2-D problem and
3
-by-Np
or
Np
-by-3
for a 3-D problem if a function specifies
the nonconstant current density and the field type is electric.
1
-by-Np
or
Np
-by-1
for a 2-D problem and
3
-by-Np
or
Np
-by-3
for a 3-D problem if a function specifies
the nonconstant current density and the field type is magnetic.
If relative permittivity, relative permeability, or conductivity for a harmonic analysis
depends on the frequency, ensure that your function returns a matrix of NaN
values of the correct size when state.frequency
is NaN
.
Solvers check whether a problem is nonlinear by passing NaN
state values and
looking for returned NaN
values.