# electromagneticProperties

Assign properties of material for electromagnetic model

## Syntax

``electromagneticProperties(emagmodel,'RelativePermittivity',epsilon)``
``electromagneticProperties(emagmodel,'RelativePermeability',mu)``
``electromagneticProperties(___,RegionType,RegionID)``
``mtl = electromagneticProperties(___)``

## Description

example

````electromagneticProperties(emagmodel,'RelativePermittivity',epsilon)` assigns relative permittivity `epsilon` to the entire geometry for an electrostatic model. Specify the permittivity of vacuum using the electromagnetic model properties.For a nonconstant or nonlinear material, specify `epsilon` as a function handle.```

example

````electromagneticProperties(emagmodel,'RelativePermeability',mu)` assigns relative permeability to the entire geometry for a magnetostatic model. Specify the permeability of vacuum using the electromagnetic model properties.For a nonconstant or nonlinear material, specify `mu` as a function handle.```

example

````electromagneticProperties(___,RegionType,RegionID)` assigns the material properties to specified faces. Use this syntax with any of the input arguments from previous syntaxes.```
````mtl = electromagneticProperties(___)` returns the material properties object.```

## Examples

collapse all

Specify relative permittivity for an electrostatic analysis.

Create an electromagnetic model for electrostatic analysis.

`emagmodel = createpde('electromagnetic','electrostatic');`

Import and plot a 2-D geometry.

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

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: 'Face' RegionID: 1 RelativePermittivity: 2.2500 RelativePermeability: [] ```

Specify relative permeability for a magnetostatic analysis.

Create an electromagnetic model for a magnetostatic analysis.

`emagmodel = createpde('electromagnetic','magnetostatic');`

Import and plot a 2-D geometry.

```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 ```

Specify relative permittivity for individual faces in an electrostatic model.

Create an electromagnetic model for an 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: [] ```
`electromagneticProperties(emagmodel,'RelativePermittivity',1,'Face',2)`
```ans = ElectromagneticMaterialAssignment with properties: RegionType: 'Face' RegionID: 2 RelativePermittivity: 1 RelativePermeability: [] ```

Use a function handle to specify a relative permittivity that depends on the electric potential.

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 electric potential,

$\epsilon =\frac{1}{\sqrt{1+{|\nabla \mathit{V}|}^{2}}}$.

```perm = @(region,state) 1./sqrt(1+state.ux.^2 + state.uy.^2); electromagneticProperties(emagmodel,'RelativePermittivity',perm)```
```ans = ElectromagneticMaterialAssignment with properties: RegionType: 'Face' RegionID: 1 RelativePermittivity: @(region,state)1./sqrt(1+state.ux.^2+state.uy.^2) RelativePermeability: [] ```

## Input Arguments

collapse all

Electromagnetic model, specified as an `ElectromagneticModel` object. The model contains a 2-D geometry, a mesh, the electromagnetic properties of the material, the electromagnetic sources, and the boundary conditions.

Example: ```electromagneticmodel = createpde('electromagnetic','electrostatic')```

Relative permittivity, specified as a positive number or a function handle. Use a function handle to specify a relative permittivity that depends on the coordinates or on the solution. For details, see Specifying Nonconstant Parameters of Electromagnetic Model.

Data Types: `double` | `function_handle`

Relative permeability, specified as a positive number or a function handle. Use a function handle to specify a relative permeability that depends on the coordinates or on the solution. For details, see Specifying Nonconstant Parameters of Electromagnetic Model.

Data Types: `double` | `function_handle`

Geometric region type, specified as `'Face'`.

Data Types: `char` | `string`

Face ID, specified as a vector of positive integers. Find the face IDs by using `pdegplot` with the `'FaceLabels'` name-value argument set to `'on'`.

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

Data Types: `double`

## Output Arguments

collapse all

Handle to material properties, returned as an `ElectromagneticMaterialAssignment` object. For more information, see ElectromagneticMaterialAssignment Properties.

`mtl` associates material properties with the geometric faces.

collapse all

### 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 or solution:

• Relative permittivity of the material

• Relative permeability of the material

• Charge density as source

• Current density as source

• Voltage at the boundary

• Magnetic potential at the boundary

For example, use function handles to specify the relative permittivity, charge density, and voltage at the boundary for this model.

```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 passes the `location` and `state` data to your function:

• `location` — A structure 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 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

• `state` — A structure containing these fields for nonlinear problems:

• `state.u` — Electric or magnetic potential at the corresponding points of the location structure

• `state.ux` — Estimates of the x-component of the electric or magnetic field at the corresponding points of the location structure

• `state.uy` — Estimates of the y-component of the electric or magnetic field at the corresponding points of the location structure

• `state.uz` — For an axisymmetric geometry, estimates of the z-component of the electric or magnetic field at the corresponding points of the location structure

• `state.ur` — For an axisymmetric geometry, estimates of the r-component of the electric or magnetic field at the corresponding points of the location structure

Electromagnetic material properties (relative permittivity or relative permeability) and electromagnetic source (charge density or current density) get these data from the solver:

• `location.x`, `location.y`, `location.z`, `location.r`

• Subdomain ID

• `state.u`, `state.ux`, `state.uy`, `state.uz`, `state.ur`

Boundary conditions (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`

• `state.u`

If properties depend on the electric or magnetic potential, ensure that your function returns a matrix of `NaN` of the correct size when `state.u` is `NaN`. Solvers check whether a problem is nonlinear by passing `NaN` state values and looking for returned `NaN` values.

Introduced in R2021a

## Support

#### Try MATLAB, Simulink, and Other Products

Get trial now