diff --git a/src/ansys/aedt/core/hfss.py b/src/ansys/aedt/core/hfss.py index 70a5d3a7feb..a8e8cc0a262 100644 --- a/src/ansys/aedt/core/hfss.py +++ b/src/ansys/aedt/core/hfss.py @@ -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`. @@ -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(): @@ -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 diff --git a/src/ansys/aedt/core/modules/setup_templates.py b/src/ansys/aedt/core/modules/setup_templates.py index 7e2a406e1d2..2bc42ffc1e9 100644 --- a/src/ansys/aedt/core/modules/setup_templates.py +++ b/src/ansys/aedt/core/modules/setup_templates.py @@ -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"}) diff --git a/src/ansys/aedt/core/visualization/advanced/farfield_visualization.py b/src/ansys/aedt/core/visualization/advanced/farfield_visualization.py index 2505def180f..8323ed5b693 100644 --- a/src/ansys/aedt/core/visualization/advanced/farfield_visualization.py +++ b/src/ansys/aedt/core/visualization/advanced/farfield_visualization.py @@ -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() diff --git a/src/ansys/aedt/core/visualization/plot/matplotlib.py b/src/ansys/aedt/core/visualization/plot/matplotlib.py index 9b93320c858..eb04434bc72 100644 --- a/src/ansys/aedt/core/visualization/plot/matplotlib.py +++ b/src/ansys/aedt/core/visualization/plot/matplotlib.py @@ -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" @@ -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 diff --git a/src/ansys/aedt/core/workflows/hfss/choke_designer.py b/src/ansys/aedt/core/workflows/hfss/choke_designer.py index 7ddc60a3edd..4dda86ba2eb 100644 --- a/src/ansys/aedt/core/workflows/hfss/choke_designer.py +++ b/src/ansys/aedt/core/workflows/hfss/choke_designer.py @@ -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 diff --git a/tests/system/general/test_20_HFSS.py b/tests/system/general/test_20_HFSS.py index b38d1f00ab1..aba5db2bdfd 100644 --- a/tests/system/general/test_20_HFSS.py +++ b/tests/system/general/test_20_HFSS.py @@ -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 diff --git a/tests/system/solvers/test_00_analyze.py b/tests/system/solvers/test_00_analyze.py index bfdd63ac9ee..53b77bc6fe6 100644 --- a/tests/system/solvers/test_00_analyze.py +++ b/tests/system/solvers/test_00_analyze.py @@ -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", @@ -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( @@ -215,12 +217,12 @@ 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") @@ -228,12 +230,16 @@ def test_02_hfss_export_results(self, hfss_app): 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")