tidy3d.BoundarySpec#

class BoundarySpec[source]#

Bases: Tidy3dBaseModel

Specifies boundary conditions on each side of the domain and along each dimension.

Parameters:
  • attrs (dict = {}) – Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields, attrs are mutable. For example, the following is allowed for setting an attr obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a TypeError if attrs contain objects that can not be serialized. One can check if attrs are serializable by calling obj.json().

  • x (Boundary = Boundary(attrs={}, plus=PML(attrs={},, name=None,, type='PML',, num_layers=12,, parameters=PMLParams(attrs={},, sigma_order=3,, sigma_min=0.0,, sigma_max=1.5,, type='PMLParams',, kappa_order=3,, kappa_min=1.0,, kappa_max=3.0,, alpha_order=1,, alpha_min=0.0,, alpha_max=0.0)), minus=PML(attrs={},, name=None,, type='PML',, num_layers=12,, parameters=PMLParams(attrs={},, sigma_order=3,, sigma_min=0.0,, sigma_max=1.5,, type='PMLParams',, kappa_order=3,, kappa_min=1.0,, kappa_max=3.0,, alpha_order=1,, alpha_min=0.0,, alpha_max=0.0)), type='Boundary')) – Boundary condition on the plus and minus sides along the x axis. If None, periodic boundaries are applied. Default will change to PML in 2.0 so explicitly setting the boundaries is recommended.

  • y (Boundary = Boundary(attrs={}, plus=PML(attrs={},, name=None,, type='PML',, num_layers=12,, parameters=PMLParams(attrs={},, sigma_order=3,, sigma_min=0.0,, sigma_max=1.5,, type='PMLParams',, kappa_order=3,, kappa_min=1.0,, kappa_max=3.0,, alpha_order=1,, alpha_min=0.0,, alpha_max=0.0)), minus=PML(attrs={},, name=None,, type='PML',, num_layers=12,, parameters=PMLParams(attrs={},, sigma_order=3,, sigma_min=0.0,, sigma_max=1.5,, type='PMLParams',, kappa_order=3,, kappa_min=1.0,, kappa_max=3.0,, alpha_order=1,, alpha_min=0.0,, alpha_max=0.0)), type='Boundary')) – Boundary condition on the plus and minus sides along the y axis. If None, periodic boundaries are applied. Default will change to PML in 2.0 so explicitly setting the boundaries is recommended.

  • z (Boundary = Boundary(attrs={}, plus=PML(attrs={},, name=None,, type='PML',, num_layers=12,, parameters=PMLParams(attrs={},, sigma_order=3,, sigma_min=0.0,, sigma_max=1.5,, type='PMLParams',, kappa_order=3,, kappa_min=1.0,, kappa_max=3.0,, alpha_order=1,, alpha_min=0.0,, alpha_max=0.0)), minus=PML(attrs={},, name=None,, type='PML',, num_layers=12,, parameters=PMLParams(attrs={},, sigma_order=3,, sigma_min=0.0,, sigma_max=1.5,, type='PMLParams',, kappa_order=3,, kappa_min=1.0,, kappa_max=3.0,, alpha_order=1,, alpha_min=0.0,, alpha_max=0.0)), type='Boundary')) – Boundary condition on the plus and minus sides along the z axis. If None, periodic boundaries are applied. Default will change to PML in 2.0 so explicitly setting the boundaries is recommended.

Notes

This BoundarySpec object defines the boundary conditions applied on each of the 6 domain edges, and is provided as an input to the simulation.

A BoundarySpec consists of three Boundary objects, each defining the boundaries on the plus and minus side of each dimension. In most cases, one just wants to specify whether there are absorbing PML layers along any of the x, y, z dimensions. By default, tidy3d simulations have PML boundaries on all sides.

If we want to explicitly set the boundaries, we can use the tidy3d.BoundarySpec.all_sides method. This can be used to set any type of boundary condition on all sides of the simulation. We can also set PML on specified sides only by calling the tidy3d.BoundarySpec.pml method, e.g. BoundarySpec.pml( x=False, y=False, z=False). This will put PML along the dimensions defined as True, and set periodic boundaries along the other dimensions.

See also

Boundary

Boundary conditions at the minus and plus extents along a dimension.

Notebooks
Lectures

Attributes

flipped_bloch_vecs

Return a copy of the instance where all Bloch vectors are multiplied by -1.

to_list

Returns edge-wise boundary conditions along each dimension for internal use.

attrs

Methods

all_sides(boundary)

Set a given boundary condition on all six sides of the domain

pec([x,Β y,Β z])

PEC along specified directions

pmc([x,Β y,Β z])

PMC along specified directions

pml([x,Β y,Β z])

PML along specified directions

Inherited Common Usage

x#
y#
z#
__getitem__(field_name)[source]#

Get the Boundary field by name (boundary_spec[field_name]).

Parameters:

field_name (str) – Name of the axis, eg. β€œy” along which Boundary is requested.

Returns:

Boundary conditions along the given axis.

Return type:

Boundary

classmethod pml(x=False, y=False, z=False)[source]#

PML along specified directions

Parameters:
  • x (bool = False) – Toggle whether to set a default PML on both plus and minus sides along the x axis.

  • y (bool = False) – Toggle whether to set a default PML on both plus and minus sides along the y axis.

  • z (bool = False) – Toggle whether to set a default PML on both plus and minus sides along the z axis.

Example

>>> boundaries = BoundarySpec.pml(y=True)
classmethod pec(x=False, y=False, z=False)[source]#

PEC along specified directions

Parameters:
  • x (bool = False) – Toggle whether to set a PEC condition on both plus and minus sides along the x axis.

  • y (bool = False) – Toggle whether to set a PEC condition on both plus and minus sides along the y axis.

  • z (bool = False) – Toggle whether to set a PEC condition on both plus and minus sides along the z axis.

Example

>>> boundaries = BoundarySpec.pec(x=True, z=True)
classmethod pmc(x=False, y=False, z=False)[source]#

PMC along specified directions

Parameters:
  • x (bool = False) – Toggle whether to set a PMC condition on both plus and minus sides along the x axis.

  • y (bool = False) – Toggle whether to set a PMC condition on both plus and minus sides along the y axis.

  • z (bool = False) – Toggle whether to set a PMC condition on both plus and minus sides along the z axis.

Example

>>> boundaries = BoundarySpec.pmc(x=True, z=True)
classmethod all_sides(boundary)[source]#

Set a given boundary condition on all six sides of the domain

Parameters:

boundary (BoundaryEdge) – Boundary condition to apply on all six sides of the domain.

Example

>>> boundaries = BoundarySpec.all_sides(boundary=PML())
property to_list#

Returns edge-wise boundary conditions along each dimension for internal use.

__hash__()#

Hash method.

property flipped_bloch_vecs#

Return a copy of the instance where all Bloch vectors are multiplied by -1.