tidy3d.components.medium.AbstractIsotropicPerturbationMedium#
- class AbstractIsotropicPerturbationMedium[source]#
Abstract class for isotropic medium perturbation.
- Parameters:
subpixel (bool = True) – This value will be transferred to the resulting custom medium. That is, if
True, the subpixel averaging will be applied to the custom medium. The type of subpixel averaging method applied is specified inSimulation’s fieldsubpixel. If the resulting medium is not a custom medium (no perturbations), this field does not have an effect.electro_optic_spec (Optional[
ElectroOpticPerturbation] = None) – Change of the refractive index by a static electric field, applied when anelectric_fieldis given toperturbed_copy. The medium then becomes aCustomAnisotropicMedium, to which the heat and charge perturbations add. A medium withelectro_optic_speccannot have anonlinear_spec.perturbation_spec (Optional[Union[
PermittivityPerturbation,IndexPerturbation]] = None) – Specification of medium perturbation as one of predefined types.
- __init__(**data)#
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Methods
coerce_numpy_scalars_for_model(data)Convert NumPy scalar inputs while preserving array fields.
construct([_fields_set])copy([deep, validate, update])Return a copy of the model.
dict(*[, include, exclude, by_alias, ...])dict_from_file(fname[, group_path, ...])Loads a dictionary containing the model from a .yaml, .json, .hdf5, or .hdf5.gz file.
dict_from_hdf5(fname[, group_path, ...])Loads a dictionary containing the model contents from a .hdf5 file.
dict_from_hdf5_gz(fname[, group_path, ...])Loads a dictionary containing the model contents from a .hdf5.gz file.
dict_from_json(fname)Load dictionary of the model from a .json file.
dict_from_yaml(fname)Load dictionary of the model from a .yaml file.
find_paths(target_field_name[, ...])Finds paths to nested model instances that have a specific field, optionally matching a value.
find_submodels(target_type)Finds all unique nested instances of a specific Tidy3D model type within this model.
from_file(fname[, group_path, lazy, ...])Loads a
Tidy3dBaseModelfrom .yaml, .json, .hdf5, or .hdf5.gz file.from_hdf5(fname[, group_path, custom_decoders])Loads
Tidy3dBaseModelinstance to .hdf5 file.from_hdf5_gz(fname[, group_path, ...])Loads
Tidy3dBaseModelinstance to .hdf5.gz file.from_json(fname, **model_validate_kwargs)Load a
Tidy3dBaseModelfrom .json file.from_orm(obj)from_unperturbed(medium[, subpixel, ...])Construct a medium with perturbation models from an unperturbed one.
from_yaml(fname, **model_validate_kwargs)Loads
Tidy3dBaseModelfrom .yaml file.generate_docstring([show_default_args, ...])Generates a docstring for a Tidy3D model.
get_sub_model(group_path, model_dict)Get the sub model for a given group path.
get_submodels_by_hash()Return a mapping
{hash(submodel): [field_path, ...]}for every nestedTidy3dBaseModelinside this model.get_tuple_group_name(index)Get the group name of a tuple element.
get_tuple_index(key_name)Get the index into the tuple based on its group name.
help([methods])Prints message describing the fields and methods of a
Tidy3dBaseModel.json(*[, include, exclude, by_alias, ...])model_construct([_fields_set])model_copy(*[, update, deep])Copy without validation, clearing derived caches when fields are updated.
model_dump(*[, mode, include, exclude, ...])model_dump_json(*args, **kwargs)Serialize with stable float exponent formatting across pydantic_core versions.
model_json_schema([by_alias, ref_template, ...])model_parametrized_name(params)model_post_init(context, /)This function is meant to behave like a BaseModel method to initialize private attributes.
model_rebuild(*[, force, raise_errors, ...])Try to rebuild the pydantic-core schema for the model.
model_validate(obj, *[, strict, extra, ...])model_validate_json(json_data, *[, strict, ...])model_validate_strings(obj, *[, strict, ...])parse_file(path, *[, content_type, ...])parse_obj(obj)parse_raw(b, *[, content_type, encoding, ...])perturbed_copy([temperature, ...])Sample perturbations on provided heat, charge, and electric field data and create a custom medium.
schema([by_alias, ref_template])schema_json(*[, by_alias, ref_template])to_file(fname)Exports
Tidy3dBaseModelinstance to .yaml, .json, or .hdf5 fileto_hdf5(fname[, custom_encoders])Exports
Tidy3dBaseModelinstance to .hdf5 file.to_hdf5_gz(fname[, custom_encoders])Exports
Tidy3dBaseModelinstance to .hdf5.gz file.to_json(fname)Exports
Tidy3dBaseModelinstance to .json fileto_static()Version of object with all autograd-traced fields removed.
to_yaml(fname)Exports
Tidy3dBaseModelinstance to .yaml file.tuple_to_dict(tuple_values)How we generate a dictionary mapping new keys to tuple values for hdf5.
update_forward_refs(**localns)updated_copy([path, deep, validate])Make copy of a component instance with
**kwargsindicating updated field values.validate(value)Attributes
model_computed_fieldsmodel_configConfiguration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
model_extraGet extra fields set during validation.
model_fieldsmodel_fields_setReturns the set of fields that have been explicitly set on this model instance.
subpixelelectro_optic_specattrs- perturbation_spec#
- classmethod from_unperturbed(medium, subpixel=True, perturbation_spec=None, **kwargs)[source]#
Construct a medium with perturbation models from an unperturbed one.
- Parameters:
medium (Union[
Medium,DispersiveMedium]) – A medium with no perturbation models.subpixel (bool = True) – Subpixel averaging of derivative custom medium.
perturbation_spec (Union[
PermittivityPerturbation,IndexPerturbation] = None) – Perturbation model specification.**kwargs – Further perturbation models of the new medium, such as
electro_optic_spec.
- Returns:
Resulting medium with perturbation model.
- Return type:
- perturbed_copy(temperature=None, electron_density=None, hole_density=None, interp_method='linear', electric_field=None)[source]#
Sample perturbations on provided heat, charge, and electric field data and create a custom medium. Any of
temperature,electron_density,hole_density, andelectric_fieldcan beNone. If all passed arguments areNone, or onlyelectric_fieldis given to a medium withoutelectro_optic_spec, the medium is returned unchanged. All provided fields must have identical coords.- Parameters:
temperature (Union[
SpatialDataArray,TriangularGridDataset,TetrahedralGridDataset] = None) – Temperature field data.electron_density (Union[
SpatialDataArray,TriangularGridDataset,TetrahedralGridDataset] = None) – Electron density field data.hole_density (Union[
SpatialDataArray,TriangularGridDataset,TetrahedralGridDataset] = None) – Hole density field data.interp_method (
Literal['nearest', 'linear'], optional) – Interpolation method to obtain heat and/or charge values that are not supplied at the Yee grids.electric_field (Union[tuple,
TriangularGridDataset,TetrahedralGridDataset] = None) – Static electric field (V/um), applied throughelectro_optic_spec. Either a tuple(Ex, Ey, Ez)of spatial fields,Nonefor a zero component, or an unstructured dataset with anaxisdimension, such asSteadyElectricFieldData.Eat one voltage.
- Returns:
Medium specification after application of heat, charge, and electric field data.
- Return type:
Union[AbstractMedium, AbstractCustomMedium]