Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into fix/default_intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
gmalinve committed Jan 14, 2025
2 parents e2a816b + 334d730 commit 9947847
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 22 deletions.
19 changes: 11 additions & 8 deletions src/ansys/aedt/core/hfss.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,10 @@ def create_setup(self, name="MySetupAuto", setup_type=None, **kwargs):
Name of the setup. The default is ``"Setup1"``.
setup_type : str, optional
Type of the setup, which is based on the solution type. Options are
``"HFSSDrivenAuto"``, ``"HFSSDrivenDefault"``, ``"HFSSEigen"``, ``"HFSSTransient"``,
and ``"HFSSSBR"``. The default is ``"HFSSDrivenAuto"``.
``"HFSSDrivenAuto"``, ``"HFSSDriven"``, ``"HFSSEigen"``, ``"HFSSTransient"``,
and ``"HFSSSBR"``. The default is ``"HFSSDriven"``.
**kwargs : dict, optional
Extra arguments to set up the circuit.
Available keys depend on the setup chosen.
Keyword arguments from the native AEDT API.
For more information, see
:doc:`../SetupTemplatesHFSS`.
Expand All @@ -838,6 +837,7 @@ def create_setup(self, name="MySetupAuto", setup_type=None, **kwargs):
setup_type = self.design_solutions.default_setup
elif setup_type in SetupKeys.SetupNames:
setup_type = SetupKeys.SetupNames.index(setup_type)
name = self.generate_unique_setup_name(name)
setup = self._create_setup(name=name, setup_type=setup_type)
setup.auto_update = False
for arg_name, arg_value in kwargs.items():
Expand Down Expand Up @@ -5846,15 +5846,18 @@ def get_antenna_data(
)
self.logger.info("Far field sphere %s is created.", setup)

if setup in self.existing_analysis_sweeps and not frequencies:
frequency_units = self.odesktop.GetDefaultUnit("Frequency")
if setup in self.existing_analysis_sweeps and frequencies is None:
trace_name = "mag(rETheta)"
farfield_data = self.post.get_far_field_data(expressions=trace_name, setup_sweep_name=setup, domain=sphere)
if farfield_data and getattr(farfield_data, "primary_sweep_values", None) is not None:
frequencies = farfield_data.primary_sweep_values
frequency_units = self.odesktop.GetDefaultUnit("Frequency")
frequencies = [str(freq) + frequency_units for freq in frequencies]

if not frequencies: # pragma: no cover
if frequencies is not None:
if type(frequencies) in [float, int, str]:
frequencies = [frequencies]
frequencies = [str(freq) + frequency_units for freq in frequencies if is_number(freq)]
else: # pragma: no cover
self.logger.info("Frequencies could not be obtained.")
return False

Expand Down
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/modules/setup_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def HFSS3DLayout_AdaptiveFrequencyData(freq):


meshlink = dict({"ImportMesh": False})
autosweep = dict({"RangeType": "LinearStep", "RangeStart": "1GHz", "RangeEnd": "10GHz", "RangeStep": "1GHz"})
autosweep = dict({"RangeType": "LinearCount", "RangeStart": "1GHz", "RangeEnd": "10GHz", "RangeCount": "501"})
autosweeps = dict({"Sweep": autosweep})
multifreq = dict({"1GHz": [0.02], "2GHz": [0.02], "5GHz": [0.02]})
sweepsbr = dict({"RangeType": "LinearStep", "RangeStart": "1GHz", "RangeEnd": "10GHz", "RangeStep": "1GHz"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class FfdSolutionData(object):
Examples
--------
>>> from ansys.aedt.core
>>> from ansys.aedt.core import Hfss
>>> from ansys.aedt.core.visualization.advanced.farfield_visualization import FfdSolutionData
>>> app = ansys.aedt.core.Hfss(version="2023.2", design="Antenna")
>>> data = app.get_antenna_data()
Expand Down
5 changes: 3 additions & 2 deletions src/ansys/aedt/core/visualization/plot/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from matplotlib.patches import PathPatch
from matplotlib.path import Path
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
except ImportError:
warnings.warn(
"The Matplotlib module is required to run some functionalities of PostProcess.\n"
Expand Down Expand Up @@ -730,9 +731,9 @@ def _update_grid(self):
self.ax.grid(which="minor", color=self.__grid_color)
if self._has_minor_axis:
if self.__grid_enable_minor_x:
self.ax.xaxis.minorticks_on()
self.ax.xaxis.set_minor_locator(ticker.AutoMinorLocator())
if self.__grid_enable_minor_y:
self.ax.yaxis.minorticks_on()
self.ax.yaxis.set_minor_locator(ticker.AutoMinorLocator())
self.ax.tick_params(which="minor", grid_linestyle="--")

@property
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/workflows/hfss/choke_designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def main(extension_args):
hfss.modeler.create_region(pad_percent=1000)

# Create setup
setup = hfss.create_setup("Setup1")
setup = hfss.create_setup("Setup1", setup_type="HFSSDriven")
setup.props["Frequency"] = "50MHz"
setup.props["MaximumPasses"] = 10

Expand Down
6 changes: 5 additions & 1 deletion tests/system/general/test_20_HFSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ def test_01_save(self):
assert os.path.exists(test_project)

def test_01A_check_setup(self):
assert self.aedtapp.active_setup is None
setup_auto = self.aedtapp.create_setup(name="auto", setup_type="HFSSDrivenAuto")
assert self.aedtapp.setups[0].name == "auto"
assert setup_auto.properties["Auto Solver Setting"] == "Balanced"
assert setup_auto.properties["Type"] == "Discrete"
assert setup_auto.delete()

def test_02_create_primitive(self):
coax1_len = 200
Expand Down
22 changes: 14 additions & 8 deletions tests/system/solvers/test_00_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ def test_01a_sbr_link_array(self, sbr_platform, array):
profile = sbr_platform.setups[0].get_profile()
assert isinstance(profile, dict)
assert not sbr_platform.get_profile("Invented_setup")
solution_data = sbr_platform.setups[0].get_solution_data()

ffdata = sbr_platform.get_antenna_data(frequencies=12e9, sphere="3D")
ffdata2 = sbr_platform.get_antenna_data(frequencies=12e9, sphere="3D", overwrite=False)
ffdata = sbr_platform.get_antenna_data(frequencies=solution_data.intrinsics["Freq"], sphere="3D")
sbr_platform.get_antenna_data(frequencies=solution_data.intrinsics["Freq"], sphere="3D", overwrite=False)

ffdata.farfield_data.plot_cut(
quantity="RealizedGain",
Expand Down Expand Up @@ -202,11 +203,12 @@ def test_02_hfss_export_results(self, hfss_app):
hfss_app.add_3d_component_array_from_json(dict_in)
exported_files = hfss_app.export_results()
assert len(exported_files) == 0
setup = hfss_app.create_setup(name="test")
setup.props["Frequency"] = "1GHz"
setup_driven = hfss_app.create_setup(name="test", setup_type="HFSSDriven", MaximumPasses=1)
exported_files = hfss_app.export_results()
solve_freq = setup_driven.props["Frequency"]
assert len(exported_files) == 0
hfss_app.analyze_setup(name="test", cores=4)
assert setup_driven.is_solved
exported_files = hfss_app.export_results()
assert len(exported_files) == 39
exported_files = hfss_app.export_results(
Expand All @@ -215,25 +217,29 @@ def test_02_hfss_export_results(self, hfss_app):
assert len(exported_files) > 0
fld_file1 = os.path.join(self.local_scratch.path, "test_fld_hfss1.fld")
assert hfss_app.post.export_field_file(
quantity="Mag_E", output_file=fld_file1, assignment="Box1", intrinsics="1GHz", phase="5deg"
quantity="Mag_E", output_file=fld_file1, assignment="Box1", intrinsics=solve_freq, phase="5deg"
)
assert os.path.exists(fld_file1)
fld_file2 = os.path.join(self.local_scratch.path, "test_fld_hfss2.fld")
assert hfss_app.post.export_field_file(
quantity="Mag_E", output_file=fld_file2, assignment="Box1", intrinsics={"frequency": "1GHz"}
quantity="Mag_E", output_file=fld_file2, assignment="Box1", intrinsics={"frequency": solve_freq}
)
assert os.path.exists(fld_file2)
fld_file2 = os.path.join(self.local_scratch.path, "test_fld_hfss3.fld")
assert hfss_app.post.export_field_file(
quantity="Mag_E",
output_file=fld_file2,
assignment="Box1",
intrinsics={"frequency": "1GHz", "phase": "30deg"},
intrinsics={"frequency": solve_freq, "phase": "30deg"},
)
assert os.path.exists(fld_file2)
fld_file2 = os.path.join(self.local_scratch.path, "test_fld_hfss4.fld")
assert hfss_app.post.export_field_file(
quantity="Mag_E", output_file=fld_file2, assignment="Box1", intrinsics={"frequency": "1GHz"}, phase="30deg"
quantity="Mag_E",
output_file=fld_file2,
assignment="Box1",
intrinsics={"frequency": solve_freq},
phase="30deg",
)
assert os.path.exists(fld_file2)
fld_file2 = os.path.join(self.local_scratch.path, "test_fld_hfss5.fld")
Expand Down

0 comments on commit 9947847

Please sign in to comment.