Skip to content
Open
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
1 change: 1 addition & 0 deletions doc/changelog.d/6612.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Delete Motion setup added
1 change: 1 addition & 0 deletions doc/changelog.d/6855.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Assign coil group
74 changes: 62 additions & 12 deletions src/ansys/aedt/core/maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,25 +1399,75 @@ def assign_coil(self, assignment, conductors_number=1, polarity="Positive", name

if isinstance(assignment[0], str):
if self.modeler._is3d:
props = dict(
{"Objects": assignment, "Conductor number": str(conductors_number), "Point out of terminal": point}
)
bound_type = "CoilTerminal"
# For 3D case with multiple faces, create a coil terminal group
if len(assignment) > 1:
coil_group_names = [name + f"_{i + 1}" for i in range(len(assignment))]
props = {"items": coil_group_names}

for i, coil_name in enumerate(coil_group_names):
bound_props = {
"Faces": [assignment[i]],
"Conductor number": str(conductors_number),
"Point out of terminal": point,
}
props[coil_name] = bound_props.copy()

bound_type = "CoilTerminalGroup"
else:
# Single face in 3D
props = {
"Faces": assignment,
"Conductor number": str(conductors_number),
"Point out of terminal": point,
}
bound_type = "CoilTerminal"
else:
props = dict(
{
# 2D case - objects only
if len(assignment) == 1:
# Single object
props = {
"Objects": assignment,
"Conductor number": str(conductors_number),
"PolarityType": polarity.lower(),
}
)
bound_type = "Coil"
bound_type = "Coil"
else:
coil_group_names = [name + f"_{i + 1}" for i in range(len(assignment))]

# Structure the properties to match the CurrentDensityGroup pattern
common_props = {
"Objects": assignment,
"Conductor number": str(conductors_number),
"PolarityType": polarity.lower(),
}
props = {"items": coil_group_names}
props[coil_group_names[0]] = common_props.copy()
name = coil_group_names[0]
bound_type = "CoilGroup"
else:
# Face IDs provided
if self.modeler._is3d:
props = dict(
{"Faces": assignment, "Conductor number": str(conductors_number), "Point out of terminal": point}
)
bound_type = "CoilTerminal"
if len(assignment) > 1:
boundaries = []
for i, face_id in enumerate(assignment):
face_name = name + f"_{i + 1}" if len(assignment) > 1 else name
face_props = {
"Faces": [face_id],
"Conductor number": str(conductors_number),
"Point out of terminal": point,
}
bound = self._create_boundary(face_name, face_props, "CoilTerminal")
if bound:
boundaries.append(bound)

return boundaries[0] if boundaries else False
else:
props = {
"Faces": assignment,
"Conductor number": str(conductors_number),
"Point out of terminal": point,
}
bound_type = "CoilTerminal"
else:
raise AEDTRuntimeError("Face Selection is not allowed in Maxwell 2D. Provide a 2D object.")

Expand Down
3 changes: 3 additions & 0 deletions src/ansys/aedt/core/modules/boundary/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ def create(self):
self._app.oboundary.AssignCoilTerminal(self._get_args())
elif bound_type == "Coil":
self._app.oboundary.AssignCoil(self._get_args())
elif bound_type == "CoilGroup":
self._app.oboundary.AssignCoilGroup(self._get_args()[2], self._get_args()[3])
return True
elif bound_type == "Source":
self._app.oboundary.AssignSource(self._get_args())
elif bound_type == "Sink":
Expand Down
34 changes: 33 additions & 1 deletion tests/system/general/test_27_Maxwell2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def test_assign_coil(self, aedtapp):
bound = aedtapp.assign_coil(assignment=["Coil"])
assert bound
polarity = "Positive"
bound = aedtapp.assign_coil(assignment=["Coil"], polarity=polarity)
assert bound.props["PolarityType"] == polarity.lower()
polarity = "Negative"
bound = aedtapp.assign_coil(assignment=["Coil"], polarity=polarity)
Expand All @@ -144,6 +143,39 @@ def test_assign_coil(self, aedtapp):
bound = aedtapp.assign_coil(assignment=["Coil"], name=bound_name)
assert bound_name == bound.name

def test_assign_coil_group(self, aedtapp):
o1 = aedtapp.modeler.create_rectangle([0, 0, 0], [3, 1], name="Coil", material="copper")
o2 = aedtapp.modeler.create_rectangle([5, 0, 0], [3, 1], name="Coil_2", material="copper")
o3 = aedtapp.modeler.create_rectangle([10, 0, 0], [3, 1], name="Coil_4", material="copper")

initial_boundary_count = len(aedtapp.boundaries)

bound = aedtapp.assign_coil(assignment=[o1.name, o2.name, o3.name])
assert bound

assert bound.type == "CoilGroup"

final_boundary_count = len(aedtapp.boundaries)
objects_assigned = [o1.name, o2.name, o3.name]
expected_new_boundaries = len(objects_assigned) # One individual coil boundary per object
assert final_boundary_count == initial_boundary_count + expected_new_boundaries

new_boundaries = [
b
for b in aedtapp.boundaries
if b.name.startswith(bound.name.split("_")[0] + "_" + bound.name.split("_")[1])
]
coil_group_boundaries = [b for b in new_boundaries if b.type == "CoilGroup"]
individual_coil_boundaries = [b for b in new_boundaries if b.type == "Coil"]

assert len(coil_group_boundaries) == 1
assert len(individual_coil_boundaries) == len(objects_assigned) - 1

coil_props = bound.props[bound.name]
assert set(coil_props["Objects"]) == {o1.name, o2.name, o3.name}
assert coil_props["PolarityType"] == "positive"
assert coil_props["Conductor number"] == "1"

def test_create_vector_potential(self, aedtapp):
region = aedtapp.modeler["Region"]
edge_object = region.edges[0]
Expand Down
40 changes: 40 additions & 0 deletions tests/system/general/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,46 @@ def test_assign_coil(self, m3d_app):
bound = m3d_app.assign_coil(assignment=face_id, name=bound_name)
assert bound_name == bound.name

def test_create_coil_group(self, m3d_app):
coil_hole = m3d_app.modeler.create_box([-50, -50, 0], [100, 100, 100], name="Coil_Hole")
coil = m3d_app.modeler.create_box([-100, -100, 0], [200, 200, 100], name="Coil", material="copper")
m3d_app.modeler.subtract([coil], [coil_hole])
m3d_app.modeler.section(["Coil"], Plane.ZX)
m3d_app.modeler.separate_bodies(["Coil_Section1"])
face_id = [m3d_app.modeler["Coil_Section1"].faces[0].id]
bound_name = generate_unique_name("CoilTerminal")
bound = m3d_app.assign_coil(assignment=face_id, name=bound_name)
assert bound_name == bound.name
assert bound.props["Conductor number"] == "1"
assert not bound.props["Point out of terminal"]
coil2 = m3d_app.modeler.create_box([50, 50, 0], [50, 50, 50], name="Coil2", material="copper")
coil3 = m3d_app.modeler.create_box([120, 120, 0], [50, 50, 50], name="Coil3", material="copper")
face_ids = [m3d_app.modeler["Coil_Section1"].faces[0].id, coil2.faces[0].id, coil3.faces[0].id]

initial_boundary_count = len(m3d_app.boundaries)

bound = m3d_app.assign_coil(assignment=face_ids)
assert bound

assert bound.type == "CoilTerminal"

final_boundary_count = len(m3d_app.boundaries)
expected_new_boundaries = len(face_ids)
assert final_boundary_count == initial_boundary_count + expected_new_boundaries

new_boundaries = [
b
for b in m3d_app.boundaries
if b.name.startswith(bound.name.split("_")[0] + "_" + bound.name.split("_")[1])
]
individual_terminal_boundaries = [b for b in new_boundaries if b.type == "CoilTerminal"]

assert len(individual_terminal_boundaries) == len(face_ids)

assert bound.props["Conductor number"] == "1"
assert not bound.props["Point out of terminal"]
assert bound.props["Faces"] == [face_ids[0]]

def test_create_air_region(self, m3d_app):
region = m3d_app.modeler.create_air_region(*[300] * 6)
assert region.material_name == "air"
Expand Down
Loading