tidy3d.components.medium.AbstractPerturbationMedium#
- class AbstractPerturbationMedium[source]#
- Abstract class for medium perturbation. - 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, - attrsare mutable. For example, the following is allowed for setting an- attr- obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a- TypeErrorif- attrscontain objects that can not be serialized. One can check if- attrsare serializable by calling- obj.json().
- 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 in- Simulation’s field- subpixel. If the resulting medium is not a custom medium (no perturbations), this field does not have an effect.
- perturbation_spec (Union[PermittivityPerturbation, IndexPerturbation, NoneType] = None) – Specification of medium perturbation as one of predefined types. 
 
 - __init__(**kwargs)#
- Init method, includes post-init validators. 
 - Methods - __init__(**kwargs)- Init method, includes post-init validators. - add_type_field()- Automatically place "type" field with model name in the model field dictionary. - construct([_fields_set])- Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. - copy([deep])- Copy a Tidy3dBaseModel. - dict(*[, include, exclude, by_alias, ...])- Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. - 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. - from_file(fname[, group_path])- 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, **parse_obj_kwargs)- Load a - Tidy3dBaseModelfrom .json file.- from_orm(obj)- from_unperturbed(medium[, subpixel, ...])- Construct a medium with pertubation models from an unpertubed one. - from_yaml(fname, **parse_obj_kwargs)- Loads - Tidy3dBaseModelfrom .yaml file.- generate_docstring()- Generates a docstring for a Tidy3D mode and saves it to the __doc__ of the class. - get_sub_model(group_path, model_dict)- Get the sub model for a given group path. - get_submodels_by_hash()- Return a dictionary of this object's sub-models indexed by their hash values. - 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.- insert_traced_fields(field_mapping)- Recursively insert a map of paths to autograd-traced fields into a copy of this obj. - json(*[, include, exclude, by_alias, ...])- Generate a JSON representation of the model, include and exclude arguments as per dict(). - parse_file(path, *[, content_type, ...])- parse_obj(obj)- parse_raw(b, *[, content_type, encoding, ...])- perturbed_copy([temperature, ...])- Sample perturbations on provided heat and/or charge data and create a custom medium. - schema([by_alias, ref_template])- schema_json(*[, by_alias, ref_template])- strip_traced_fields([starting_path, ...])- Extract a dictionary mapping paths in the model to the data traced by - autograd.- to_file(fname)- Exports - Tidy3dBaseModelinstance to .yaml, .json, or .hdf5 file- to_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 file- to_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)- Try to update ForwardRefs on fields based on this Model, globalns and localns. - updated_copy([path, deep])- Make copy of a component instance with - **kwargsindicating updated field values.- validate(value)- Attributes - attrs- subpixel#
 - perturbation_spec#
 - abstract perturbed_copy(temperature=None, electron_density=None, hole_density=None, interp_method='linear')[source]#
- Sample perturbations on provided heat and/or charge data and create a custom medium. Any of - temperature,- electron_density, and- hole_densitycan be- None. If all passed arguments are- Nonethen a non-custom medium is returned. All provided fields must have identical coords.- Parameters:
- temperature (Union[) – - ] = None Temperature field data. 
- electron_density (Union[) – - ] = None Electron density field data. 
- hole_density (Union[) – - ] = None Hole density field data. 
- interp_method ( - InterpMethod, optional) – Interpolation method to obtain heat and/or charge values that are not supplied at the Yee grids.
 
- Returns:
- Medium specification after application of heat and/or charge data. 
- Return type:
- Union[AbstractMedium, AbstractCustomMedium] 
 
 - classmethod from_unperturbed(medium, subpixel=True, perturbation_spec=None, **kwargs)[source]#
- Construct a medium with pertubation models from an unpertubed one. - Parameters:
- medium (Union[) – - ] A medium with no perturbation models. 
- subpixel (bool = True) – Subpixel averaging of derivative custom medium. 
- perturbation_spec (Union[) – - PermittivityPerturbation,
- IndexPerturbation,
 - ] = None Perturbation model specification. 
 
- Returns:
- Resulting medium with perturbation model. 
- Return type:
 
 - __hash__()#
- Hash method.