|
6 | 6 | from pyaedt.generic.general_methods import aedt_exception_handler, generate_unique_name
|
7 | 7 | from collections import OrderedDict
|
8 | 8 | from pyaedt.modules.Boundary import BoundaryObject
|
9 |
| -from pyaedt.generic.DataHandlers import _dict2arg |
10 | 9 | import os
|
11 | 10 | import warnings
|
12 | 11 |
|
@@ -718,6 +717,7 @@ def __init__(
|
718 | 717 | student_version,
|
719 | 718 | )
|
720 | 719 |
|
| 720 | + @aedt_exception_handler |
721 | 721 | def create_rectangle(self, position, dimension_list, name="", matname=""):
|
722 | 722 | """
|
723 | 723 | Create a rectangle.
|
@@ -748,6 +748,7 @@ def create_rectangle(self, position, dimension_list, name="", matname=""):
|
748 | 748 | position, dimension_list=dimension_list, name=name, matname=matname
|
749 | 749 | )
|
750 | 750 |
|
| 751 | + @aedt_exception_handler |
751 | 752 | def assign_single_signal_line(self, target_objects, name="", solve_option="SolveInside", thickness=None, unit="um"):
|
752 | 753 | """Assign conductor type to sheets.
|
753 | 754 |
|
@@ -779,6 +780,7 @@ def assign_single_signal_line(self, target_objects, name="", solve_option="Solve
|
779 | 780 | )
|
780 | 781 | self.assign_single_conductor(target_objects, name, "SignalLine", solve_option, thickness, unit)
|
781 | 782 |
|
| 783 | + @aedt_exception_handler |
782 | 784 | def assign_single_conductor(
|
783 | 785 | self,
|
784 | 786 | target_objects,
|
@@ -808,10 +810,11 @@ def assign_single_conductor(
|
808 | 810 | thickness is used.
|
809 | 811 | unit : str, optional
|
810 | 812 | Thickness unit. The default is ``"um"``.
|
| 813 | +
|
811 | 814 | Returns
|
812 | 815 | -------
|
813 |
| - bool |
814 |
| - ``True`` when successful, ``False`` when failed. |
| 816 | + :class:`pyaedt.modules.Boundary.BoundaryObject` |
| 817 | + Source object. |
815 | 818 |
|
816 | 819 | References
|
817 | 820 | ----------
|
@@ -840,17 +843,13 @@ def assign_single_conductor(
|
840 | 843 |
|
841 | 844 | props = OrderedDict({"Objects": obj_names, "SolveOption": solve_option, "Thickness": str(thickness) + unit})
|
842 | 845 |
|
843 |
| - arg = ["NAME:" + name] |
844 |
| - _dict2arg(props, arg) |
845 |
| - if conductor_type == "SignalLine": |
846 |
| - self.oboundary.AssignSingleSignalLine(arg) |
847 |
| - elif conductor_type == "ReferenceGround": |
848 |
| - self.oboundary.AssignSingleReferenceGround(arg) |
849 |
| - else: |
850 |
| - return False |
851 |
| - |
852 |
| - return True |
| 846 | + bound = BoundaryObject(self, name, props, conductor_type) |
| 847 | + if bound.create(): |
| 848 | + self.boundaries.append(bound) |
| 849 | + return bound |
| 850 | + return False |
853 | 851 |
|
| 852 | + @aedt_exception_handler |
854 | 853 | def assign_huray_finitecond_to_edges(self, edges, radius, ratio, unit="um", name=""):
|
855 | 854 | """
|
856 | 855 | Assign Huray surface roughness model to edges.
|
@@ -891,3 +890,55 @@ def assign_huray_finitecond_to_edges(self, edges, radius, ratio, unit="um", name
|
891 | 890 | self.boundaries.append(bound)
|
892 | 891 | return bound
|
893 | 892 | return False
|
| 893 | + |
| 894 | + @aedt_exception_handler |
| 895 | + def auto_assign_conductors(self): |
| 896 | + """Auto Assign Conductors to Signal Lines. |
| 897 | +
|
| 898 | + Returns |
| 899 | + ------- |
| 900 | + bool |
| 901 | + """ |
| 902 | + original_nets = list(self.oboundary.GetExcitations()) |
| 903 | + self.oboundary.AutoAssignSignals() |
| 904 | + new_nets = [i for i in list(self.oboundary.GetExcitations()) if i not in original_nets] |
| 905 | + i = 0 |
| 906 | + while i < len(new_nets): |
| 907 | + objects = self.modeler.convert_to_selections( |
| 908 | + [int(k) for k in list(self.oboundary.GetExcitationAssignment(new_nets[i]))], True |
| 909 | + ) |
| 910 | + props = OrderedDict({"Objects": objects}) |
| 911 | + bound = BoundaryObject(self, new_nets[i], props, new_nets[i + 1]) |
| 912 | + self.boundaries.append(bound) |
| 913 | + i += 2 |
| 914 | + if new_nets: |
| 915 | + self.logger.info("{} Nets have been identified: {}".format(len(new_nets), ", ".join(new_nets))) |
| 916 | + else: |
| 917 | + self.logger.info("No new nets identified") |
| 918 | + return True |
| 919 | + |
| 920 | + @aedt_exception_handler |
| 921 | + def toggle_conductor_type(self, conductor_name, new_type): |
| 922 | + """Change the conductor type. |
| 923 | +
|
| 924 | + Parameters |
| 925 | + ---------- |
| 926 | + conductor_name : str |
| 927 | + Name of the conductor to update. |
| 928 | + new_type : str |
| 929 | + New conductor type. |
| 930 | +
|
| 931 | + Returns |
| 932 | + ------- |
| 933 | + bool |
| 934 | + """ |
| 935 | + try: |
| 936 | + self.oboundary.ToggleConductor(conductor_name, new_type) |
| 937 | + for bound in self.boundaries: |
| 938 | + if bound.name == conductor_name: |
| 939 | + bound.type = new_type |
| 940 | + self.logger.info("Conductor type correctly updated") |
| 941 | + return True |
| 942 | + except: |
| 943 | + self.logger.error("Error in updating conductor type") |
| 944 | + return False |
0 commit comments