From 70477a21c0a1b8ac994fa90d0b9e86c2be5c91c0 Mon Sep 17 00:00:00 2001 From: AlfVII Date: Wed, 7 Aug 2024 12:11:31 +0200 Subject: [PATCH 1/4] Added separation of faces and objects in assign_voltage method (cherry picked from commit 3d6d09b0114936c2d6e390a68371a561a15e6ec9) --- pyaedt/maxwell.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyaedt/maxwell.py b/pyaedt/maxwell.py index 99a61115fe3..88553f1486b 100644 --- a/pyaedt/maxwell.py +++ b/pyaedt/maxwell.py @@ -1007,7 +1007,12 @@ def assign_voltage(self, assignment, amplitude=1, name=None): else: props = OrderedDict({"Faces": assignment, "Value": amplitude}) else: - props = OrderedDict({"Faces": assignment, "Voltage": amplitude}) + props = OrderedDict({"Faces": [], "Objects": [], "Voltage": amplitude}) + for element in assignment: + if isinstance(element, str) and element in self.modeler.object_names: + props["Objects"].append(element) + else: + props["Faces"].append(element) bound = BoundaryObject(self, name, props, "Voltage") if bound.create(): self._boundaries[bound.name] = bound From a45c31bbece39709aa000d224690a40cfc4019c1 Mon Sep 17 00:00:00 2001 From: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> Date: Wed, 7 Aug 2024 13:15:50 +0200 Subject: [PATCH 2/4] Update pyaedt/maxwell.py Co-authored-by: ansys-reviewer-bot[bot] <143693109+ansys-reviewer-bot[bot]@users.noreply.github.com> (cherry picked from commit 917423d6803d8487a9303fb98d4166744d1b69d6) --- pyaedt/maxwell.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pyaedt/maxwell.py b/pyaedt/maxwell.py index 88553f1486b..50a4100344c 100644 --- a/pyaedt/maxwell.py +++ b/pyaedt/maxwell.py @@ -1007,12 +1007,13 @@ def assign_voltage(self, assignment, amplitude=1, name=None): else: props = OrderedDict({"Faces": assignment, "Value": amplitude}) else: - props = OrderedDict({"Faces": [], "Objects": [], "Voltage": amplitude}) - for element in assignment: - if isinstance(element, str) and element in self.modeler.object_names: - props["Objects"].append(element) - else: - props["Faces"].append(element) +object_names_set = set(self.modeler.object_names) +props = OrderedDict({"Faces": [, "Objects": [, "Voltage": amplitude}) +for element in assignment: + if isinstance(element, (str, unicode)) and element in object_names_set: + props["Objects".append(element) + else: + props["Faces".append(element) bound = BoundaryObject(self, name, props, "Voltage") if bound.create(): self._boundaries[bound.name] = bound From ab25a634f0d7ef7249cf4dc99515c991e9436bb2 Mon Sep 17 00:00:00 2001 From: Samuelopez-ansys Date: Wed, 7 Aug 2024 13:20:46 +0200 Subject: [PATCH 3/4] Fix bot changes --- pyaedt/maxwell.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pyaedt/maxwell.py b/pyaedt/maxwell.py index 50a4100344c..bb1b321f486 100644 --- a/pyaedt/maxwell.py +++ b/pyaedt/maxwell.py @@ -1007,13 +1007,13 @@ def assign_voltage(self, assignment, amplitude=1, name=None): else: props = OrderedDict({"Faces": assignment, "Value": amplitude}) else: -object_names_set = set(self.modeler.object_names) -props = OrderedDict({"Faces": [, "Objects": [, "Voltage": amplitude}) -for element in assignment: - if isinstance(element, (str, unicode)) and element in object_names_set: - props["Objects".append(element) - else: - props["Faces".append(element) + object_names_set = set(self.modeler.object_names) + props = OrderedDict({"Faces": [], "Objects": [], "Voltage": amplitude}) + for element in assignment: + if isinstance(element, str) and element in object_names_set: + props["Objects"].append(element) + else: + props["Faces"].append(element) bound = BoundaryObject(self, name, props, "Voltage") if bound.create(): self._boundaries[bound.name] = bound From 7dc4340bf1e3acbe877c7742aa7c62da54b59127 Mon Sep 17 00:00:00 2001 From: Giulia Malinverno Date: Thu, 8 Aug 2024 12:07:24 +0200 Subject: [PATCH 4/4] increase codecov --- _unittest/test_28_Maxwell3D.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_unittest/test_28_Maxwell3D.py b/_unittest/test_28_Maxwell3D.py index 9cb02156b5e..fb1a7b4ede0 100644 --- a/_unittest/test_28_Maxwell3D.py +++ b/_unittest/test_28_Maxwell3D.py @@ -483,12 +483,16 @@ def test_32_matrix(self, add_app): rectangle2 = m3d.modeler.create_rectangle(0, [9, 1.5, 0], [2.5, 5], name="Sheet2") rectangle3 = m3d.modeler.create_rectangle(0, [16.5, 1.5, 0], [2.5, 5], name="Sheet3") rectangle4 = m3d.modeler.create_rectangle(0, [32.5, 1.5, 0], [2.5, 5], name="Sheet4") + box1 = m3d.modeler.create_box([0, 0, 0], [10, 10, 5], "MyBox1") + box2 = m3d.modeler.create_box([10, 10, 10], [10, 10, 5], "MyBox2") m3d.assign_voltage(rectangle1.faces[0], amplitude=1, name="Voltage1") m3d.assign_voltage("Sheet1", amplitude=1, name="Voltage5") m3d.assign_voltage(rectangle2.faces[0], amplitude=1, name="Voltage2") m3d.assign_voltage(rectangle3.faces[0], amplitude=1, name="Voltage3") m3d.assign_voltage(rectangle4.faces[0], amplitude=1, name="Voltage4") + m3d.assign_voltage(box1.faces, amplitude=1, name="Voltage6") + m3d.assign_voltage(box2, amplitude=1, name="Voltage7") L = m3d.assign_matrix(assignment="Voltage1") assert L.props["MatrixEntry"]["MatrixEntry"][0]["Source"] == "Voltage1"