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: SetupMaxwell refactoring to save fields and new SweepMaxwell for EC solvers #5670

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
77 changes: 55 additions & 22 deletions src/ansys/aedt/core/modules/solve_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2881,8 +2881,7 @@

Returns
-------
:class:`ansys.aedt.core.modules.solve_sweeps.SweepHFSS` or
:class:`ansys.aedt.core.modules.solve_sweeps.SweepMatrix`
:class:`ansys.aedt.core.modules.solve_sweeps.SweepHFSS`
Sweep object.

References
Expand All @@ -2891,16 +2890,8 @@
"""
if not name:
name = generate_unique_name("Sweep")
if self.setuptype == 7:
self._app.logger.warning("This method only applies to HFSS and Q3D. Use add_eddy_current_sweep method.")
return False
if self.setuptype <= 4:
sweep_n = SweepHFSS(self, name=name, sweep_type=sweep_type)
elif self.setuptype in [14, 30, 31]:
sweep_n = SweepMatrix(self, name=name, sweep_type=sweep_type)
else:
self._app.logger.warning("This method only applies to HFSS, Q2D, and Q3D.")
return False
sweep_n.create()
self.sweeps.append(sweep_n)
return sweep_n
Expand Down Expand Up @@ -3717,6 +3708,58 @@

return True

@pyaedt_function_handler()
def set_save_fields(
self, enable=True, range_type="Custom", subrange_type=None, start=None, stop=None, count=None, units=None
):
"""Enable the save fields option in the setup.

Parameters
----------
Returns
-------
"""
if self.setuptype != 5:
if enable:
self.props["SolveFieldOnly"] = True

Check warning on line 3724 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#L3722-L3724

Added lines #L3722 - L3724 were not covered by tests
else:
self.props["SolveFieldOnly"] = False
self.update()
return True

Check warning on line 3728 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#L3726-L3728

Added lines #L3726 - L3728 were not covered by tests
else:
if enable:
if range_type == "Custom":
self.props["SaveFieldsType"] = range_type
range_props = {

Check warning on line 3733 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#L3730-L3733

Added lines #L3730 - L3733 were not covered by tests
"RangeType": subrange_type,
"RangeStart": f"{start}{units}",
"RangeEnd": f"{stop}{units}",
}
if subrange_type == "LinearStep":
range_props["RangeStep"] = f"{count}{units}"
elif subrange_type == "LinearCount":
range_props["RangeCount"] = count
elif subrange_type == "SinglePoints":
range_props["RangeEnd"] = f"{start}{units}"
if "SweepRanges" in self.props.keys():
self.props["SweepRanges"]["Subrange"].append(range_props)

Check warning on line 3745 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#L3738-L3745

Added lines #L3738 - L3745 were not covered by tests
else:
self.props["SweepRanges"] = {"Subrange": range_props}
self.update()

Check warning on line 3748 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#L3747-L3748

Added lines #L3747 - L3748 were not covered by tests
else:
self.props["SaveFieldsType"] = "Every N Steps"
self.props["N Steps"] = f"{count}"
self.props["Steps From"] = f"{start}{units}"
self.props["Steps To"] = f"{stop}{units}"
self.update()
return True

Check warning on line 3755 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#L3750-L3755

Added lines #L3750 - L3755 were not covered by tests
else:
self.props["SaveFieldsType"] = "None"
self.props.pop("SweepRanges", None)
self.update()
return True

Check warning on line 3760 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#L3757-L3760

Added lines #L3757 - L3760 were not covered by tests
return False


class SetupQ3D(Setup, object):
"""Initializes, creates, and updates an Q3D setup.
Expand Down Expand Up @@ -4026,7 +4069,6 @@

Returns
-------
:class:`ansys.aedt.core.modules.solve_sweeps.SweepHFSS` or
:class:`ansys.aedt.core.modules.solve_sweeps.SweepMatrix`
Sweep object.

Expand All @@ -4036,16 +4078,8 @@
"""
if not name:
name = generate_unique_name("Sweep")
if self.setuptype == 7:
self._app.logger.warning("This method only applies to HFSS and Q3D. Use add_eddy_current_sweep method.")
return False
if self.setuptype <= 4:
sweep_n = SweepHFSS(self, name=name, sweep_type=sweep_type)
elif self.setuptype in [14, 30, 31]:
if self.setuptype in [14, 30, 31]:

Check warning on line 4081 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#L4081

Added line #L4081 was not covered by tests
sweep_n = SweepMatrix(self, name=name, sweep_type=sweep_type)
else:
self._app.logger.warning("This method only applies to HFSS, Q2D, and Q3D.")
return False
sweep_n.create()
self.sweeps.append(sweep_n)
for setup in self.p_app.setups:
Expand All @@ -4066,8 +4100,7 @@

Returns
-------
:class:`ansys.aedt.core.modules.solve_sweeps.SweepQ3D` or
:class:`ansys.aedt.core.modules.solve_sweeps.SweepMatrix`
:class:`ansys.aedt.core.modules.solve_sweeps.SweepQ3D`

Examples
--------
Expand Down
Loading