How is "a" calculated in a function

How to use openEMS. Discussion on examples, tutorials etc

Moderator: thorsten

Post Reply
jam
Posts: 18
Joined: Wed 28 Mar 2012, 00:17

How is "a" calculated in a function

Post by jam » Thu 05 Apr 2012, 00:39

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?

thorsten
Posts: 1438
Joined: Mon 27 Jun 2011, 12:26

Re: How is "a" calculated in a function

Post by thorsten » Thu 05 Apr 2012, 09:19

Hello jam,

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 coordinates

This 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) ')']
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

Post Reply