Home | Contact

Calculation of the field of a line-source in front of dielectric half-space.

This example shows how to use the ND-SDP method.

Contents

 Set-up some global variables Set-up parameters Source parameters Grid points at which the field is to be evaluated Set options Calculate field Show the result

Set-up some global variables

```clear
initialize_globals
```

Set-up parameters

```permittivityLowerRegion = 1; % Relative permittivity of the y < 0 region.
permittivityUpperRegion = 3; % Relative permittivity of the y > 0 region.
componentString = 'Ez'; % Cartesian component to calculate.
```

Source parameters

```lambda = 1; % free-space wavelength [m]
Source.lambda = lambda;
Source.polarizationString = 'TM'; % An electric line source, use 'TE' for a magnetic one.
Source.x = 0; Source.y = -lambda; % Source coordinates
```

Grid points at which the field is to be evaluated

```nX = 100; nY = nX;
r = lambda*3;
x = linspace(-r, r, nX);
y = linspace(-r, r, nY);
[EvalAt.x, EvalAt.y] = meshgrid(x,y);
```

Set options

```Options.quasistaticRule = 'discretization'; % Use discretization method for quasi-static case.
% Default value is 'Legendre'.

% if options.useAdaptive = false, the following option must be set:
Options.nPoints = 20; % Number of integration points (should be even).

% if options.useAdaptive = true, the following options must be set:
Options.tol = 1e-3; % Maximum relative error for adaptive scheme.
Options.maxPoints = 2^10; % Max. number of integration points in the adaptive scheme.
```

Calculate field

```tic
field = ndsdp(EvalAt, Source, permittivityLowerRegion, permittivityUpperRegion, componentString, Options);
toc
```
```Elapsed time is 3.651567 seconds.
```

Show the result

```clf
imagesc(x/lambda, y/lambda, real(field));
set(gca, 'ydir', 'normal');
axis image
colorbar
line([min(x/lambda), max(x/lambda)], [0 0])
```