# electromagneticProperties

## Syntax

## Description

`electromagneticProperties(`

assigns the relative permittivity `emagmodel`

,"RelativePermittivity",`epsilon`

)`epsilon`

to the entire geometry.
Specify the permittivity of vacuum using the electromagnetic model properties. The solver
uses a relative permittivity for electrostatic and harmonic analyses.

For a nonconstant material, specify `epsilon`

as a function
handle.

`electromagneticProperties(`

assigns the relative permeability to the entire geometry. Specify the permeability of vacuum
using the electromagnetic model properties. The solver uses a relative permeability for
magnetostatic and harmonic analyses.`emagmodel`

,"RelativePermeability",`mu`

)

For a nonconstant material, specify `mu`

as a function handle.

`electromagneticProperties(`

assigns the relative permittivity, relative permeability, and conductivity to the entire
geometry. Specify the permittivity and permeability of vacuum using the electromagnetic
model properties. The solver requires all three parameters for a harmonic analysis.`emagmodel`

,"RelativePermittivity",`epsilon`

,"RelativePermeability",`mu`

,"Conductivity",`sigma`

)

For a nonconstant material, specify `epsilon`

,
`mu`

, and `sigma`

as function handles.

`electromagneticProperties(___,`

assigns the material properties to specified faces of a 2-D geometry or cells of a 3-D
geometry. Use this syntax with any of the input argument combinations in the previous
syntaxes.`RegionType`

,`RegionID`

)

returns the material properties object.`mtl`

= electromagneticProperties(___)

## Examples

### Specify Relative Permittivity

Specify relative permittivity for an electrostatic analysis.

Create an electromagnetic model for electrostatic analysis.

emagmodel = createpde("electromagnetic","electrostatic");

Import and plot a geometry of a plate with a hole in its center.

```
gm = importGeometry(emagmodel,"PlateHoleSolid.stl");
pdegplot(gm)
```

Specify the vacuum permittivity value in the SI system of units.

emagmodel.VacuumPermittivity = 8.8541878128E-12;

Specify the relative permittivity of the material.

`mtl = electromagneticProperties(emagmodel,"RelativePermittivity",2.25)`

mtl = ElectromagneticMaterialAssignment with properties: RegionType: 'Cell' RegionID: 1 RelativePermittivity: 2.2500 RelativePermeability: [] Conductivity: []

### Specify Relative Permeability

Specify relative permeability for a magnetostatic analysis.

Create an electromagnetic model for magnetostatic analysis.

emagmodel = createpde("electromagnetic","magnetostatic");

Import and plot a 2-D geometry representing a plate with a hole.

gm = importGeometry(emagmodel,"PlateHolePlanar.stl"); pdegplot(gm,"EdgeLabels","on","FaceLabels","on")

Specify the vacuum permeability value in the SI system of units.

emagmodel.VacuumPermeability = 1.2566370614E-6;

Specify the relative permeability of the material.

`mtl = electromagneticProperties(emagmodel,"RelativePermeability",5000)`

mtl = ElectromagneticMaterialAssignment with properties: RegionType: 'Face' RegionID: 1 RelativePermittivity: [] RelativePermeability: 5000 Conductivity: []

### Specify Conductivity

Specify a conductivity for DC conduction analysis.

Create an electromagnetic model for DC conduction analysis.

emagmodel = createpde("electromagnetic","conduction");

Import and plot a geometry representing a plate with a hole in its center.

```
gm = importGeometry(emagmodel,"PlateHoleSolid.stl");
pdegplot(gm)
```

Specify the conductivity of the material.

`electromagneticProperties(emagmodel,"Conductivity",3.7e7)`

ans = ElectromagneticMaterialAssignment with properties: RegionType: 'Cell' RegionID: 1 RelativePermittivity: [] RelativePermeability: [] Conductivity: 37000000

### Specify Material Properties for Harmonic Analysis

Specify relative permittivity, relative permeability, and conductivity of a material for harmonic analysis.

Create an electromagnetic model for harmonic analysis.

emagmodel = createpde("electromagnetic","harmonic");

Import and plot a geometry of a plate with a hole in its center.

```
gm = importGeometry(emagmodel,"PlateHoleSolid.stl");
pdegplot(gm)
```

Specify the vacuum permittivity and permeability values in the SI system of units.

emagmodel.VacuumPermeability = 1.2566370614E-6; emagmodel.VacuumPermittivity = 8.8541878128E-12;

Specify the relative permittivity, relative permeability, and conductivity of the material.

electromagneticProperties(emagmodel,"RelativePermittivity",2.25, ... "RelativePermeability",5000, ... "Conductivity",1)

ans = ElectromagneticMaterialAssignment with properties: RegionType: 'Cell' RegionID: 1 RelativePermittivity: 2.2500 RelativePermeability: 5000 Conductivity: 1

### Specify Relative Permittivity for Each Face

Specify relative permittivity for individual faces in an electrostatic model.

Create an electromagnetic model for electrostatic analysis.

emagmodel = createpde("electromagnetic","electrostatic");

Create a 2-D geometry with two faces. First, import and plot a 2-D geometry representing a plate with a hole.

gm = importGeometry(emagmodel,"PlateHolePlanar.stl"); pdegplot(gm,"EdgeLabels","on","FaceLabels","on")

Then, fill the hole by adding a face and plot the resulting geometry.

gm = addFace(gm,5); pdegplot(gm,"FaceLabels","on")

Specify the vacuum permittivity value in the SI system of units.

emagmodel.VacuumPermittivity = 8.8541878128E-12;

Specify relative permittivities separately for faces 1 and 2.

electromagneticProperties(emagmodel,"RelativePermittivity",2.25, ... "Face",1)

ans = ElectromagneticMaterialAssignment with properties: RegionType: 'Face' RegionID: 1 RelativePermittivity: 2.2500 RelativePermeability: [] Conductivity: []

electromagneticProperties(emagmodel,"RelativePermittivity",1, ... "Face",2)

ans = ElectromagneticMaterialAssignment with properties: RegionType: 'Face' RegionID: 2 RelativePermittivity: 1 RelativePermeability: [] Conductivity: []

### Specify Nonconstant Relative Permittivity

Use a function handle to specify a relative permittivity that depends on the spatial coordinates.

Create an electromagnetic model for electrostatic analysis.

emagmodel = createpde("electromagnetic","electrostatic");

Create a square geometry and include it in the model.

geometryFromEdges(emagmodel,@squareg);

Specify the vacuum permittivity value in the SI system of units.

emagmodel.VacuumPermittivity = 8.8541878128E-12;

Specify the relative permittivity of the material as a function of the *x*-coordinate, $\epsilon =\sqrt{1+{\mathit{x}}^{2}}$.

```
perm = @(location,~)sqrt(1 + location.x.^2);
electromagneticProperties(emagmodel,"RelativePermittivity",perm)
```

ans = ElectromagneticMaterialAssignment with properties: RegionType: 'Face' RegionID: 1 RelativePermittivity: @(location,~)sqrt(1+location.x.^2) RelativePermeability: [] Conductivity: []

## Input Arguments

`emagmodel`

— Electromagnetic model

`ElectromagneticModel`

object

Electromagnetic model, specified as an `ElectromagneticModel`

object. The model contains a geometry, a mesh, the
electromagnetic properties of the material, the electromagnetic sources, and the
boundary conditions.

`epsilon`

— Relative permittivity

number | function handle

Relative permittivity, specified as a number or a function handle.

Use a positive number to specify a relative permittivity for an electrostatic analysis.

Use a real or complex number to specify a relative permittivity for a harmonic electromagnetic analysis.

Use a function handle to specify a relative permittivity that depends on the coordinates and, for a harmonic analysis, on the frequency.

For details, see More About.

**Data Types: **`double`

| `function_handle`

**Complex Number Support: **Yes

`mu`

— Relative permeability

positive number | complex number | function handle

Relative permeability, specified as a positive or complex number or a function handle.

Use a positive number to specify a relative permeability for a magnetostatic analysis.

Use a complex number to specify a relative permeability for а harmonic electromagnetic analysis.

Use a function handle to specify a relative permeability that depends on the coordinates and, for a harmonic analysis, on the frequency.

For details, see More About.

**Data Types: **`double`

| `function_handle`

**Complex Number Support: **Yes

`sigma`

— Conductivity

nonnegative number | function handle

Conductivity, specified as a nonnegative number or a function handle. Use a function handle to specify a conductivity that depends on the coordinates and, for a harmonic analysis, on the frequency. For details, see More About.

**Data Types: **`double`

| `function_handle`

`RegionType`

— Geometric region type

`"Face"`

for a 2-D model | `"Cell"`

for a 3-D model

Geometric region type, specified as `"Face"`

for a 2-D geometry or
`"Cell"`

for a 3-D geometry.

**Data Types: **`char`

| `string`

`RegionID`

— Region ID

vector of positive integers

Region ID, specified as a vector of positive integers. Find the face or cell IDs by
using `pdegplot`

with the
`"FaceLabels"`

or `"CellLabels"`

name-value argument
set to `"on"`

.

**Example: **`electromagneticProperties(emagmodel,"RelativePermeability",5000,"Face",1:3)`

**Data Types: **`double`

## Output Arguments

`mtl`

— Handle to material properties

`ElectromagneticMaterialAssignment`

object

Handle to material properties, returned as an
`ElectromagneticMaterialAssignment`

object. For more information, see
ElectromagneticMaterialAssignment Properties.

`mtl`

associates material properties with the geometric
faces.

## More About

### Specifying Nonconstant Parameters of Electromagnetic Model

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`

.

electromagneticProperties(emagmodel, ... "RelativePermittivity", ... @myfunPermittivity) electromagneticSource(emagmodel, ... "ChargeDensity",@myfunCharge, ... "Face",2) electromagneticBC(emagmodel, ... "Voltage",@myfunBC, ... "Edge",2)

The function must be of the form:

`function emagVal = myfun(location,state)`

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:`state.frequency`

- Frequency at evaluation points

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 analysisSubdomain 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:

`location.x`

,`location.y`

,`location.z`

,`location.r`

Subdomain ID

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.

### Additional Arguments in Functions for Nonconstant Electromagnetic Parameters

To use additional arguments in your function, wrap your function (that takes additional arguments) with an anonymous function that takes only the `location`

and `state`

arguments. For example:

emagVal = @(location,state) myfunWithAdditionalArgs(location,arg1,arg2,...) electromagneticBC(model,"Edge",3,"Voltage",emagVal)

## Version History

**Introduced in R2021a**

### R2023a: Nonlinear magnetostatics

Relative permeability can depend on the magnetic flux density, magnetic potential, and its gradients.

### R2022a: Material properties for harmonic analysis

Material properties now include conductivity. For harmonic analysis, relative permittivity, relative permeability, and conductivity can depend on frequency. Also for harmonic analysis, relative permittivity and permeability can be a complex value.

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)