In the previous section the structure was assumed to have an inverse symmetry in direction and the matching interface (MI) was automatically set at the outer boundary of the last layer. As the electric component of the electric field at the MI must have non-zero value it was possible only to analyze even TE-like and odd TM-like modes.

In the real problems it is often necessary to consider also the modes with electric field perpendicular to symmetry plane as well as the non-symmetric structure. For this purpose PSlab offers possibility to define the whole structure and set the MI at an arbitrary position.

Consider the structure from the previous example. Assume that in reality the core is not suspended in the air but has a subsrate with below.

>>> substrate = Geometry.addLayer(2.25) >>>

The PML for any layer can be generate automatically with function `generatePML`

which as the arguments take
the adjacent layer and PML parameter .

>>> PML2 = Geometry.generatePML(substrate, sz) >>>

Now the arrangement of the layers can be cleared (assuming you continue session from the previous section) and new one set up.

>>> geometry.clear() >>> geometry.addLayer( PML(width=0.5) ) >>> geometry.addLayer( cladding(4.0) ) >>> geometry.addLayer( core(0.3) ) >>> geometry.setInterface() >>> geometry.addLayer( core(0.3) ) >>> geometry.addLayer( substrate(4.0) ) >>> geometry.addLayer( PML2(width=0.5) ) >>>

`geometry.setInterface()`

gives information about the position of the MI, which is located after
the last added layer. Alternatively you can call this method giving the explicit position of MI as the number
of layers before it. So in the example above you can call equivalently
>>> geometry.setInterface(3) >>>

Please note that the `core`

layer is added twice. In such case PSlab will do the time-consuming
eigendecomposition for this layer only once thus saving the numerical effort. This property is particuralry
useful in case of many periodic layers as e.g. DBR mirrors.

The full code of this section example is to be found in `examples/example2.py` and looks as follow:

#!/usr/bin/python ## Import the program modules from pslab import Geometry, Simulation ## Define the lattice vectors of unit cell a1 = (1,0) a2 = (0,1) ## Declare the geometry geometry = Geometry.Geometry3D(a1, a2) ## Fill it with some layers # PML has anisotropic electric and magnetic tensor sz = 1-2j PML = Geometry.Layer(epsilon=[sz,sz,1/sz], mu=[sz,sz,1/sz]) # Cladding is a uniform layer of air cladding = Geometry.Layer(1) # Core has isotropic epsilon equal to 12.25 and a circular air rod core = Geometry.Layer(12.25) core.addObject( Geometry.Cylinder(center=(0,0), radius=0.3, epsilon=1) ) # The substrate substrate = Geometry.Layer(2.25) # The PML can be generated automatically PML2 = Geometry.generatePML(substrate, sz) ## Now construct a stack geometry.addLayer( PML(width=0.5) ) geometry.addLayer( cladding(4.0) ) geometry.addLayer( core(0.3) ) geometry.setInterface() geometry.addLayer( core(0.3) ) geometry.addLayer( substrate(4.0) ) geometry.addLayer( PML2(width=0.5) ) ## Define the simulation simulation = Simulation(geometry, size=3) ## Find some mode around angular frequency 0.5 c/a mode = simulation.getMode(2.5) print mode