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

CHORE: refacto maxwell test #5601

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bf90449
refacto test
gmalinve Dec 18, 2024
8038ad0
refacto test
gmalinve Dec 18, 2024
7e7fa37
Merge branch 'refs/heads/main' into chore/refacto_maxwell_test
gmalinve Dec 19, 2024
6efc10f
refacto test + delete useless aedt file
gmalinve Dec 19, 2024
80265a8
improve tests
gmalinve Dec 19, 2024
deb3181
improve tests
gmalinve Dec 19, 2024
6cd3378
improve tests
gmalinve Dec 19, 2024
83c2a0b
improve tests
gmalinve Dec 19, 2024
79399f9
refacto m2d and m3d tests + add maxwell app in conftest.py
gmalinve Dec 20, 2024
22548d3
Merge branch 'refs/heads/main' into chore/refacto_maxwell_test
gmalinve Dec 20, 2024
b99a08b
refacto m2d and m3d tests + add maxwell app in conftest.py
gmalinve Dec 20, 2024
f1bfb35
Merge branch 'refs/heads/main' into chore/refacto_maxwell_test
gmalinve Jan 2, 2025
c374fa2
refacto m2d and m3d tests + fix assign current density
gmalinve Jan 2, 2025
fc68975
CHORE: Auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2025
f887aab
refacto m2d and m3d tests + delete unused test files + improve methods
gmalinve Jan 3, 2025
c67fba0
Merge remote-tracking branch 'origin/chore/refacto_maxwell_test' into…
gmalinve Jan 3, 2025
d0d6c1c
Merge branch 'refs/heads/main' into chore/refacto_maxwell_test
gmalinve Jan 3, 2025
599e127
refacto m3d tests
gmalinve Jan 7, 2025
213be64
Merge branch 'main' into chore/refacto_maxwell_test
gmalinve Jan 7, 2025
3239b31
refacto maxwell class boundary objects and improve readability
gmalinve Jan 7, 2025
9fcff2b
fix test coil
gmalinve Jan 8, 2025
38c8bbe
fix tests
gmalinve Jan 8, 2025
138f731
fix tests
gmalinve Jan 8, 2025
f8057f0
Merge branch 'refs/heads/main' into chore/refacto_maxwell_test
gmalinve Jan 8, 2025
a621fc3
Merge branch 'main' into chore/refacto_maxwell_test
gmalinve Jan 9, 2025
89565f0
Update src/ansys/aedt/core/maxwell.py
gmalinve Jan 9, 2025
65f0d50
Update src/ansys/aedt/core/maxwell.py
gmalinve Jan 9, 2025
b3f4c16
Merge branch 'refs/heads/main' into chore/refacto_maxwell_test
gmalinve Jan 9, 2025
774e52b
Merge branch 'refs/heads/main' into chore/refacto_maxwell_test
gmalinve Jan 10, 2025
0b03cbf
Move get solution data test to solvers
Samuelopez-ansys Jan 10, 2025
1f7ed6b
Merge branch 'main' into chore/refacto_maxwell_test
Samuelopez-ansys Jan 10, 2025
31cca63
Merge remote-tracking branch 'origin/chore/refacto_maxwell_test' into…
Samuelopez-ansys Jan 10, 2025
2158e18
revert back get_solution_data
gmalinve Jan 10, 2025
5980969
delete test - not needed
gmalinve Jan 10, 2025
592bebb
Merge branch 'refs/heads/main' into chore/refacto_maxwell_test
gmalinve Jan 10, 2025
5c686db
fix UT m3d
gmalinve Jan 10, 2025
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: 0 additions & 3 deletions src/ansys/aedt/core/application/analysis_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1312,9 +1312,6 @@ def import_dxf(
import_method : int, bool
Whether the import method is ``Script`` or ``Acis``.
The default is ``1``, which means that the ``Acis`` is used.
sheet_bodies_2d : bool, optional
Whether importing as 2D sheet bodies causes imported objects to
be organized in terms of 2D sheets. The default is ``True``.

Returns
-------
Expand Down
129 changes: 70 additions & 59 deletions src/ansys/aedt/core/maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,10 @@
>>> oModule.SetEddyEffect
"""
solid_objects_names = self.get_all_conductors_names()
if not solid_objects_names:
self.logger.error("No conductors defined in active design.")
return False
assignment = self.modeler.convert_to_selections(assignment, True)

Check warning on line 557 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L554-L557

Added lines #L554 - L557 were not covered by tests

EddyVector = ["NAME:EddyEffectVector"]
if self.modeler._is3d:
Expand Down Expand Up @@ -1661,71 +1665,73 @@

try:
if self.modeler._is3d:
if self.solution_type == "Transient":
self.logger.error(

Check warning on line 1669 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L1668-L1669

Added lines #L1668 - L1669 were not covered by tests
"Current density can only be applied to Eddy current or Magnetostatic " "solution types."
gmalinve marked this conversation as resolved.
Show resolved Hide resolved
)
return False

Check warning on line 1672 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L1672

Added line #L1672 was not covered by tests

common_props = {

Check warning on line 1674 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L1674

Added line #L1674 was not covered by tests
"Objects": objects_list,
"CurrentDensityX": current_density_x,
"CurrentDensityY": current_density_y,
"CurrentDensityZ": current_density_z,
"CoordinateSystem Name": coordinate_system,
"CoordinateSystem Type": coordinate_system_type,
}

if len(objects_list) > 1:
current_density_group_names = []
for x in range(0, len(objects_list)):
current_density_group_names.append(current_density_name + f"_{str(x + 1)}")
props = {}
props["items"] = current_density_group_names
props[current_density_group_names[0]] = dict(
{
"Objects": objects_list,
"Phase": phase,
"CurrentDensityX": current_density_x,
"CurrentDensityY": current_density_y,
"CurrentDensityZ": current_density_z,
"CoordinateSystem Name": coordinate_system,
"CoordinateSystem Type": coordinate_system_type,
}
)
bound = BoundaryObject(self, current_density_group_names[0], props, "CurrentDensityGroup")
bound_props = {"items": current_density_group_names}
if self.solution_type == "EddyCurrent":
common_props["Phase"] = phase
bound_props[current_density_group_names[0]] = common_props.copy()
bound_name = current_density_group_names[0]
bound_type = "CurrentDensityGroup"

Check warning on line 1692 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L1687-L1692

Added lines #L1687 - L1692 were not covered by tests
else:
props = dict(
{
"Objects": objects_list,
"Phase": phase,
"CurrentDensityX": current_density_x,
"CurrentDensityY": current_density_y,
"CurrentDensityZ": current_density_z,
"CoordinateSystem Name": coordinate_system,
"CoordinateSystem Type": coordinate_system_type,
}
)
bound = BoundaryObject(self, current_density_name, props, "CurrentDensity")
if self.solution_type == "EddyCurrent":
common_props["Phase"] = phase
bound_props = common_props
bound_name = current_density_name
bound_type = "CurrentDensity"
bound = BoundaryObject(self, bound_name, bound_props, bound_type)

Check warning on line 1699 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L1694-L1699

Added lines #L1694 - L1699 were not covered by tests
else:
common_props = {

Check warning on line 1701 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L1701

Added line #L1701 was not covered by tests
"Objects": objects_list,
"Value": current_density_2d,
"CoordinateSystem": "",
}
if len(objects_list) > 1:
current_density_group_names = []
for x in range(0, len(objects_list)):
current_density_group_names.append(current_density_name + f"_{str(x + 1)}")
props = {}
props["items"] = current_density_group_names
props[current_density_group_names[0]] = dict(
{
"Objects": objects_list,
"Value": current_density_2d,
"CoordinateSystem": "",
}
)
bound = BoundaryObject(self, current_density_group_names[0], props, "CurrentDensityGroup")
bound_props = {"items": current_density_group_names}
if self.solution_type == "EddyCurrent":
common_props["Phase"] = phase
bound_props[current_density_group_names[0]] = common_props.copy()
bound_name = current_density_group_names[0]
bound_type = "CurrentDensityGroup"

Check warning on line 1715 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L1710-L1715

Added lines #L1710 - L1715 were not covered by tests
else:
props = dict(
{
"Objects": objects_list,
"Value": current_density_2d,
"CoordinateSystem": "",
}
)
bound = BoundaryObject(self, current_density_name, props, "CurrentDensity")
if self.solution_type == "EddyCurrent":
common_props["Phase"] = phase
bound_props = common_props
bound_name = current_density_name
bound_type = "CurrentDensity"
bound = BoundaryObject(self, bound_name, bound_props, bound_type)

Check warning on line 1722 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L1717-L1722

Added lines #L1717 - L1722 were not covered by tests

if bound.create():
self._boundaries[bound.name] = bound
return bound
return True
return False

Check warning on line 1727 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L1727

Added line #L1727 was not covered by tests
gmalinve marked this conversation as resolved.
Show resolved Hide resolved
except Exception:
self.logger.error("Couldn't assign current density to desired list of objects.")
return False
else:
self.logger.error("Current density can only be applied to Eddy current or magnetostatic solution types.")
self.logger.error(

Check warning on line 1732 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L1732

Added line #L1732 was not covered by tests
"Current density can only be applied to Eddy current, Magnetostatic and 2D Transient " "solution types."
gmalinve marked this conversation as resolved.
Show resolved Hide resolved
)
return False

@pyaedt_function_handler(input_object="assignment", radiation_name="radiation")
Expand Down Expand Up @@ -2455,8 +2461,8 @@

Parameters
----------
assignment : list
Objects to assign the current to.
assignment : list of int or :class:`ansys.aedt.core.modeler.elements_3d.FacePrimitive`
Faces or sheet objects to assign the current density terminal to.
current_density_name : str, optional
Current density name.
If no name is provided a random name is generated.
Expand All @@ -2472,23 +2478,28 @@

objects_list = self.modeler.convert_to_selections(assignment, True)

existing_2d_objects_list = [x.name for x in self.modeler.object_list if not x.is3d]
if [x for x in objects_list if x not in existing_2d_objects_list]:
self.logger.error("Entity provided not a planar entity.")
return False
# existing_2d_objects_list = [x.name for x in self.modeler.object_list if not x.is3d]
# if [x for x in objects_list if x not in existing_2d_objects_list]:
# self.logger.error("Entity provided not a planar entity.")
# return False
gmalinve marked this conversation as resolved.
Show resolved Hide resolved

try:
if self.modeler._is3d:
bound_objects = {"Faces": objects_list}

Check warning on line 2488 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L2487-L2488

Added lines #L2487 - L2488 were not covered by tests
else:
bound_objects = {"Objects": objects_list}

Check warning on line 2490 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L2490

Added line #L2490 was not covered by tests
if len(objects_list) > 1:
current_density_group_names = []
for x in range(0, len(objects_list)):
current_density_group_names.append(current_density_name + f"_{str(x + 1)}")
props = {}
props["items"] = current_density_group_names
props[current_density_group_names[0]] = dict({"Objects": objects_list})
bound = BoundaryObject(self, current_density_group_names[0], props, "CurrentDensityTerminalGroup")
bound_name = current_density_group_names[0]
props = {"items": current_density_group_names, bound_name: bound_objects}
bound_type = "CurrentDensityTerminalGroup"

Check warning on line 2497 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L2495-L2497

Added lines #L2495 - L2497 were not covered by tests
else:
props = dict({"Objects": objects_list})
bound = BoundaryObject(self, current_density_name, props, "CurrentDensityTerminal")
props = dict(bound_objects)
gmalinve marked this conversation as resolved.
Show resolved Hide resolved
bound_name = current_density_name
bound_type = "CurrentDensityTerminal"
bound = BoundaryObject(self, bound_name, props, bound_type)

Check warning on line 2502 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L2499-L2502

Added lines #L2499 - L2502 were not covered by tests

if bound.create():
self._boundaries[bound.name] = bound
Expand All @@ -2497,7 +2508,7 @@
except Exception:
return False
else:
self.logger.error("Current density can only be applied to Eddy current or magnetostatic solution types.")
self.logger.error("Current density can only be applied to Eddy current or Magnetostatic solution types.")

Check warning on line 2511 in src/ansys/aedt/core/maxwell.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/maxwell.py#L2511

Added line #L2511 was not covered by tests
SMoraisAnsys marked this conversation as resolved.
Show resolved Hide resolved
return False

@pyaedt_function_handler()
Expand Down
2 changes: 0 additions & 2 deletions src/ansys/aedt/core/modules/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,6 @@ def assign_length_mesh(self, assignment, inside_selection=True, maximum_length=1
if maximum_length is None and maximum_elements is None:
self.logger.error("mesh not assigned due to incorrect settings")
return
assignment = self._app.modeler.convert_to_selections(assignment, True)
gmalinve marked this conversation as resolved.
Show resolved Hide resolved

if isinstance(assignment[0], int) and not inside_selection:
seltype = "Faces"
Expand Down Expand Up @@ -1318,7 +1317,6 @@ def assign_curvilinear_elements(self, assignment, enable=True, name=None):
name = generate_unique_name(name)
else:
name = generate_unique_name("CurvilinearElements")
assignment = self._app.modeler.convert_to_selections(assignment, True)
gmalinve marked this conversation as resolved.
Show resolved Hide resolved

if isinstance(assignment[0], int):
seltype = "Faces"
Expand Down
17 changes: 4 additions & 13 deletions src/ansys/aedt/core/modules/solve_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@
Name of the source design.
solution : str, optional
Name of the source design solution in the format ``"name : solution_name"``.
If ``None``, the default value is ``name : LastAdaptive``.
If ``None``, the default value is taken from the nominal adaptive solution.
parameters : dict, optional
Dictionary of the "mapping" variables from the source design.
If ``None``, the default is `appname.available_variations.nominal_w_values_dict`.
Expand Down Expand Up @@ -919,9 +919,7 @@
design_type = self.p_app.design_type
meshlinks["Product"] = design_type
# design name
if not design or design is None:
raise ValueError("Provide design name to add mesh link to.")
elif design not in self.p_app.design_list:
if design not in self.p_app.design_list:

Check warning on line 922 in src/ansys/aedt/core/modules/solve_setup.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modules/solve_setup.py#L922

Added line #L922 was not covered by tests
raise ValueError("Design does not exist in current project.")
else:
meshlinks["Design"] = design
Expand All @@ -939,15 +937,8 @@
meshlinks["ImportMesh"] = True
# solution name
if solution is None:
meshlinks["Soln"] = (
f'{self.p_app.oproject.GetDesign(design).GetChildObject("Analysis").GetChildNames()[0]} : '
f"LastAdaptive"
)
elif (
solution.split()[0] in self.p_app.oproject.GetDesign(design).GetChildObject("Analysis").GetChildNames()
):
meshlinks["Soln"] = f"{solution.split()[0]} : LastAdaptive"
else:
meshlinks["Soln"] = self.p_app.nominal_adaptive
elif solution.split()[0] not in self.p_app.existing_analysis_setups:

Check warning on line 941 in src/ansys/aedt/core/modules/solve_setup.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modules/solve_setup.py#L940-L941

Added lines #L940 - L941 were not covered by tests
raise ValueError("Setup does not exist in current design.")
# parameters
meshlinks["Params"] = {}
Expand Down
1 change: 0 additions & 1 deletion tests/system/general/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
# Initialize default desktop configuration
default_version = "2024.2"


if inside_desktop and "oDesktop" in dir(sys.modules["__main__"]):
default_version = sys.modules["__main__"].oDesktop.GetVersion()[0:6]
config = {
Expand Down
Loading
Loading