Skip to content

Commit

Permalink
Fix KeyError in enable_adaptive_setup_multifrequency (#3930)
Browse files Browse the repository at this point in the history
* fix: KeyError in `enable_adaptive_setup_multifrequency`
test: case for using auto-open region

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update pyaedt/modules/SolveSetup.py

* Update pyaedt/modules/SolveSetup.py

Co-authored-by: Maxime Rey <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Disable auto open. Auto open only allows one setup in the design

* Create a new design

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Samuel Lopez <[email protected]>
Co-authored-by: Maxime Rey <[email protected]>
Co-authored-by: Samuelopez-ansys <[email protected]>
  • Loading branch information
5 people authored Nov 30, 2023
1 parent ba5169b commit dc75b24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions _unittest/test_11_Setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ def test_01b_create_hfss_sweep(self):
sweep4 = setup1.create_frequency_sweep("GHz", 23, 25, 401, sweep_type="Fast")
assert sweep4.props["Type"] == "Fast"

def test_01c_create_hfss_setup_auto_open(self):
self.aedtapp.duplicate_design("auto_open")
for setup in self.aedtapp.get_setups():
self.aedtapp.delete_setup(setup)
self.aedtapp.set_auto_open()
setup1 = self.aedtapp.get_setup("Auto1")
setup1.enable_adaptive_setup_multifrequency([1.9, 2.4], 0.02)
assert setup1.update({"MaximumPasses": 20})
assert setup1.props["SolveType"] == "MultiFrequency"

def test_02_create_circuit_setup(self):
circuit = Circuit(specified_version=desktop_version)
setup1 = circuit.create_setup("circuit", self.aedtapp.SETUPS.NexximLNA)
Expand All @@ -77,6 +87,7 @@ def test_02_create_circuit_setup(self):
setup1.enable()

def test_03_non_valid_setup(self):
self.aedtapp.set_active_design("HFSSDesign")
self.aedtapp.duplicate_design("non_valid")
setup1 = self.aedtapp.create_setup("My_HFSS_Setup2", self.aedtapp.SETUPS.HFSSDrivenAuto)
assert not setup1.enable_adaptive_setup_multifrequency([1, 2, 3])
Expand Down
4 changes: 4 additions & 0 deletions pyaedt/modules/SolveSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2629,6 +2629,10 @@ def enable_adaptive_setup_multifrequency(self, frequencies, max_delta_s=0.02):
return False
self.auto_update = False
self.props["SolveType"] = "MultiFrequency"
# props["MultipleAdaptiveFreqsSetup"] could potentially be nonexistent.
# A known case is the setup automatically created by setting auto-open region.
if "MultipleAdaptiveFreqsSetup" not in self.props: # pragma no cover
self.props["MultipleAdaptiveFreqsSetup"] = {}
for el in list(self.props["MultipleAdaptiveFreqsSetup"].keys()):
del self.props["MultipleAdaptiveFreqsSetup"][el]
i = 0
Expand Down

0 comments on commit dc75b24

Please sign in to comment.