TMM

Main class

NonlinearTMM.TMM

alias of NonlinearTMM

class NonlinearTMM.NonlinearTMM

Bases: object

This class is mainly used to calculate linear propagation of plane waves in stratified medium. It can work like ordinary TMM and calculate the propagation of the input waves. It is also capable of nonlinear calculations, but for this purpose use specialized class Second-order NLTMM.

Default constructor takes no arguments.

Attributes:
E0complex

The amplitude of the input plane wave (given in vaccuum, not in the first layer). Only used if overrideE0 is set to True (default is False), otherwise intensity I0 is used instead. Default: 1.0.

I0float

The intensity of the input beam in the first medium. Only used if overrideE0 is set to False (default). Default: 1.0.

betafloat

Normalized tangential wave vector. Determines the angle of incidence through relation beta = sin(theta) * n_p, where theta is angle of incidence and n_p is the refractive index of the prism. Default: not defined.

layerslist of helper class _NonlinerLayer

Allows to access layers by index.

modestr

By default “incident” which corresponds to Ordinary TMM. Other mode is, “nonlinear” but it is automatically set by Second-order NLTMM (i.e, this parameter has to be modified only in special cases).

overrideE0bool

If True, then parameter E0 is used, otherwise intensity I0 is used. Default: False.

polstr

“p” or “s” corresponding to p- and s-polarization, respectively. Default: Not defined.

wave_Wave

Innstance of helper class _Wave for non plane wave calculations.

wlfloat

Wavelength of calculations in meters.

Methods

AddLayer(d, material)

Adds layer to the TMM.

GetAbsorbedIntensity()

Calculates intensity of absorption.

GetEnhancement(layerNr[, z])

Calculates the enhancement of electical field norm at specified layer at fixed z-cooridnate.

GetFields(zs[, dir])

Calculates electical and magnetic fields along z-axis.

GetFields2D(zs, xs[, dir])

Calculates electical and magnetic fields in xz-plane.

GetIntensities()

Returns the intensities and amplitutes of incident, reflected and transmitted wave.

SetParams(**kwargs)

Helper method to set the values of all the attributes.

Solve(**kwargs)

Solves the structure.

Sweep(paramStr, values[, layerNr, layerZ, ...])

Solves the structure for series of values of param paramStr.

WaveGetEnhancement(layerNr[, z])

Calculates enhencment of electical field norm in comparison to the imput beam in vacuum.

WaveGetFields2D(zs, xs[, dirStr])

Calculates 2D electric and magnetic fields of beam propagating in the structure.

WaveGetPowerFlows(layerNr[, x0, x1, z])

Analogous to the GetIntensities, but calculates the powers of the beams instead of the intensities of the plane-waves.

WaveSweep(paramStr, values[, layerNr, ...])

Solves the structure for waves for series of values of param paramStr.

AddLayer(d, material)

Adds layer to the TMM.

Parameters:
dfloat

Thickness of the layer in meters. First and the last medium have infinite thickness.

materialMaterial

Instance of the helper class Material

Examples

>>> tmm = TMM()
>>> tmm.AddLayer(float("inf"), Material.Static(1.5))
>>> tmm.AddLayer(50e-9, Material.Static(0.3 + 3j))
>>> tmm.AddLayer(float("inf"), Material.Static(1.0))
GetAbsorbedIntensity()

Calculates intensity of absorption. The structure must be solved first.

Returns:
float

Absorption intensity

GetEnhancement(layerNr, z=0.0)

Calculates the enhancement of electical field norm at specified layer at fixed z-cooridnate.

Parameters:
layerNrint

Number of layer where to calculate the enhancement.

zfloat

Z-distance from the beginning of the layer.

Returns:
float

The enhancment of the electrical field norm in comparison to the input wave in the vacuum.

GetFields(zs, dir='total')

Calculates electical and magnetic fields along z-axis. The structure must be solved first.

Parameters:
zsndarray of floats

Points on z-axis where to calculate the fields. The beginning of the first layer is at z = 0.

dir{‘total’, ‘forward’, ‘backward’}

Specifies the components of the output fields.

Returns:
_FieldsZ

Helper class to store electric and magnetic fields.

GetFields2D(zs, xs, dir='total')

Calculates electical and magnetic fields in xz-plane. Made as fast as possible. The structure must be solved first.

Parameters:
zsndarray of floats

Points on z-axis where to calculate the fields. The beginning of the first layer is at z = 0.

xsndarray of floats

Points on x-axis where to calculate the fields.

dir{‘total’, ‘forward’, ‘backward’}

Specifies the components of the output fields.

Returns:
_FieldsZX

Helper class to store electric and magnetic fields in regular grid.

GetIntensities()

Returns the intensities and amplitutes of incident, reflected and transmitted wave. The structure must be solved first.

Returns:
_Intensities

Helper class to hold intensity data.

SetParams(**kwargs)

Helper method to set the values of all the attributes. See the docstring of NonlinearTMM.

Solve(**kwargs)

Solves the structure.

Parameters:
wlfloat, optional

Wavelength in meters.

polstr, optional

“p” or “s” denoting the polarization of the waves.

betafloat, optional

Normalized tangential wave vector.

E0complex, optional

Input plane wave amplitude in vacuum. Only used if overrideE0 is True.

I0float, optional

Input plane wave intensity in the first layer. Only used if overrideE0 is False.

overrideE0bool, optional

Selects between E0 and I0.

Examples

>>> tmm.Solve(wl = 532e-9, beta = 0.0)
Sweep(paramStr, values, layerNr=0, layerZ=0, outPwr=True, outAbs=False, outEnh=False)

Solves the structure for series of values of param paramStr. Using this function is more confortable and faster than just changing params and solving the structure.

Parameters:
paramStrstr
‘wl’:

Wavelength in meters

‘beta’:

normalized tangential wavevector

‘I0’:

intensity of the wave

‘d_i’: thikness of layer i (0..N-1)

valuesndarray of floats

Correspondig values of param paramStr.

layerNrint

Specifies layer, where electrical field enhancment is calculated.

layerZdouble

Specifies z-coordinate of enchncment calculation inside layerNr.

outPwrbool

Turns calculation of intensities on/off.

outAbsbool

Turns calculation of absoprtiopn in the entire structure on/off.

outEnhbool

Turns calculation of enhancment in layer layerNr at distance layerZ on/off.values

Returns:
_SweepResultNonlinearTMM

Helper class to store the result.

WaveGetEnhancement(layerNr, z=0.0)

Calculates enhencment of electical field norm in comparison to the imput beam in vacuum. Analogous to GetEnhancement.

Parameters:
layerNrint

Number of layer where to calculate the enhancement.

zfloat

Z-distance from the beginning of the layer.

Returns:
float

The enhancment of the electrical field norm in comparison to the input wave in the vacuum.

WaveGetFields2D(zs, xs, dirStr='total')

Calculates 2D electric and magnetic fields of beam propagating in the structure. Analogous to the GetFields2D of plane waves.

Parameters:
zsndarray of floats

Points on z-axis where to calculate the fields. The beginning of the first layer is at z = 0.

xsndarray of floats

Points on x-axis where to calculate the fields.

dir{‘total’, ‘forward’, ‘backward’}

Specifies the components of the output fields.

Returns:
_FieldsZX

Helper class to store electric and magnetic fields in regular grid.

WaveGetPowerFlows(layerNr, x0=float('nan'), x1=float('nan'), z=0.0)

Analogous to the GetIntensities, but calculates the powers of the beams instead of the intensities of the plane-waves.

Parameters:
layerNrint

Specifies layer number where to calculate the power of the beam.

x0float

Specifies the starting point of the integration of the power in the x-direction. By default this parameter is selected by the _Wave class.

x1float

Specifies the end point of the integration of the power in the x-direction. By default this parameter is selected by the _Wave class.

zfloat

Specifies the z-position of the line through which the integration of the power of the beam is done.

Returns:
tuple of floats (PB, PF)

PB is the power propageted into netagtive infinity and PF denotes the power propagation to the positive direction of z-axis.

WaveSweep(paramStr, values, layerNr=0, layerZ=0.0, outPwr=True, outR=False, outT=False, outEnh=False)

Solves the structure for waves for series of values of param paramStr. Using this function is more confortable and faster than just changing params and solving the structure. Analogous to Sweep.

Parameters:
paramStrstr
‘wl’:

Wavelength in meters

‘beta’:

normalized tangential wavevector

‘I0’:

intensity of the wave

‘d_i’:

thikness of layer i (0..N-1)

‘w0’:

waist size of the input beam

valuesndarray of floats

Correspondig values of param paramStr.

layerNrint

Specifies layer, where electrical field enhancment is calculated.

layerZdouble

Specifies z-coordinate of enchncment calculation inside layerNr.

outPwrbool

Turns calculation of all powers on/off.

outRbool

Turns calculation of reflected power on/off.

outTbool

Turns calculation of transmitted power on/off.

outEnhbool

Turns calculation of enhancment in layer layerNr at distance layerZ on/off.

Returns:
_SweepResultNonlinearTMM

Helper class to store the result.

Helper classes

class NonlinearTMM._Intensities

Bases: object

Helper class to store intensities for NonlinearTMM.

Attributes:
inccomplex

Electical field amplitute of the incident plane wave.

rcomplex

Electical field amplitute of the reflected plane wave.

tcomplex

Electrical field amplitute of the transmitted plane wave.

Ifloat

Intensity of the incident plane wave.

Rfloat

Intensity of the reflected plane wave.

Tfloat

Intensity of the transmitted plane wave.

class NonlinearTMM._SweepResultNonlinearTMM

Bases: object

Helper class to store the result of the NonlinearTMM.Sweep method.

Attributes:
incndarray of complex

The complex amplitutes of the incident plane waves.

rndarray of complex

The complex amplitutes of the reflected plane waves.

tndarray of complex

The complex amplitutes of the transmitted plane waves.

Iindarray of double

The intensities of the incident plane waves.

Irndarray of double

The intensities of the reflected plane waves.

Itndarray of double

The intensities of the transmitted plane waves.

Iandarray of double

The intensities of asborption in the structure.

enhndarray of double

The enhancment values of the electrical field norm.

class NonlinearTMM._WaveSweepResultNonlinearTMM

Bases: object

The helper class to store the results of WaveSweep.

Attributes:
Pindarray of floats

The power of the incident beam.

Prndarray of floats

The power of the reflected beam.

Ptndarray of floats

The power of the transmitted beam.

enhndarray of floats

The enhancment of the beam.

beamAreandarray of floats

The area of the beam with correction of angle of incidence.

class NonlinearTMM._FieldsZ

Bases: object

Helper class to store the results of GetFields.

Attributes:
Endarray(N, 3) of complex

Electrical fields along z-coordinate. First index is determines the z-coorinate and the second corrorrespond to the x-, y-, z-component (0..2).

Hndarray(N, 3) of complex

Magnetic fields along z-coordinate. First index is determines the z-coorinate and the second corrorrespond to the x-, y-, z-component (0..2).

class NonlinearTMM._FieldsZX

Bases: object

Helper class to store the result of GetFields2D and WaveGetFields2D.

Attributes:
Exndarray(N, M) of complex

Electrical field x-component in zx-plane. First index corresponds to z-coorinate and the second to the x-coordinate.

Eyndarray(N, M) of complex

Electrical field y-component in zx-plane. First index corresponds to z-coorinate and the second to the x-coordinate.

Ezndarray(N, M) of complex

Electrical field z-component in zx-plane. First index corresponds to z-coorinate and the second to the x-coordinate.

ENndarray(N, M) of float

Electical field norm in zx-plane. First index corresponds to z-coorinate and the second to the x-coordinate.

Hxndarray(N, M) of complex

Magnetic field x-component in zx-plane. First index corresponds to z-coorinate and the second to the x-coordinate.

Hyndarray(N, M) of complex

Magnetic field y-component in zx-plane. First index corresponds to z-coorinate and the second to the x-coordinate.

Hzndarray(N, M) of complex

Magnetic field z-component in zx-plane. First index corresponds to z-coorinate and the second to the x-coordinate.

HNndarray(N, M) of float

Magnetic field norm in zx-plane. First index corresponds to z-coorinate and the second to the x-coordinate.

class NonlinearTMM._HomogeneousWave

Bases: object

Helper class for NonlinearLayer to describe the parameters of the homogeneous waves in the layer.

Attributes:
kzFcomplex

Z-component of the wave vector.

kxfloat

X-component of the wave vector.

Methods

GetMainFields(z)

Returns forward and backward component of the main fields at the distance z.

GetMainFields(z)

Returns forward and backward component of the main fields at the distance z. In case of s-pol the main field is Ey and in case of p-pol the main field is Hy.

Parameters:
zfloat

z-coorinate for the main fields calculation. z=0 is the beginning of the layer.

Returns:
ndarray(2,) of complex

The foreard and backward component of the main fields.

class NonlinearTMM._NonlinearLayer

Bases: object

Helper class for layer specific data and mathods.

Attributes:
dfloat

The thikness of the layer.

Methods

GetAbsorbedIntensity()

Returns absorbed intensity in the layer.

GetIntensity(z)

Returns intensity of the plane wave at coordinate z.

GetSrcIntensity()

Calculates source power of the layer.

GetAbsorbedIntensity()

Returns absorbed intensity in the layer.

Returns:
float
GetIntensity(z)

Returns intensity of the plane wave at coordinate z.

Parameters:
zfloat

z-coorinate

Returns:
float

The intensity of the plane waves in layer.

GetSrcIntensity()

Calculates source power of the layer. Only nonzero if the material is nonlinear.

Returns:
float
class NonlinearTMM._Wave

Bases: object

This is a helper class for using non plane waves as an input.

Attributes:
waveTypestr
‘planewave’:

Usual plane wave

‘gaussian’:

Standard Gaussian beam with waist size w0

‘tukey’:

Rectangular wave with cosine tapered edges (Tukey window). The width is given by w0 and the tapered region is determined by a.

‘spdc’:

Wave used to represent vacuum fluctuations in case of SPDC calculation.

Default is ‘planewave’.

pwrfloat

Power of the wave (in watts). Default 1.0. The area of the beam is calculated as w0 * Ly.

overrideE0bool

if True, then pwr is ignored and E0 is used. Default False.

E0float

Maximum electrical field of the beam in vacuum.

w0float

Waist size of the beam (in meters). Dafualt is 0.1 mm.

Lyfloat

Beam size in y-direction (in meters). Default is 1 mm.

afloat

Parameter used for Tukey wave. If a = 1, then the wave is perfect rectangle, if a = 0.5, then half of the profile is tapered by cosines. Defualt is 0.7.

nPointsIntegint

Number of points used to represenbt the profile of the wave. Default is 100.

maxXfloat

The wave profile is given in x-range (-maxX..maxX). Only used if dynamicMaxX is False. Default is 1 mm.

dynamicMaxXbool

Selects between dynamic determination of x-span of the wave (region where nPointsInteg samples are taken) or fixed span by maxX. Default is True.

dynamicMaxXCoeffloat

Dynamic maxX equals to the beam width (corrected to the angle of incidence) times dynamicMaxXCoef. Default is 2.0.

dynamicMaxXAdditionfloat

Constant factor that is added to maxX if dynamicMaxX is true. Default is 0.0.

maxPhifloat

Determines the maximum angle of deviation form the direction of propagation of the participating fields. Increases the range of x-span (i.e maxX) if it is neccesary to limit the angular distribution of the participating plane waves. Default is 0.17 rad.

xRangetuple of floats (xMin, xMax)

Current x-span calculated from maxX, dynamicMaxXCoef and maxPhi. The wave must be solved to access this quantity.

betasndarray of floats

Normalized tangential wave vectors of plane wave expansion. The wave must be solved to access this quantity.

phisndarray of floats

Same information as in betas, but converted to angles in respect to the direction of the propagation. The wave must be solved to access this quantity.

kxsndarray of floats

Same information as in betas, but converted to the x-component of the wave vector. The wave must be solved to access this quantity.

kzsndarray of floats

Same information as in betas, but converted to the z-component of the wave vector. The wave must be solved to access this quantity.

fieldProfiletuple(2,) of ndarray of floats (xs, fiedProfile)

The field profile of the input wave sample by nPointsInteg points. The wave must be solved to access this quantity.

expansionCoefsKxndarray of complex

Array of plane wave expansion coefs.

Methods

SetParams(**kwargs)

Helper method to set all the attributes of the class.

SetParams(**kwargs)

Helper method to set all the attributes of the class.

Returns:
None