Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: PyAEDT compatibility #282

Merged
merged 6 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions doc/source/examples/antenna_toolkit_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions doc/source/examples/create_antenna_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -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
#
Expand Down
66 changes: 33 additions & 33 deletions src/ansys/aedt/toolkits/antenna/backend/antenna_models/bowtie.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -674,30 +674,30 @@ 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
sub.history().props["Coordinate System"] = coordinate_system

# 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)
slot.history().props["Coordinate System"] = coordinate_system

# 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)
Expand Down Expand Up @@ -727,19 +727,19 @@ 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)
feed.history().props["Coordinate System"] = coordinate_system
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)
Expand All @@ -749,19 +749,19 @@ 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)
p1.history().props["Coordinate System"] = coordinate_system
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)
Expand Down
38 changes: 19 additions & 19 deletions src/ansys/aedt/toolkits/antenna/backend/antenna_models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down
28 changes: 14 additions & 14 deletions src/ansys/aedt/toolkits/antenna/backend/antenna_models/helix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -341,66 +341,66 @@ 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),
],
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),
],
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),
],
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),
],
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),
Expand Down
Loading
Loading