Skip to content

Commit 862aa7b

Browse files
Maxwell impedance BC can now be assigned to faces as well, improved docstring (#4229)
* impedance BC can now be assigned to faces as well, improved docstring * updated assign_impedance unit test --------- Co-authored-by: Samuel Lopez <[email protected]>
1 parent eac02f8 commit 862aa7b

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

_unittest/test_28_Maxwell3D.py

+3
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,9 @@ def test_39_assign_current_density_terminal(self):
639639

640640
def test_40_assign_impedance(self):
641641
impedance_box = self.aedtapp.modeler.create_box([-50, -50, -50], [294, 294, 19], name="impedance_box")
642+
impedance_faces = self.aedtapp.modeler.select_allfaces_fromobjects([impedance_box.name])
643+
assert self.aedtapp.assign_impedance(impedance_faces, "copper")
644+
assert self.aedtapp.assign_impedance(impedance_box, "copper")
642645
impedance_assignment = self.aedtapp.assign_impedance(
643646
impedance_box.name,
644647
permeability=1.3,

pyaedt/maxwell.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,7 @@ def assign_impedance(
21892189
Parameters
21902190
----------
21912191
geometry_selection : str
2192-
Objects to apply the impedance boundary to.
2192+
Faces or objects to apply the impedance boundary to.
21932193
material_name : str, optional
21942194
If it is different from ``None``, then material properties values will be extracted from
21952195
the named material in the list of materials available. The default value is ``None``.
@@ -2216,11 +2216,12 @@ def assign_impedance(
22162216
Examples
22172217
--------
22182218
2219-
Create a box and assign impedance boundary to it.
2219+
Create a box and assign impedance boundary to the faces.
2220+
2221+
>>> shield = m3d.modeler.create_box([-50, -50, -50], [294, 294, 19], name="shield")
2222+
>>> shield_faces = m3d.modeler.select_allfaces_fromobjects(["shield"])
2223+
>>> impedance_assignment = m3d.assign_impedance(shield_faces, "ShieldImpedance")
22202224
2221-
>>> impedance_box = self.aedtapp.modeler.create_box([-50, -50, -50], [294, 294, 19], name="impedance_box")
2222-
>>> impedance_assignment = self.aedtapp.assign_impedance(impedance_box.name, "InsulatingExample")
2223-
>>> type(impedance_assignment)
22242225
<class 'pyaedt.modules.Boundary.BoundaryObject'>
22252226
22262227
"""
@@ -2235,7 +2236,12 @@ def assign_impedance(
22352236
impedance_name = generate_unique_name(impedance_name)
22362237

22372238
listobj = self.modeler.convert_to_selections(geometry_selection, True)
2238-
props = {"Objects": listobj}
2239+
props = {"Objects": [], "Faces": []}
2240+
for sel in listobj:
2241+
if isinstance(sel, str):
2242+
props["Objects"].append(sel)
2243+
elif isinstance(sel, int):
2244+
props["Faces"].append(sel)
22392245

22402246
if material_name is not None:
22412247
props["UseMaterial"] = True

0 commit comments

Comments
 (0)