Skip to content

Commit

Permalink
Return basis frequencies with the default units. (#3966)
Browse files Browse the repository at this point in the history
* Return basis frequencies with the default units.

* Unit test
  • Loading branch information
Samuelopez-ansys authored Dec 12, 2023
1 parent bd23538 commit cd52713
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Binary file modified _unittest/example_models/T12/coax_setup_solved_231.aedtz
Binary file not shown.
1 change: 1 addition & 0 deletions _unittest/test_12_1_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def test_01B_Field_Plot(self):
)
assert len(self.aedtapp.setups[0].sweeps[0].frequencies) > 0
assert isinstance(self.aedtapp.setups[0].sweeps[0].basis_frequencies, list)
assert len(self.aedtapp.setups[0].sweeps[1].basis_frequencies) == 2

@pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in ironpython")
def test_01_Animate_plt(self):
Expand Down
15 changes: 14 additions & 1 deletion pyaedt/modules/SolveSweeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pyaedt import pyaedt_function_handler
from pyaedt.generic.DataHandlers import _dict2arg
from pyaedt.generic.LoadAEDTFile import load_entire_aedt_file
from pyaedt.generic.constants import unit_converter
from pyaedt.modules.SetupTemplates import Sweep3DLayout
from pyaedt.modules.SetupTemplates import SweepHfss3D
from pyaedt.modules.SetupTemplates import SweepSiwave
Expand Down Expand Up @@ -166,6 +167,12 @@ def basis_frequencies(self):
try:
new_list = [float(i) for i in v["Fields"]["IDDblMap"][1::2]]
new_list.sort()
new_list = unit_converter(
values=new_list,
unit_system="Freq",
input_units="Hz",
output_units=self._app._app.odesktop.GetDefaultUnit("Frequency"),
)
fr.append(new_list)
except (KeyError, NameError, IndexError):
pass
Expand Down Expand Up @@ -697,9 +704,15 @@ def basis_frequencies(self):
solutions = load_entire_aedt_file(solutions_file)
for k, v in solutions.items():
if "SolutionBlock" in k and "SolutionName" in v and v["SolutionName"] == self.name and "Fields" in v:
try:
try: # pragma: no cover
new_list = [float(i) for i in v["Fields"]["IDDblMap"][1::2]]
new_list.sort()
new_list = unit_converter(
values=new_list,
unit_system="Freq",
input_units="Hz",
output_units=self._app._app.odesktop.GetDefaultUnit("Frequency"),
)
fr.append(new_list)
except (KeyError, NameError, IndexError):
pass
Expand Down

0 comments on commit cd52713

Please sign in to comment.