diff --git a/tests/test_components/test_heat_charge.py b/tests/test_components/test_heat_charge.py index 4921cd3e29..88d6043fa5 100644 --- a/tests/test_components/test_heat_charge.py +++ b/tests/test_components/test_heat_charge.py @@ -711,6 +711,9 @@ def test_heat_charge_bcs_validation(boundary_conditions): with pytest.raises(pd.ValidationError): td.CurrentBC(source=td.DCCurrentSource(current=td.inf)) + with pytest.raises(pd.ValidationError): + td.VoltageBC(source=td.DCVoltageSource(voltage=np.array([td.inf, 0, 1]))) + def test_heat_charge_monitors_validation(monitors): """Checks for no name and negative size in monitors.""" @@ -790,6 +793,7 @@ def test_device_characteristics(): steady_dc_hole_capacitance=capacitance, steady_dc_electron_capacitance=capacitance, steady_dc_current_voltage=current_voltage, + steady_dc_resistance_voltage=current_voltage, ) diff --git a/tidy3d/components/spice/sources/dc.py b/tidy3d/components/spice/sources/dc.py index 7c560ff165..df3917d38c 100644 --- a/tidy3d/components/spice/sources/dc.py +++ b/tidy3d/components/spice/sources/dc.py @@ -19,12 +19,14 @@ """ -from typing import Optional, Union +from typing import Optional import pydantic.v1 as pd from tidy3d.components.base import Tidy3dBaseModel +from tidy3d.components.types import ArrayFloat1D from tidy3d.constants import AMP, VOLT +from tidy3d.constants import inf as td_inf class DCVoltageSource(Tidy3dBaseModel): @@ -45,11 +47,19 @@ class DCVoltageSource(Tidy3dBaseModel): """ name: Optional[str] - voltage: Union[pd.FiniteFloat, list[pd.FiniteFloat]] = pd.Field( + voltage: ArrayFloat1D = pd.Field( + ..., title="Voltage", description="DC voltage usually used as source in 'VoltageBC' boundary conditions.", + units=VOLT, ) - units: str = VOLT + + @pd.validator("voltage") + def check_voltage(cls, val): + for v in val: + if v == td_inf: + raise ValueError(f"Voltages must be finite. Currently voltage={val}.") + return val class DCCurrentSource(Tidy3dBaseModel): diff --git a/tidy3d/components/tcad/data/sim_data.py b/tidy3d/components/tcad/data/sim_data.py index 0a9a8e4898..2d0c5cde13 100644 --- a/tidy3d/components/tcad/data/sim_data.py +++ b/tidy3d/components/tcad/data/sim_data.py @@ -73,6 +73,14 @@ class DeviceCharacteristics(Tidy3dBaseModel): description="Device steady DC current-voltage relation for the device.", ) + steady_dc_resistance_voltage: Optional[SteadyVoltageDataArray] = pd.Field( + None, + title="Small signal resistance", + description="Steady DC computation of the small signal resistance. This is computed " + "as the derivative of the current-voltage relation, delta(V)/delta(I) and the result " + "is given in Ohms. Note that in 2D the resistance is given in :math:`\\Omega \\mu`.", + ) + class HeatChargeSimulationData(AbstractSimulationData): """Stores results of a :class:`HeatChargeSimulation`. diff --git a/tidy3d/components/tcad/simulation/heat_charge.py b/tidy3d/components/tcad/simulation/heat_charge.py index 60f57ffa1b..72c90bc21a 100644 --- a/tidy3d/components/tcad/simulation/heat_charge.py +++ b/tidy3d/components/tcad/simulation/heat_charge.py @@ -434,11 +434,8 @@ def check_voltage_array_if_capacitance(cls, values): for bc in bounday_spec: if isinstance(bc.condition, VoltageBC): if isinstance(bc.condition.source, DCVoltageSource): - if isinstance(bc.condition.source.voltage, list) or isinstance( - bc.condition.source.voltage, tuple - ): - if len(bc.condition.source.voltage) > 1: - voltage_array_present = True + if len(bc.condition.source.voltage) > 1: + voltage_array_present = True if is_capacitance_mnt and not voltage_array_present: raise SetupError( "Monitors of type 'SteadyCapacitanceMonitor' have been defined but no array of voltages " @@ -521,15 +518,14 @@ def check_only_one_voltage_array_provided(cls, val, values): if isinstance(bc.condition.source, DCVoltageSource): voltages = bc.condition.source.voltage - if isinstance(voltages, tuple): - if len(voltages) > 1: - if not array_already_provided: - array_already_provided = True - else: - raise SetupError( - "More than one voltage array has been provided. " - "Currently voltage arrays are supported only for one of the BCs." - ) + if len(voltages) > 1: + if not array_already_provided: + array_already_provided = True + else: + raise SetupError( + "More than one voltage array has been provided. " + "Currently voltage arrays are supported only for one of the BCs." + ) return val @pd.root_validator(skip_on_failure=True)