diff --git a/src/ansys/aedt/core/application/analysis.py b/src/ansys/aedt/core/application/analysis.py index 424497c7247..494e4b58d8c 100644 --- a/src/ansys/aedt/core/application/analysis.py +++ b/src/ansys/aedt/core/application/analysis.py @@ -530,6 +530,16 @@ def excitation_objects(self): if el.name in exc_names: self._excitation_objects[el.name] = el + # Delete objects that are not anymore available + keys_to_remove = [ + internal_excitation + for internal_excitation in self._excitation_objects + if internal_excitation not in self.excitations + ] + + for key in keys_to_remove: + del self._excitation_objects[key] + return self._excitation_objects @pyaedt_function_handler() diff --git a/src/ansys/aedt/core/application/analysis_3d.py b/src/ansys/aedt/core/application/analysis_3d.py index 37228551970..58377f595e5 100644 --- a/src/ansys/aedt/core/application/analysis_3d.py +++ b/src/ansys/aedt/core/application/analysis_3d.py @@ -1377,7 +1377,7 @@ def import_gds_3d(self, input_file: str, mapping_layers: dict, units: str = "um" input_file : str Path to the GDS file. mapping_layers : dict - Dictionary keys are GDS layer numbers, and the value is a tuple with the thickness and elevation. + Dictionary keys are GDS layer numbers, and the value is a tuple with the elevation and thickness. units : str, optional Length unit values. The default is ``"um"``. import_method : integer, optional diff --git a/src/ansys/aedt/core/application/design.py b/src/ansys/aedt/core/application/design.py index d3884f1f8cd..54795763700 100644 --- a/src/ansys/aedt/core/application/design.py +++ b/src/ansys/aedt/core/application/design.py @@ -85,6 +85,7 @@ from ansys.aedt.core.generic.load_aedt_file import load_entire_aedt_file from ansys.aedt.core.modules.boundary.common import BoundaryObject from ansys.aedt.core.modules.boundary.icepak_boundary import NetworkObject +from ansys.aedt.core.modules.boundary.layout_boundary import BoundaryObject3dLayout from ansys.aedt.core.modules.boundary.maxwell_boundary import MaxwellParameters if sys.version_info.major > 2: @@ -492,10 +493,14 @@ def boundaries(self) -> List[BoundaryObject]: self._boundaries[boundary] = NetworkObject(self, boundary) else: self._boundaries[boundary] = BoundaryObject(self, boundary, boundarytype=boundarytype) + try: for k, v in zip(current_excitations, current_excitation_types): if k not in self._boundaries: - self._boundaries[k] = BoundaryObject(self, k, boundarytype=v) + if self.design_type == "HFSS 3D Layout Design" and v == "Port": + self._boundaries[k] = BoundaryObject3dLayout(self, k, props=None, boundarytype=v) + else: + self._boundaries[k] = BoundaryObject(self, k, boundarytype=v) except Exception: self.logger.info("Failed to design boundary object.") return list(self._boundaries.values()) diff --git a/src/ansys/aedt/core/hfss.py b/src/ansys/aedt/core/hfss.py index b77bf3aa13d..3183bbaa4cf 100644 --- a/src/ansys/aedt/core/hfss.py +++ b/src/ansys/aedt/core/hfss.py @@ -251,6 +251,7 @@ def field_setups(self): List of :class:`ansys.aedt.core.modules.boundary.hfss_boundary.FarFieldSetup` and :class:`ansys.aedt.core.modules.hfss_boundary.NearFieldSetup` """ + self._field_setups = [] for field in self.field_setup_names: obj_field = self.odesign.GetChildObject("Radiation").GetChildObject(field) type_field = obj_field.GetPropValue("Type") diff --git a/src/ansys/aedt/core/modeler/cad/elements_3d.py b/src/ansys/aedt/core/modeler/cad/elements_3d.py index 594fbb58525..78c25db6661 100644 --- a/src/ansys/aedt/core/modeler/cad/elements_3d.py +++ b/src/ansys/aedt/core/modeler/cad/elements_3d.py @@ -1370,43 +1370,60 @@ def __init__(self, node, child_object, first_level=False, get_child_obj_arg=None self._props = None if not root_name: root_name = node - saved_root_name = node if first_level else root_name - self.node = node + self._saved_root_name = node if first_level else root_name + self._get_child_obj_arg = get_child_obj_arg + self._node = node self.child_object = child_object - self.children = {} self.auto_update = True + self._children = {} + self.__first_level = first_level + if first_level: + self._update_children() + + def _update_children(self): + self._children = {} name = None try: - if get_child_obj_arg is None: - child_names = [i for i in list(child_object.GetChildNames()) if not i.startswith("CachedBody")] + if self._get_child_obj_arg is None: + child_names = [i for i in list(self.child_object.GetChildNames()) if not i.startswith("CachedBody")] else: child_names = [ - i for i in list(child_object.GetChildNames(get_child_obj_arg)) if not i.startswith("CachedBody") + i + for i in list(self.child_object.GetChildNames(self._get_child_obj_arg)) + if not i.startswith("CachedBody") ] except Exception: # pragma: no cover child_names = [] for i in child_names: if not name: name = i - if i == "OperandPart_" + saved_root_name or i == "OperandPart_" + saved_root_name.split("_")[0]: + if i == "OperandPart_" + self._saved_root_name or i == "OperandPart_" + self._saved_root_name.split("_")[0]: continue elif not i.startswith("OperandPart_"): try: - self.children[i] = BinaryTreeNode(i, self.child_object.GetChildObject(i), root_name=saved_root_name) + self._children[i] = BinaryTreeNode( + i, self.child_object.GetChildObject(i), root_name=self._saved_root_name + ) except Exception: # nosec pass else: names = self.child_object.GetChildObject(i).GetChildNames() for name in names: - self.children[name] = BinaryTreeNode( - name, self.child_object.GetChildObject(i).GetChildObject(name), root_name=saved_root_name + self._children[name] = BinaryTreeNode( + name, self.child_object.GetChildObject(i).GetChildObject(name), root_name=self._saved_root_name ) - if first_level: - self.child_object = self.children[name].child_object - self._props = self.children[name]._props + if name and self.__first_level: + self.child_object = self._children[name].child_object + self._props = self._children[name].properties if name == "CreatePolyline:1": - self.segments = self.children[name].children - del self.children[name] + self.segments = self._children[name].children + del self._children[name] + + @property + def children(self): + if not self._children: + self._update_children() + return self._children @property def properties(self): @@ -1417,6 +1434,8 @@ def properties(self): :class:``ansys.aedt.coree.modeler.cad.elements_3d.HistoryProps`` """ self._props = {} + if not getattr(self, "child_object", None): + return self._props if settings.aedt_version >= "2024.2": try: from ansys.aedt.core.application import _get_data_model @@ -1464,18 +1483,28 @@ def update_property(self, prop_name, prop_value): bool ``True`` when successful, ``False`` when failed. """ + if prop_value is None: + settings.logger.warning(f"Property {prop_name} set to None ignored.") + return try: - self.child_object.SetPropValue(prop_name, prop_value) - return True + result = self.child_object.SetPropValue(prop_name, prop_value) + if result: + if prop_name == "Name" and getattr(self, "_name", False): + setattr(self, "_name", prop_value) + else: + settings.logger.warning(f"Property {prop_name} is read-only.") + # Property Name duplicated + return except Exception: # pragma: no cover - return False + # Property read-only + raise KeyError @pyaedt_function_handler def _jsonalize_tree(self, binary_tree_node): childrend_dict = {} for _, node in binary_tree_node.children.items(): childrend_dict.update(self._jsonalize_tree(node)) - return {binary_tree_node.node: {"Props": binary_tree_node.properties, "Children": childrend_dict}} + return {binary_tree_node._node: {"Props": binary_tree_node.properties, "Children": childrend_dict}} @pyaedt_function_handler def jsonalize_tree(self): @@ -1496,7 +1525,7 @@ def _suppress(self, node, app, suppress): "NAME:AllTabs", [ "NAME:Geometry3DCmdTab", - ["NAME:PropServers", node.child_object.GetObjPath().split("/")[3] + ":" + node.node], + ["NAME:PropServers", node.child_object.GetObjPath().split("/")[3] + ":" + node._node], ["NAME:ChangedProps", ["NAME:Suppress Command", "Value:=", suppress]], ], ] diff --git a/src/ansys/aedt/core/modules/boundary/common.py b/src/ansys/aedt/core/modules/boundary/common.py index c304f8e032d..b6cb0e6872f 100644 --- a/src/ansys/aedt/core/modules/boundary/common.py +++ b/src/ansys/aedt/core/modules/boundary/common.py @@ -96,6 +96,8 @@ def _get_args(self, props=None): def _initialize_bynary_tree(self): if self._child_object: BinaryTreeNode.__init__(self, self._name, self._child_object, False) + return True + return False @pyaedt_function_handler() def delete(self): @@ -219,7 +221,6 @@ def __init__(self, app, name, props=None, boundarytype=None, auto_update=True): self.__props = None self.__props = BoundaryProps(self, props) if props else {} self._type = boundarytype - self._boundary_name = self.name self.auto_update = auto_update self._initialize_bynary_tree() @@ -232,36 +233,50 @@ def _child_object(self): class:`ansys.aedt.core.modeler.cad.elements_3d.BinaryTreeNode` """ - child_object = None design_childs = self._app.get_oo_name(self._app.odesign) + if "Nets" in design_childs: + cc = self._app.get_oo_object(self._app.odesign, "Nets") + cc_names = self._app.get_oo_name(cc) + if self._name in cc_names: + return cc.GetChildObject(self._name) + for name in cc_names: + cc = self._app.get_oo_object(self._app.odesign, f"Nets\\{name}") + cc_names = self._app.get_oo_name(cc) + if self._name in cc_names: + return cc.GetChildObject(self._name) + if "Thermal" in design_childs: cc = self._app.get_oo_object(self._app.odesign, "Thermal") cc_names = self._app.get_oo_name(cc) - if self.name in cc_names: - child_object = cc.GetChildObject(self.name) - elif "Boundaries" in design_childs: + if self._name in cc_names: + return cc.GetChildObject(self._name) + + if "Boundaries" in design_childs: cc = self._app.get_oo_object(self._app.odesign, "Boundaries") - if self.name in cc.GetChildNames(): - child_object = cc.GetChildObject(self.name) - elif "Excitations" in design_childs and self.name in self._app.get_oo_name( - self._app.odesign, "Excitations" - ): - child_object = self._app.get_oo_object(self._app.odesign, "Excitations").GetChildObject(self.name) - elif self._app.design_type in ["Maxwell 3D", "Maxwell 2D"] and "Model" in design_childs: - model = self._app.get_oo_object(self._app.odesign, "Model") - if self.name in model.GetChildNames(): - child_object = model.GetChildObject(self.name) - elif "Excitations" in design_childs and self._app.get_oo_name(self._app.odesign, "Excitations"): + if self._name in cc.GetChildNames(): + return cc.GetChildObject(self._name) + + if "Excitations" in design_childs: + if self._name in self._app.get_oo_name(self._app.odesign, "Excitations"): + return self._app.get_oo_object(self._app.odesign, "Excitations").GetChildObject(self._name) + elif self._app.get_oo_name(self._app.odesign, "Excitations"): for port in self._app.get_oo_name(self._app.odesign, "Excitations"): terminals = self._app.get_oo_name(self._app.odesign, f"Excitations\\{port}") - if self.name in terminals: - child_object = self._app.get_oo_object(self._app.odesign, f"Excitations\\{port}\\{self.name}") - elif "Conductors" in design_childs and self._app.get_oo_name(self._app.odesign, "Conductors"): - for port in self._app.get_oo_name(self._app.odesign, "Conductors"): - if self.name == port: - child_object = self._app.get_oo_object(self._app.odesign, f"Conductors\\{port}") - return child_object + if self._name in terminals: + return self._app.get_oo_object(self._app.odesign, f"Excitations\\{port}\\{self._name}") + + if self._app.design_type in ["Maxwell 3D", "Maxwell 2D"] and "Model" in design_childs: + model = self._app.get_oo_object(self._app.odesign, "Model") + if self._name in model.GetChildNames(): + return model.GetChildObject(self._name) + + if "Conductors" in design_childs and self._app.get_oo_name(self._app.odesign, "Conductors"): + for port in self._app.get_oo_name(self._app.odesign, "Conductors"): + if self._name == port: + return self._app.get_oo_object(self._app.odesign, f"Conductors\\{port}") + + return None @property def props(self): @@ -310,12 +325,18 @@ def type(self, value): @property def name(self): """Boundary Name.""" + if getattr(self, "child_object", None): + self._name = str(self.properties["Name"]) return self._name @name.setter def name(self, value): - self._name = value - self.update() + if getattr(self, "child_object", None): + try: + self.properties["Name"] = value + self._app._boundaries[value] = self + except KeyError: + self._app.logger.error("Name %s already assigned in the design", value) @pyaedt_function_handler() def _get_args(self, props=None): @@ -359,6 +380,7 @@ def create(self): self._app.oboundary.AssignRadiation(self._get_args()) elif bound_type == "FE-BI": self._app.oboundary.AssignFEBI(self._get_args()) + return True elif bound_type == "Finite Conductivity": self._app.oboundary.AssignFiniteCond(self._get_args()) elif bound_type == "Lumped RLC": @@ -397,6 +419,7 @@ def create(self): self._app.oboundary.AssignDependent(self._get_args()) elif bound_type == "Band": self._app.omodelsetup.AssignBand(self._get_args()) + return True elif bound_type == "InfiniteGround": self._app.oboundary.AssignInfiniteGround(self._get_args()) elif bound_type == "ThinConductor": @@ -504,10 +527,12 @@ def create(self): ) elif bound_type == "SBRTxRxSettings": self._app.oboundary.SetSBRTxRxSettings(self._get_args()) + return True elif bound_type == "EndConnection": self._app.oboundary.AssignEndConnection(self._get_args()) elif bound_type == "Hybrid": self._app.oboundary.AssignHybridRegion(self._get_args()) + return True elif bound_type == "FluxTangential": self._app.oboundary.AssignFluxTangential(self._get_args()) elif bound_type == "Plane Incident Wave": @@ -516,9 +541,8 @@ def create(self): self._app.oboundary.AssignResistiveSheet(self._get_args()) else: return False - self._initialize_bynary_tree() - return True + return self._initialize_bynary_tree() @pyaedt_function_handler() def update(self): @@ -532,95 +556,91 @@ def update(self): """ bound_type = self.type if bound_type == "Perfect E": - self._app.oboundary.EditPerfectE(self._boundary_name, self._get_args()) + self._app.oboundary.EditPerfectE(self.name, self._get_args()) elif bound_type == "Perfect H": - self._app.oboundary.EditPerfectH(self._boundary_name, self._get_args()) + self._app.oboundary.EditPerfectH(self.name, self._get_args()) elif bound_type == "Aperture": - self._app.oboundary.EditAperture(self._boundary_name, self._get_args()) + self._app.oboundary.EditAperture(self.name, self._get_args()) elif bound_type == "Radiation": - self._app.oboundary.EditRadiation(self._boundary_name, self._get_args()) + self._app.oboundary.EditRadiation(self.name, self._get_args()) elif bound_type == "Finite Conductivity": - self._app.oboundary.EditFiniteCond(self._boundary_name, self._get_args()) + self._app.oboundary.EditFiniteCond(self.name, self._get_args()) elif bound_type == "Lumped RLC": - self._app.oboundary.EditLumpedRLC(self._boundary_name, self._get_args()) + self._app.oboundary.EditLumpedRLC(self.name, self._get_args()) elif bound_type == "Impedance": - self._app.oboundary.EditImpedance(self._boundary_name, self._get_args()) + self._app.oboundary.EditImpedance(self.name, self._get_args()) elif bound_type == "Layered Impedance": - self._app.oboundary.EditLayeredImpedance(self._boundary_name, self._get_args()) + self._app.oboundary.EditLayeredImpedance(self.name, self._get_args()) elif bound_type == "Anisotropic Impedance": - self._app.oboundary.EditAssignAnisotropicImpedance( - self._boundary_name, self._get_args() - ) # pragma: no cover + self._app.oboundary.EditAssignAnisotropicImpedance(self.name, self._get_args()) # pragma: no cover elif bound_type == "Primary": - self._app.oboundary.EditPrimary(self._boundary_name, self._get_args()) + self._app.oboundary.EditPrimary(self.name, self._get_args()) elif bound_type == "Secondary": - self._app.oboundary.EditSecondary(self._boundary_name, self._get_args()) + self._app.oboundary.EditSecondary(self.name, self._get_args()) elif bound_type == "Lattice Pair": - self._app.oboundary.EditLatticePair(self._boundary_name, self._get_args()) + self._app.oboundary.EditLatticePair(self.name, self._get_args()) elif bound_type == "HalfSpace": - self._app.oboundary.EditHalfSpace(self._boundary_name, self._get_args()) + self._app.oboundary.EditHalfSpace(self.name, self._get_args()) elif bound_type == "Multipaction SEE": - self._app.oboundary.EditMultipactionSEE(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditMultipactionSEE(self.name, self._get_args()) # pragma: no cover elif bound_type == "Fresnel": - self._app.oboundary.EditFresnel(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditFresnel(self.name, self._get_args()) # pragma: no cover elif bound_type == "Symmetry": - self._app.oboundary.EditSymmetry(self._boundary_name, self._get_args()) + self._app.oboundary.EditSymmetry(self.name, self._get_args()) elif bound_type == "Zero Tangential H Field": - self._app.oboundary.EditZeroTangentialHField(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditZeroTangentialHField(self.name, self._get_args()) # pragma: no cover elif bound_type == "Zero Integrated Tangential H Field": - self._app.oboundary.EditIntegratedZeroTangentialHField( - self._boundary_name, self._get_args() - ) # pragma: no cover + self._app.oboundary.EditIntegratedZeroTangentialHField(self.name, self._get_args()) # pragma: no cover elif bound_type == "Tangential H Field": - self._app.oboundary.EditTangentialHField(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditTangentialHField(self.name, self._get_args()) # pragma: no cover elif bound_type == "Insulating": - self._app.oboundary.EditInsulating(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditInsulating(self.name, self._get_args()) # pragma: no cover elif bound_type == "Independent": - self._app.oboundary.EditIndependent(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditIndependent(self.name, self._get_args()) # pragma: no cover elif bound_type == "Dependent": - self._app.oboundary.EditDependent(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditDependent(self.name, self._get_args()) # pragma: no cover elif bound_type == "Band": - self._app.omodelsetup.EditMotionSetup(self._boundary_name, self._get_args()) # pragma: no cover + self._app.omodelsetup.EditMotionSetup(self.name, self._get_args()) # pragma: no cover elif bound_type == "InfiniteGround": - self._app.oboundary.EditInfiniteGround(self._boundary_name, self._get_args()) + self._app.oboundary.EditInfiniteGround(self.name, self._get_args()) elif bound_type == "ThinConductor": - self._app.oboundary.EditThinConductor(self._boundary_name, self._get_args()) + self._app.oboundary.EditThinConductor(self.name, self._get_args()) elif bound_type == "Stationary Wall": - self._app.oboundary.EditStationaryWallBoundary(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditStationaryWallBoundary(self.name, self._get_args()) # pragma: no cover elif bound_type == "Symmetry Wall": - self._app.oboundary.EditSymmetryWallBoundary(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditSymmetryWallBoundary(self.name, self._get_args()) # pragma: no cover elif bound_type == "Recirculating": - self._app.oboundary.EditRecircBoundary(self._boundary_name, self._get_args()) + self._app.oboundary.EditRecircBoundary(self.name, self._get_args()) elif bound_type == "Resistance": - self._app.oboundary.EditResistanceBoundary(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditResistanceBoundary(self.name, self._get_args()) # pragma: no cover elif bound_type == "Conducting Plate": - self._app.oboundary.EditConductingPlateBoundary(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditConductingPlateBoundary(self.name, self._get_args()) # pragma: no cover elif bound_type == "Adiabatic Plate": - self._app.oboundary.EditAdiabaticPlateBoundary(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditAdiabaticPlateBoundary(self.name, self._get_args()) # pragma: no cover elif bound_type == "Network": - self._app.oboundary.EditNetworkBoundary(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditNetworkBoundary(self.name, self._get_args()) # pragma: no cover elif bound_type == "Grille": - self._app.oboundary.EditGrilleBoundary(self._boundary_name, self._get_args()) + self._app.oboundary.EditGrilleBoundary(self.name, self._get_args()) elif bound_type == "Opening": - self._app.oboundary.EditOpeningBoundary(self._boundary_name, self._get_args()) + self._app.oboundary.EditOpeningBoundary(self.name, self._get_args()) elif bound_type == "EMLoss": - self._app.oboundary.EditEMLoss(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditEMLoss(self.name, self._get_args()) # pragma: no cover elif bound_type == "Block": - self._app.oboundary.EditBlockBoundary(self._boundary_name, self._get_args()) + self._app.oboundary.EditBlockBoundary(self.name, self._get_args()) elif bound_type == "Blower": - self._app.oboundary.EditBlowerBoundary(self._boundary_name, self._get_args()) + self._app.oboundary.EditBlowerBoundary(self.name, self._get_args()) elif bound_type == "SourceIcepak": - self._app.oboundary.EditSourceBoundary(self._boundary_name, self._get_args()) + self._app.oboundary.EditSourceBoundary(self.name, self._get_args()) elif bound_type == "HeatFlux": - self._app.oboundary.EditHeatFlux(self._boundary_name, self._get_args()) + self._app.oboundary.EditHeatFlux(self.name, self._get_args()) elif bound_type == "HeatGeneration": - self._app.oboundary.EditHeatGeneration(self._boundary_name, self._get_args()) + self._app.oboundary.EditHeatGeneration(self.name, self._get_args()) elif bound_type == "Voltage": - self._app.oboundary.EditVoltage(self._boundary_name, self._get_args()) + self._app.oboundary.EditVoltage(self.name, self._get_args()) elif bound_type == "VoltageDrop": - self._app.oboundary.EditVoltageDrop(self._boundary_name, self._get_args()) + self._app.oboundary.EditVoltageDrop(self.name, self._get_args()) elif bound_type == "Current": - self._app.oboundary.EditCurrent(self._boundary_name, self._get_args()) + self._app.oboundary.EditCurrent(self.name, self._get_args()) elif bound_type == "CurrentDensity": self._app.oboundary.AssignCurrentDensity(self._get_args()) elif bound_type == "CurrentDensityGroup": @@ -630,45 +650,42 @@ def update(self): elif bound_type == "CurrentDensityTerminalGroup": self._app.oboundary.AssignCurrentDensityTerminalGroup(self._get_args()[2], self._get_args()[3]) elif bound_type == "Winding" or bound_type == "Winding Group": - self._app.oboundary.EditWindingGroup(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditWindingGroup(self.name, self._get_args()) # pragma: no cover elif bound_type == "Vector Potential": - self._app.oboundary.EditVectorPotential(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditVectorPotential(self.name, self._get_args()) # pragma: no cover elif bound_type == "CoilTerminal" or bound_type == "Coil Terminal": - self._app.oboundary.EditCoilTerminal(self._boundary_name, self._get_args()) + self._app.oboundary.EditCoilTerminal(self.name, self._get_args()) elif bound_type == "Coil": - self._app.oboundary.EditCoil(self._boundary_name, self._get_args()) + self._app.oboundary.EditCoil(self.name, self._get_args()) elif bound_type == "Source": - self._app.oboundary.EditTerminal(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditTerminal(self.name, self._get_args()) # pragma: no cover elif bound_type == "Sink": - self._app.oboundary.EditTerminal(self._boundary_name, self._get_args()) + self._app.oboundary.EditTerminal(self.name, self._get_args()) elif bound_type == "SignalNet" or bound_type == "GroundNet" or bound_type == "FloatingNet": - self._app.oboundary.EditTerminal(self._boundary_name, self._get_args()) + self._app.oboundary.EditTerminal(self.name, self._get_args()) elif bound_type in "Circuit Port": - self._app.oboundary.EditCircuitPort(self._boundary_name, self._get_args()) + self._app.oboundary.EditCircuitPort(self.name, self._get_args()) elif bound_type in "Lumped Port": - self._app.oboundary.EditLumpedPort(self._boundary_name, self._get_args()) + self._app.oboundary.EditLumpedPort(self.name, self._get_args()) elif bound_type in "Wave Port": - self._app.oboundary.EditWavePort(self._boundary_name, self._get_args()) + self._app.oboundary.EditWavePort(self.name, self._get_args()) elif bound_type == "SetSBRTxRxSettings": self._app.oboundary.SetSBRTxRxSettings(self._get_args()) # pragma: no cover elif bound_type == "Floquet Port": - self._app.oboundary.EditFloquetPort(self._boundary_name, self._get_args()) # pragma: no cover + self._app.oboundary.EditFloquetPort(self.name, self._get_args()) # pragma: no cover elif bound_type == "End Connection": - self._app.oboundary.EditEndConnection(self._boundary_name, self._get_args()) + self._app.oboundary.EditEndConnection(self.name, self._get_args()) elif bound_type == "Hybrid": - self._app.oboundary.EditHybridRegion(self._boundary_name, self._get_args()) + self._app.oboundary.EditHybridRegion(self.name, self._get_args()) elif bound_type == "Terminal": - self._app.oboundary.EditTerminal(self._boundary_name, self._get_args()) + self._app.oboundary.EditTerminal(self.name, self._get_args()) elif bound_type == "Plane Incident Wave": - self._app.oboundary.EditIncidentWave(self._boundary_name, self._get_args()) + self._app.oboundary.EditIncidentWave(self.name, self._get_args()) elif bound_type == "ResistiveSheet": - self._app.oboundary.EditResistiveSheet(self._boundary_name, self._get_args()) + self._app.oboundary.EditResistiveSheet(self.name, self._get_args()) else: return False # pragma: no cover - self._app._boundaries[self.name] = self._app._boundaries.pop(self._boundary_name) - self._boundary_name = self.name - return True @pyaedt_function_handler() diff --git a/src/ansys/aedt/core/modules/boundary/hfss_boundary.py b/src/ansys/aedt/core/modules/boundary/hfss_boundary.py index 7cbab30d372..3932aec0fd3 100644 --- a/src/ansys/aedt/core/modules/boundary/hfss_boundary.py +++ b/src/ansys/aedt/core/modules/boundary/hfss_boundary.py @@ -52,9 +52,26 @@ def __init__(self, app, component_name, props, component_type): self._name = component_name self.__props = BoundaryProps(self, props) if props else {} self.auto_update = True - child_object = self._app.get_oo_object(self._app.odesign, f"Radiation/{self._name}") - if child_object: - BinaryTreeNode.__init__(self, self._name, child_object, False) + self._initialize_bynary_tree() + + @property + def _child_object(self): + """Object-oriented properties. + + Returns + ------- + class:`ansys.aedt.core.modeler.cad.elements_3d.BinaryTreeNode` + + """ + child_object = None + design_childs = self._app.get_oo_name(self._app.odesign) + + if "Radiation" in design_childs: + cc = self._app.get_oo_object(self._app.odesign, "Radiation") + cc_names = self._app.get_oo_name(cc) + if self._name in cc_names: + child_object = cc.GetChildObject(self._name) + return child_object @property def props(self): @@ -76,13 +93,18 @@ def props(self): @property def name(self): - """Variable name.""" + """Boundary Name.""" + if self._child_object: + self._name = str(self.properties["Name"]) return self._name @name.setter def name(self, value): - self._app.oradfield.RenameSetup(self._name, value) - self._name = value + if self._child_object: + try: + self.properties["Name"] = value + except KeyError: + self._app.logger.error("Name %s already assigned in the design", value) @pyaedt_function_handler() def _get_args(self, props=None): @@ -102,7 +124,6 @@ def create(self): ``True`` when successful, ``False`` when failed. """ - if self.type == "FarFieldSphere": self._app.oradfield.InsertInfiniteSphereSetup(self._get_args()) elif self.type == "NearFieldBox": @@ -117,10 +138,7 @@ def create(self): self._app.oradfield.AddAntennaOverlay(self._get_args()) elif self.type == "FieldSourceGroup": self._app.oradfield.AddRadFieldSourceGroup(self._get_args()) - child_object = self._app.get_oo_object(self._app.odesign, f"Radiation/{self._name}") - if child_object: - BinaryTreeNode.__init__(self, self._name, child_object, False) - return True + return self._initialize_bynary_tree() @pyaedt_function_handler() def update(self): diff --git a/src/ansys/aedt/core/modules/boundary/layout_boundary.py b/src/ansys/aedt/core/modules/boundary/layout_boundary.py index 41df52a5e97..18a77b1fa40 100644 --- a/src/ansys/aedt/core/modules/boundary/layout_boundary.py +++ b/src/ansys/aedt/core/modules/boundary/layout_boundary.py @@ -105,37 +105,47 @@ def __init__(self, app, component_type, component_name, props): self._update_props(self.__props, props) self.native_properties = self.__props["NativeComponentDefinitionProvider"] self.auto_update = True - child_object = self._app.get_oo_object(self._app.oeditor, self._name) - if child_object: - BinaryTreeNode.__init__(self, self._name, child_object, False) - @property - def props(self): - return self.__props + self._initialize_bynary_tree() @property - def name(self): - """Name of the object. + def _child_object(self): + """Object-oriented properties. Returns ------- - str - Name of the object. + class:`ansys.aedt.core.modeler.cad.elements_3d.BinaryTreeNode` """ + child_object = None + for el in self._app.oeditor.GetChildNames("ComponentDefinition"): + design_childs = self._app.get_oo_object(self._app.oeditor, el).GetChildNames() + if self._name in design_childs: + child_object = self._app.get_oo_object(self._app.oeditor, f"{el}\\{self._name}") + break + return child_object + + @property + def props(self): + return self.__props + + @property + def name(self): + """Boundary Name.""" + if self._child_object: + self._name = str(self.properties["Name"]) return self._name @name.setter - def name(self, component_name): - if component_name != self._name: - if component_name not in self._app.native_component_names: - self.properties["Name"] = component_name - self._app.native_components.update({component_name: self}) - del self._app.native_components[self._name] - del self._app.modeler.user_defined_components[self._name] - self._name = component_name - else: # pragma: no cover - self._app._logger.warning("Name %s already assigned in the design", component_name) + def name(self, value): + if self._child_object: + try: + legacy_name = self._name + self.properties["Name"] = value + self._app.modeler.user_defined_components[self._name] = self + del self._app.modeler.user_defined_components[legacy_name] + except KeyError: + self._app.logger.error("Name %s already assigned in the design", value) @property def definition_name(self): @@ -207,11 +217,8 @@ def create(self): a = [i for i in self._app.excitations if i not in names] self.excitation_name = a[0].split(":")[0] except (GrpcApiError, IndexError): - self.excitation_name = self.name - child_object = self._app.get_oo_object(self._app.oeditor, self._name) - if child_object: - BinaryTreeNode.__init__(self, self._name, child_object, False) - return True + self.excitation_name = self._name + return self._initialize_bynary_tree() @pyaedt_function_handler() def update(self): @@ -273,13 +280,13 @@ class BoundaryObject3dLayout(BoundaryCommon, BinaryTreeNode): An AEDT application from ``ansys.aedt.core.application``. name : str Name of the boundary. - props : dict + props : dict, optional Properties of the boundary. boundarytype : str Type of the boundary. """ - def __init__(self, app, name, props, boundarytype): + def __init__(self, app, name, props=None, boundarytype="Port"): self.auto_update = False self._app = app self._name = name @@ -287,10 +294,8 @@ def __init__(self, app, name, props, boundarytype): if props: self.__props = BoundaryProps(self, props) self.type = boundarytype - self._boundary_name = self.name self.auto_update = True - if self._child_object: - BinaryTreeNode.__init__(self, self.name, self._child_object, False) + self._initialize_bynary_tree() @property def _child_object(self): diff --git a/src/ansys/aedt/core/modules/boundary/maxwell_boundary.py b/src/ansys/aedt/core/modules/boundary/maxwell_boundary.py index a95c7b6e8e3..b21f8c8697b 100644 --- a/src/ansys/aedt/core/modules/boundary/maxwell_boundary.py +++ b/src/ansys/aedt/core/modules/boundary/maxwell_boundary.py @@ -62,12 +62,10 @@ def __init__(self, app, name, props=None, boundarytype=None): self._name = name self.__props = BoundaryProps(self, props) if props else {} self.type = boundarytype - self._boundary_name = self.name self.auto_update = True self.__reduced_matrices = None self.matrix_assignment = None - if self._child_object: - BinaryTreeNode.__init__(self, self.name, self._child_object, False) + self._initialize_bynary_tree() @property def reduced_matrices(self): @@ -99,10 +97,10 @@ def _child_object(self): cc = self._app.odesign.GetChildObject("Parameters") child_object = None - if self.name in cc.GetChildNames(): - child_object = self._app.odesign.GetChildObject("Parameters").GetChildObject(self.name) - elif self.name in self._app.odesign.GetChildObject("Parameters").GetChildNames(): - child_object = self._app.odesign.GetChildObject("Parameters").GetChildObject(self.name) + if self._name in cc.GetChildNames(): + child_object = self._app.odesign.GetChildObject("Parameters").GetChildObject(self._name) + elif self._name in self._app.odesign.GetChildObject("Parameters").GetChildNames(): + child_object = self._app.odesign.GetChildObject("Parameters").GetChildObject(self._name) return child_object @@ -125,13 +123,18 @@ def props(self): @property def name(self): - """Boundary name.""" + """Boundary Name.""" + if self._child_object: + self._name = str(self.properties["Name"]) return self._name @name.setter def name(self, value): - self._name = value - self.update() + if self._child_object: + try: + self.properties["Name"] = value + except KeyError: + self._app.logger.error("Name %s already assigned in the design", value) @pyaedt_function_handler() def _get_args(self, props=None): @@ -174,9 +177,7 @@ def create(self): self._app.o_maxwell_parameters.AssignLayoutForce(self._get_args()) else: return False - if self._child_object: - BinaryTreeNode.__init__(self, self.name, self._child_object, False) - return True + return self._initialize_bynary_tree() @pyaedt_function_handler() def update(self): @@ -189,14 +190,13 @@ def update(self): """ if self.type == "Matrix": - self._app.o_maxwell_parameters.EditMatrix(self._boundary_name, self._get_args()) + self._app.o_maxwell_parameters.EditMatrix(self.name, self._get_args()) elif self.type == "Force": - self._app.o_maxwell_parameters.EditForce(self._boundary_name, self._get_args()) + self._app.o_maxwell_parameters.EditForce(self.name, self._get_args()) elif self.type == "Torque": - self._app.o_maxwell_parameters.EditTorque(self._boundary_name, self._get_args()) + self._app.o_maxwell_parameters.EditTorque(self.name, self._get_args()) else: return False - self._boundary_name = self.name return True @pyaedt_function_handler() diff --git a/src/ansys/aedt/core/modules/mesh.py b/src/ansys/aedt/core/modules/mesh.py index 425bed2e3d1..7c5fbcf5772 100644 --- a/src/ansys/aedt/core/modules/mesh.py +++ b/src/ansys/aedt/core/modules/mesh.py @@ -125,11 +125,26 @@ def __init__(self, mesh, name, props, meshoptype): self._type = meshoptype self._name = name self.auto_update = True + self._initialize_bynary_tree() - child_object = self._app.get_oo_object(self._app.odesign, f"Mesh/{self._name}") + @property + def _child_object(self): + """Object-oriented properties. - if child_object: - BinaryTreeNode.__init__(self, self._name, child_object, False) + Returns + ------- + class:`ansys.aedt.core.modeler.cad.elements_3d.BinaryTreeNode` + + """ + child_object = None + design_childs = self._app.get_oo_name(self._app.odesign) + + if "Mesh" in design_childs: + cc = self._app.get_oo_object(self._app.odesign, "Mesh") + cc_names = self._app.get_oo_name(cc) + if self._name in cc_names: + child_object = cc.GetChildObject(self._name) + return child_object @property def type(self): @@ -182,7 +197,7 @@ def props(self): def _get_args(self): """Retrieve arguments.""" props = self.props - arg = ["NAME:" + self._name] + arg = ["NAME:" + self.name] _dict2arg(props, arg) return arg @@ -196,18 +211,17 @@ def name(self): Name of the mesh operation. """ - try: - self._name = self.properties["Name"] - except KeyError: - pass + if self._child_object: + self._name = str(self.properties["Name"]) return self._name @name.setter def name(self, meshop_name): - try: - self.properties["Name"] = meshop_name - except KeyError: - self._mesh.logger.warning("Name %s already assigned in the design", meshop_name) + if self._child_object: + try: + self.properties["Name"] = meshop_name + except KeyError: + self._mesh.logger.error("Name %s already assigned in the design", meshop_name) @pyaedt_function_handler() def create(self): @@ -245,11 +259,7 @@ def create(self): self._mesh.omeshmodule.AssignCylindricalGapOp(self._get_args()) else: return False - child_object = self._app.get_oo_object(self._app.odesign, f"Mesh/{self._name}") - - if child_object: - BinaryTreeNode.__init__(self, self._name, child_object, False) - return True + return self._initialize_bynary_tree() @pyaedt_function_handler() def update(self, key_name=None, value=None): @@ -394,6 +404,13 @@ def delete(self): self._mesh.meshoperations.remove(el) return True + @pyaedt_function_handler() + def _initialize_bynary_tree(self): + if self._child_object: + BinaryTreeNode.__init__(self, self._name, self._child_object, False) + return True + return False + class Mesh(object): """Manages AEDT mesh functions for 2D and 3D solvers (HFSS, Maxwell, and Q3D). @@ -1120,7 +1137,7 @@ def assign_length_mesh(self, assignment, inside_selection=True, maximum_length=1 assignment = self._modeler.convert_to_selections(assignment, True) if name: for m in self.meshoperations: - if name == m.name: + if name == m.name: # If the mesh operation name exists, find a new, unique name. name = generate_unique_name(name) else: name = generate_unique_name("length") @@ -1165,14 +1182,12 @@ def assign_length_mesh(self, assignment, inside_selection=True, maximum_length=1 ) mop = MeshOperation(self, name, props, "LengthBased") + for meshop in self.meshoperations[:]: - try: - if meshop.name == mop.name: - meshop.delete() - break - # Handle case where mop has no child_object - except AttributeError: - continue + if meshop.name == mop.name: + meshop.delete() + break + mop.create() self.meshoperations.append(mop) return mop diff --git a/src/ansys/aedt/core/modules/solve_setup.py b/src/ansys/aedt/core/modules/solve_setup.py index 181edf207ad..f27e155f0e3 100644 --- a/src/ansys/aedt/core/modules/solve_setup.py +++ b/src/ansys/aedt/core/modules/solve_setup.py @@ -53,6 +53,7 @@ class CommonSetup(PropsManager, BinaryTreeNode): + def __init__(self, app, solution_type, name="MySetupAuto", is_new_setup=True): self.auto_update = False self._app = None @@ -71,10 +72,33 @@ def __init__(self, app, solution_type, name="MySetupAuto", is_new_setup=True): self._is_new_setup = is_new_setup # self._init_props(is_new_setup) self.auto_update = True - child_object = self._app.get_oo_object(self._app.odesign, f"Analysis/{self._name}") + self._initialize_bynary_tree() + + @property + def _child_object(self): + """Object-oriented properties. + + Returns + ------- + class:`ansys.aedt.core.modeler.cad.elements_3d.BinaryTreeNode` + + """ + child_object = None + design_childs = self._app.get_oo_name(self._app.odesign) - if child_object: - BinaryTreeNode.__init__(self, self._name, child_object, False) + if "Analysis" in design_childs: + cc = self._app.get_oo_object(self._app.odesign, "Analysis") + cc_names = self._app.get_oo_name(cc) + if self._name in cc_names: + child_object = cc.GetChildObject(self._name) + return child_object + + @pyaedt_function_handler() + def _initialize_bynary_tree(self): + if self._child_object: + BinaryTreeNode.__init__(self, self._name, self._child_object, False) + return True + return False @property def sweeps(self): @@ -534,8 +558,8 @@ def create(self): Returns ------- - dict - Dictionary of arguments. + bool + Result of operation. References ---------- @@ -545,12 +569,7 @@ def create(self): arg = ["NAME:" + self._name] _dict2arg(self.props, arg) self.omodule.InsertSetup(soltype, arg) - child_object = self._app.get_oo_object(self._app.odesign, f"Analysis/{self._name}") - - if child_object: - BinaryTreeNode.__init__(self, self._name, child_object, False) - - return arg + return self._initialize_bynary_tree() @pyaedt_function_handler(update_dictionary="properties") def update(self, properties=None): @@ -1137,8 +1156,8 @@ def create(self): Returns ------- - dict - Dictionary of the arguments. + bool + Result of operation. References ---------- @@ -1153,11 +1172,7 @@ def create(self): arg = ["NAME:SimSetup"] _dict2arg(self.props, arg) self._setup(soltype, arg) - child_object = self._app.get_oo_object(self._app.odesign, f"Analysis/{self._name}") - - if child_object: - BinaryTreeNode.__init__(self, self._name, child_object, False) - return arg + return self._initialize_bynary_tree() @pyaedt_function_handler() def _setup(self, soltype, arg, newsetup=True): @@ -1898,7 +1913,7 @@ def create(self): arg = ["NAME:" + self.name] _dict2arg(self.props, arg) self.omodule.Add(arg) - return True + return self._initialize_bynary_tree() @pyaedt_function_handler(update_dictionary="properties") def update(self, properties=None): diff --git a/src/ansys/aedt/core/rmxprt.py b/src/ansys/aedt/core/rmxprt.py index c3938067512..f4c1d7a83f5 100644 --- a/src/ansys/aedt/core/rmxprt.py +++ b/src/ansys/aedt/core/rmxprt.py @@ -73,7 +73,10 @@ def _apply_val(dict_in, name, value): prps = dict_in.properties[name][::] prps[1] = value value = prps - dict_in.properties[name] = value + try: + dict_in.properties[name] = value + except KeyError: + self._app.logger.error(f"{name} is read only.") return True else: for _, child in dict_in.children.items(): @@ -346,10 +349,10 @@ def export_configuration(self, output_file): """ def jsonalize(dict_in, dict_out): - dict_out[dict_in.node] = {} + dict_out[dict_in._node] = {} for k, v in dict_in.properties.items(): if not k.endswith("/Choices"): - dict_out[dict_in.node][k] = v + dict_out[dict_in._node][k] = v for _, c in dict_in.children.items(): jsonalize(c, dict_out) diff --git a/src/ansys/aedt/core/visualization/post/solution_data.py b/src/ansys/aedt/core/visualization/post/solution_data.py index ef9e3a6e6de..aa24e3212ad 100644 --- a/src/ansys/aedt/core/visualization/post/solution_data.py +++ b/src/ansys/aedt/core/visualization/post/solution_data.py @@ -962,9 +962,15 @@ def plot_3d( min_r = 1e12 max_r = -1e12 - for el in r: - min_r = min(min_r, el.values.min()) - max_r = max(max_r, el.values.max()) + if self.enable_pandas_output: + for el in r: + min_r = min(min_r, el.values.min()) + max_r = max(max_r, el.values.max()) + else: + for el in r: + min_r = min(min_r, min(el)) + max_r = max(max_r, max(el)) + if min_r < 0: r = [i + np.abs(min_r) for i in r] theta_grid, phi_grid = np.meshgrid(theta, phi) diff --git a/src/ansys/aedt/core/visualization/report/common.py b/src/ansys/aedt/core/visualization/report/common.py index 21f67485d8a..b4365ce54f9 100644 --- a/src/ansys/aedt/core/visualization/report/common.py +++ b/src/ansys/aedt/core/visualization/report/common.py @@ -418,7 +418,7 @@ def _initialize_tree_node(self): if self._is_created: oo = self._post.oreportsetup.GetChildObject(self._legacy_props["plot_name"]) if oo: - BinaryTreeNode.__init__(self, self.plot_name, oo, False) + BinaryTreeNode.__init__(self, self._legacy_props["plot_name"], oo, False) @property def __all_props(self): @@ -1314,6 +1314,7 @@ def create(self, name=None): bool ``True`` when successful, ``False`` when failed. """ + self._is_created = False if not name: self.plot_name = generate_unique_name("Plot") else: diff --git a/tests/system/general/test_01_configuration_files.py b/tests/system/general/test_01_configuration_files.py index 05168479c8e..27045e04704 100644 --- a/tests/system/general/test_01_configuration_files.py +++ b/tests/system/general/test_01_configuration_files.py @@ -97,6 +97,7 @@ def hfss3dl_b(add_app): class TestClass: def test_01_hfss_export(self, aedtapp, add_app): aedtapp.mesh.assign_length_mesh("sub") + aedtapp.boundaries[-1].props conf_file = aedtapp.configurations.export_config() assert aedtapp.configurations.validate(conf_file) filename = aedtapp.design_name diff --git a/tests/system/general/test_07_Object3D.py b/tests/system/general/test_07_Object3D.py index 3cd578af1f7..128f1d4e612 100644 --- a/tests/system/general/test_07_Object3D.py +++ b/tests/system/general/test_07_Object3D.py @@ -660,11 +660,11 @@ def test_27_get_object_history_properties(self): box_subtract.split("XY") box_history = box.history() box_clone_history = box_clone.history() - assert box_history.node == "box_history" + assert box_history._node == "box_history" assert box_history.command == "CreateBox" assert box_history.properties["Command"] == "CreateBox" assert box_history.children == {} - assert box_clone_history.node == "box_history1" + assert box_clone_history._node == "box_history1" assert box_clone_history.command == box_history.command assert box_clone_history.properties["Command"] == box_history.properties["Command"] assert box_clone_history.properties["Position/X"] == box_history.properties["Position/X"] diff --git a/tests/system/general/test_20_HFSS.py b/tests/system/general/test_20_HFSS.py index 5968ce166e5..572799e5995 100644 --- a/tests/system/general/test_20_HFSS.py +++ b/tests/system/general/test_20_HFSS.py @@ -1488,7 +1488,7 @@ def test_61_create_lumped_ports_on_object_driven_terminal(self): ) term = [term for term in self.aedtapp.boundaries if term.type == "Terminal"][0] - assert self.aedtapp.boundaries[0].type == "Terminal" + assert term.type == "Terminal" term.name = "test" assert term.name == "test" term.props["TerminalResistance"] = "1ohm" diff --git a/tests/system/general/test_98_Icepak.py b/tests/system/general/test_98_Icepak.py index 7fddff4754f..54848cda534 100644 --- a/tests/system/general/test_98_Icepak.py +++ b/tests/system/general/test_98_Icepak.py @@ -659,6 +659,12 @@ def test_35_create_fan(self): fan = self.aedtapp.create_fan("Fan1", cross_section="YZ", radius="15mm", hub_radius="5mm", origin=[5, 21, 1]) assert fan assert fan.name in self.aedtapp.modeler.oeditor.Get3DComponentInstanceNames(fan.definition_name)[0] + fan.name = "Fan2" + assert fan.name in self.aedtapp.modeler.oeditor.Get3DComponentInstanceNames(fan.definition_name)[0] + assert fan.name in self.aedtapp.modeler.user_defined_components + assert fan.name in self.aedtapp.native_components + assert not "Fan1" in self.aedtapp.native_components + assert not "Fan1" in self.aedtapp.modeler.user_defined_components self.aedtapp.delete_design() def test_36_create_heat_sink(self): diff --git a/tests/system/solvers/test_00_analyze.py b/tests/system/solvers/test_00_analyze.py index 346ac718ce0..58ac97c911b 100644 --- a/tests/system/solvers/test_00_analyze.py +++ b/tests/system/solvers/test_00_analyze.py @@ -649,6 +649,6 @@ def test_10_export_to_maxwell(self, add_app): m3d = app.create_maxwell_design("Setup1", maxwell_2d=False) assert m3d.design_type == "Maxwell 3D" config = app.export_configuration(os.path.join(self.local_scratch.path, "assm.json")) - app2 = add_app("assm_test2", application=Rmxprt) + app2 = add_app("assm_test2", application=Rmxprt, solution_type="ASSM") app2.import_configuration(config) assert app2.circuit diff --git a/tests/system/solvers/test_31_Q3D.py b/tests/system/solvers/test_31_Q3D.py index 2a12b0b9b31..e3e797308e5 100644 --- a/tests/system/solvers/test_31_Q3D.py +++ b/tests/system/solvers/test_31_Q3D.py @@ -151,17 +151,17 @@ def test_06b_create_setup(self): mysetup = self.aedtapp.create_setup() mysetup.props["SaveFields"] = True assert mysetup.update() - sweep2 = mysetup.create_frequency_sweep(sweepname="mysweep2", unit="GHz", freqstart=1, freqstop=4) + sweep2 = mysetup.create_frequency_sweep(name="mysweep2", unit="GHz", start_frequency=1, stop_frequency=4) assert sweep2 - sweep2_1 = mysetup.create_frequency_sweep(sweepname="mysweep2", unit="GHz", freqstart=1, freqstop=4) + sweep2_1 = mysetup.create_frequency_sweep(name="mysweep2", unit="GHz", start_frequency=1, stop_frequency=4) assert sweep2_1 assert sweep2.name != sweep2_1.name assert sweep2.props["RangeEnd"] == "4GHz" - sweep3 = mysetup.create_frequency_sweep(unit="GHz", freqstart=1, freqstop=4) + sweep3 = mysetup.create_frequency_sweep(unit="GHz", start_frequency=1, stop_frequency=4) assert sweep3 with pytest.raises(AttributeError) as execinfo: mysetup.create_frequency_sweep( - sweepname="mysweep4", unit="GHz", freqstart=1, freqstop=4, sweep_type="Invalid" + name="mysweep4", unit="GHz", start_frequency=1, stop_frequency=4, sweep_type="Invalid" ) assert ( execinfo.args[0] @@ -180,12 +180,31 @@ def test_07_create_source_sinks(self): assert sink.name == "Sink1" assert len(self.aedtapp.excitations) > 0 - def test_07B_create_source_tosheet(self): + def test_07b_create_source_to_sheet(self): + self.aedtapp.insert_design("source_to_sheet") + + udp = self.aedtapp.modeler.Position(0, 0, 0) + coax_dimension = 30 + self.aedtapp.modeler.create_cylinder( + self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, name="MyCylinder", material="brass" + ) + + udp = self.aedtapp.modeler.Position(10, 10, 0) + coax_dimension = 30 + self.aedtapp.modeler.create_cylinder( + self.aedtapp.PLANE.XY, udp, 3, coax_dimension, 0, name="GND", material="brass" + ) + + self.aedtapp.auto_identify_nets() self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.XY, [0, 0, 0], 4, name="Source1") - self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.XY, [10, 10, 10], 4, name="Sink1") + self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.XY, [0, 0, coax_dimension], 4, name="Sink1") + + self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.XY, [10, 10, 0], 4, name="Source2") + self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.XY, [10, 10, coax_dimension], 4, name="Sink2") source = self.aedtapp.source("Source1", name="Source3") sink = self.aedtapp.sink("Sink1", name="Sink3") + assert source.name == "Source3" assert sink.name == "Sink3" assert source.props["TerminalType"] == "ConstantVoltage" @@ -193,19 +212,20 @@ def test_07B_create_source_tosheet(self): self.aedtapp.modeler.delete("Source1") self.aedtapp.modeler.delete("Sink1") + self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.XY, [0, 0, 0], 4, name="Source1") - self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.XY, [10, 10, 10], 4, name="Sink1") + self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.XY, [0, 0, coax_dimension], 4, name="Sink1") + source = self.aedtapp.source("Source1", name="Source3", terminal_type="current") sink = self.aedtapp.sink("Sink1", name="Sink3", terminal_type="current") + assert source.props["TerminalType"] == "UniformCurrent" assert sink.props["TerminalType"] == "UniformCurrent" - self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.XY, [0, 0, 0], 4, name="Source1") - self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.XY, [10, 10, 10], 4, name="Sink1") + source = self.aedtapp.source("Source2", name="Cylinder1", net_name="GND") + source.props["Objects"] = ["Source2"] + sink = self.aedtapp.sink("Sink2", net_name="GND") - source = self.aedtapp.source(["Source1", "Sink1"], name="Cylinder1", net_name="GND") - source.props["Objects"] = ["Source1"] - sink = self.aedtapp.sink("Sink1", net_name="GND") assert source assert sink sink.name = "My_new_name"