Skip to content

Commit 40d657d

Browse files
maxcapodi78maxcapodi78
maxcapodi78
authored and
maxcapodi78
committed
Implemented new class ScatteringMethods which is common to Circuit, Hfss and hfss3dlayout classes and contains all the common scattering methods.
refactored expressions so that now is coherent across the different classes and returns a list of names added expression_objects property which returns the list of the Boundary objects of excitations added property ports which returns the ports objects (HFSS driven terminal only)
1 parent cdf0a38 commit 40d657d

15 files changed

+491
-460
lines changed

_unittest/test_21_Circuit.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -676,22 +676,21 @@ def test_41_assign_excitations(self, add_app):
676676
port.reference_node = "NoNet"
677677
port.reference_node = "Z"
678678

679-
assert c.excitation_objets
679+
assert c.excitation_objects
680680

681681
setup = c.create_setup()
682682

683-
c.excitations["Port3"].enabled_sources = ["PowerTest"]
684-
assert len(c.excitations["Port3"].enabled_sources) == 1
683+
c.excitation_objects["Port3"].enabled_sources = ["PowerTest"]
684+
assert len(c.excitation_objects["Port3"].enabled_sources) == 1
685685
setup1 = c.create_setup()
686686
setup2 = c.create_setup()
687-
c.excitations["Port3"].enabled_analyses = {"PowerTest": [setup.name, setup2.name]}
688-
assert c.excitations["Port3"].enabled_analyses["PowerTest"][0] == setup.name
687+
c.excitation_objects["Port3"].enabled_analyses = {"PowerTest": [setup.name, setup2.name]}
688+
assert c.excitation_objects["Port3"].enabled_analyses["PowerTest"][0] == setup.name
689689

690-
c.excitations["Port3"].name = "PortTest"
690+
c.excitation_objects["Port3"].name = "PortTest"
691691
assert "PortTest" in c.excitations
692-
assert "PortTest" in c.excitation_names
693-
c.excitations["PortTest"].delete()
694-
assert len(c.excitation_objets) == 0
692+
c.excitation_objects["PortTest"].delete()
693+
assert len(c.excitation_objects) == 0
695694
self.aedtapp.save_project()
696695
c = add_app(application=Circuit, design_name="sources")
697696
assert c.sources

_unittest/test_22_Circuit_DynamicLink.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ def test_07_create_page_port_and_interface_port(self):
176176
"Port_remove",
177177
[hfss3Dlayout_pin2location["J3B2.2.USBH2_DN_CH"][0], hfss3Dlayout_pin2location["J3B2.2.USBH2_DN_CH"][1]],
178178
)
179-
self.aedtapp.excitations[portname.name].delete()
179+
self.aedtapp.excitation_objects[portname.name].delete()
180180

181-
assert "Port_remove" not in self.aedtapp.excitation_names
181+
assert "Port_remove" not in self.aedtapp.excitations
182182

183183
@pytest.mark.skipif(is_ironpython or is_linux, reason="Skipped because Desktop is crashing")
184184
def test_08_assign_excitations(self):

_unittest/test_27_Maxwell2D.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -545,14 +545,16 @@ def test_35_solution_types_setup(self, add_app):
545545
def test_36_design_excitations_by_type(self):
546546
coils = self.aedtapp.excitations_by_type["Coil"]
547547
assert coils
548-
assert len(coils) == len([bound for bound in self.aedtapp.design_excitations if bound.type == "Coil"])
548+
assert len(coils) == len([bound for bound in self.aedtapp.excitation_objects.values() if bound.type == "Coil"])
549549
currents = self.aedtapp.excitations_by_type["Current"]
550550
assert currents
551-
assert len(currents) == len([bound for bound in self.aedtapp.design_excitations if bound.type == "Current"])
551+
assert len(currents) == len(
552+
[bound for bound in self.aedtapp.excitation_objects.values() if bound.type == "Current"]
553+
)
552554
wdg_group = self.aedtapp.excitations_by_type["Winding Group"]
553555
assert wdg_group
554556
assert len(wdg_group) == len(
555-
[bound for bound in self.aedtapp.design_excitations if bound.type == "Winding Group"]
557+
[bound for bound in self.aedtapp.excitation_objects.values() if bound.type == "Winding Group"]
556558
)
557559

558560
def test_37_boundaries_by_type(self):

pyaedt/application/Analysis.py

+41
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def __init__(
122122
port,
123123
aedt_process_id,
124124
)
125+
self._excitation_objects = {}
125126
self._setup = None
126127
if setup_name:
127128
self.active_setup = setup_name
@@ -477,6 +478,46 @@ def excitations(self):
477478
except Exception:
478479
return []
479480

481+
@property
482+
def excitations_by_type(self):
483+
"""Design excitations by type.
484+
485+
Returns
486+
-------
487+
dict
488+
Dictionary of excitations.
489+
"""
490+
_dict_out = {}
491+
for bound in self.excitation_objects.values():
492+
if bound.type in _dict_out:
493+
_dict_out[bound.type].append(bound)
494+
else:
495+
_dict_out[bound.type] = [bound]
496+
return _dict_out
497+
498+
@property
499+
def excitation_objects(self):
500+
"""Get all excitation.
501+
502+
Returns
503+
-------
504+
dict
505+
List of excitation boundaries. Excitations with multiple modes will return one
506+
excitation for each mode.
507+
508+
References
509+
----------
510+
511+
>>> oModule.GetExcitations
512+
"""
513+
exc_names = self.excitations[::]
514+
515+
for el in self.boundaries:
516+
if el.name in exc_names:
517+
self._excitation_objects[el.name] = el
518+
519+
return self._excitation_objects
520+
480521
@pyaedt_function_handler()
481522
def get_traces_for_plot(
482523
self,

pyaedt/application/Analysis3DLayout.py

-29
Original file line numberDiff line numberDiff line change
@@ -158,35 +158,6 @@ def excitations(self):
158158
"""
159159
return list(self.oboundary.GetAllPortsList())
160160

161-
@property
162-
def get_all_sparameter_list(self, excitation_names=[]):
163-
"""List of all S parameters for a list of excitations.
164-
165-
Parameters
166-
----------
167-
excitation_names : list, optional
168-
List of excitations. The default is ``[]``, in which case
169-
the S parameters for all excitations are to be provided.
170-
For example, ``["1", "2"]``.
171-
172-
Returns
173-
-------
174-
list
175-
List of strings representing the S parameters of the excitations.
176-
For example, ``["S(1, 1)", "S(1, 2)", S(2, 2)]``.
177-
178-
"""
179-
if not excitation_names:
180-
excitation_names = self.excitations
181-
spar = []
182-
k = 0
183-
for i in excitation_names:
184-
k = excitation_names.index(i)
185-
while k < len(excitation_names):
186-
spar.append("S({},{})".format(i, excitation_names[k]))
187-
k += 1
188-
return spar
189-
190161
@pyaedt_function_handler()
191162
def change_design_settings(self, settings):
192163
"""Set HFSS 3D Layout Design Settings.

pyaedt/application/AnalysisNexxim.py

+14-55
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def sources(self):
287287
return props
288288

289289
@property
290-
def excitation_names(self):
290+
def excitations(self):
291291
"""List of port names.
292292
293293
Returns
@@ -304,36 +304,24 @@ def excitation_names(self):
304304
return ports
305305

306306
@property
307-
def excitation_objets(self):
307+
def excitation_objects(self):
308308
"""List of port objects.
309309
310310
Returns
311311
-------
312-
list
312+
dict
313313
List of port objects.
314314
"""
315-
return [self.excitations[name] for name in self.excitations]
316-
317-
@property
318-
def excitations(self):
319-
"""Get all ports.
320-
321-
Returns
322-
-------
323-
list
324-
List of ports.
325-
326-
"""
327315
props = {}
328316
if not self._internal_excitations:
329-
for port in self.excitation_names:
317+
for port in self.excitations:
330318
props[port] = Excitations(self, port)
331319
self._internal_excitations = props
332320
else:
333321
props = self._internal_excitations
334-
if not sorted(list(props.keys())) == sorted(self.excitation_names):
322+
if not sorted(list(props.keys())) == sorted(self.excitations):
335323
a = set(str(x) for x in props.keys())
336-
b = set(str(x) for x in self.excitation_names)
324+
b = set(str(x) for x in self.excitations)
337325
if len(a) == len(b):
338326
unmatched_new_name = list(b - a)[0]
339327
unmatched_old_name = list(a - b)[0]
@@ -342,44 +330,15 @@ def excitations(self):
342330
else:
343331
if len(a) > len(b):
344332
for old_port in props.keys():
345-
if old_port not in self.excitation_names:
333+
if old_port not in self.excitations:
346334
del props[old_port]
347335
return props
348336
else:
349-
for new_port in self.excitation_names:
337+
for new_port in self.excitations:
350338
if new_port not in props.keys():
351339
props[new_port] = Excitations(self, new_port)
352340
return props
353341

354-
@property
355-
def get_all_sparameter_list(self, excitation_names=[]):
356-
"""List of all S parameters for a list of excitations.
357-
358-
Parameters
359-
----------
360-
excitation_names : list, optional
361-
List of excitations. The default value is ``[]``, in which case
362-
the S parameters for all excitations are to be provided.
363-
For example, ``["1", "2"]``.
364-
365-
Returns
366-
-------
367-
list of str
368-
List of strings representing the S parameters of the excitations.
369-
For example, ``"S(1,1)", "S(1,2)", "S(2,2)"``.
370-
371-
"""
372-
if not excitation_names:
373-
excitation_names = list(self.excitations.keys())
374-
spar = []
375-
k = 0
376-
for i in excitation_names:
377-
k = excitation_names.index(i)
378-
while k < len(excitation_names):
379-
spar.append("S({},{})".format(i, excitation_names[k]))
380-
k += 1
381-
return spar
382-
383342
@pyaedt_function_handler()
384343
def get_all_return_loss_list(self, excitation_names=None, excitation_name_prefix=""):
385344
"""Retrieve a list of all return losses for a list of exctitations.
@@ -408,7 +367,7 @@ def get_all_return_loss_list(self, excitation_names=None, excitation_name_prefix
408367
excitation_names = []
409368

410369
if not excitation_names:
411-
excitation_names = list(self.excitations.keys())
370+
excitation_names = list(self.excitations)
412371
if excitation_name_prefix:
413372
excitation_names = [i for i in excitation_names if excitation_name_prefix.lower() in i.lower()]
414373
spar = []
@@ -450,9 +409,9 @@ def get_all_insertion_loss_list(self, trlist=None, reclist=None, tx_prefix="", r
450409

451410
spar = []
452411
if not trlist:
453-
trlist = [i for i in list(self.excitations.keys()) if tx_prefix in i]
412+
trlist = [i for i in list(self.excitations) if tx_prefix in i]
454413
if not reclist:
455-
reclist = [i for i in list(self.excitations.keys()) if rx_prefix in i]
414+
reclist = [i for i in list(self.excitations) if rx_prefix in i]
456415
if len(trlist) != len(reclist):
457416
self.logger.error("The TX and RX lists should be the same length.")
458417
return False
@@ -485,7 +444,7 @@ def get_next_xtalk_list(self, trlist=[], tx_prefix=""):
485444
"""
486445
next_xtalks = []
487446
if not trlist:
488-
trlist = [i for i in list(self.excitations.keys()) if tx_prefix in i]
447+
trlist = [i for i in list(self.excitations) if tx_prefix in i]
489448
for i in trlist:
490449
k = trlist.index(i) + 1
491450
while k < len(trlist):
@@ -528,9 +487,9 @@ def get_fext_xtalk_list(self, trlist=None, reclist=None, tx_prefix="", rx_prefix
528487
"""
529488
fext = []
530489
if trlist is None:
531-
trlist = [i for i in list(self.excitations.keys()) if tx_prefix in i]
490+
trlist = [i for i in list(self.excitations) if tx_prefix in i]
532491
if reclist is None:
533-
reclist = [i for i in list(self.excitations.keys()) if rx_prefix in i]
492+
reclist = [i for i in list(self.excitations) if rx_prefix in i]
534493
for i in trlist:
535494
for k in reclist:
536495
if not skip_same_index_couples or reclist.index(k) != trlist.index(i):

pyaedt/application/Design.py

+16-53
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,16 @@ def boundaries(self):
378378
self._boundaries[boundary] = NetworkObject(self, boundary)
379379
else:
380380
self._boundaries[boundary] = BoundaryObject(self, boundary, boundarytype=boundarytype)
381-
382-
excitations = self.design_excitations
383-
for exc in excitations:
384-
if not self._boundaries or exc.name not in list(self._boundaries.keys()):
385-
self._boundaries[exc.name] = exc
386-
381+
try:
382+
if "GetExcitations" in self.oboundary.__dir__():
383+
ee = list(self.oboundary.GetExcitations())
384+
current_boundaries = [i.split(":")[0] for i in ee[::2]]
385+
current_types = ee[1::2]
386+
for k, v in zip(current_boundaries, current_types):
387+
if k not in self._boundaries:
388+
self._boundaries[k] = BoundaryObject(self, k, boundarytype=v)
389+
except:
390+
pass
387391
return list(self._boundaries.values())
388392

389393
@property
@@ -403,71 +407,30 @@ def boundaries_by_type(self):
403407
return _dict_out
404408

405409
@property
406-
def excitations_by_type(self):
407-
"""Design excitations by type.
408-
409-
Returns
410-
-------
411-
dict
412-
Dictionary of excitations.
413-
"""
414-
_dict_out = {}
415-
for bound in self.design_excitations:
416-
if bound.type in _dict_out:
417-
_dict_out[bound.type].append(bound)
418-
else:
419-
_dict_out[bound.type] = [bound]
420-
return _dict_out
421-
422-
@property
423-
def design_excitations(self):
410+
def ports(self):
424411
"""Design excitations.
425412
426413
Returns
427414
-------
428415
list
429-
List of :class:`pyaedt.modules.Boundary.BoundaryObject`.
416+
Port names.
430417
"""
431-
design_excitations = {}
418+
design_excitations = []
432419

433420
if "GetExcitations" in self.oboundary.__dir__():
434421
ee = list(self.oboundary.GetExcitations())
435-
current_boundaries = [i.split(":")[0] for i in ee[::2]]
436422
current_types = ee[1::2]
437423
for i in set(current_types):
438424
new_port = []
439425
if "GetExcitationsOfType" in self.oboundary.__dir__():
440426
new_port = list(self.oboundary.GetExcitationsOfType(i))
441427
if new_port:
442-
current_boundaries = current_boundaries + new_port
428+
design_excitations += new_port
443429
current_types = current_types + [i] * len(new_port)
444-
445-
for boundary, boundarytype in zip(current_boundaries, current_types):
446-
design_excitations[boundary] = BoundaryObject(self, boundary, boundarytype=boundarytype)
447-
if (
448-
design_excitations[boundary].object_properties
449-
and design_excitations[boundary].object_properties.props["Type"] == "Terminal"
450-
): # pragma: no cover
451-
props_terminal = OrderedDict()
452-
props_terminal["TerminalResistance"] = design_excitations[boundary].object_properties.props[
453-
"Terminal Renormalizing Impedance"
454-
]
455-
props_terminal["ParentBndID"] = design_excitations[boundary].object_properties.props["Port Name"]
456-
design_excitations[boundary] = BoundaryObject(
457-
self, boundary, props=props_terminal, boundarytype="Terminal"
458-
)
430+
return design_excitations
459431

460432
elif "GetAllPortsList" in self.oboundary.__dir__() and self.design_type in ["HFSS 3D Layout Design"]:
461-
for port in self.oboundary.GetAllPortsList():
462-
if port in self._boundaries:
463-
continue
464-
bound = self._update_port_info(port)
465-
if bound:
466-
design_excitations[port] = bound
467-
468-
if design_excitations:
469-
return list(design_excitations.values())
470-
433+
return self.oboundary.GetAllPortsList()
471434
return []
472435

473436
@property

0 commit comments

Comments
 (0)