Source code for tidy3d.components.tcad.data.monitor_data.charge
"""Monitor level data, store the DataArrays associated with a single heat-charge monitor."""from__future__importannotationsfromtypingimportDict,Unionimportpydantic.v1aspdfromtidy3d.components.baseimportskip_if_fields_missingfromtidy3d.components.data.data_arrayimport(DataArray,IndexedVoltageDataArray,SpatialDataArray,SteadyVoltageDataArray,)fromtidy3d.components.data.utilsimportTetrahedralGridDataset,TriangularGridDatasetfromtidy3d.components.tcad.data.monitor_data.abstractimportHeatChargeMonitorDatafromtidy3d.components.tcad.monitors.chargeimport(SteadyCapacitanceMonitor,SteadyFreeCarrierMonitor,SteadyPotentialMonitor,)fromtidy3d.components.typesimportTYPE_TAG_STR,annotate_typefromtidy3d.logimportlogFieldDataset=Union[SpatialDataArray,annotate_type(Union[TriangularGridDataset,TetrahedralGridDataset])]UnstructuredFieldType=Union[TriangularGridDataset,TetrahedralGridDataset]
[docs]classSteadyPotentialData(HeatChargeMonitorData):"""Stores electric potential :math:`\\psi` from a charge simulation."""monitor:SteadyPotentialMonitor=pd.Field(...,title="Electric potential monitor",description="Electric potential monitor associated with a `charge` simulation.",)potential:FieldDataset=pd.Field(None,title="Electric potential series",description="Contains the electric potential series.",)@propertydeffield_components(self)->Dict[str,DataArray]:"""Maps the field components to their associated data."""returndict(potential=self.potential)
[docs]@pd.validator("potential",always=True)@skip_if_fields_missing(["monitor"])defwarn_no_data(cls,val,values):"""Warn if no data provided."""mnt=values.get("monitor")ifvalisNone:log.warning(f"No data is available for monitor '{mnt.name}'. This is typically caused by ""monitor not intersecting any solid medium.")returnval
@propertydefsymmetry_expanded_copy(self)->SteadyPotentialData:"""Return copy of self with symmetry applied."""new_potential=self._symmetry_expanded_copy(property=self.potential)returnself.updated_copy(potential=new_potential,symmetry=(0,0,0))
[docs]deffield_name(self,val:str)->str:"""Gets the name of the fields to be plot."""ifval=="abs^2":return"|V|²"else:return"V"
[docs]classSteadyFreeCarrierData(HeatChargeMonitorData):""" Stores free-carrier concentration in charge simulations. Notes ----- This data contains the carrier concentrations: the amount of electrons and holes per unit volume as defined in the ``monitor``. """monitor:SteadyFreeCarrierMonitor=pd.Field(...,title="Free carrier monitor",description="Free carrier data associated with a Charge simulation.",)electrons:UnstructuredFieldType=pd.Field(None,title="Electrons series",description=r"Contains the computed electrons concentration $n$.",discriminator=TYPE_TAG_STR,)# n = electronsholes:UnstructuredFieldType=pd.Field(None,title="Holes series",description=r"Contains the computed holes concentration $p$.",discriminator=TYPE_TAG_STR,)# p = holes@propertydeffield_components(self)->Dict[str,DataArray]:"""Maps the field components to their associated data."""returndict(electrons=self.electrons,holes=self.holes)
[docs]@pd.root_validator(skip_on_failure=True)defcheck_correct_data_type(cls,values):"""Issue error if incorrect data type is used"""mnt=values.get("monitor")field_data={field:values.get(field)forfieldin["electrons","holes"]}forfield,datainfield_data.items():ifisinstance(data,TetrahedralGridDataset)orisinstance(data,TriangularGridDataset):ifnotisinstance(data.values,IndexedVoltageDataArray):raiseValueError(f"In the data associated with monitor {mnt}, the field {field} does not contain ""data associated to any voltage value.")returnvalues
[docs]@pd.root_validator(skip_on_failure=True)defwarn_no_data(cls,values):"""Warn if no data provided."""mnt=values.get("monitor")electrons=values.get("electrons")holes=values.get("holes")ifelectronsisNoneorholesisNone:log.warning(f"No data is available for monitor '{mnt.name}'. This is typically caused by ""monitor not intersecting any solid medium.")returnvalues
@propertydefsymmetry_expanded_copy(self)->SteadyFreeCarrierData:"""Return copy of self with symmetry applied."""new_electrons=self._symmetry_expanded_copy(property=self.electrons)new_holes=self._symmetry_expanded_copy(property=self.holes)returnself.updated_copy(electrons=new_electrons,holes=new_holes,symmetry=(0,0,0),)
[docs]deffield_name(self,val:str="")->str:"""Gets the name of the fields to be plot."""ifval=="abs^2":return"Electrons², Holes²"else:return"Electrons, Holes"
[docs]classSteadyCapacitanceData(HeatChargeMonitorData):""" Class that stores capacitance data from a Charge simulation. Notes ----- The small signal-capacitance of electrons :math:`C_n` and holes :math:`C_p` is computed from the charge due to electrons :math:`Q_n` and holes :math:`Q_p` at an applied voltage :math:`V` at a voltage difference :math:`\\Delta V` between two simulations. .. math:: C_{n,p} = \\frac{Q_{n,p}(V + \\Delta V) - Q_{n,p}(V)}{\\Delta V} This is only computed when a voltage source with more than two sources is included within the simulation and determines the :math:`\\Delta V`. """monitor:SteadyCapacitanceMonitor=pd.Field(...,title="Capacitance monitor",description="Capacitance data associated with a Charge simulation.",)hole_capacitance:SteadyVoltageDataArray=pd.Field(None,title="Hole capacitance",description=r"Small signal capacitance ($\frac{dQ_p}{dV}$) associated to the monitor.",)# C_p = hole_capacitanceelectron_capacitance:SteadyVoltageDataArray=pd.Field(None,title="Electron capacitance",description=r"Small signal capacitance ($\frac{dQn}{dV}$) associated to the monitor.",)# C_n = electron_capacitance
[docs]@pd.validator("hole_capacitance",always=True)@skip_if_fields_missing(["monitor"])defwarn_no_data(cls,val,values):"""Warn if no data provided."""mnt=values.get("monitor")ifvalisNone:log.warning(f"No data is available for monitor '{mnt.name}'. This is typically caused by ""monitor not intersecting any solid medium.")returnval
[docs]deffield_name(self,val:str)->str:"""Gets the name of the fields to be plot."""return""
@propertydefsymmetry_expanded_copy(self)->SteadyCapacitanceData:"""Return copy of self with symmetry applied."""returnself