From ca916e11c92b1755ba67417f686a06bd78b26178 Mon Sep 17 00:00:00 2001 From: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:42:40 +0200 Subject: [PATCH] FIX: PyAEDT compatibility (#282) --- .../examples/antenna_toolkit_example.py | 18 +- doc/source/examples/create_antenna_simple.py | 4 +- .../antenna/backend/antenna_models/bowtie.py | 66 +-- .../antenna/backend/antenna_models/common.py | 38 +- .../antenna/backend/antenna_models/helix.py | 28 +- .../antenna/backend/antenna_models/horn.py | 502 +++++++++--------- .../antenna/backend/antenna_models/patch.py | 118 ++-- .../aedt/toolkits/antenna/backend/api.py | 76 ++- src/ansys/aedt/toolkits/antenna/ui/actions.py | 87 ++- .../antenna_results/antenna_results_menu.py | 92 ++-- .../tests_toolkit_api/test_backend_toolkit.py | 2 +- .../test_rest_api_toolkit.py | 2 +- 12 files changed, 504 insertions(+), 529 deletions(-) diff --git a/doc/source/examples/antenna_toolkit_example.py b/doc/source/examples/antenna_toolkit_example.py index 725d69f02..2c752b582 100644 --- a/doc/source/examples/antenna_toolkit_example.py +++ b/doc/source/examples/antenna_toolkit_example.py @@ -9,7 +9,7 @@ import tempfile import pyaedt -from pyaedt.modules.solutions import FfdSolutionData +from pyaedt.generic.farfield_visualization import FfdSolutionData from ansys.aedt.toolkits.antenna.backend.api import ToolkitBackend from ansys.aedt.toolkits.antenna.backend.models import properties @@ -29,7 +29,7 @@ # ## Create temporary directory temp_dir = tempfile.TemporaryDirectory(suffix="_ansys") -project_name = pyaedt.generate_unique_project_name(rootname=temp_dir.name, project_name="antenna_toolkit") +project_name = pyaedt.generate_unique_project_name(root_name=temp_dir.name, project_name="antenna_toolkit") # ## Set default properties @@ -183,12 +183,10 @@ # ## Get farfield results -farfield_data = toolkit_api.farfield_results() - -# ## Get farfield results - frequency_str = str(properties.antenna.synthesis.frequency) + properties.antenna.synthesis.frequency_unit -farfield_eep, farfield_frequency = toolkit_api.export_farfield(frequencies=frequency_str, sphere="3D", encode=False) +farfield_metadata, farfield_frequency = toolkit_api.export_farfield( + frequencies=frequency_str, sphere="3D", encode=False +) # ## Get antenna model @@ -210,15 +208,15 @@ for file in files: model.add_object(file[0], file[1], file[2]) -model.plot() +model.plot(show=False) # ## Load far field -farfield_data = FfdSolutionData(farfield_eep[0], farfield_frequency) +farfield_data = FfdSolutionData(farfield_metadata) # ## Plot far field -data = farfield_data.polar_plot_3d_pyvista() +data = farfield_data.plot_3d(show=False) # ## Clean temporary directory diff --git a/doc/source/examples/create_antenna_simple.py b/doc/source/examples/create_antenna_simple.py index c48e069ba..91569c175 100644 --- a/doc/source/examples/create_antenna_simple.py +++ b/doc/source/examples/create_antenna_simple.py @@ -29,7 +29,7 @@ # ## Create temporary directory temp_dir = tempfile.TemporaryDirectory(suffix="_ansys") -project_name = pyaedt.generate_unique_project_name(rootname=temp_dir.name, project_name="bowtie_example") +project_name = pyaedt.generate_unique_project_name(root_name=temp_dir.name, project_name="bowtie_example") # ## Create antenna object only for synthesis # @@ -63,7 +63,7 @@ # # Create an empty HFSS design. -app = pyaedt.Hfss(projectname=project_name, specified_version=aedt_version, non_graphical=non_graphical) +app = pyaedt.Hfss(project=project_name, version=aedt_version, non_graphical=non_graphical) # ## Create antenna in HFSS # diff --git a/src/ansys/aedt/toolkits/antenna/backend/antenna_models/bowtie.py b/src/ansys/aedt/toolkits/antenna/backend/antenna_models/bowtie.py index 76815cf52..0786c943c 100644 --- a/src/ansys/aedt/toolkits/antenna/backend/antenna_models/bowtie.py +++ b/src/ansys/aedt/toolkits/antenna/backend/antenna_models/bowtie.py @@ -200,10 +200,10 @@ def model_hfss(self): # Substrate sub = self._app.modeler.create_box( - position=["-" + sub_x + "/2", "-" + sub_y + "/2", 0.0], - dimensions_list=[sub_x, sub_y, sub_h], + origin=["-" + sub_x + "/2", "-" + sub_y + "/2", 0.0], + sizes=[sub_x, sub_y, sub_h], name="sub_" + antenna_name, - matname=self.material, + material=self.material, ) sub.color = (0, 128, 0) sub.transparency = 0.8 @@ -225,9 +225,9 @@ def model_hfss(self): ant2 = self._app.modeler[ant2_name] ant2.transparency = 0.1 p1 = self._app.modeler.create_rectangle( - csPlane=self._app.PLANE.XY, - position=["-{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], - dimension_list=[inner_width, port_gap], + orientation=self._app.PLANE.XY, + origin=["-{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], + sizes=[inner_width, port_gap], name="port_lump_" + antenna_name, ) p1.color = (128, 0, 0) @@ -433,10 +433,10 @@ def model_hfss(self): # Substrate sub = self._app.modeler.create_box( - position=["-" + sub_x + "/2", "-" + sub_y + "/2", 0.0], - dimensions_list=[sub_x, sub_y, sub_h], + origin=["-" + sub_x + "/2", "-" + sub_y + "/2", 0.0], + sizes=[sub_x, sub_y, sub_h], name="sub_" + antenna_name, - matname=self.material, + material=self.material, ) sub.color = (0, 128, 0) sub.transparency = 0.8 @@ -466,9 +466,9 @@ def model_hfss(self): ant2 = self._app.modeler[ant2_name] ant2.transparency = 0.1 p1 = self._app.modeler.create_rectangle( - csPlane=self._app.PLANE.XY, - position=["-{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], - dimension_list=[inner_width, port_gap], + orientation=self._app.PLANE.XY, + origin=["-{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], + sizes=[inner_width, port_gap], name="port_lump_" + antenna_name, ) p1.color = (128, 0, 0) @@ -674,10 +674,10 @@ def model_hfss(self): # Substrate sub = self._app.modeler.create_box( - position=["-" + sub_x + "/2", "-" + sub_y + "/2", 0.0], - dimensions_list=[sub_x, sub_y, sub_h], + origin=["-" + sub_x + "/2", "-" + sub_y + "/2", 0.0], + sizes=[sub_x, sub_y, sub_h], name="sub_" + antenna_name, - matname=self.material, + material=self.material, ) sub.color = (0, 128, 0) sub.transparency = 0.8 @@ -685,9 +685,9 @@ def model_hfss(self): # Slot slot = self._app.modeler.create_rectangle( - csPlane=self._app.PLANE.XY, - position=["-" + sub_x + "/2", "-" + sub_y + "/2", 0.0], - dimension_list=[sub_x, sub_y], + orientation=self._app.PLANE.XY, + origin=["-" + sub_x + "/2", "-" + sub_y + "/2", 0.0], + sizes=[sub_x, sub_y], name="ant_" + antenna_name, ) slot.color = (0, 128, 0) @@ -695,9 +695,9 @@ def model_hfss(self): # Inner Slot islot = self._app.modeler.create_rectangle( - csPlane=self._app.PLANE.XY, - position=["-" + inner_width + "/2", "-" + port_gap + "/2", 0.0], - dimension_list=[inner_width, port_gap], + orientation=self._app.PLANE.XY, + origin=["-" + inner_width + "/2", "-" + port_gap + "/2", 0.0], + sizes=[inner_width, port_gap], name="slot_" + antenna_name, ) islot.color = (0, 128, 0) @@ -727,9 +727,9 @@ def model_hfss(self): ) feed = self._app.modeler.create_rectangle( - csPlane=self._app.PLANE.XY, - position=["-{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], - dimension_list=["-{}/2+{}/2".format(sub_x, inner_width), "-{}".format(port_gap)], + orientation=self._app.PLANE.XY, + origin=["-{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], + sizes=["-{}/2+{}/2".format(sub_x, inner_width), "-{}".format(port_gap)], name="feed_" + antenna_name, ) feed.color = (128, 0, 0) @@ -737,9 +737,9 @@ def model_hfss(self): self._app.modeler.move([feed.name], [0, feed_offset, 0]) feed1 = self._app.modeler.create_rectangle( - csPlane=self._app.PLANE.XY, - position=["{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], - dimension_list=["{}/2-{}/2".format(sub_x, inner_width), "-{}".format(port_gap)], + orientation=self._app.PLANE.XY, + origin=["{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], + sizes=["{}/2-{}/2".format(sub_x, inner_width), "-{}".format(port_gap)], name="feed_" + antenna_name, ) feed1.color = (128, 0, 0) @@ -749,9 +749,9 @@ def model_hfss(self): self._app.modeler.unite([slot.name, feed.name, feed1.name]) p1 = self._app.modeler.create_rectangle( - csPlane=self._app.PLANE.XY, - position=["{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], - dimension_list=["-{}*0.95".format(inner_width), "-{}".format(port_gap)], + orientation=self._app.PLANE.XY, + origin=["{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], + sizes=["-{}*0.95".format(inner_width), "-{}".format(port_gap)], name="port_lump_" + antenna_name, ) p1.color = (128, 0, 0) @@ -759,9 +759,9 @@ def model_hfss(self): self._app.modeler.move([p1.name], [0, feed_offset, 0]) ref = self._app.modeler.create_rectangle( - csPlane=self._app.PLANE.XY, - position=["-{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], - dimension_list=["{}*0.05".format(inner_width), "-{}".format(port_gap)], + orientation=self._app.PLANE.XY, + origin=["-{}/2".format(inner_width), "-{}/2".format(port_gap), 0.0], + sizes=["{}*0.05".format(inner_width), "-{}".format(port_gap)], name="gnd_" + antenna_name, ) ref.color = (128, 0, 0) diff --git a/src/ansys/aedt/toolkits/antenna/backend/antenna_models/common.py b/src/ansys/aedt/toolkits/antenna/backend/antenna_models/common.py index bc30c3230..d4249b451 100644 --- a/src/ansys/aedt/toolkits/antenna/backend/antenna_models/common.py +++ b/src/ansys/aedt/toolkits/antenna/backend/antenna_models/common.py @@ -256,31 +256,31 @@ def create_lattice_pair(self, lattice_height=None, bottom_extend=False): if bottom_extend: lattice_box = self._app.modeler.create_box( - position=[ + origin=[ str(bounding_box[0]) + self._app.modeler.model_units, str(bounding_box[1]) + self._app.modeler.model_units, str(bounding_box[2]) + self._app.modeler.model_units + "-" + hfss_parameter, ], - dimensions_list=[ + sizes=[ str(bounding_dim[0]) + self._app.modeler.model_units, str(bounding_dim[1]) + self._app.modeler.model_units, str(bounding_dim[2]) + self._app.modeler.model_units + "+2*" + hfss_parameter, ], - matname="vacuum", + material="vacuum", ) else: lattice_box = self._app.modeler.create_box( - position=[ + origin=[ str(bounding_box[0]) + self._app.modeler.model_units, str(bounding_box[1]) + self._app.modeler.model_units, str(bounding_box[2]) + self._app.modeler.model_units, ], - dimensions_list=[ + sizes=[ str(bounding_dim[0]) + self._app.modeler.model_units, str(bounding_dim[1]) + self._app.modeler.model_units, str(bounding_dim[2]) + self._app.modeler.model_units + "+" + hfss_parameter, ], - matname="vacuum", + material="vacuum", ) lattice1 = self._app.assign_lattice_pair(face_couple=[lattice_box.bottom_face_x.id, lattice_box.top_face_x.id]) @@ -334,26 +334,26 @@ def create_3dcomponent(self, component_file=None, component_name=None, replace=F boundaries = [""] self._app.modeler.create_3dcomponent( - component_file=component_file, - component_name=component_name, + input_file=component_file, + name=component_name, variables_to_include=parameters, - object_list=list(self.object_list.keys()), - boundaries_list=boundaries, - excitation_list=list(self.excitations.keys()), - included_cs=[self.coordinate_system], - reference_cs=self.coordinate_system, + assignment=list(self.object_list.keys()), + boundaries=boundaries, + excitations=list(self.excitations.keys()), + coordinate_systems=[self.coordinate_system], + reference_coordinate_system=self.coordinate_system, component_outline="None", ) if replace: user_defined_component = self._app.modeler.replace_3dcomponent( - component_name=component_name, + name=component_name, variables_to_include=parameters, - object_list=list(self.object_list.keys()), - boundaries_list=boundaries, - excitation_list=list(self.excitations.keys()), - included_cs=[self.coordinate_system], - reference_cs=self.coordinate_system, + assignment=list(self.object_list.keys()), + boundaries=boundaries, + excitations=list(self.excitations.keys()), + coordinate_systems=[self.coordinate_system], + reference_coordinate_system=self.coordinate_system, ) if self._app.modeler.oeditor.GetObjectsInGroup(self.name).count == 0: self._app.modeler.oeditor.Delete(["NAME:Selections", "Selections:=", self.name]) diff --git a/src/ansys/aedt/toolkits/antenna/backend/antenna_models/helix.py b/src/ansys/aedt/toolkits/antenna/backend/antenna_models/helix.py index 28e805e5e..0b2bf825d 100644 --- a/src/ansys/aedt/toolkits/antenna/backend/antenna_models/helix.py +++ b/src/ansys/aedt/toolkits/antenna/backend/antenna_models/helix.py @@ -329,7 +329,7 @@ def model_hfss(self): cutout = self._app.modeler.create_circle( cs_plane=2, - position=[ + origin=[ "{}/2".format(diameter), "-{}/2".format(feed_pinD), "-{}-{}/2".format(feed_pinL, wire_diameter), @@ -341,8 +341,8 @@ def model_hfss(self): # Negative air feed_pin = self._app.modeler.create_cylinder( - cs_axis=2, - position=[ + orientation=2, + origin=[ "{}/2".format(diameter), "-{}/2".format(feed_pinD), "-{}-{}/2".format(feed_pinL, wire_diameter), @@ -350,13 +350,13 @@ def model_hfss(self): radius=feed_pinD + "/2", height=feed_pinL + "+" + wire_diameter + "/2", name="Feed_{}".format(antenna_name), - matname="pec", + material="pec", ) feed_pin.history().props["Coordinate System"] = coordinate_system feed_coax = self._app.modeler.create_cylinder( - cs_axis=2, - position=[ + orientation=2, + origin=[ "{}/2".format(diameter), "-{}/2".format(feed_pinD), "-{}-{}/2".format(feed_pinL, wire_diameter), @@ -364,13 +364,13 @@ def model_hfss(self): radius=coax_inner_radius, height="-{}".format(feeder_length), name="Feed1_{}".format(antenna_name), - matname="pec", + material="pec", ) feed_coax.history().props["Coordinate System"] = coordinate_system Coax = self._app.modeler.create_cylinder( - cs_axis=2, - position=[ + orientation=2, + origin=[ "{}/2".format(diameter), "-{}/2".format(feed_pinD), "-{}-{}/2".format(feed_pinL, wire_diameter), @@ -378,14 +378,14 @@ def model_hfss(self): radius=coax_outer_radius, height="-{}".format(feeder_length), name="coax_{}".format(antenna_name), - matname="Teflon (tm)", + material="Teflon (tm)", ) Coax.history().props["Coordinate System"] = coordinate_system # Cap cap = self._app.modeler.create_cylinder( - cs_axis=2, - position=[ + orientation=2, + origin=[ "{}/2".format(diameter), "-{}/2".format(feed_pinD), "-{}-{}/2-{}".format(feed_pinL, wire_diameter, feeder_length), @@ -393,14 +393,14 @@ def model_hfss(self): radius=coax_outer_radius, height="-{}/2".format(feed_pinL), name="port_cap_" + antenna_name, - matname="pec", + material="pec", ) cap.history().props["Coordinate System"] = coordinate_system # P1 p1 = self._app.modeler.create_circle( cs_plane=2, - position=[ + origin=[ "{}/2".format(diameter), "-{}/2".format(feed_pinD), "-{}-{}/2-{}".format(feed_pinL, wire_diameter, feeder_length), diff --git a/src/ansys/aedt/toolkits/antenna/backend/antenna_models/horn.py b/src/ansys/aedt/toolkits/antenna/backend/antenna_models/horn.py index 744d7b5c5..c1cf8d60d 100644 --- a/src/ansys/aedt/toolkits/antenna/backend/antenna_models/horn.py +++ b/src/ansys/aedt/toolkits/antenna/backend/antenna_models/horn.py @@ -231,22 +231,22 @@ def model_hfss(self): # Negative air neg_air = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "0"], + orientation=2, + origin=["0", "0", "0"], radius=wg_radius, height="-" + wg_length, - matname="vacuum", + material="vacuum", ) neg_air.history().props["Coordinate System"] = coordinate_system # Wall wall = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "0"], + orientation=2, + origin=["0", "0", "0"], radius=wg_radius + "+" + wall_thickness, height="-" + wg_length, name="wg_outer_" + antenna_name, - matname=self.material, + material=self.material, ) wall.history().props["Coordinate System"] = coordinate_system @@ -255,30 +255,30 @@ def model_hfss(self): # Input wg_in = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "0"], + orientation=2, + origin=["0", "0", "0"], radius=wg_radius, height="-" + wg_length, name="wg_inner_" + antenna_name, - matname="vacuum", + material="vacuum", ) wg_in.history().props["Coordinate System"] = coordinate_system # Cap cap = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "-" + wg_length], + orientation=2, + origin=["0", "0", "-" + wg_length], radius=wg_radius + "+" + wall_thickness, height="-" + wall_thickness, name="port_cap_" + antenna_name, - matname="pec", + material="pec", ) cap.history().props["Coordinate System"] = coordinate_system # P1 p1 = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "-" + wg_length], + origin=["0", "0", "-" + wg_length], radius=wg_radius, name="port_" + antenna_name, ) @@ -288,28 +288,28 @@ def model_hfss(self): # Horn wall base = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "0"], + origin=["0", "0", "0"], radius=wg_radius, ) base.history().props["Coordinate System"] = coordinate_system base_wall = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "0"], + origin=["0", "0", "0"], radius=wg_radius + "+" + wall_thickness, ) base_wall.history().props["Coordinate System"] = coordinate_system horn_top = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", horn_length], + origin=["0", "0", horn_length], radius=horn_radius, ) horn_top.history().props["Coordinate System"] = coordinate_system horn_sheet = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", horn_length], + origin=["0", "0", horn_length], radius=horn_radius + "+" + wall_thickness, ) horn_sheet.history().props["Coordinate System"] = coordinate_system @@ -323,14 +323,14 @@ def model_hfss(self): air_base = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "0"], + origin=["0", "0", "0"], radius=wg_radius, ) air_base.history().props["Coordinate System"] = coordinate_system air_top = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", horn_length], + origin=["0", "0", horn_length], radius=horn_radius, ) air_top.history().props["Coordinate System"] = coordinate_system @@ -536,30 +536,30 @@ def model_hfss(self): # Base of the horn # Air air = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimensions_list=[wg_width, wg_height, wg_length], - matname="vacuum", + sizes=[wg_width, wg_height, wg_length], + material="vacuum", ) air.history().props["Coordinate System"] = coordinate_system # Wall wall = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "-" + wg_length, ], - dimensions_list=[ + sizes=[ wg_width + "+2*" + wall_thickness, wg_height + "+2*" + wall_thickness, wg_length, ], name="wall_" + antenna_name, - matname="vacuum", + material="vacuum", ) wall.history().props["Coordinate System"] = coordinate_system @@ -569,45 +569,45 @@ def model_hfss(self): # Top of the horn # Input wg_in = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimensions_list=[wg_width, wg_height, wg_length], + sizes=[wg_width, wg_height, wg_length], name="wg_inner" + antenna_name, - matname="vacuum", + material="vacuum", ) wg_in.history().props["Coordinate System"] = coordinate_system wg_in.color = (128, 255, 255) # Cap cap = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "-" + wg_length, ], - dimensions_list=[ + sizes=[ wg_width + "+" + "2*" + wall_thickness, wg_height + "+2*" + wall_thickness, "-" + wall_thickness, ], name="port_cap_" + antenna_name, - matname="pec", + material="pec", ) cap.history().props["Coordinate System"] = coordinate_system cap.color = (132, 132, 193) # P1 p1 = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimension_list=[wg_width, wg_height], + sizes=[wg_width, wg_height], name="port_" + antenna_name, ) p1.color = (128, 0, 0) @@ -615,25 +615,25 @@ def model_hfss(self): # Horn wall base = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "0", ], - dimension_list=[wg_width, wg_height], + sizes=[wg_width, wg_height], name="base_" + antenna_name, ) base.history().props["Coordinate System"] = coordinate_system base_wall = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "0", ], - dimension_list=[ + sizes=[ wg_width + "+" + "2*" + wall_thickness, wg_height + "+2*" + wall_thickness, ], @@ -642,25 +642,25 @@ def model_hfss(self): base_wall.history().props["Coordinate System"] = coordinate_system horn_top = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + aperture_width + "/2", "-" + aperture_height + "/2", flare_length, ], - dimension_list=[aperture_width, aperture_height], + sizes=[aperture_width, aperture_height], name="horn_top_" + antenna_name, ) horn_top.history().props["Coordinate System"] = coordinate_system horn = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + aperture_width + "/2" + "-" + wall_thickness, "-" + aperture_height + "/2" + "-" + wall_thickness, flare_length, ], - dimension_list=[ + sizes=[ aperture_width + "+" + "2*" + wall_thickness, aperture_height + "+" + "2*" + wall_thickness, ], @@ -937,7 +937,7 @@ def ridge_position(sign="+"): position_list=ridge_position(), cover_surface=True, name="right_ridge" + antenna_name, - matname=self.material, + material=self.material, ) ridge = self._app.modeler.thicken_sheet(ridge, ridge_width, True) ridge.history().props["Coordinate System"] = coordinate_system @@ -947,7 +947,7 @@ def ridge_position(sign="+"): position_list=ridge_position("-"), cover_surface=True, name="left_ridge" + antenna_name, - matname=self.material, + material=self.material, ) mridge = self._app.modeler.thicken_sheet(mridge, ridge_width, True) mridge.history().props["Coordinate System"] = coordinate_system @@ -956,36 +956,36 @@ def ridge_position(sign="+"): # Connectors of the ridge # Connector connector = self._app.modeler.create_box( - position=[ + origin=[ "-" + ridge_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimensions_list=[ + sizes=[ ridge_width, "(" + wg_height + "-" + ridge_spacing + ")/2", wg_length, ], name="connector_" + antenna_name, - matname="pec", + material="pec", ) connector.history().props["Coordinate System"] = coordinate_system connector.color = (132, 132, 193) # Bottom connector bconnector = self._app.modeler.create_box( - position=[ + origin=[ "-" + ridge_width + "/2", wg_height + "/2", "-" + wg_length, ], - dimensions_list=[ + sizes=[ ridge_width, "-(" + wg_height + "-" + ridge_spacing + ")/2", wg_length, ], name="bconnector_" + antenna_name, - matname="pec", + material="pec", ) bconnector.history().props["Coordinate System"] = coordinate_system bconnector.color = (132, 132, 193) @@ -1001,13 +1001,13 @@ def ridge_position(sign="+"): # Air base air_base = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "0", ], - dimension_list=[ + sizes=[ wg_width, wg_height, ], @@ -1017,13 +1017,13 @@ def ridge_position(sign="+"): # Air top air_top = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + aperture_width + "/2", "-" + aperture_height + "/2", flare_length, ], - dimension_list=[ + sizes=[ aperture_width, aperture_height, ], @@ -1290,7 +1290,7 @@ def model_hfss(self): position_list=pts, cover_surface=True, name="horn" + antenna_name, - matname=self.material, + material=self.material, ) horn = horn.sweep_around_axis(2) horn.history().props["Coordinate System"] = coordinate_system @@ -1298,19 +1298,19 @@ def model_hfss(self): # Cap cap = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "0"], + orientation=2, + origin=["0", "0", "0"], radius=wg_radius + "+" + wall_thickness, height="-" + wall_thickness, name="port_cap_" + antenna_name, - matname="pec", + material="pec", ) cap.history().props["Coordinate System"] = coordinate_system # P1 p1 = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "0"], + origin=["0", "0", "0"], radius=wg_radius, name="port_" + antenna_name, ) @@ -1483,22 +1483,22 @@ def model_hfss(self): # Negative air neg_air = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "0"], + orientation=2, + origin=["0", "0", "0"], radius=wg_radius, height="-" + wg_length, - matname="vacuum", + material="vacuum", ) neg_air.history().props["Coordinate System"] = coordinate_system # Wall wall = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "0"], + orientation=2, + origin=["0", "0", "0"], radius=wg_radius + "+" + wall_thickness, height="-" + wg_length, name="wg_outer_" + antenna_name, - matname=self.material, + material=self.material, ) wall.history().props["Coordinate System"] = coordinate_system @@ -1507,30 +1507,30 @@ def model_hfss(self): # Input wg_in = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "0"], + orientation=2, + origin=["0", "0", "0"], radius=wg_radius, height="-" + wg_length, name="wg_inner_" + antenna_name, - matname="vacuum", + material="vacuum", ) wg_in.history().props["Coordinate System"] = coordinate_system # Cap cap = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "-" + wg_length], + orientation=2, + origin=["0", "0", "-" + wg_length], radius=wg_radius + "+" + wall_thickness, height="-" + wall_thickness, name="port_cap_" + antenna_name, - matname="pec", + material="pec", ) cap.history().props["Coordinate System"] = coordinate_system # P1 p1 = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "-" + wg_length], + origin=["0", "0", "-" + wg_length], radius=wg_radius, name="port_" + antenna_name, ) @@ -1540,21 +1540,21 @@ def model_hfss(self): # Horn wall base = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "0"], + origin=["0", "0", "0"], radius=wg_radius, ) base.history().props["Coordinate System"] = coordinate_system base_wall = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "0"], + origin=["0", "0", "0"], radius=wg_radius + "+" + wall_thickness, ) base_wall.history().props["Coordinate System"] = coordinate_system horn_top = self._app.modeler.create_ellipse( cs_plane=2, - position=["0", "0", horn_length], + origin=["0", "0", horn_length], major_radius=horn_radius, ratio=ellipse_ratio, ) @@ -1562,7 +1562,7 @@ def model_hfss(self): horn_sheet = self._app.modeler.create_ellipse( cs_plane=2, - position=["0", "0", horn_length], + origin=["0", "0", horn_length], major_radius=horn_radius + "+" + wall_thickness, ratio=ellipse_ratio, ) @@ -1577,14 +1577,14 @@ def model_hfss(self): air_base = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "0"], + origin=["0", "0", "0"], radius=wg_radius, ) air_base.history().props["Coordinate System"] = coordinate_system air_top = self._app.modeler.create_ellipse( cs_plane=2, - position=["0", "0", horn_length], + origin=["0", "0", horn_length], major_radius=horn_radius, ratio=ellipse_ratio, ) @@ -1800,30 +1800,30 @@ def model_hfss(self): # Base of the horn # Air air = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimensions_list=[wg_width, wg_height, wg_length], - matname="vacuum", + sizes=[wg_width, wg_height, wg_length], + material="vacuum", ) air.history().props["Coordinate System"] = coordinate_system # Wall wall = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "-" + wg_length, ], - dimensions_list=[ + sizes=[ wg_width + "+2*" + wall_thickness, wg_height + "+2*" + wall_thickness, wg_length, ], name="wall_" + antenna_name, - matname="vacuum", + material="vacuum", ) wall.history().props["Coordinate System"] = coordinate_system @@ -1833,45 +1833,45 @@ def model_hfss(self): # Top of the horn # Input wg_in = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimensions_list=[wg_width, wg_height, wg_length], + sizes=[wg_width, wg_height, wg_length], name="wg_inner" + antenna_name, - matname="vacuum", + material="vacuum", ) wg_in.history().props["Coordinate System"] = coordinate_system wg_in.color = (128, 255, 255) # Cap cap = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "-" + wg_length, ], - dimensions_list=[ + sizes=[ wg_width + "+" + "2*" + wall_thickness, wg_height + "+2*" + wall_thickness, "-" + wall_thickness, ], name="port_cap_" + antenna_name, - matname="pec", + material="pec", ) cap.history().props["Coordinate System"] = coordinate_system cap.color = (132, 132, 193) # P1 p1 = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimension_list=[wg_width, wg_height], + sizes=[wg_width, wg_height], name="port_" + antenna_name, ) p1.color = (128, 0, 0) @@ -1879,25 +1879,25 @@ def model_hfss(self): # Horn wall base = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "0", ], - dimension_list=[wg_width, wg_height], + sizes=[wg_width, wg_height], name="base_" + antenna_name, ) base.history().props["Coordinate System"] = coordinate_system base_wall = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "0", ], - dimension_list=[ + sizes=[ wg_width + "+" + "2*" + wall_thickness, wg_height + "+2*" + wall_thickness, ], @@ -1906,25 +1906,25 @@ def model_hfss(self): base_wall.history().props["Coordinate System"] = coordinate_system horn_top = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + flare + "/2", horn_length, ], - dimension_list=[wg_width, flare], + sizes=[wg_width, flare], name="horn_top_" + antenna_name, ) horn_top.history().props["Coordinate System"] = coordinate_system horn = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + flare + "/2" + "-" + wall_thickness, horn_length, ], - dimension_list=[ + sizes=[ wg_width + "+" + "2*" + wall_thickness, flare + "+" + "2*" + wall_thickness, ], @@ -1944,13 +1944,13 @@ def model_hfss(self): # Air base air_base = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "0", ], - dimension_list=[ + sizes=[ wg_width, wg_height, ], @@ -1960,13 +1960,13 @@ def model_hfss(self): # Air top air_top = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + flare + "/2", horn_length, ], - dimension_list=[ + sizes=[ wg_width, flare, ], @@ -2162,30 +2162,30 @@ def model_hfss(self): # Base of the horn # Air air = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimensions_list=[wg_width, wg_height, wg_length], - matname="vacuum", + sizes=[wg_width, wg_height, wg_length], + material="vacuum", ) air.history().props["Coordinate System"] = coordinate_system # Wall wall = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "-" + wg_length, ], - dimensions_list=[ + sizes=[ wg_width + "+2*" + wall_thickness, wg_height + "+2*" + wall_thickness, wg_length, ], name="wall_" + antenna_name, - matname="vacuum", + material="vacuum", ) wall.history().props["Coordinate System"] = coordinate_system @@ -2195,45 +2195,45 @@ def model_hfss(self): # Top of the horn # Input wg_in = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimensions_list=[wg_width, wg_height, wg_length], + sizes=[wg_width, wg_height, wg_length], name="wg_inner" + antenna_name, - matname="vacuum", + material="vacuum", ) wg_in.history().props["Coordinate System"] = coordinate_system wg_in.color = (128, 255, 255) # Cap cap = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "-" + wg_length, ], - dimensions_list=[ + sizes=[ wg_width + "+" + "2*" + wall_thickness, wg_height + "+2*" + wall_thickness, "-" + wall_thickness, ], name="port_cap_" + antenna_name, - matname="pec", + material="pec", ) cap.history().props["Coordinate System"] = coordinate_system cap.color = (132, 132, 193) # P1 p1 = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimension_list=[wg_width, wg_height], + sizes=[wg_width, wg_height], name="port_" + antenna_name, ) p1.color = (128, 0, 0) @@ -2241,25 +2241,25 @@ def model_hfss(self): # Horn wall base = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "0", ], - dimension_list=[wg_width, wg_height], + sizes=[wg_width, wg_height], name="base_" + antenna_name, ) base.history().props["Coordinate System"] = coordinate_system base_wall = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "0", ], - dimension_list=[ + sizes=[ wg_width + "+" + "2*" + wall_thickness, wg_height + "+2*" + wall_thickness, ], @@ -2268,25 +2268,25 @@ def model_hfss(self): base_wall.history().props["Coordinate System"] = coordinate_system horn_top = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + flare + "/2", "-" + wg_height + "/2", horn_length, ], - dimension_list=[flare, wg_height], + sizes=[flare, wg_height], name="horn_top_" + antenna_name, ) horn_top.history().props["Coordinate System"] = coordinate_system horn = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + flare + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, horn_length, ], - dimension_list=[ + sizes=[ flare + "+" + "2*" + wall_thickness, wg_height + "+" + "2*" + wall_thickness, ], @@ -2306,13 +2306,13 @@ def model_hfss(self): # Air base air_base = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "0", ], - dimension_list=[ + sizes=[ wg_width, wg_height, ], @@ -2322,13 +2322,13 @@ def model_hfss(self): # Air top air_top = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + flare + "/2", "-" + wg_height + "/2", horn_length, ], - dimension_list=[ + sizes=[ flare, wg_height, ], @@ -2527,30 +2527,30 @@ def model_hfss(self): # Base of the horn # Air air = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimensions_list=[wg_width, wg_height, wg_length], - matname="vacuum", + sizes=[wg_width, wg_height, wg_length], + material="vacuum", ) air.history().props["Coordinate System"] = coordinate_system # Wall wall = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "-" + wg_length, ], - dimensions_list=[ + sizes=[ wg_width + "+2*" + wall_thickness, wg_height + "+2*" + wall_thickness, wg_length, ], name="wall_" + antenna_name, - matname="vacuum", + material="vacuum", ) wall.history().props["Coordinate System"] = coordinate_system @@ -2560,45 +2560,45 @@ def model_hfss(self): # Top of the horn # Input wg_in = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimensions_list=[wg_width, wg_height, wg_length], + sizes=[wg_width, wg_height, wg_length], name="wg_inner" + antenna_name, - matname="vacuum", + material="vacuum", ) wg_in.history().props["Coordinate System"] = coordinate_system wg_in.color = (128, 255, 255) # Cap cap = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "-" + wg_length, ], - dimensions_list=[ + sizes=[ wg_width + "+" + "2*" + wall_thickness, wg_height + "+2*" + wall_thickness, "-" + wall_thickness, ], name="port_cap_" + antenna_name, - matname="pec", + material="pec", ) cap.history().props["Coordinate System"] = coordinate_system cap.color = (132, 132, 193) # P1 p1 = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "-" + wg_length, ], - dimension_list=[wg_width, wg_height], + sizes=[wg_width, wg_height], name="port_" + antenna_name, ) p1.color = (128, 0, 0) @@ -2606,25 +2606,25 @@ def model_hfss(self): # Horn wall base = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "0", ], - dimension_list=[wg_width, wg_height], + sizes=[wg_width, wg_height], name="base_" + antenna_name, ) base.history().props["Coordinate System"] = coordinate_system base_wall = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_height + "/2" + "-" + wall_thickness, "0", ], - dimension_list=[ + sizes=[ wg_width + "+" + "2*" + wall_thickness, wg_height + "+2*" + wall_thickness, ], @@ -2633,25 +2633,25 @@ def model_hfss(self): base_wall.history().props["Coordinate System"] = coordinate_system horn_top = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + flare_a + "/2", "-" + flare_b + "/2", horn_length, ], - dimension_list=[flare_a, flare_b], + sizes=[flare_a, flare_b], name="horn_top_" + antenna_name, ) horn_top.history().props["Coordinate System"] = coordinate_system horn = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + flare_a + "/2" + "-" + wall_thickness, "-" + flare_b + "/2" + "-" + wall_thickness, horn_length, ], - dimension_list=[ + sizes=[ flare_a + "+" + "2*" + wall_thickness, flare_b + "+" + "2*" + wall_thickness, ], @@ -2671,13 +2671,13 @@ def model_hfss(self): # Air base air_base = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_height + "/2", "0", ], - dimension_list=[ + sizes=[ wg_width, wg_height, ], @@ -2687,13 +2687,13 @@ def model_hfss(self): # Air top air_top = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + flare_a + "/2", "-" + flare_b + "/2", horn_length, ], - dimension_list=[ + sizes=[ flare_a, flare_b, ], @@ -2928,30 +2928,30 @@ def model_hfss(self): # Base of the horn # Air air = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2", "-" + wg_width + "/2", "-" + wg_length, ], - dimensions_list=[wg_width, wg_width, wg_length], - matname="vacuum", + sizes=[wg_width, wg_width, wg_length], + material="vacuum", ) air.history().props["Coordinate System"] = coordinate_system # Wall wall = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_length, ], - dimensions_list=[ + sizes=[ wg_width + "+2*" + wall_thickness, wg_width + "+2*" + wall_thickness, wg_length, ], name="wall_" + antenna_name, - matname="vacuum", + material="vacuum", ) wall.history().props["Coordinate System"] = coordinate_system @@ -2961,45 +2961,45 @@ def model_hfss(self): # Top of the horn # Input wg_in = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2", "-" + wg_width + "/2", "-" + wg_length, ], - dimensions_list=[wg_width, wg_width, wg_length], + sizes=[wg_width, wg_width, wg_length], name="wg_inner" + antenna_name, - matname="vacuum", + material="vacuum", ) wg_in.history().props["Coordinate System"] = coordinate_system wg_in.color = (128, 255, 255) # Cap cap = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_length, ], - dimensions_list=[ + sizes=[ wg_width + "+" + "2*" + wall_thickness, wg_width + "+2*" + wall_thickness, "-" + wall_thickness, ], name="port_cap_" + antenna_name, - matname="pec", + material="pec", ) cap.history().props["Coordinate System"] = coordinate_system cap.color = (132, 132, 193) # P1 p1 = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_width + "/2", "-" + wg_length, ], - dimension_list=[wg_width, wg_width], + sizes=[wg_width, wg_width], name="port_" + antenna_name, ) p1.color = (128, 0, 0) @@ -3007,25 +3007,25 @@ def model_hfss(self): # Horn wall base = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_width + "/2", "0", ], - dimension_list=[wg_width, wg_width], + sizes=[wg_width, wg_width], name="base_" + antenna_name, ) base.history().props["Coordinate System"] = coordinate_system base_wall = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2" + "-" + wall_thickness, "-" + wg_width + "/2" + "-" + wall_thickness, "0", ], - dimension_list=[ + sizes=[ wg_width + "+" + "2*" + wall_thickness, wg_width + "+2*" + wall_thickness, ], @@ -3034,25 +3034,25 @@ def model_hfss(self): base_wall.history().props["Coordinate System"] = coordinate_system horn_top = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + aperture_width + "/2", "-" + aperture_width + "/2", flare_length, ], - dimension_list=[aperture_width, aperture_width], + sizes=[aperture_width, aperture_width], name="horn_top_" + antenna_name, ) horn_top.history().props["Coordinate System"] = coordinate_system horn = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + aperture_width + "/2" + "-" + wall_thickness, "-" + aperture_width + "/2" + "-" + wall_thickness, flare_length, ], - dimension_list=[ + sizes=[ aperture_width + "+" + "2*" + wall_thickness, aperture_width + "+" + "2*" + wall_thickness, ], @@ -3117,7 +3117,7 @@ def model_hfss(self): position_list=position_ridge_1, cover_surface=True, name="ridge_1" + antenna_name, - matname=self.material, + material=self.material, ) ridge1 = self._app.modeler.thicken_sheet(ridge1, ridge_width, True) ridge1.history().props["Coordinate System"] = coordinate_system @@ -3127,7 +3127,7 @@ def model_hfss(self): position_list=position_ridge_2, cover_surface=True, name="ridge_2" + antenna_name, - matname=self.material, + material=self.material, ) ridge2 = self._app.modeler.thicken_sheet(ridge2, ridge_width, True) ridge2.history().props["Coordinate System"] = coordinate_system @@ -3137,7 +3137,7 @@ def model_hfss(self): position_list=position_ridge_3, cover_surface=True, name="ridge_3" + antenna_name, - matname=self.material, + material=self.material, ) ridge3 = self._app.modeler.thicken_sheet(ridge3, ridge_width, True) ridge3.history().props["Coordinate System"] = coordinate_system @@ -3147,7 +3147,7 @@ def model_hfss(self): position_list=position_ridge_4, cover_surface=True, name="ridge_4" + antenna_name, - matname=self.material, + material=self.material, ) ridge4 = self._app.modeler.thicken_sheet(ridge4, ridge_width, True) ridge4.history().props["Coordinate System"] = coordinate_system @@ -3156,69 +3156,69 @@ def model_hfss(self): # Connectors of the ridge # Connector connector1 = self._app.modeler.create_box( - position=[ + origin=[ "-" + ridge_width + "/2", "-" + wg_width + "/2", "-" + wg_length, ], - dimensions_list=[ + sizes=[ ridge_width, "(" + wg_width + "-" + ridge_spacing + ")/2", wg_length, ], name="connector_" + antenna_name, - matname="pec", + material="pec", ) connector1.history().props["Coordinate System"] = coordinate_system connector1.color = (132, 132, 193) connector2 = self._app.modeler.create_box( - position=[ + origin=[ "-" + ridge_width + "/2", wg_width + "/2", "-" + wg_length, ], - dimensions_list=[ + sizes=[ ridge_width, "-(" + wg_width + "-" + ridge_spacing + ")/2", wg_length, ], name="connector_" + antenna_name, - matname="pec", + material="pec", ) connector2.history().props["Coordinate System"] = coordinate_system connector2.color = (132, 132, 193) connector3 = self._app.modeler.create_box( - position=[ + origin=[ "-" + wg_width + "/2", "-" + ridge_width + "/2", "-" + wg_length, ], - dimensions_list=[ + sizes=[ "(" + wg_width + "-" + ridge_spacing + ")/2", ridge_width, wg_length, ], name="connector_" + antenna_name, - matname="pec", + material="pec", ) connector3.history().props["Coordinate System"] = coordinate_system connector3.color = (132, 132, 193) connector4 = self._app.modeler.create_box( - position=[ + origin=[ wg_width + "/2", "-" + ridge_width + "/2", "-" + wg_length, ], - dimensions_list=[ + sizes=[ "-(" + wg_width + "-" + ridge_spacing + ")/2", ridge_width, wg_length, ], name="connector_" + antenna_name, - matname="pec", + material="pec", ) connector4.history().props["Coordinate System"] = coordinate_system connector4.color = (132, 132, 193) @@ -3247,13 +3247,13 @@ def model_hfss(self): # Air base air_base = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + wg_width + "/2", "-" + wg_width + "/2", "0", ], - dimension_list=[ + sizes=[ wg_width, wg_width, ], @@ -3263,13 +3263,13 @@ def model_hfss(self): # Air top air_top = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + aperture_width + "/2", "-" + aperture_width + "/2", flare_length, ], - dimension_list=[ + sizes=[ aperture_width, aperture_width, ], @@ -3450,22 +3450,22 @@ def model_hfss(self): # Negative air neg_air = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "0"], + orientation=2, + origin=["0", "0", "0"], radius=wg_radius, height="-" + wg_length, - matname="vacuum", + material="vacuum", ) neg_air.history().props["Coordinate System"] = coordinate_system # Wall wall = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "0"], + orientation=2, + origin=["0", "0", "0"], radius=wg_radius + "+" + wall_thickness, height="-" + wg_length, name="wg_outer_" + antenna_name, - matname=self.material, + material=self.material, ) wall.history().props["Coordinate System"] = coordinate_system @@ -3474,30 +3474,30 @@ def model_hfss(self): # Input wg_in = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "0"], + orientation=2, + origin=["0", "0", "0"], radius=wg_radius, height="-" + wg_length, name="wg_inner_" + antenna_name, - matname="vacuum", + material="vacuum", ) wg_in.history().props["Coordinate System"] = coordinate_system # Cap cap = self._app.modeler.create_cylinder( - cs_axis=2, - position=["0", "0", "-" + wg_length], + orientation=2, + origin=["0", "0", "-" + wg_length], radius=wg_radius + "+" + wall_thickness, height="-" + wall_thickness, name="port_cap_" + antenna_name, - matname="pec", + material="pec", ) cap.history().props["Coordinate System"] = coordinate_system # P1 p1 = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "-" + wg_length], + origin=["0", "0", "-" + wg_length], radius=wg_radius, name="port_" + antenna_name, ) @@ -3507,28 +3507,28 @@ def model_hfss(self): # Horn wall base = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "0"], + origin=["0", "0", "0"], radius=wg_radius, ) base.history().props["Coordinate System"] = coordinate_system base_wall = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "0"], + origin=["0", "0", "0"], radius=wg_radius + "+" + wall_thickness, ) base_wall.history().props["Coordinate System"] = coordinate_system horn_top = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", horn_length], + origin=["0", "0", horn_length], radius=horn_radius, ) horn_top.history().props["Coordinate System"] = coordinate_system horn_sheet = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", horn_length], + origin=["0", "0", horn_length], radius=horn_radius + "+" + wall_thickness, ) horn_sheet.history().props["Coordinate System"] = coordinate_system @@ -3542,14 +3542,14 @@ def model_hfss(self): air_base = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", "0"], + origin=["0", "0", "0"], radius=wg_radius, ) air_base.history().props["Coordinate System"] = coordinate_system air_top = self._app.modeler.create_circle( cs_plane=2, - position=["0", "0", horn_length], + origin=["0", "0", horn_length], radius=horn_radius, ) air_top.history().props["Coordinate System"] = coordinate_system diff --git a/src/ansys/aedt/toolkits/antenna/backend/antenna_models/patch.py b/src/ansys/aedt/toolkits/antenna/backend/antenna_models/patch.py index ba79e0382..cbfcd180b 100644 --- a/src/ansys/aedt/toolkits/antenna/backend/antenna_models/patch.py +++ b/src/ansys/aedt/toolkits/antenna/backend/antenna_models/patch.py @@ -323,10 +323,10 @@ def model_hfss(self): # Substrate sub = self._app.modeler.create_box( - position=["-" + sub_x + "/2", "-" + sub_y + "/2", "0"], - dimensions_list=[sub_x, sub_y, sub_h], + origin=["-" + sub_x + "/2", "-" + sub_y + "/2", "0"], + sizes=[sub_x, sub_y, sub_h], name="sub_" + antenna_name, - matname=self.material, + material=self.material, ) sub.color = (0, 128, 0) sub.transparency = 0.8 @@ -334,9 +334,9 @@ def model_hfss(self): # Ground gnd = self._app.modeler.create_rectangle( - csPlane=2, - position=["-" + gnd_x + "/2", "-" + gnd_y + "/2", "0"], - dimension_list=[gnd_x, gnd_y], + orientation=2, + origin=["-" + gnd_x + "/2", "-" + gnd_y + "/2", "0"], + sizes=[gnd_x, gnd_y], name="gnd_" + antenna_name, ) gnd.color = (255, 128, 65) @@ -345,13 +345,13 @@ def model_hfss(self): # Antenna ant = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + patch_x + "/2", "-" + patch_y + "/2", sub_h, ], - dimension_list=[patch_x, patch_y], + sizes=[patch_x, patch_y], name="ant_" + antenna_name, ) ant.color = (255, 128, 65) @@ -360,7 +360,7 @@ def model_hfss(self): void = self._app.modeler.create_circle( cs_plane=2, - position=[feed_x, feed_y, "0"], + origin=[feed_x, feed_y, "0"], radius=coax_outer_rad, name="void_" + antenna_name, ) @@ -368,52 +368,52 @@ def model_hfss(self): self._app.modeler.subtract(gnd, void, False) feed_pin = self._app.modeler.create_cylinder( - cs_axis=2, - position=[feed_x, feed_y, "0"], + orientation=2, + origin=[feed_x, feed_y, "0"], radius=coax_inner_rad, height=sub_h, name="feed_pin_" + antenna_name, - matname="pec", + material="pec", ) feed_pin.color = (255, 128, 65) feed_pin.history().props["Coordinate System"] = coordinate_system feed_coax = self._app.modeler.create_cylinder( - cs_axis=2, - position=[feed_x, feed_y, "0"], + orientation=2, + origin=[feed_x, feed_y, "0"], radius=coax_inner_rad, height="-" + feed_length, name="feed_coax_" + antenna_name, - matname="pec", + material="pec", ) feed_coax.color = (255, 128, 65) feed_coax.history().props["Coordinate System"] = coordinate_system coax = self._app.modeler.create_cylinder( - cs_axis=2, - position=[feed_x, feed_y, "0"], + orientation=2, + origin=[feed_x, feed_y, "0"], radius=coax_outer_rad, height="-" + feed_length, name="coax_" + antenna_name, - matname="Teflon (tm)", + material="Teflon (tm)", ) coax.color = (128, 255, 255) coax.history().props["Coordinate System"] = coordinate_system port_cap = self._app.modeler.create_cylinder( - cs_axis=2, - position=[feed_x, feed_y, "-" + feed_length], + orientation=2, + origin=[feed_x, feed_y, "-" + feed_length], radius=coax_outer_rad, height="-" + sub_h + "/" + str(10), name="port_cap_" + antenna_name, - matname="pec", + material="pec", ) port_cap.color = (132, 132, 193) port_cap.history().props["Coordinate System"] = coordinate_system p1 = self._app.modeler.create_circle( cs_plane=2, - position=[feed_x, feed_y, "-" + feed_length], + origin=[feed_x, feed_y, "-" + feed_length], radius=coax_outer_rad, name="port_" + antenna_name, ) @@ -663,10 +663,10 @@ def model_hfss(self): # Substrate sub = self._app.modeler.create_box( - position=["-" + sub_x + "/2", "-" + sub_y + "/2", "0"], - dimensions_list=[sub_x, sub_y, sub_h], + origin=["-" + sub_x + "/2", "-" + sub_y + "/2", "0"], + sizes=[sub_x, sub_y, sub_h], name="sub_" + antenna_name, - matname=self.material, + material=self.material, ) sub.color = (0, 128, 0) sub.transparency = 0.8 @@ -674,9 +674,9 @@ def model_hfss(self): # Ground gnd = self._app.modeler.create_rectangle( - csPlane=2, - position=["-" + sub_x + "/2", "-" + sub_y + "/2", "0"], - dimension_list=[sub_x, sub_y], + orientation=2, + origin=["-" + sub_x + "/2", "-" + sub_y + "/2", "0"], + sizes=[sub_x, sub_y], name="gnd_" + antenna_name, ) gnd.color = (255, 128, 65) @@ -685,13 +685,13 @@ def model_hfss(self): # Antenna ant = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + patch_x + "/2", "-" + patch_y + "/2", sub_h, ], - dimension_list=[patch_x, patch_y], + sizes=[patch_x, patch_y], name="ant_" + antenna_name, ) ant.color = (255, 128, 65) @@ -699,13 +699,13 @@ def model_hfss(self): ant.history().props["Coordinate System"] = coordinate_system cutout = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + feed_width + "/2" + "-" + inset_gap, patch_y + "/2" + "-" + inset_distance, sub_h, ], - dimension_list=[feed_width + "+2*" + inset_gap, feed_length], + sizes=[feed_width + "+2*" + inset_gap, feed_length], name="cutout_" + antenna_name, ) cutout.color = (255, 128, 65) @@ -714,13 +714,13 @@ def model_hfss(self): self._app.modeler.subtract(ant, cutout, False) feed = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + feed_width + "/2", patch_y + "/2" "-" + inset_distance, sub_h, ], - dimension_list=[feed_width, feed_length + "+" + inset_distance], + sizes=[feed_width, feed_length + "+" + inset_distance], name="feed_" + antenna_name, ) feed.color = (255, 128, 65) @@ -729,13 +729,13 @@ def model_hfss(self): self._app.modeler.unite([ant, feed]) p1 = self._app.modeler.create_rectangle( - csPlane=1, - position=[ + orientation=1, + origin=[ "-" + feed_width + "/2", patch_y + "/2" + "+" + feed_length, "0", ], - dimension_list=[sub_h, feed_width], + sizes=[sub_h, feed_width], name="port_lump_" + antenna_name, ) p1.color = (255, 128, 65) @@ -983,10 +983,10 @@ def model_hfss(self): # Substrate sub = self._app.modeler.create_box( - position=["-" + sub_x + "/2", "-" + sub_y + "/2", "0"], - dimensions_list=[sub_x, sub_y, sub_h], + origin=["-" + sub_x + "/2", "-" + sub_y + "/2", "0"], + sizes=[sub_x, sub_y, sub_h], name="sub_" + antenna_name, - matname=self.material, + material=self.material, ) sub.color = (0, 128, 0) sub.transparency = 0.8 @@ -994,9 +994,9 @@ def model_hfss(self): # Ground gnd = self._app.modeler.create_rectangle( - csPlane=2, - position=["-" + sub_x + "/2", "-" + sub_y + "/2", "0"], - dimension_list=[sub_x, sub_y], + orientation=2, + origin=["-" + sub_x + "/2", "-" + sub_y + "/2", "0"], + sizes=[sub_x, sub_y], name="gnd_" + antenna_name, ) gnd.color = (255, 128, 65) @@ -1005,13 +1005,13 @@ def model_hfss(self): # Antenna ant = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + patch_x + "/2", "-" + patch_y + "/2", sub_h, ], - dimension_list=[patch_x, patch_y], + sizes=[patch_x, patch_y], name="ant_" + antenna_name, ) ant.color = (255, 128, 65) @@ -1019,26 +1019,26 @@ def model_hfss(self): ant.history().props["Coordinate System"] = coordinate_system edge_feed = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + edge_feed_width + "/2", "0", sub_h, ], - dimension_list=[edge_feed_width, patch_y + "/2" + "+" + edge_feed_length], + sizes=[edge_feed_width, patch_y + "/2" + "+" + edge_feed_length], name="cutout_" + antenna_name, ) edge_feed.color = (255, 128, 65) edge_feed.history().props["Coordinate System"] = coordinate_system feed = self._app.modeler.create_rectangle( - csPlane=2, - position=[ + orientation=2, + origin=[ "-" + feed_width + "/2", patch_y + "/2" + "+" + edge_feed_length, sub_h, ], - dimension_list=[feed_width, feed_length], + sizes=[feed_width, feed_length], name="feed_" + antenna_name, ) feed.color = (255, 128, 65) @@ -1047,13 +1047,13 @@ def model_hfss(self): self._app.modeler.unite([ant, edge_feed, feed]) p1 = self._app.modeler.create_rectangle( - csPlane=1, - position=[ + orientation=1, + origin=[ "-" + feed_width + "/2", patch_y + "/2" + "+" + edge_feed_length + "+" + feed_length, "0", ], - dimension_list=[sub_h, feed_width], + sizes=[sub_h, feed_width], name="port_lump_" + antenna_name, ) p1.color = (255, 128, 65) diff --git a/src/ansys/aedt/toolkits/antenna/backend/api.py b/src/ansys/aedt/toolkits/antenna/backend/api.py index 9c17503d6..4b8a8f455 100644 --- a/src/ansys/aedt/toolkits/antenna/backend/api.py +++ b/src/ansys/aedt/toolkits/antenna/backend/api.py @@ -33,6 +33,7 @@ from ansys.aedt.toolkits.common.backend.api import AEDTCommon from ansys.aedt.toolkits.common.backend.logger_handler import logger import pyaedt +from pyaedt.generic.touchstone_parser import find_touchstone_files from ansys.aedt.toolkits.antenna.backend import antenna_models @@ -300,13 +301,14 @@ def scattering_results(self): return return sol_data.primary_sweep_values, sol_data.data_db20() - def export_farfield(self, frequencies, setup=None, sphere=None, variations=None, encode=True): + def export_farfield(self, frequencies=None, setup=None, sphere=None, variations=None, encode=True): """Export far field data and then encode the file if the ``encode`` parameter is enabled. Parameters ---------- frequencies : float, list - Frequency value or list of frequencies to compute far field data. + Frequency value or list of frequencies to compute far field data. The default is ``None,`` in which case + all available frequencies are computed. setup : str, optional Name of the setup to use. The default is ``None,`` in which case ``nominal_adaptive`` is used. sphere : str, optional @@ -328,55 +330,49 @@ def export_farfield(self, frequencies, setup=None, sphere=None, variations=None, if self.aedtapp: self.aedtapp.save_project() - farfield_exporter = self.aedtapp.get_antenna_ffd_solution_data( + farfield_exporter = self.aedtapp.get_antenna_data( frequencies=frequencies, setup=setup, sphere=sphere, variations=variations ) - frequencies = farfield_exporter.frequencies + if encode: + encoded_json_file = None + encoded_geometry_files = [] + encoded_ffd_files = [] + encoded_scattering_file = None + + metadata_file = farfield_exporter.metadata_file + metadata_dir = os.path.dirname(metadata_file) - eep_files = farfield_exporter.eep_files - encoded_eep_files = [] - encoded_eep_json_files = [] - encoded_geometry_files = {} - encoded_ffd_files = {} - cont = 0 - for eep_file in eep_files: - eep_path = os.path.abspath(os.path.dirname(eep_file)) - serialized_file = self.serialize_obj_base64(eep_file) - encoded_eep_files.append(serialized_file.decode("utf-8")) - eep_json = os.path.abspath(os.path.join(eep_path, "eep.json")) - if os.path.isfile(eep_json): - serialized_file = self.serialize_obj_base64(eep_json) - encoded_eep_json_files.append(serialized_file.decode("utf-8")) - geometry_path = os.path.abspath(os.path.join(eep_path, "geometry")) - if os.path.exists(geometry_path): - encoded_geometry_files[cont] = [] - for root, _, files in os.walk(geometry_path): - for file in files: - if file.lower().endswith(".obj"): - geometry_file = os.path.abspath(os.path.join(root, file)) - serialized_file = self.serialize_obj_base64(geometry_file) - encoded_geometry_files[cont].append(serialized_file.decode("utf-8")) - - encoded_ffd_files[cont] = [] - for root, _, files in os.walk(eep_path): + if os.path.isfile(metadata_file): + serialized_file = self.serialize_obj_base64(metadata_file) + encoded_json_file = serialized_file.decode("utf-8") + + geometry_path = os.path.abspath(os.path.join(metadata_dir, "geometry")) + if os.path.exists(geometry_path): + for root, _, files in os.walk(geometry_path): + for file in files: + if file.lower().endswith(".obj"): + geometry_file = os.path.abspath(os.path.join(root, file)) + serialized_file = self.serialize_obj_base64(geometry_file) + encoded_geometry_files.append(serialized_file.decode("utf-8")) + + for root, _, files in os.walk(metadata_dir): for file in files: if file.lower().endswith(".ffd"): ffd_file = os.path.abspath(os.path.join(root, file)) serialized_file = self.serialize_obj_base64(ffd_file) - encoded_ffd_files[cont].append(serialized_file.decode("utf-8")) + encoded_ffd_files.append(serialized_file.decode("utf-8")) + + sNp_files = find_touchstone_files(metadata_dir) - cont += 1 + if sNp_files: + snP_file = list(sNp_files.keys())[0] + serialized_file = self.serialize_obj_base64(sNp_files[snP_file]) + encoded_scattering_file = serialized_file.decode("utf-8") self.release_aedt(False, False) - return ( - encoded_eep_files, - encoded_eep_json_files, - encoded_geometry_files, - encoded_ffd_files, - frequencies, - ) + return encoded_json_file, encoded_geometry_files, encoded_ffd_files, encoded_scattering_file self.release_aedt(False, False) - return farfield_exporter.eep_files, farfield_exporter.frequencies + return farfield_exporter.metadata_file, farfield_exporter.frequencies diff --git a/src/ansys/aedt/toolkits/antenna/ui/actions.py b/src/ansys/aedt/toolkits/antenna/ui/actions.py index 213a7e0c1..b41b3e307 100644 --- a/src/ansys/aedt/toolkits/antenna/ui/actions.py +++ b/src/ansys/aedt/toolkits/antenna/ui/actions.py @@ -28,8 +28,8 @@ from PySide6.QtWidgets import QComboBox from PySide6.QtWidgets import QLabel from PySide6.QtWidgets import QLineEdit +from pyaedt.generic.farfield_visualization import FfdSolutionData from pyaedt.generic.general_methods import read_json -from pyaedt.modules.solutions import FfdSolutionData # isort: off @@ -81,7 +81,7 @@ def antenna_generate(self): design_selected = be_properties["active_design"] if project_selected and design_selected: if project_selected == "No Project": - project_selected = generate_unique_project_name(rootname=self.temp_folder) + project_selected = generate_unique_project_name(root_name=self.temp_folder) be_properties["active_project"] = project_selected for project in be_properties["project_list"]: @@ -175,69 +175,46 @@ def export_farfield(self): if response.ok: data = response.json() - # Create directories - cont = 0 - for encoded_data in range(len(data[0])): - os.mkdir(os.path.join(self.temp_folder, str(cont))) - os.mkdir(os.path.join(self.temp_folder, str(cont), "geometry")) - cont += 1 - - # EEP files - cont = 0 - eep_files = [] - for encoded_data in data[0]: - encoded_data_bytes = bytes(encoded_data, "utf-8") - decoded_data = base64.b64decode(encoded_data_bytes) - file_path = os.path.join(self.temp_folder, str(cont), "eep.txt") - eep_files.append(file_path) - with open(file_path, "wb") as f: - f.write(decoded_data) - cont += 1 + # Create directory + os.mkdir(os.path.join(self.temp_folder, "geometry")) # JSON files - json_data = [] - cont = 0 + encoded_data_bytes = bytes(data[0], "utf-8") + decoded_data = base64.b64decode(encoded_data_bytes) + metadata_path = os.path.join(self.temp_folder, "pyaedt_antenna_metadata.json") + with open(metadata_path, "wb") as f: + f.write(decoded_data) + json_data = read_json(metadata_path) + + # Geometry files + cont_geom = 0 for encoded_data in data[1]: + geometry_names = list(json_data["model_info"].keys()) encoded_data_bytes = bytes(encoded_data, "utf-8") decoded_data = base64.b64decode(encoded_data_bytes) - file_path = os.path.join(self.temp_folder, str(cont), "eep.json") + file_path = os.path.join(self.temp_folder, "geometry", geometry_names[cont_geom] + ".obj") with open(file_path, "wb") as f: f.write(decoded_data) - cont += 1 - json_data.append(read_json(file_path)) + cont_geom += 1 - # LOAD json to know the obj names + # FFD files + cont_ffd = 0 + for encoded_ffd in data[2]: + encoded_data_bytes = bytes(encoded_ffd, "utf-8") + decoded_data = base64.b64decode(encoded_data_bytes) + file_path = os.path.join(self.temp_folder, "exportfield_{}.ffd".format(str(cont_ffd))) + with open(file_path, "wb") as f: + f.write(decoded_data) + cont_ffd += 1 - # Geometry files - cont = 0 - for encoded_data in data[2].values(): - cont_geom = 0 - geometry_names = list(json_data[0]["model_info"].keys()) - for encoded_geometry in encoded_data: - encoded_data_bytes = bytes(encoded_geometry, "utf-8") - decoded_data = base64.b64decode(encoded_data_bytes) - file_path = os.path.join( - self.temp_folder, str(cont), "geometry", geometry_names[cont_geom] + ".obj" - ) - with open(file_path, "wb") as f: - f.write(decoded_data) - cont_geom += 1 - cont += 1 + # Scattering files + encoded_data_bytes = bytes(data[3], "utf-8") + decoded_data = base64.b64decode(encoded_data_bytes) + sNp_file = os.path.join(self.temp_folder, json_data["touchstone_file"]) + with open(sNp_file, "wb") as f: + f.write(decoded_data) - # FFD files - cont = 0 - for encoded_data in data[3].values(): - cont_ffd = 1 - for encoded_ffd in encoded_data: - encoded_data_bytes = bytes(encoded_ffd, "utf-8") - decoded_data = base64.b64decode(encoded_data_bytes) - file_path = os.path.join(self.temp_folder, str(cont), "eep_{}.ffd".format(str(cont_ffd))) - with open(file_path, "wb") as f: - f.write(decoded_data) - cont_ffd += 1 - cont += 1 - - farfield_data = FfdSolutionData(eep_files[0], data[4]) + farfield_data = FfdSolutionData(file_path) if farfield_data: msg = "Far field results extracted" diff --git a/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py b/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py index 23167218b..4119f0a6f 100644 --- a/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py +++ b/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py @@ -52,7 +52,7 @@ import os import sys -from pyaedt.modules.solutions import FfdSolutionData +from pyaedt.generic.farfield_visualization import FfdSolutionData class GetResultsThread(QThread): @@ -308,29 +308,29 @@ def antenna_results_finished(self): self.theta_cut_combobox.currentIndexChanged.connect(self.theta_cut_combobox_clicked) - data = self.farfield_data.plot_2d_cut(quantity="RealizedGain", - primary_sweep="theta", - secondary_sweep_value=phi[0], - phi=0, - theta=0, - title="Far Field Cut", - quantity_format="dB10", - image_path=None, - show=False, - is_polar=False) + data = self.farfield_data.plot_cut(quantity="RealizedGain", + primary_sweep="theta", + secondary_sweep_value=phi[0], + phi=0, + theta=0, + title="Far Field Cut", + quantity_format="dB10", + output_file=None, + show=False, + is_polar=False) self.__plot_2d_cut(self.farfield_2d_phi_graph, data, phi[0], "Phi", "Theta") - data = self.farfield_data.plot_2d_cut(quantity="RealizedGain", - primary_sweep="phi", - secondary_sweep_value=theta[0], - phi=0, - theta=0, - title="Far Field Cut", - quantity_format="dB10", - image_path=None, - show=False, - is_polar=False) + data = self.farfield_data.plot_cut(quantity="RealizedGain", + primary_sweep="phi", + secondary_sweep_value=theta[0], + phi=0, + theta=0, + title="Far Field Cut", + quantity_format="dB10", + output_file=None, + show=False, + is_polar=False) self.__plot_2d_cut(self.farfield_2d_theta_graph, data, theta[0], "Theta", "Phi") @@ -339,7 +339,8 @@ def antenna_results_finished(self): background_hex = background_hex.lstrip('#') rgb_tuple = tuple(int(background_hex[i:i + 2], 16) for i in (0, 2, 4)) self.farfield_3d_plotter.clear() - self.farfield_data.polar_plot_3d_pyvista(pyvista_object=self.farfield_3d_plotter, background=rgb_tuple) + self.farfield_data.plot_3d(pyvista_object=self.farfield_3d_plotter, + background=rgb_tuple) except Exception as e: self.ui.update_logger("Far field results can not be obtained") self.ui.update_logger("An error occurred:{}".format(e)) @@ -347,16 +348,16 @@ def antenna_results_finished(self): def phi_cut_combobox_clicked(self): if self.farfield_data: phi = self.phi_cut_combobox.currentText() - data = self.farfield_data.plot_2d_cut(quantity="RealizedGain", - primary_sweep="theta", - secondary_sweep_value=float(phi), - phi=0, - theta=0, - title="Far Field Cut", - quantity_format="dB10", - image_path=None, - show=False, - is_polar=False) + data = self.farfield_data.plot_cut(quantity="RealizedGain", + primary_sweep="theta", + secondary_sweep_value=float(phi), + phi=0, + theta=0, + title="Far Field Cut", + quantity_format="dB10", + output_file=None, + show=False, + is_polar=False) overlap = self.phi_cut_overlap.isChecked() if not overlap: self.farfield_2d_phi_graph.clear() @@ -365,25 +366,28 @@ def phi_cut_combobox_clicked(self): def theta_cut_combobox_clicked(self): if self.farfield_data: theta = self.theta_cut_combobox.currentText() - data = self.farfield_data.plot_2d_cut(quantity="RealizedGain", - primary_sweep="phi", - secondary_sweep_value=float(theta), - phi=0, - theta=0, - title="Far Field Cut", - quantity_format="dB10", - image_path=None, - show=False, - is_polar=False) + data = self.farfield_data.plot_cut(quantity="RealizedGain", + primary_sweep="phi", + secondary_sweep_value=float(theta), + phi=0, + theta=0, + title="Far Field Cut", + quantity_format="dB10", + output_file=None, + show=False, + is_polar=False) overlap = self.theta_cut_overlap.isChecked() if not overlap: self.farfield_2d_theta_graph.clear() self.__plot_2d_cut(self.farfield_2d_theta_graph, data, theta, "Theta", "Phi") def __plot_2d_cut(self, graph_obj, data, cut, cut_name, sweep): + lines = data.gca().get_lines() + x_data = lines[-1].get_xdata() + y_data = lines[-1].get_ydata() graph_obj.plot( - data[0][0], - data[0][1], + x_data, + y_data, pen=self.line_color ) graph_obj.setTitle("Realized gain at {} {}".format(cut_name, cut)) diff --git a/tests/backend/tests_toolkit_api/test_backend_toolkit.py b/tests/backend/tests_toolkit_api/test_backend_toolkit.py index 0c8325c31..b6ef4584a 100644 --- a/tests/backend/tests_toolkit_api/test_backend_toolkit.py +++ b/tests/backend/tests_toolkit_api/test_backend_toolkit.py @@ -93,7 +93,7 @@ def test_05_export_farfield(self, aedt_common): aedt_common.properties.antenna.synthesis.frequency_unit) encoded_files = aedt_common.export_farfield(frequencies=frequency, encode=True, sphere="3D") assert isinstance(encoded_files, tuple) - assert len(encoded_files) == 5 + assert len(encoded_files) == 4 farfield_data = aedt_common.export_farfield(frequencies=frequency, encode=False, sphere="3D") assert isinstance(farfield_data, tuple) assert len(farfield_data) == 2 diff --git a/tests/backend/tests_toolkit_rest_api/test_rest_api_toolkit.py b/tests/backend/tests_toolkit_rest_api/test_rest_api_toolkit.py index 1bd75ced0..48f648c5c 100644 --- a/tests/backend/tests_toolkit_rest_api/test_rest_api_toolkit.py +++ b/tests/backend/tests_toolkit_rest_api/test_rest_api_toolkit.py @@ -87,4 +87,4 @@ def test_05_farfield_results(self, client): response2 = client.get("/export_farfield", json={"sphere": "3D"}) assert response2.status_code == 200 data = json.loads(response2.data.decode("utf-8")) - assert len(data) == 5 + assert len(data) == 4