tidy3d.Medium2D
tidy3d.Medium2D#
- class tidy3d.Medium2D#
Bases:
tidy3d.components.medium.AbstractMedium
2D diagonally anisotropic medium.
- Parameters
name (Optional[str] = None) – Optional unique name for medium.
frequency_range (Optional[Tuple[float, float]] = None) – [units = (Hz, Hz)]. Optional range of validity for the medium.
ss (Union[Medium, PoleResidue, Sellmeier, Lorentz, Debye, Drude]) – Medium describing the ss-component of the diagonal permittivity tensor. The ss-component refers to the in-plane dimension of the medium that is the first component in order of ‘x’, ‘y’, ‘z’. If the 2D material is normal to the y-axis, for example, then this determines the xx-component of the corresponding 3D medium.
tt (Union[Medium, PoleResidue, Sellmeier, Lorentz, Debye, Drude]) – Medium describing the tt-component of the diagonal permittivity tensor. The tt-component refers to the in-plane dimension of the medium that is the second component in order of ‘x’, ‘y’, ‘z’. If the 2D material is normal to the y-axis, for example, then this determines the zz-component of the corresponding 3D medium.
Note
Only diagonal anisotropy is currently supported.
Example
>>> drude_medium = Drude(eps_inf=2.0, coeffs=[(1,2), (3,4)]) >>> medium2d = Medium2D(ss=drude_medium, tt=drude_medium)
Show JSON schema
{ "title": "Medium2D", "description": "2D diagonally anisotropic medium.\n\nParameters\n----------\nname : Optional[str] = None\n Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n [units = (Hz, Hz)]. Optional range of validity for the medium.\nss : Union[Medium, PoleResidue, Sellmeier, Lorentz, Debye, Drude]\n Medium describing the ss-component of the diagonal permittivity tensor. The ss-component refers to the in-plane dimension of the medium that is the first component in order of 'x', 'y', 'z'. If the 2D material is normal to the y-axis, for example, then this determines the xx-component of the corresponding 3D medium.\ntt : Union[Medium, PoleResidue, Sellmeier, Lorentz, Debye, Drude]\n Medium describing the tt-component of the diagonal permittivity tensor. The tt-component refers to the in-plane dimension of the medium that is the second component in order of 'x', 'y', 'z'. If the 2D material is normal to the y-axis, for example, then this determines the zz-component of the corresponding 3D medium.\n\nNote\n----\nOnly diagonal anisotropy is currently supported.\n\nExample\n-------\n>>> drude_medium = Drude(eps_inf=2.0, coeffs=[(1,2), (3,4)])\n>>> medium2d = Medium2D(ss=drude_medium, tt=drude_medium)", "type": "object", "properties": { "name": { "title": "Name", "description": "Optional unique name for medium.", "type": "string" }, "frequency_range": { "title": "Frequency Range", "description": "Optional range of validity for the medium.", "units": [ "Hz", "Hz" ], "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "number" }, { "type": "number" } ] }, "type": { "title": "Type", "default": "Medium2D", "enum": [ "Medium2D" ], "type": "string" }, "ss": { "title": "SS Component", "description": "Medium describing the ss-component of the diagonal permittivity tensor. The ss-component refers to the in-plane dimension of the medium that is the first component in order of 'x', 'y', 'z'. If the 2D material is normal to the y-axis, for example, then this determines the xx-component of the corresponding 3D medium.", "discriminator": { "propertyName": "type", "mapping": { "Medium": "#/definitions/Medium", "PoleResidue": "#/definitions/PoleResidue", "Sellmeier": "#/definitions/Sellmeier", "Lorentz": "#/definitions/Lorentz", "Debye": "#/definitions/Debye", "Drude": "#/definitions/Drude" } }, "oneOf": [ { "$ref": "#/definitions/Medium" }, { "$ref": "#/definitions/PoleResidue" }, { "$ref": "#/definitions/Sellmeier" }, { "$ref": "#/definitions/Lorentz" }, { "$ref": "#/definitions/Debye" }, { "$ref": "#/definitions/Drude" } ] }, "tt": { "title": "TT Component", "description": "Medium describing the tt-component of the diagonal permittivity tensor. The tt-component refers to the in-plane dimension of the medium that is the second component in order of 'x', 'y', 'z'. If the 2D material is normal to the y-axis, for example, then this determines the zz-component of the corresponding 3D medium.", "discriminator": { "propertyName": "type", "mapping": { "Medium": "#/definitions/Medium", "PoleResidue": "#/definitions/PoleResidue", "Sellmeier": "#/definitions/Sellmeier", "Lorentz": "#/definitions/Lorentz", "Debye": "#/definitions/Debye", "Drude": "#/definitions/Drude" } }, "oneOf": [ { "$ref": "#/definitions/Medium" }, { "$ref": "#/definitions/PoleResidue" }, { "$ref": "#/definitions/Sellmeier" }, { "$ref": "#/definitions/Lorentz" }, { "$ref": "#/definitions/Debye" }, { "$ref": "#/definitions/Drude" } ] } }, "required": [ "ss", "tt" ], "additionalProperties": false, "definitions": { "Medium": { "title": "Medium", "description": "Dispersionless medium.\n\nParameters\n----------\nname : Optional[str] = None\n Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n [units = (Hz, Hz)]. Optional range of validity for the medium.\npermittivity : ConstrainedFloatValue = 1.0\n [units = None (relative permittivity)]. Relative permittivity.\nconductivity : ConstrainedFloatValue = 0.0\n [units = S/um]. Electric conductivity. Defined such that the imaginary part of the complex permittivity at angular frequency omega is given by conductivity/omega.\n\nExample\n-------\n>>> dielectric = Medium(permittivity=4.0, name='my_medium')\n>>> eps = dielectric.eps_model(200e12)", "type": "object", "properties": { "name": { "title": "Name", "description": "Optional unique name for medium.", "type": "string" }, "frequency_range": { "title": "Frequency Range", "description": "Optional range of validity for the medium.", "units": [ "Hz", "Hz" ], "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "number" }, { "type": "number" } ] }, "type": { "title": "Type", "default": "Medium", "enum": [ "Medium" ], "type": "string" }, "permittivity": { "title": "Permittivity", "description": "Relative permittivity.", "default": 1.0, "minimum": 1.0, "units": "None (relative permittivity)", "type": "number" }, "conductivity": { "title": "Conductivity", "description": "Electric conductivity. Defined such that the imaginary part of the complex permittivity at angular frequency omega is given by conductivity/omega.", "default": 0.0, "minimum": 0.0, "units": "S/um", "type": "number" } }, "additionalProperties": false }, "ComplexNumber": { "title": "ComplexNumber", "description": "Complex number with a well defined schema.", "type": "object", "properties": { "real": { "title": "Real", "type": "number" }, "imag": { "title": "Imag", "type": "number" } }, "required": [ "real", "imag" ] }, "PoleResidue": { "title": "PoleResidue", "description": "A dispersive medium described by the pole-residue pair model.\nThe frequency-dependence of the complex-valued permittivity is described by:\n\nParameters\n----------\nname : Optional[str] = None\n Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n [units = (Hz, Hz)]. Optional range of validity for the medium.\neps_inf : PositiveFloat = 1.0\n [units = None (relative permittivity)]. Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).\npoles : Tuple[Tuple[Union[tidy3d.components.types.tidycomplex, tidy3d.components.types.ComplexNumber], Union[tidy3d.components.types.tidycomplex, tidy3d.components.types.ComplexNumber]], ...] = ()\n [units = (rad/sec, rad/sec)]. Tuple of complex-valued (:math:`a_i, c_i`) poles for the model.\n\nNote\n----\n.. math::\n\n \\epsilon(\\omega) = \\epsilon_\\infty - \\sum_i\n \\left[\\frac{c_i}{j \\omega + a_i} +\n \\frac{c_i^*}{j \\omega + a_i^*}\\right]\n\nExample\n-------\n>>> pole_res = PoleResidue(eps_inf=2.0, poles=[((1+2j), (3+4j)), ((5+6j), (7+8j))])\n>>> eps = pole_res.eps_model(200e12)", "type": "object", "properties": { "name": { "title": "Name", "description": "Optional unique name for medium.", "type": "string" }, "frequency_range": { "title": "Frequency Range", "description": "Optional range of validity for the medium.", "units": [ "Hz", "Hz" ], "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "number" }, { "type": "number" } ] }, "type": { "title": "Type", "default": "PoleResidue", "enum": [ "PoleResidue" ], "type": "string" }, "eps_inf": { "title": "Epsilon at Infinity", "description": "Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).", "default": 1.0, "units": "None (relative permittivity)", "exclusiveMinimum": 0, "type": "number" }, "poles": { "title": "Poles", "description": "Tuple of complex-valued (:math:`a_i, c_i`) poles for the model.", "default": [], "units": [ "rad/sec", "rad/sec" ], "type": "array", "items": { "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "anyOf": [ { "title": "ComplexNumber", "description": "Complex number with a well defined schema.", "type": "object", "properties": { "real": { "title": "Real", "type": "number" }, "imag": { "title": "Imag", "type": "number" } }, "required": [ "real", "imag" ] }, { "$ref": "#/definitions/ComplexNumber" } ] }, { "anyOf": [ { "title": "ComplexNumber", "description": "Complex number with a well defined schema.", "type": "object", "properties": { "real": { "title": "Real", "type": "number" }, "imag": { "title": "Imag", "type": "number" } }, "required": [ "real", "imag" ] }, { "$ref": "#/definitions/ComplexNumber" } ] } ] } } }, "additionalProperties": false }, "Sellmeier": { "title": "Sellmeier", "description": "A dispersive medium described by the Sellmeier model.\nThe frequency-dependence of the refractive index is described by:\n\nParameters\n----------\nname : Optional[str] = None\n Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n [units = (Hz, Hz)]. Optional range of validity for the medium.\ncoeffs : Tuple[Tuple[float, pydantic.types.PositiveFloat], ...]\n [units = (None, um^2)]. List of Sellmeier (:math:`B_i, C_i`) coefficients.\n\nNote\n----\n.. math::\n\n n(\\lambda)^2 = 1 + \\sum_i \\frac{B_i \\lambda^2}{\\lambda^2 - C_i}\n\nExample\n-------\n>>> sellmeier_medium = Sellmeier(coeffs=[(1,2), (3,4)])\n>>> eps = sellmeier_medium.eps_model(200e12)", "type": "object", "properties": { "name": { "title": "Name", "description": "Optional unique name for medium.", "type": "string" }, "frequency_range": { "title": "Frequency Range", "description": "Optional range of validity for the medium.", "units": [ "Hz", "Hz" ], "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "number" }, { "type": "number" } ] }, "type": { "title": "Type", "default": "Sellmeier", "enum": [ "Sellmeier" ], "type": "string" }, "coeffs": { "title": "Coefficients", "description": "List of Sellmeier (:math:`B_i, C_i`) coefficients.", "units": [ null, "um^2" ], "type": "array", "items": { "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "number" }, { "type": "number", "exclusiveMinimum": 0 } ] } } }, "required": [ "coeffs" ], "additionalProperties": false }, "Lorentz": { "title": "Lorentz", "description": "A dispersive medium described by the Lorentz model.\nThe frequency-dependence of the complex-valued permittivity is described by:\n\nParameters\n----------\nname : Optional[str] = None\n Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n [units = (Hz, Hz)]. Optional range of validity for the medium.\neps_inf : PositiveFloat = 1.0\n [units = None (relative permittivity)]. Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).\ncoeffs : Tuple[Tuple[float, float, float], ...]\n [units = (None (relative permittivity), Hz, Hz)]. List of (:math:`\\Delta\\epsilon_i, f_i, \\delta_i`) values for model.\n\nNote\n----\n.. math::\n\n \\epsilon(f) = \\epsilon_\\infty + \\sum_i\n \\frac{\\Delta\\epsilon_i f_i^2}{f_i^2 - 2jf\\delta_i - f^2}\n\nExample\n-------\n>>> lorentz_medium = Lorentz(eps_inf=2.0, coeffs=[(1,2,3), (4,5,6)])\n>>> eps = lorentz_medium.eps_model(200e12)", "type": "object", "properties": { "name": { "title": "Name", "description": "Optional unique name for medium.", "type": "string" }, "frequency_range": { "title": "Frequency Range", "description": "Optional range of validity for the medium.", "units": [ "Hz", "Hz" ], "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "number" }, { "type": "number" } ] }, "type": { "title": "Type", "default": "Lorentz", "enum": [ "Lorentz" ], "type": "string" }, "eps_inf": { "title": "Epsilon at Infinity", "description": "Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).", "default": 1.0, "units": "None (relative permittivity)", "exclusiveMinimum": 0, "type": "number" }, "coeffs": { "title": "Coefficients", "description": "List of (:math:`\\Delta\\epsilon_i, f_i, \\delta_i`) values for model.", "units": [ "None (relative permittivity)", "Hz", "Hz" ], "type": "array", "items": { "type": "array", "minItems": 3, "maxItems": 3, "items": [ { "type": "number" }, { "type": "number" }, { "type": "number" } ] } } }, "required": [ "coeffs" ], "additionalProperties": false }, "Debye": { "title": "Debye", "description": "A dispersive medium described by the Debye model.\nThe frequency-dependence of the complex-valued permittivity is described by:\n\nParameters\n----------\nname : Optional[str] = None\n Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n [units = (Hz, Hz)]. Optional range of validity for the medium.\neps_inf : PositiveFloat = 1.0\n [units = None (relative permittivity)]. Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).\ncoeffs : Tuple[Tuple[float, pydantic.types.PositiveFloat], ...]\n [units = (None (relative permittivity), sec)]. List of (:math:`\\Delta\\epsilon_i, \\tau_i`) values for model.\n\nNote\n----\n.. math::\n\n \\epsilon(f) = \\epsilon_\\infty + \\sum_i\n \\frac{\\Delta\\epsilon_i}{1 - jf\\tau_i}\n\nExample\n-------\n>>> debye_medium = Debye(eps_inf=2.0, coeffs=[(1,2),(3,4)])\n>>> eps = debye_medium.eps_model(200e12)", "type": "object", "properties": { "name": { "title": "Name", "description": "Optional unique name for medium.", "type": "string" }, "frequency_range": { "title": "Frequency Range", "description": "Optional range of validity for the medium.", "units": [ "Hz", "Hz" ], "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "number" }, { "type": "number" } ] }, "type": { "title": "Type", "default": "Debye", "enum": [ "Debye" ], "type": "string" }, "eps_inf": { "title": "Epsilon at Infinity", "description": "Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).", "default": 1.0, "units": "None (relative permittivity)", "exclusiveMinimum": 0, "type": "number" }, "coeffs": { "title": "Coefficients", "description": "List of (:math:`\\Delta\\epsilon_i, \\tau_i`) values for model.", "units": [ "None (relative permittivity)", "sec" ], "type": "array", "items": { "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "number" }, { "type": "number", "exclusiveMinimum": 0 } ] } } }, "required": [ "coeffs" ], "additionalProperties": false }, "Drude": { "title": "Drude", "description": "A dispersive medium described by the Drude model.\nThe frequency-dependence of the complex-valued permittivity is described by:\n\nParameters\n----------\nname : Optional[str] = None\n Optional unique name for medium.\nfrequency_range : Optional[Tuple[float, float]] = None\n [units = (Hz, Hz)]. Optional range of validity for the medium.\neps_inf : PositiveFloat = 1.0\n [units = None (relative permittivity)]. Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).\ncoeffs : Tuple[Tuple[float, pydantic.types.PositiveFloat], ...]\n [units = (Hz, Hz)]. List of (:math:`f_i, \\delta_i`) values for model.\n\nNote\n----\n.. math::\n\n \\epsilon(f) = \\epsilon_\\infty - \\sum_i\n \\frac{ f_i^2}{f^2 + jf\\delta_i}\n\nExample\n-------\n>>> drude_medium = Drude(eps_inf=2.0, coeffs=[(1,2), (3,4)])\n>>> eps = drude_medium.eps_model(200e12)", "type": "object", "properties": { "name": { "title": "Name", "description": "Optional unique name for medium.", "type": "string" }, "frequency_range": { "title": "Frequency Range", "description": "Optional range of validity for the medium.", "units": [ "Hz", "Hz" ], "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "number" }, { "type": "number" } ] }, "type": { "title": "Type", "default": "Drude", "enum": [ "Drude" ], "type": "string" }, "eps_inf": { "title": "Epsilon at Infinity", "description": "Relative permittivity at infinite frequency (:math:`\\epsilon_\\infty`).", "default": 1.0, "units": "None (relative permittivity)", "exclusiveMinimum": 0, "type": "number" }, "coeffs": { "title": "Coefficients", "description": "List of (:math:`f_i, \\delta_i`) values for model.", "units": [ "Hz", "Hz" ], "type": "array", "items": { "type": "array", "minItems": 2, "maxItems": 2, "items": [ { "type": "number" }, { "type": "number", "exclusiveMinimum": 0 } ] } } }, "required": [ "coeffs" ], "additionalProperties": false } } }
- attribute frequency_range: Tuple[float, float] = None#
Optional range of validity for the medium.
- attribute name: str = None#
Optional unique name for medium.
- Validated by
field_has_unique_names
- attribute ss: Union[tidy3d.components.medium.Medium, tidy3d.components.medium.PoleResidue, tidy3d.components.medium.Sellmeier, tidy3d.components.medium.Lorentz, tidy3d.components.medium.Debye, tidy3d.components.medium.Drude] [Required]#
Medium describing the ss-component of the diagonal permittivity tensor. The ss-component refers to the in-plane dimension of the medium that is the first component in order of ‘x’, ‘y’, ‘z’. If the 2D material is normal to the y-axis, for example, then this determines the xx-component of the corresponding 3D medium.
- attribute tt: Union[tidy3d.components.medium.Medium, tidy3d.components.medium.PoleResidue, tidy3d.components.medium.Sellmeier, tidy3d.components.medium.Lorentz, tidy3d.components.medium.Debye, tidy3d.components.medium.Drude] [Required]#
Medium describing the tt-component of the diagonal permittivity tensor. The tt-component refers to the in-plane dimension of the medium that is the second component in order of ‘x’, ‘y’, ‘z’. If the 2D material is normal to the y-axis, for example, then this determines the zz-component of the corresponding 3D medium.
- classmethod add_type_field() None #
Automatically place “type” field with model name in the model field dictionary.
- classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model #
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
- copy(**kwargs) tidy3d.components.base.Tidy3dBaseModel #
Copy a Tidy3dBaseModel. With
deep=True
as default.
- dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny #
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- classmethod dict_from_file(fname: str, group_path: Optional[str] = None) dict #
Loads a dictionary containing the model from a .yaml, .json, or .hdf5 file.
- Parameters
fname (str) – Full path to the .yaml or .json file to load the
Tidy3dBaseModel
from.group_path (str, optional) – Path to a group inside the file to use as the base level.
- Returns
A dictionary containing the model.
- Return type
dict
Example
>>> simulation = Simulation.from_file(fname='folder/sim.json')
- classmethod dict_from_hdf5(fname: str, group_path: str = '') dict #
Loads a dictionary containing the model contents from a .hdf5 file.
- Parameters
fname (str) – Full path to the .hdf5 file to load the
Tidy3dBaseModel
from.group_path (str, optional) – Path to a group inside the file to selectively load a sub-element of the model only.
- Returns
Dictionary containing the model.
- Return type
dict
Example
>>> sim_dict = Simulation.dict_from_hdf5(fname='folder/sim.hdf5')
- classmethod dict_from_json(fname: str) dict #
Load dictionary of the model from a .json file.
- Parameters
fname (str) – Full path to the .json file to load the
Tidy3dBaseModel
from.- Returns
A dictionary containing the model.
- Return type
dict
Example
>>> sim_dict = Simulation.dict_from_json(fname='folder/sim.json')
- classmethod dict_from_yaml(fname: str) dict #
Load dictionary of the model from a .yaml file.
- Parameters
fname (str) – Full path to the .yaml file to load the
Tidy3dBaseModel
from.- Returns
A dictionary containing the model.
- Return type
dict
Example
>>> sim_dict = Simulation.dict_from_yaml(fname='folder/sim.yaml')
- static eps_complex_to_eps_sigma(eps_complex: complex, freq: float) Tuple[float, float] #
Convert complex permittivity at frequency
freq
to permittivity and conductivity values.- Parameters
eps_complex (complex) – Complex-valued relative permittivity.
freq (float) – Frequency to evaluate permittivity at (Hz).
- Returns
Real part of relative permittivity & electric conductivity.
- Return type
Tuple[float, float]
- static eps_complex_to_nk(eps_c: complex) Tuple[float, float] #
Convert complex permittivity to n, k values.
- Parameters
eps_c (complex) – Complex-valued relative permittivity.
- Returns
Real and imaginary parts of refractive index (n & k).
- Return type
Tuple[float, float]
- eps_diagonal(frequency: float) Tuple[complex, complex] #
Main diagonal of the complex-valued permittivity tensor as a function of frequency.
- eps_model(frequency: float) complex #
Complex-valued permittivity as a function of frequency.
- static eps_sigma_to_eps_complex(eps_real: float, sigma: float, freq: float) complex #
convert permittivity and conductivity to complex permittivity at freq
- Parameters
eps_real (float) – Real-valued relative permittivity.
sigma (float) – Conductivity.
freq (float) – Frequency to evaluate permittivity at (Hz). If not supplied, returns real part of permittivity (limit as frequency -> infinity.)
- Returns
Complex-valued relative permittivity.
- Return type
complex
- classmethod from_anisotropic_medium(medium: tidy3d.components.medium.AnisotropicMedium, axis: Literal[0, 1, 2], thickness: float) tidy3d.components.medium.Medium2D #
Generate a
Medium2D
equivalent of aAnisotropicMedium
with given normal axis and thickness. Thess
andtt
components of the resulting 2D medium correspond to the first of thexx
,yy
, andzz
components of the 3D medium, with theaxis
component removed.- Parameters
medium (
AnisotropicMedium
) – The 3D anisotropic medium to convert.axis (
Axis
) – The normal axis to the 2D material.thickness (float) – The thickness of the 3D material.
- Returns
The 2D equivalent of the given 3D medium.
- Return type
- classmethod from_dispersive_medium(medium: tidy3d.components.medium.DispersiveMedium, thickness: float) tidy3d.components.medium.Medium2D #
Generate a
Medium2D
equivalent of aDispersiveMedium
with a given thickness.- Parameters
medium (
DispersiveMedium
) – The 3D dispersive medium to convert.thickness (float) – The thickness of the 3D material.
- Returns
The 2D equivalent of the given 3D medium.
- Return type
- classmethod from_file(fname: str, group_path: Optional[str] = None, **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel #
Loads a
Tidy3dBaseModel
from .yaml, .json, or .hdf5 file.- Parameters
fname (str) – Full path to the .yaml or .json file to load the
Tidy3dBaseModel
from.group_path (str, optional) – Path to a group inside the file to use as the base level. Only for
.hdf5
files. Starting / is optional.**parse_obj_kwargs – Keyword arguments passed to either pydantic’s
parse_obj
function when loading model.
- Returns
An instance of the component class calling load.
- Return type
Tidy3dBaseModel
Example
>>> simulation = Simulation.from_file(fname='folder/sim.json')
- classmethod from_hdf5(fname: str, group_path: str = '', **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel #
Loads
Tidy3dBaseModel
instance to .hdf5 file.- Parameters
fname (str) – Full path to the .hdf5 file to load the
Tidy3dBaseModel
from.group_path (str, optional) – Path to a group inside the file to selectively load a sub-element of the model only. Starting / is optional.
**parse_obj_kwargs – Keyword arguments passed to pydantic’s
parse_obj
method.
Example
>>> simulation.to_hdf5(fname='folder/sim.hdf5')
- classmethod from_json(fname: str, **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel #
Load a
Tidy3dBaseModel
from .json file.- Parameters
fname (str) – Full path to the .json file to load the
Tidy3dBaseModel
from.- Returns
Tidy3dBaseModel
– An instance of the component class calling load.**parse_obj_kwargs – Keyword arguments passed to pydantic’s
parse_obj
method.
Example
>>> simulation = Simulation.from_json(fname='folder/sim.json')
- classmethod from_medium(medium: tidy3d.components.medium.Medium, thickness: float) tidy3d.components.medium.Medium2D #
Generate a
Medium2D
equivalent of aMedium
with a given thickness.
- classmethod from_orm(obj: Any) Model #
- classmethod from_yaml(fname: str, **parse_obj_kwargs) tidy3d.components.base.Tidy3dBaseModel #
Loads
Tidy3dBaseModel
from .yaml file.- Parameters
fname (str) – Full path to the .yaml file to load the
Tidy3dBaseModel
from.**parse_obj_kwargs – Keyword arguments passed to pydantic’s
parse_obj
method.
- Returns
An instance of the component class calling from_yaml.
- Return type
Tidy3dBaseModel
Example
>>> simulation = Simulation.from_yaml(fname='folder/sim.yaml')
- classmethod generate_docstring() str #
Generates a docstring for a Tidy3D mode and saves it to the __doc__ of the class.
- classmethod get_sub_model(group_path: str, model_dict: dict | list) dict #
Get the sub model for a given group path.
- static get_tuple_group_name(index: int) str #
Get the group name of a tuple element.
- static get_tuple_index(key_name: str) int #
Get the index into the tuple based on its group name.
- help(methods: bool = False) None #
Prints message describing the fields and methods of a
Tidy3dBaseModel
.- Parameters
methods (bool = False) – Whether to also print out information about object’s methods.
Example
>>> simulation.help(methods=True)
- json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode #
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
- nk_model(frequency: float) Tuple[float, float] #
Real and imaginary parts of the refactive index as a function of frequency.
- Parameters
frequency (float) – Frequency to evaluate permittivity at (Hz).
- Returns
Real part (n) and imaginary part (k) of refractive index of medium.
- Return type
Tuple[float, float]
- static nk_to_eps_complex(n: float, k: float = 0.0) complex #
Convert n, k to complex permittivity.
- Parameters
n (float) – Real part of refractive index.
k (float = 0.0) – Imaginary part of refrative index.
- Returns
Complex-valued relative permittivty.
- Return type
complex
- static nk_to_eps_sigma(n: float, k: float, freq: float) Tuple[float, float] #
Convert
n
,k
at frequencyfreq
to permittivity and conductivity values.- Parameters
n (float) – Real part of refractive index.
k (float = 0.0) – Imaginary part of refrative index.
frequency (float) – Frequency to evaluate permittivity at (Hz).
- Returns
Real part of relative permittivity & electric conductivity.
- Return type
Tuple[float, float]
- classmethod parse_file(path: Union[str, pathlib.Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: pydantic.parse.Protocol = None, allow_pickle: bool = False) Model #
- classmethod parse_obj(obj: Any) Model #
- classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: pydantic.parse.Protocol = None, allow_pickle: bool = False) Model #
- plot(freqs: float, ax: matplotlib.axes._axes.Axes = None) matplotlib.axes._axes.Axes #
Plot n, k of a
Medium
as a function of frequency.
- plot_sigma(freqs: float, ax: matplotlib.axes._axes.Axes = None) matplotlib.axes._axes.Axes #
Plot the surface conductivity of the 2D material.
- classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') DictStrAny #
- classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) unicode #
- sigma_model(freq: float) complex #
Complex-valued conductivity as a function of frequency.
- Parameters
freq (float) – Frequency to evaluate conductivity at (Hz).
- Returns
Complex conductivity at this frequency.
- Return type
complex
- to_anisotropic_medium(axis: Literal[0, 1, 2], thickness: float) tidy3d.components.medium.AnisotropicMedium #
Generate a 3D
AnisotropicMedium
equivalent of a given thickness.- Parameters
axis (Axis) – The normal axis to the 2D medium.
thickness (float) – The thickness of the desired 3D medium.
- Returns
The 3D equivalent of this 2D medium.
- Return type
- to_file(fname: str) None #
Exports
Tidy3dBaseModel
instance to .yaml, .json, or .hdf5 file- Parameters
fname (str) – Full path to the .yaml or .json file to save the
Tidy3dBaseModel
to.
Example
>>> simulation.to_file(fname='folder/sim.json')
- to_hdf5(fname: str) None #
Exports
Tidy3dBaseModel
instance to .hdf5 file.- Parameters
fname (str) – Full path to the .hdf5 file to save the
Tidy3dBaseModel
to.
Example
>>> simulation.to_hdf5(fname='folder/sim.hdf5')
- to_json(fname: str) None #
Exports
Tidy3dBaseModel
instance to .json file- Parameters
fname (str) – Full path to the .json file to save the
Tidy3dBaseModel
to.
Example
>>> simulation.to_json(fname='folder/sim.json')
- to_medium(thickness: float) tidy3d.components.medium.Medium #
Generate a
Medium
equivalent of a given thickness. The 2D medium should be isotropic in-plane (otherwise the components are averaged) and non-dispersive besides a constant conductivity.- Parameters
thickness (float) – The thickness of the desired 3D medium.
- Returns
The 3D equivalent of this 2D medium.
- Return type
- to_pole_residue(thickness: float) tidy3d.components.medium.PoleResidue #
Generate a
PoleResidue
equivalent of a given thickness. The 2D medium to be isotropic in-plane (otherwise the components are averaged).- Parameters
thickness (float) – The thickness of the desired 3D medium.
- Returns
The 3D equivalent pole residue model of this 2D medium.
- Return type
- to_yaml(fname: str) None #
Exports
Tidy3dBaseModel
instance to .yaml file.- Parameters
fname (str) – Full path to the .yaml file to save the
Tidy3dBaseModel
to.
Example
>>> simulation.to_yaml(fname='folder/sim.yaml')
- classmethod tuple_to_dict(tuple_values: tuple) dict #
How we generate a dictionary mapping new keys to tuple values for hdf5.
- classmethod update_forward_refs(**localns: Any) None #
Try to update ForwardRefs on fields based on this Model, globalns and localns.
- updated_copy(**kwargs) tidy3d.components.base.Tidy3dBaseModel #
Make copy of a component instance with
**kwargs
indicating updated field values.
- classmethod validate(value: Any) Model #
- volumetric_equivalent(axis: Literal[0, 1, 2], adjacent_media: Tuple[Union[tidy3d.components.medium.Medium, tidy3d.components.medium.CustomMedium, tidy3d.components.medium.AnisotropicMedium, tidy3d.components.medium.PECMedium, tidy3d.components.medium.PoleResidue, tidy3d.components.medium.Sellmeier, tidy3d.components.medium.Lorentz, tidy3d.components.medium.Debye, tidy3d.components.medium.Drude], Union[tidy3d.components.medium.Medium, tidy3d.components.medium.CustomMedium, tidy3d.components.medium.AnisotropicMedium, tidy3d.components.medium.PECMedium, tidy3d.components.medium.PoleResidue, tidy3d.components.medium.Sellmeier, tidy3d.components.medium.Lorentz, tidy3d.components.medium.Debye, tidy3d.components.medium.Drude]], adjacent_dls: Tuple[float, float]) tidy3d.components.medium.AnisotropicMedium #
Produces a 3D volumetric equivalent medium. The new medium has thickness equal to the average of the
dls
in theaxis
direction. The ss and tt components of the 2D material are mapped in order onto the xx, yy, and zz components of the 3D material, excluding theaxis
component. The conductivity and residues (in the case of a dispersive 2D material) are rescaled by1/dl
. The neighboring medianeighbors
enter in as a background for the resulting volumetric equivalent.- Parameters
axis (Axis) – Index (0, 1, or 2 for x, y, or z respectively) of the normal direction to the 2D material.
adjacent_media (Tuple[MediumType3D, MediumType3D]) – The neighboring media on either side of the 2D material. The first element is directly on the - side of the 2D material in the supplied axis, and the second element is directly on the + side.
adjacent_dls (Tuple[float, float]) – Each dl represents twice the thickness of the desired volumetric model on the respective side of the 2D material.
- Returns
The 3D material corresponding to this 2D material.
- Return type
- property elements: Dict[str, Union[tidy3d.components.medium.Medium, tidy3d.components.medium.PoleResidue, tidy3d.components.medium.Sellmeier, tidy3d.components.medium.Lorentz, tidy3d.components.medium.Debye, tidy3d.components.medium.Drude]]#
The diagonal elements of the 2D medium as a dictionary.
- property n_cfl#
This property computes the index of refraction related to CFL condition, so that the FDTD with this medium is stable when the time step size that doesn’t take material factor into account is multiplied by
n_cfl
.