Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maxwell impedance BC can now be assigned to faces as well, improved docstring #4229

Merged
merged 3 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _unittest/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,9 @@ def test_39_assign_current_density_terminal(self):

def test_40_assign_impedance(self):
impedance_box = self.aedtapp.modeler.create_box([-50, -50, -50], [294, 294, 19], name="impedance_box")
impedance_faces = self.aedtapp.modeler.select_allfaces_fromobjects([impedance_box.name])
assert self.aedtapp.assign_impedance(impedance_faces, "copper")
assert self.aedtapp.assign_impedance(impedance_box, "copper")
impedance_assignment = self.aedtapp.assign_impedance(
impedance_box.name,
permeability=1.3,
Expand Down
18 changes: 12 additions & 6 deletions pyaedt/maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,7 @@ def assign_impedance(
Parameters
----------
geometry_selection : str
Objects to apply the impedance boundary to.
Faces or objects to apply the impedance boundary to.
material_name : str, optional
If it is different from ``None``, then material properties values will be extracted from
the named material in the list of materials available. The default value is ``None``.
Expand All @@ -2216,11 +2216,12 @@ def assign_impedance(
Examples
--------

Create a box and assign impedance boundary to it.
Create a box and assign impedance boundary to the faces.

>>> shield = m3d.modeler.create_box([-50, -50, -50], [294, 294, 19], name="shield")
>>> shield_faces = m3d.modeler.select_allfaces_fromobjects(["shield"])
>>> impedance_assignment = m3d.assign_impedance(shield_faces, "ShieldImpedance")

>>> impedance_box = self.aedtapp.modeler.create_box([-50, -50, -50], [294, 294, 19], name="impedance_box")
>>> impedance_assignment = self.aedtapp.assign_impedance(impedance_box.name, "InsulatingExample")
>>> type(impedance_assignment)
<class 'pyaedt.modules.Boundary.BoundaryObject'>

"""
Expand All @@ -2235,7 +2236,12 @@ def assign_impedance(
impedance_name = generate_unique_name(impedance_name)

listobj = self.modeler.convert_to_selections(geometry_selection, True)
props = {"Objects": listobj}
props = {"Objects": [], "Faces": []}
for sel in listobj:
if isinstance(sel, str):
props["Objects"].append(sel)
elif isinstance(sel, int):
props["Faces"].append(sel)

if material_name is not None:
props["UseMaterial"] = True
Expand Down
Loading