Skip to content

Commit d5fed48

Browse files
fix #169
1 parent 44580d7 commit d5fed48

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

PySpice/Spice/BasicElement.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,17 +1423,19 @@ class LosslessTransmissionLine(TwoPortElement):
14231423
14241424
.. code-block:: none
14251425
1426-
TXXXXXXX N1 N2 N3 N4 Z0=VALUE <TD=VALUE> <F=FREQ <NL=NRMLEN>>
1426+
TXXXXXXX N1 N2 N3 N4 Z0=VALUE <TD=VALUE> <F=FREQ <NL=NRMLEN>> <IC=V1, I1, V2, I2>
14271427
14281428
where TD or F, NL must be specified.
14291429
14301430
Keyword Parameters:
14311431
14321432
:attr:`impedance`
14331433
alias:`Z0`
1434+
is the characteristic impedance
14341435
14351436
:attr:`time_delay`
14361437
alias:`TD`
1438+
is the transmission delay
14371439
14381440
:attr:`frequency`
14391441
alias:`F`
@@ -1451,6 +1453,13 @@ class LosslessTransmissionLine(TwoPortElement):
14511453
14521454
:attr:`normalized_length`
14531455
1456+
The transmission delay, `td`, may be specified directly (as `td=10ns`, for example).
1457+
Alternatively, a frequency `f` may be given, together with `nl`, the normalized electrical
1458+
length of the transmission line with respect to the wavelength in the line at the frequency
1459+
`f`. If a frequency is specified but `nl` is omitted, 0.25 is assumed (that is, the frequency is
1460+
assumed to be the quarter-wave frequency). Note that although both forms for expressing the line
1461+
length are indicated as optional, one of the two must be specified.
1462+
14541463
Note: Either time_delay or frequency must be given.
14551464
14561465
"""
@@ -1467,13 +1476,12 @@ class LosslessTransmissionLine(TwoPortElement):
14671476

14681477
def __init__(self, name, *args, **kwargs):
14691478

1470-
# check: ^ xor, & bitwise and
1471-
if not (('time_delay' in kwargs) ^
1472-
(('frequency' in kwargs) & ('normalized_length' in kwargs))):
1473-
raise NameError('Either TD or F, NL must be specified')
1474-
14751479
super().__init__(name, *args, **kwargs)
14761480

1481+
if not (self.has_parameter('time_delay') or
1482+
(self.has_parameter('frequency') and self.has_parameter('normalized_length'))):
1483+
raise NameError('Either TD or F, NL must be specified')
1484+
14771485
####################################################################################################
14781486

14791487
class LossyTransmission(TwoPortElement):

PySpice/Spice/Netlist.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,11 @@ def __init__(self, netlist, name, *args, **kwargs):
530530

531531
##############################################
532532

533+
def has_parameter(self, name):
534+
return hasattr(self, '_' + name)
535+
536+
##############################################
537+
533538
def copy_to(self, element):
534539

535540
for parameter_dict in self.__positional_parameters__, self.__optional_parameters__:

issues/issue-169.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
from PySpice.Spice.BasicElement import BehavioralSource
77

88
circuit = Circuit('test')
9-
circuit.LosslessTransmissionLine('line', 'output', circuit.gnd, 'input', circuit.gnd, Z0=50, TD=40e-9)
9+
# circuit.LosslessTransmissionLine('line1', 'output', circuit.gnd, 'input', circuit.gnd, Z0=50)
10+
circuit.LosslessTransmissionLine('line1', 'output', circuit.gnd, 'input', circuit.gnd, Z0=50, TD=40e-9)
11+
circuit.LosslessTransmissionLine('line2', 'output', circuit.gnd, 'input', circuit.gnd, Z0=50, time_delay=40@u_ns)
12+
# circuit.LosslessTransmissionLine('line3', 'output', circuit.gnd, 'input', circuit.gnd, Z0=50, frequency=50@u_ns)
13+
circuit.LosslessTransmissionLine('line3', 'output', circuit.gnd, 'input', circuit.gnd, Z0=50, frequency=50@u_Hz, normalized_length=10)
14+
circuit.LosslessTransmissionLine('line4', 'output', circuit.gnd, 'input', circuit.gnd, Z0=50, F=50@u_Hz, NL=10)
1015

1116
print(circuit)

0 commit comments

Comments
 (0)