Skip to content

Commit

Permalink
Linear step sweep (#4158)
Browse files Browse the repository at this point in the history
* pragma no cover

* hfss3dl sweep

---------

Co-authored-by: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com>
  • Loading branch information
gmalinve and Samuelopez-ansys authored Jan 31, 2024
1 parent 8d0c6c5 commit aca9ac7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
14 changes: 14 additions & 0 deletions _unittest/test_41_3dlayout_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ def test_18b_create_linear_step_sweep(self):
use_q3d_for_dc=True,
)
assert sweep3.props["Sweeps"]["Data"] == "LIN 1GHz 10GHz 0.2GHz"
assert sweep3.props["FreqSweepType"] == "kInterpolating"
sweep4 = self.aedtapp.create_linear_step_sweep(
setupname=setup_name,
unit="GHz",
Expand All @@ -434,6 +435,19 @@ def test_18b_create_linear_step_sweep(self):
save_fields=True,
)
assert sweep4.props["Sweeps"]["Data"] == "LIN 1GHz 10GHz 0.12GHz"
assert sweep4.props["FreqSweepType"] == "kDiscrete"
sweep5 = self.aedtapp.create_linear_step_sweep(
setupname=setup_name,
unit="GHz",
freqstart=1,
freqstop=10,
step_size=0.12,
sweepname="RFBoardSweep4",
sweep_type="Fast",
save_fields=True,
)
assert sweep5.props["Sweeps"]["Data"] == "LIN 1GHz 10GHz 0.12GHz"
assert sweep5.props["FreqSweepType"] == "kBroadbandFast"

# Create a linear step sweep with the incorrect sweep type.
with pytest.raises(AttributeError) as execinfo:
Expand Down
6 changes: 3 additions & 3 deletions pyaedt/hfss3dlayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,8 @@ def create_linear_step_sweep(
``save_fields=True``. The default is ``False``.
sweep_type : str, optional
Type of the sweep. Options are ``"Fast"``,
``"Interpolating"``, and ``"Discrete"``. The default is
``"Interpolating"``.
``"Interpolating"``, and ``"Discrete"``.
The default is ``"Interpolating"``.
interpolation_tol_percent : float, optional
Error tolerance threshold for the interpolation
process. The default is ``0.5``.
Expand Down Expand Up @@ -1093,7 +1093,7 @@ def create_linear_step_sweep(
self.logger.warning(
"Sweep %s is already present. Sweep has been renamed in %s.", oldname, sweepname
)
sweep = setupdata.add_sweep(sweepname=sweepname)
sweep = setupdata.add_sweep(sweepname=sweepname, sweeptype=sweep_type)
if not sweep:
return False
sweep.change_range("LinearStep", freqstart, freqstop, step_size, unit)
Expand Down
3 changes: 2 additions & 1 deletion pyaedt/modules/SolveSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2156,7 +2156,8 @@ def add_sweep(self, sweepname=None, sweeptype="Interpolating"):
sweepname : str, optional
Name of the sweep. The default is ``None``.
sweeptype : str, optional
Type of the sweep. Options are ``"Interpolating"`` and ``"Discrete"``.
Type of the sweep. Options are ``"Fast"``,
``"Interpolating"``, and ``"Discrete"``.
The default is ``"Interpolating"``.
Returns
Expand Down
6 changes: 4 additions & 2 deletions pyaedt/modules/SolveSweeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,12 @@ def __init__(self, setup, sweepname, sweeptype="Interpolating", save_fields=True
self.props = copy.deepcopy(Sweep3DLayout)
# for t in props:
# _tuple2dict(t, self.props)
if SequenceMatcher(None, sweeptype.lower(), "kinterpolating").ratio() > 0.8:
if SequenceMatcher(None, sweeptype.lower(), "interpolating").ratio() > 0.8:
sweeptype = "kInterpolating"
elif SequenceMatcher(None, sweeptype.lower(), "kdiscrete").ratio() > 0.8:
elif SequenceMatcher(None, sweeptype.lower(), "discrete").ratio() > 0.8:
sweeptype = "kDiscrete"
elif SequenceMatcher(None, sweeptype.lower(), "fast").ratio() > 0.8:
sweeptype = "kBroadbandFast"
else:
warnings.warn("Sweep type is invalid. `kInterpolating` is set as the default.")
sweeptype = "kInterpolating"
Expand Down

0 comments on commit aca9ac7

Please sign in to comment.