Skip to content

Commit 9e75675

Browse files
committed
Revert to the old version
1 parent 449132f commit 9e75675

File tree

9 files changed

+91
-148
lines changed

9 files changed

+91
-148
lines changed

docs/api/spice.rst

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,11 @@ Sources
1010
:toctree: _autosummary/
1111
:template: module.rst
1212

13-
tidy3d.ACVoltageSource
13+
tidy3d.SSACVoltageSource
1414
tidy3d.DCVoltageSource
1515
tidy3d.GroundVoltageSource
1616
tidy3d.DCCurrentSource
1717

18-
Signal
19-
----------------
20-
21-
.. autosummary::
22-
:toctree: _autosummary/
23-
:template: module.rst
24-
25-
tidy3d.SinusoidalSignal
26-
27-
2818
Analysis
2919
----------------
3020

@@ -34,6 +24,7 @@ Analysis
3424

3525
tidy3d.SteadyChargeDCAnalysis
3626
tidy3d.IsothermalSteadyChargeDCAnalysis
27+
tidy3d.AbstractSSACAnalysis
3728
tidy3d.SSACAnalysis
3829
tidy3d.IsothermalSSACAnalysis
3930
tidy3d.ChargeToleranceSpec

tests/test_components/test_heat_charge.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -897,17 +897,13 @@ def test_heat_charge_bcs_validation(boundary_conditions):
897897
with pytest.raises(pd.ValidationError):
898898
td.VoltageBC(source=td.DCVoltageSource(voltage=np.array([td.inf, 0, 1])))
899899

900-
# Invalid ACVoltageSource: infinite voltage
900+
# Invalid SSACVoltageSource: infinite voltage
901901
with pytest.raises(pd.ValidationError):
902-
td.VoltageBC(
903-
source=td.ACVoltageSource(
904-
voltage=np.array([td.inf, 0, 1]), signal=td.SinusoidalSignal(amplitude=1e-2)
905-
)
906-
)
902+
td.VoltageBC(source=td.SSACVoltageSource(voltage=np.array([td.inf, 0, 1]), amplitude=1e-2))
907903

908904

909905
def test_ssac_freqs_validation():
910-
"""Test validation that ssac_freqs requires ACVoltageSource."""
906+
"""Test validation that ssac_freqs requires SSACVoltageSource."""
911907
solid_box_1 = td.Box(center=(0, 0, 0), size=(2, 2, 2))
912908
solid_box_2 = td.Box(center=(1, 1, 1), size=(2, 2, 2))
913909
solid_box_3 = td.Box(center=(2, 2, 2), size=(2, 2, 2))
@@ -948,16 +944,16 @@ def test_ssac_freqs_validation():
948944
ssac_freqs=ssac_freqs_input,
949945
)
950946

951-
# Test that ssac_freqs with ACVoltageSource works
952-
ac_source = td.ACVoltageSource(voltage=[0, 1, 2], signal=td.SinusoidalSignal(amplitude=1e-3))
947+
# Test that ssac_freqs with SSACVoltageSource works
948+
ssac_source = td.SSACVoltageSource(voltage=[0, 1, 2], amplitude=1e-3)
953949
sim = td.HeatChargeSimulation(
954950
size=(8, 8, 8),
955951
center=(0, 0, 0),
956952
structures=structures,
957953
boundary_spec=[
958954
td.HeatChargeBoundarySpec(
959955
placement=td.StructureStructureInterface(structures=["anode", "silicon"]),
960-
condition=td.VoltageBC(source=ac_source),
956+
condition=td.VoltageBC(source=ssac_source),
961957
),
962958
td.HeatChargeBoundarySpec(
963959
placement=td.StructureStructureInterface(structures=["cathode", "silicon"]),
@@ -969,10 +965,10 @@ def test_ssac_freqs_validation():
969965
analysis_spec=isothermal_spec,
970966
)
971967

972-
# Test that ssac_freqs without ACVoltageSource raises error
968+
# Test that ssac_freqs without SSACVoltageSource raises error
973969
with pytest.raises(
974970
pd.ValidationError,
975-
match="If 'ssac_freqs' is provided and not empty, at least one 'ACVoltageSource' must be present in the boundary conditions.",
971+
match="If 'ssac_freqs' is provided and not empty, at least one 'SSACVoltageSource' must be present in the boundary conditions.",
976972
):
977973
sim.updated_copy(
978974
boundary_spec=[
@@ -1597,14 +1593,12 @@ def test_charge_simulation(
15971593
]
15981594
)
15991595

1600-
condition_ssac_n = td.VoltageBC(
1601-
source=td.ACVoltageSource(voltage=[0, 1], signal=td.SinusoidalSignal(amplitude=1e-3))
1602-
)
1603-
condition_ssac_p = td.VoltageBC(
1604-
source=td.ACVoltageSource(voltage=[0, 1], signal=td.SinusoidalSignal(amplitude=1e-3))
1605-
)
1596+
condition_ssac_n = td.VoltageBC(source=td.SSACVoltageSource(voltage=[0, 1], amplitude=1e-3))
1597+
condition_ssac_p = td.VoltageBC(source=td.SSACVoltageSource(voltage=[0, 1], amplitude=1e-3))
16061598
# Two AC sources cannot be defined
1607-
with pytest.raises(pd.ValidationError, match="Only a single AC source can be supplied."):
1599+
with pytest.raises(
1600+
pd.ValidationError, match="Only a single 'SSACVoltageSource' source can be supplied."
1601+
):
16081602
analysis = td.IsothermalSSACAnalysis(ssac_freqs=[1e2, 1e3], temperature=300)
16091603
sim.updated_copy(
16101604
boundary_spec=[
@@ -1615,7 +1609,9 @@ def test_charge_simulation(
16151609
)
16161610

16171611
# Test SSACAnalysis as well
1618-
with pytest.raises(pd.ValidationError, match="Only a single AC source can be supplied."):
1612+
with pytest.raises(
1613+
pd.ValidationError, match="Only a single 'SSACVoltageSource' source can be supplied."
1614+
):
16191615
analysis_ssac = td.SSACAnalysis(
16201616
ssac_freqs=[1e2, 1e3], tolerance_settings=charge_tolerance
16211617
)

tidy3d/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
IsothermalSteadyChargeDCAnalysis,
2727
SteadyChargeDCAnalysis,
2828
)
29-
from tidy3d.components.spice.sources.ac import ACVoltageSource, SinusoidalSignal
29+
from tidy3d.components.spice.sources.ac import SSACVoltageSource
3030
from tidy3d.components.spice.sources.dc import DCCurrentSource, DCVoltageSource, GroundVoltageSource
3131
from tidy3d.components.spice.sources.types import VoltageSourceType
3232
from tidy3d.components.tcad.analysis.heat_simulation_type import UnsteadyHeatAnalysis, UnsteadySpec
@@ -446,7 +446,6 @@ def set_logging_level(level: str) -> None:
446446
"PML",
447447
"TFSF",
448448
"ABCBoundary",
449-
"ACVoltageSource",
450449
"Absorber",
451450
"AbsorberParams",
452451
"AbstractFieldProjectionData",
@@ -684,6 +683,7 @@ def set_logging_level(level: str) -> None:
684683
"RotationAroundAxis",
685684
"RunTimeSpec",
686685
"SSACAnalysis",
686+
"SSACVoltageSource",
687687
"ScalarFieldDataArray",
688688
"ScalarFieldTimeDataArray",
689689
"ScalarModeFieldCylindricalDataArray",
@@ -697,7 +697,6 @@ def set_logging_level(level: str) -> None:
697697
"SimulationData",
698698
"SimulationDataMap",
699699
"SimulationMap",
700-
"SinusoidalSignal",
701700
"SlotboomBandGapNarrowing",
702701
"SolidMedium",
703702
"SolidSpec",

tidy3d/components/spice/analysis/ac.py

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from __future__ import annotations
22

3+
from abc import ABC
4+
35
import pydantic.v1 as pd
46

7+
from tidy3d.components.base import Tidy3dBaseModel
58
from tidy3d.components.spice.analysis.dc import (
69
IsothermalSteadyChargeDCAnalysis,
710
SteadyChargeDCAnalysis,
@@ -11,9 +14,18 @@
1114
from tidy3d.constants import inf as td_inf
1215

1316

14-
class SSACAnalysis(SteadyChargeDCAnalysis):
17+
class AbstractSSACAnalysis(Tidy3dBaseModel, ABC):
1518
"""
16-
Configures Small-Signal AC (SSAC) analysis parameters for charge simulation.
19+
Abstract base class for Small-Signal AC (SSAC) analysis parameters.
20+
21+
Notes
22+
-----
23+
This class provides the common interface for SSAC analysis by adding the
24+
``ssac_freqs`` field to any DC analysis class.
25+
26+
Small-signal analysis is performed by linearizing the device equations
27+
around a DC operating point. The analysis computes the small-signal response
28+
at the specified frequencies.
1729
1830
Examples
1931
--------
@@ -27,7 +39,7 @@ class SSACAnalysis(SteadyChargeDCAnalysis):
2739
...,
2840
title="Small Signal AC Frequencies",
2941
description="List of frequencies for small signal AC analysis. "
30-
"At least one :class:`.ACVoltageSource` must be present in the boundary conditions.",
42+
"At least one :class:`.SSACVoltageSource` must be present in the boundary conditions.",
3143
units=HERTZ,
3244
)
3345

@@ -44,7 +56,20 @@ def validate_ssac_freqs(cls, val):
4456
return val
4557

4658

47-
class IsothermalSSACAnalysis(IsothermalSteadyChargeDCAnalysis):
59+
class SSACAnalysis(SteadyChargeDCAnalysis, AbstractSSACAnalysis):
60+
"""
61+
Configures Small-Signal AC (SSAC) analysis parameters for charge simulation.
62+
63+
Examples
64+
--------
65+
>>> import tidy3d as td
66+
>>> freq_range = td.FreqRange.from_freq_interval(start_freq=1e3, stop_freq=1e6)
67+
>>> sweep_freqs = freq_range.sweep_decade(num_points_per_decade=10)
68+
>>> ssac_spec = td.SSACAnalysis(ssac_freqs=sweep_freqs)
69+
"""
70+
71+
72+
class IsothermalSSACAnalysis(IsothermalSteadyChargeDCAnalysis, AbstractSSACAnalysis):
4873
"""
4974
Configures Isothermal Small-Signal AC (SSAC) analysis parameters for charge simulation.
5075
@@ -59,23 +84,3 @@ class IsothermalSSACAnalysis(IsothermalSteadyChargeDCAnalysis):
5984
>>> sweep_freqs = freq_range.sweep_decade(num_points_per_decade=10)
6085
>>> ssac_spec = td.IsothermalSSACAnalysis(ssac_freqs=sweep_freqs)
6186
"""
62-
63-
ssac_freqs: ArrayFloat1D = pd.Field(
64-
...,
65-
title="Small Signal AC Frequencies",
66-
description="List of frequencies for small signal AC analysis. "
67-
"At least one :class:`.ACVoltageSource` must be present in the boundary conditions.",
68-
units=HERTZ,
69-
)
70-
71-
@pd.validator("ssac_freqs")
72-
def validate_ssac_freqs(cls, val):
73-
if len(val) == 0:
74-
raise ValueError("'ssac_freqs' cannot be empty (size 0).")
75-
else:
76-
for freq in val:
77-
if freq == td_inf:
78-
raise ValueError("'ssac_freqs' cannot contain infinite frequencies.")
79-
elif freq < 0:
80-
raise ValueError("'ssac_freqs' cannot contain negative frequencies.")
81-
return val

tidy3d/components/spice/analysis/dc.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44

55
from __future__ import annotations
66

7-
from typing import Optional
8-
97
import pydantic.v1 as pd
108

119
from tidy3d.components.base import Tidy3dBaseModel
12-
from tidy3d.components.types import ArrayFloat1D
13-
from tidy3d.constants import HERTZ, KELVIN
10+
from tidy3d.constants import KELVIN
1411

1512

1613
class ChargeToleranceSpec(Tidy3dBaseModel):
@@ -81,14 +78,6 @@ class SteadyChargeDCAnalysis(Tidy3dBaseModel):
8178
"either the conduction or valence energy bands.",
8279
)
8380

84-
ssac_freqs: Optional[ArrayFloat1D] = pd.Field(
85-
[],
86-
title="Small Signal AC Frequencies",
87-
description="List of frequencies for small signal AC analysis. If provided, "
88-
"at least one 'ACVoltageSource' must be present in the boundary conditions.",
89-
units=HERTZ,
90-
)
91-
9281

9382
class IsothermalSteadyChargeDCAnalysis(SteadyChargeDCAnalysis):
9483
"""
Lines changed: 24 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,42 @@
11
from __future__ import annotations
22

3-
from typing import Optional, Union
3+
from typing import Optional
44

55
import pydantic.v1 as pd
66

77
from tidy3d.components.base import Tidy3dBaseModel
88
from tidy3d.components.types import ArrayFloat1D
9-
from tidy3d.constants import HERTZ, VOLT
9+
from tidy3d.constants import VOLT
1010
from tidy3d.constants import inf as td_inf
1111

1212

13-
class SinusoidalSignal(Tidy3dBaseModel):
13+
class SSACVoltageSource(Tidy3dBaseModel):
1414
"""
15-
Sinusoidal signal in the time domain.
15+
Small-Signal AC (SSAC) voltage source.
1616
1717
Notes
1818
-----
19-
The parameter ``frequency`` is not employed in small-signal analysis (See :class:`.IsothermalSSACAnalysis`).
19+
This source represents a small-signal AC excitation defined by a DC operating point
20+
voltage and the amplitude of the small signal perturbation.
2021
21-
Examples
22-
--------
23-
>>> import tidy3d as td
24-
>>> signal = td.SinusoidalSignal(amplitude=0.1)
25-
>>> ac_source = td.ACVoltageSource(
26-
... name="VIN",
27-
... voltage=0.8, # DC bias voltage
28-
... signal=signal
29-
... )
30-
"""
31-
32-
amplitude: pd.FiniteFloat = pd.Field(
33-
default=1.0,
34-
title="Signal Amplitude",
35-
description="Amplitude of the sinusoidal signal",
36-
units=VOLT,
37-
)
38-
39-
frequency: Optional[pd.PositiveFloat] = pd.Field(
40-
default=None,
41-
title="Frequency",
42-
description="When using SSAC analysis, the value is optional, and even if provided it is overwritten by the 'ssac_freqs' in the analysis specification.",
43-
units=HERTZ,
44-
)
45-
46-
@pd.validator("amplitude")
47-
def validate_amplitude(cls, val):
48-
if val == td_inf:
49-
raise ValueError(f"Signal amplitude must be finite. Current amplitude={val}.")
50-
return val
51-
52-
@pd.validator("frequency")
53-
def validate_frequency(cls, val):
54-
if val is not None and val == td_inf:
55-
raise ValueError(f"Signal frequency must be finite. Current frequency={val}.")
56-
return val
57-
58-
59-
ACSignalType = Union[SinusoidalSignal]
60-
61-
62-
class ACVoltageSource(Tidy3dBaseModel):
63-
"""
64-
AC voltage source.
65-
66-
Notes
67-
-----
68-
This source represents an AC excitation defined by a list of bias voltages,
69-
and a signal specification.
70-
71-
The bias ``voltage`` refers to the DC operating point above the simulation ground.
22+
The ``voltage`` refers to the DC operating point above the simulation ground.
23+
The ``amplitude`` defines the magnitude of the small-signal perturbation.
7224
Currently, full circuit simulation through electrical ports is not supported.
7325
7426
Examples
7527
--------
7628
>>> import tidy3d as td
77-
>>> voltages = [-0.5, 0, 1, 2, 3, 4]
78-
>>> signal = td.SinusoidalSignal(amplitude=1e-3)
79-
>>> voltage_source = td.ACVoltageSource(
80-
... voltage=voltages,
81-
... signal=signal,
29+
>>> ssac_source = td.SSACVoltageSource(
30+
... name="VIN",
31+
... voltage=0.8, # DC bias voltage
32+
... amplitude=1e-3 # Small signal amplitude
8233
... )
8334
"""
8435

8536
name: Optional[str] = pd.Field(
8637
None,
8738
title="Name",
88-
description="Unique name for the AC voltage source.",
39+
description="Unique name for the SSAC voltage source.",
8940
min_length=1,
9041
)
9142

@@ -96,10 +47,11 @@ class ACVoltageSource(Tidy3dBaseModel):
9647
units=VOLT,
9748
)
9849

99-
signal: ACSignalType = pd.Field(
100-
default=SinusoidalSignal(),
101-
title="AC signal properties",
102-
description="Currently employed only for small-signal analysis.",
50+
amplitude: pd.FiniteFloat = pd.Field(
51+
default=1.0,
52+
title="Small Signal Amplitude",
53+
description="Amplitude of the small-signal perturbation for SSAC analysis.",
54+
units=VOLT,
10355
)
10456

10557
@pd.validator("voltage")
@@ -108,3 +60,9 @@ def validate_voltage(cls, val):
10860
if v == td_inf:
10961
raise ValueError(f"Voltages must be finite. Current voltage={val}.")
11062
return val
63+
64+
@pd.validator("amplitude")
65+
def validate_amplitude(cls, val):
66+
if val == td_inf:
67+
raise ValueError(f"Signal amplitude must be finite. Current amplitude={val}.")
68+
return val

0 commit comments

Comments
 (0)