Skip to content

Commit 81615d7

Browse files
authored
Merge branch 'main' into ci/refact_cicd
2 parents 9b03897 + efac98b commit 81615d7

19 files changed

+562
-935
lines changed

Diff for: _unittest/test_01_Design.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,17 @@ def test_app(self):
3838
assert self.aedtapp
3939

4040
def test_01_designname(self):
41-
self.aedtapp.design_name = "myname"
42-
assert self.aedtapp.design_name == "myname"
41+
# TODO: Remove subsequent dependence on string "myname"
42+
design_names = ["myname", "design2"]
43+
self.aedtapp.design_name = design_names[0] # Change the design name.
44+
assert self.aedtapp.design_name == design_names[0]
45+
self.aedtapp.insert_design(design_names[1]) # Insert a new design
46+
assert self.aedtapp.design_name == design_names[1]
47+
self.aedtapp.design_name = design_names[0] # Change current design back.
48+
assert len(self.aedtapp.design_list) == 2 # Make sure there are still 2 designs.
49+
assert self.aedtapp.design_list[0] == design_names[0] # Make sure the name is correct.
50+
self.aedtapp.delete_design(design_names[1]) # Delete the 2nd design
51+
assert len(self.aedtapp.design_list) == 1
4352

4453
def test_01_version_id(self):
4554
assert self.aedtapp.aedt_version_id

Diff for: _unittest/test_21_Circuit.py

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

680-
assert c.excitation_objets
680+
assert c.excitation_objects
681681

682682
setup = c.create_setup()
683683

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

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

Diff for: _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):

Diff for: _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):

Diff for: 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,

Diff for: pyaedt/application/Analysis3DLayout.py

-247
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.
@@ -235,224 +206,6 @@ def export_mesh_stats(self, setup_name, variation_string="", mesh_path=None):
235206
self.odesign.ExportMeshStats(setup_name, variation_string, mesh_path)
236207
return mesh_path
237208

238-
@pyaedt_function_handler()
239-
def get_all_return_loss_list(
240-
self, excitation_names=None, excitation_name_prefix="", math_formula="", net_list=None
241-
):
242-
"""Get a list of all return losses for a list of excitations.
243-
244-
Parameters
245-
----------
246-
excitation_names : list, optional
247-
List of excitations. The default is ``None``, in which case
248-
the return losses for all excitations are provided.
249-
For example ``["1", "2"]``.
250-
excitation_name_prefix : string, optional
251-
Prefix to add to the excitation names. The default is ``""``,
252-
math_formula : str, optional
253-
One of the available AEDT mathematical formulas to apply. For example, ``abs, dB``.
254-
net_list : list, optional
255-
List of nets to filter the output. The default is ``None``, in which case all parameters are returned.
256-
257-
Returns
258-
-------
259-
list of str
260-
List of strings representing the return losses of the excitations.
261-
For example, ``["S(1, 1)", S(2, 2)]``.
262-
263-
References
264-
----------
265-
266-
>>> oEditor.GetAllPorts
267-
"""
268-
if excitation_names == None:
269-
excitation_names = []
270-
271-
if not excitation_names:
272-
excitation_names = list(self.excitations)
273-
if excitation_name_prefix:
274-
excitation_names = [i for i in excitation_names if excitation_name_prefix.lower() in i.lower()]
275-
spar = []
276-
for i in excitation_names:
277-
if not net_list or (net_list and [net for net in net_list if net in i]):
278-
if math_formula:
279-
spar.append("{}(S({},{}))".format(math_formula, i, i))
280-
else:
281-
spar.append("S({},{})".format(i, i))
282-
return spar
283-
284-
@pyaedt_function_handler()
285-
def get_all_insertion_loss_list(
286-
self, trlist=None, reclist=None, tx_prefix="", rx_prefix="", math_formula="", net_list=None
287-
):
288-
"""Get a list of all insertion losses from two lists of excitations (driver and receiver).
289-
290-
Parameters
291-
----------
292-
trlist : list, optional
293-
List of drivers. The default is ``[]``. For example, ``["1"]``.
294-
reclist : list, optional
295-
List of receivers. The default is ``[]``. The number of drivers equals
296-
the number of receivers. For example, ``["2"]``.
297-
tx_prefix : str, optional
298-
Prefix to add to driver names. For example, ``"DIE"``. The default is ``""``.
299-
rx_prefix : str, optional
300-
Prefix to add to receiver names. For example, ``"BGA"``. The default is ``""``.
301-
math_formula : str, optional
302-
One of the available AEDT mathematical formulas to apply. For example, ``abs, dB``.
303-
net_list : list, optional
304-
List of nets to filter the output. The default is ``None``, in which
305-
case all parameters are returned.
306-
307-
Returns
308-
-------
309-
list of str
310-
List of strings representing insertion losses of the excitations.
311-
For example, ``["S(1,2)"]``.
312-
313-
References
314-
----------
315-
316-
>>> oEditor.GetAllPorts
317-
"""
318-
if trlist is None:
319-
trlist = [i for i in list(self.excitations)]
320-
321-
if reclist is None:
322-
reclist = [i for i in list(self.excitations)]
323-
if tx_prefix:
324-
trlist = [i for i in trlist if i.startswith(tx_prefix)]
325-
if rx_prefix:
326-
reclist = [i for i in reclist if i.startswith(rx_prefix)]
327-
spar = []
328-
if not net_list and len(trlist) != len(reclist):
329-
self.logger.error("The TX and RX lists should be the same length.")
330-
return False
331-
if net_list:
332-
for el in net_list:
333-
x = [i for i in trlist if el in i]
334-
y = [i for i in reclist if el in i]
335-
for x1 in x:
336-
for y1 in y:
337-
if x1[-2:] == y1[-2:]:
338-
if math_formula:
339-
spar.append("{}(S({},{}))".format(math_formula, x1, y1))
340-
else:
341-
spar.append("S({},{})".format(x1, y1))
342-
break
343-
else:
344-
for i, j in zip(trlist, reclist):
345-
if math_formula:
346-
spar.append("{}(S({},{}))".format(math_formula, i, j))
347-
else:
348-
spar.append("S({},{})".format(i, j))
349-
return spar
350-
351-
@pyaedt_function_handler()
352-
def get_next_xtalk_list(self, trlist=None, tx_prefix="", math_formula="", net_list=None):
353-
"""Get a list of all the near end XTalks from a list of excitations (driver and receiver).
354-
355-
Parameters
356-
----------
357-
trlist : list, optional
358-
List of drivers. The default is ``None``. For example,
359-
``["1", "2", "3"]``.
360-
tx_prefix : str, optional
361-
Prefix to add to driver names. For example, ``"DIE"``. The default is ``""``.
362-
math_formula : str, optional
363-
One of the available AEDT mathematical formulas to apply. For example, ``abs, dB``.
364-
net_list : list, optional
365-
List of nets to filter the output. The default is ``None``, in which case
366-
all parameters are returned.
367-
368-
Returns
369-
-------
370-
list of str
371-
List of strings representing near end XTalks of the excitations.
372-
For example, ``["S(1, 2)", "S(1, 3)", "S(2, 3)"]``.
373-
374-
References
375-
----------
376-
377-
>>> oEditor.GetAllPorts
378-
"""
379-
next_xtalks = []
380-
if not trlist:
381-
trlist = [i for i in list(self.excitations) if tx_prefix in i]
382-
for i in trlist:
383-
if not net_list or (net_list and [net for net in net_list if net in i]):
384-
k = trlist.index(i) + 1
385-
while k < len(trlist):
386-
if math_formula:
387-
next_xtalks.append("{}(S({},{}))".format(math_formula, i, trlist[k]))
388-
else:
389-
next_xtalks.append("S({},{})".format(i, trlist[k]))
390-
k += 1
391-
return next_xtalks
392-
393-
@pyaedt_function_handler()
394-
def get_fext_xtalk_list(
395-
self,
396-
trlist=None,
397-
reclist=None,
398-
tx_prefix="",
399-
rx_prefix="",
400-
skip_same_index_couples=True,
401-
math_formula="",
402-
net_list=None,
403-
):
404-
"""Geta list of all the far end XTalks from two lists of excitations (driver and receiver).
405-
406-
Parameters
407-
----------
408-
trlist : list, optional
409-
List of drivers. The default is ``[]``. For example,
410-
``["1", "2"]``.
411-
reclist : list, optional
412-
List of receiver. The default is ``[]``. For example,
413-
``["3", "4"]``.
414-
tx_prefix : str, optional
415-
Prefix for driver names. For example, ``"DIE"``. The default is ``""``.
416-
rx_prefix : str, optional
417-
Prefix for receiver names. For examples, ``"BGA"`` The default is ``""``.
418-
skip_same_index_couples : bool, optional
419-
Whether to skip driver and receiver couples with the same index position.
420-
The default is ``True``, in which case the drivers and receivers
421-
with the same index position are considered insertion losses and
422-
excluded from the list.
423-
math_formula : str, optional
424-
One of the available AEDT mathematical formulas to apply. For example, ``abs, dB``.
425-
net_list : list, optional
426-
List of nets to filter the output. The default is ``None``, in which case all
427-
parameters are returned.
428-
429-
Returns
430-
-------
431-
list of str
432-
List of strings representing the far end XTalks of the excitations.
433-
For example, ``["S(1, 4)", "S(2, 3)"]``.
434-
435-
References
436-
----------
437-
438-
>>> oEditor.GetAllPorts
439-
"""
440-
441-
fext = []
442-
if trlist is None:
443-
trlist = [i for i in list(self.excitations) if tx_prefix in i]
444-
if reclist is None:
445-
reclist = [i for i in list(self.excitations) if rx_prefix in i]
446-
for i in trlist:
447-
if not net_list or (net_list and [net for net in net_list if net in i]):
448-
for k in reclist:
449-
if not skip_same_index_couples or reclist.index(k) != trlist.index(i):
450-
if math_formula:
451-
fext.append("{}(S({},{}))".format(math_formula, i, k))
452-
else:
453-
fext.append("S({},{})".format(i, k))
454-
return fext
455-
456209
@property
457210
def modeler(self):
458211
"""Modeler object.

0 commit comments

Comments
 (0)