Skip to content

Commit

Permalink
SetupMaxwell refactoring to save fields
Browse files Browse the repository at this point in the history
  • Loading branch information
gmalinve committed Jan 17, 2025
1 parent 11e2fdd commit 5cf2d00
Showing 1 changed file with 55 additions and 22 deletions.
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 @@ def add_sweep(self, name=None, sweep_type="Interpolating"):
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 @@ def add_sweep(self, name=None, sweep_type="Interpolating"):
"""
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 @@ def enable_control_program(self, control_program_path, control_program_args=" ",

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 @@ def add_sweep(self, name=None, sweep_type="Interpolating"):
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 @@ def add_sweep(self, name=None, sweep_type="Interpolating"):
"""
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 @@ def get_sweep(self, name=None):
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

0 comments on commit 5cf2d00

Please sign in to comment.