For example in the Circ_Waveguide.m file, there are some functions defined:

Ex:

func_Ex = ['(' func_Er '*cos(a) - ' func_Ea '*sin(a) )*(rho<' num2str(rad) ')']

How is a assigned to the sin and cos function? All I know is that t is the timestep in such function sin(t).

What does a correspond to?

## How is "a" calculated in a function

**Moderator:** thorsten

### Re: How is "a" calculated in a function

Hello jam,

you can define functions that have access to the following predefined variables:

This means that

If you use Cartesian FDTD, a is calculated as atan2(y,x)

This means therefore, that the electric field excitation (and detection) is defined to be in radial direction. But you are looking at the example for a circular waveguide defined in Cartesian coordinates. Therefore this Er has to be mapped to Ex and Ey using this given transformation from a cylindrical to a Cartesian vector.

A much easier definition for such a waveguide is of course to use the cylindrical FDTD supported by openEMS, Have a look at the Tutorial "Circ_Waveguide"

regards

Thorsten

you can define functions that have access to the following predefined variables:

*x, y, z*as the Cartesian coordinates*rho, a, z*as the cylindrical coordinates*r,t,a*as the spherical coordinatesThis means that

*a*is the azimuth angle between the x-z-plane and the current coordinate...If you use Cartesian FDTD, a is calculated as atan2(y,x)

*a*and*t*are therefore an angle in radiant, and*x,y,z,rho*and*r*are in drawing units, e.g. in mm if you created the mesh to be in this drawing unit...Code: Select all

`func_Ex = ['(' func_Er '*cos(a) - ' func_Ea '*sin(a) )*(rho<' num2str(rad) ')']`

A much easier definition for such a waveguide is of course to use the cylindrical FDTD supported by openEMS, Have a look at the Tutorial "Circ_Waveguide"

regards

Thorsten