Lattice#
- class nannos.Lattice(basis_vectors, discretization=(256, 256), truncation='circular', harmonics_array=None)[source]#
A lattice object defining the unit cell.
- Parameters:
basis_vectors (tuple) – The lattice vectors \(((u_x,u_y),(v_x,v_y))\). For mono-periodic gratings, specify the x-periodicity with a float a.
discretization (int or tuple of length 2) – Spatial discretization of the lattice. If given an integer N, the discretization will be (N, N).
truncation (str) – The truncation method, available values are “circular” and “parallelogrammic” (the default is “circular”). This has no effect for mono-periodic gratings.
harmonics_array (array of shape (2, nh)) – Array of harmonics. If specified, this is used instead of harmonics generated by the lattice object and nh is deduced from it.
- Layer(name='layer', thickness=0, epsilon=1, mu=1, lattice=None, tangent_field=None, tangent_field_type='opt')[source]#
Return a new Layer object.
- Parameters:
name (str, optional) – Name of the layer. The default is “layer”.
thickness (float, optional) – Thickness of the layer. The default is 0.
epsilon (complex or array_like, optional) – Relative permittivity. The default is 1.
mu (complex or array_like, optional) – Relative permeability. The default is 1.
lattice (nannos.Lattice, optional) – The lattice object. The default is None.
tangent_field (array_like, optional) – The tangent field. The default is None.
tangent_field_type (str, optional) – Type of tangent field (‘opt’ or ‘fft’). The default is “opt”.
- Returns:
The new layer object.
- Return type:
nannos.Layer
- constant(value)[source]#
Return a new array filled with value.
- Returns:
A uniform complex 2D array with shape
self.discretization
.- Return type:
array like
- geometry_mask(geom)[source]#
Return a geametry boolean mask discretized on the lattice grid.
- Parameters:
geom (Shapely object) – The geometry.
- Returns:
The shape mask.
- Return type:
array of bool
- get_harmonics(nh, sort=False)[source]#
Get the harmonics with a given truncation method.
- Parameters:
nh (int) – Number of harmonics.
- Returns:
G (list of tuple of integers of length 2) – Harmonics (i1, i2).
nh (int) – The number of harmonics after truncation.
- property grid#
Grid in lattice vectors basis.
- Returns:
The grid of size equal to the attribute discretization.
- Return type:
array like
- property matrix#
Basis matrix.
- Returns:
Matrix containing the lattice vectors (L1,L2).
- Return type:
array like
- ones()[source]#
Return a new array filled with ones.
- Returns:
A uniform complex 2D array with shape
self.discretization
.- Return type:
array like
- polygon(vertices)[source]#
Return a boolean mask for a polygon.
- Parameters:
vertices (array like) – The vertices of the polygon.
- Returns:
The shape mask.
- Return type:
array of bool
- property reciprocal#
Reciprocal matrix.
- Returns:
Matrix containing the lattice vectors (K1,K2) in reciprocal space.
- Return type:
array like
- transform(grid)[source]#
Transform from cartesian to lattice coordinates.
- Parameters:
grid (tuple of array like) – Input grid, typically obtained by meshgrid.
- Returns:
Transformed grid in lattice vectors basis.
- Return type:
array like
- property unit_grid#
Unit grid in cartesian coordinates.
- Returns:
The unit grid of size equal to the attribute discretization.
- Return type:
array like