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.

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

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

zeros()[source]#

Return a new array filled with zeros.

Returns

A uniform complex 2D array with shape self.discretization.

Return type

array like

Examples#