Skip to content

Commit

Permalink
Merge branch 'main' into release/0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcapodi78 authored and maxcapodi78 committed Feb 16, 2022
2 parents 5722be1 + fe7af1a commit 420cb6d
Show file tree
Hide file tree
Showing 44 changed files with 953 additions and 316 deletions.
20 changes: 10 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PyAEDT supports AEDT versions 2021 R1 or newer.
Student Version
---------------

PyAEDT now supports supports also AEDT Student version 2021 R2. Visit
PyAEDT now supports also AEDT Student version 2021 R2. Visit
`Student Version page <https://www.ansys.com/academic/students/ansys-e
lectronics-desktop-student>`_
for more info.
Expand All @@ -57,7 +57,7 @@ for more info.
Why PyAEDT?
-----------
A quick and easy approach for automating a simple operation in the
AEDT UI is to record and reuse a scripts. However, disadvantages of
AEDT UI is to record and reuse a script. However, disadvantages of
this approach are:

- Recorded code is dirty and difficult to read and understand.
Expand Down Expand Up @@ -97,7 +97,7 @@ Explicit Desktop Declaration and Error Management

.. code:: python
Launch AEDT 2021 R1 in Non-Graphical mode
# Launch AEDT 2021 R1 in Non-Graphical mode
from pyaedt import Desktop, Circuit
with Desktop(specified_version="2021.1",
Expand All @@ -116,9 +116,9 @@ Implicit Desktop Declaration and Error Management

.. code:: python
Launch the latest installed version of AEDT in graphical mode
# Launch the latest installed version of AEDT in graphical mode
from pyaedt import Circuit
from pyaedt import Circuit
with Circuit(specified_version="2021.2",
non_graphical=False) as circuit:
...
Expand All @@ -141,7 +141,7 @@ On a CPython Server
launch_server()
On any windows client machine
On any Windows client machine

.. code:: python
Expand All @@ -166,12 +166,12 @@ Modeler

.. code:: python
Create a box, assign variables, and assign materials.
# Create a box, assign variables, and assign materials.
from pyaedt.hfss import Hfss
with Hfss as hfss:
hfss.modeler.primitives.create_box([0, 0, 0], [10, "dim", 10],
"mybox", "aluminum")
hfss.modeler.create_box([0, 0, 0], [10, "dim", 10],
"mybox", "aluminum")
License
-------
Expand All @@ -181,7 +181,7 @@ This PyAEDT module makes no commercial claim over Ansys
whatsoever. PyAEDT extends the functionality of AEDT by adding
an additional Python interface to AEDT without changing the core
behavior or license of the original software. The use of the
interactive APDL control of PyAEDT requires a legally licensed
interactive control of PyAEDT requires a legally licensed
local copy of AEDT. For more information about AEDT,
visit the `AEDT page <https://www.ansys.com/products/electronics>`_
on the Ansys website.
Binary file modified _unittest/example_models/Galileo_edb.aedb/edb.def
Binary file not shown.
Binary file modified _unittest/example_models/Galileo_edb.aedb/edb.def.bak
Binary file not shown.
30 changes: 28 additions & 2 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def test_09_assign_rlc(self):
def test_10_add_layer(self):
layers = self.edbapp.core_stackup.stackup_layers
assert layers.add_layer("NewLayer", "TOP", "copper", "air", "10um", 0)
assert layers.add_layer("NewLayer2", None, "pec", "air", "0um", 0)

def test_11_add_dielectric(self):
diel = self.edbapp.core_stackup.create_dielectric("MyDiel", 3.3, 0.02)
Expand All @@ -170,6 +171,13 @@ def test_14_add_debye(self):
diel = self.edbapp.core_stackup.create_debye_material("My_Debye", 3, 2.5, 0.02, 0.04, 1e6, 1e9)
assert diel

def test_14b_add_multipole_debye(self):
freq = [0, 2, 3, 4, 5, 6]
rel_perm = [1e9, 1.1e9, 1.2e9, 1.3e9, 1.5e9, 1.6e9]
loss_tan = [0.025, 0.026, 0.027, 0.028, 0.029, 0.030]
diel = self.edbapp.core_stackup.create_multipole_debye_material("My_MP_Debye", freq, rel_perm, loss_tan)
assert diel

def test_15_update_layer(self):
assert "LYR_1" in self.edbapp.core_stackup.stackup_layers.layers.keys()
self.edbapp.core_stackup.stackup_layers["LYR_1"].name
Expand Down Expand Up @@ -464,7 +472,25 @@ def test_54_create_component_from_pins(self):

def test_55b_create_cutout(self):
output = os.path.join(self.local_scratch.path, "cutout.aedb")
assert self.edbapp.create_cutout(["A0_N", "A0_P"], ["GND"], output_aedb_path=output)
assert self.edbapp.create_cutout(["A0_N", "A0_P"], ["GND"], output_aedb_path=output, open_cutout_at_end=False)
assert os.path.exists(os.path.join(output, "edb.def"))
bounding = self.edbapp.get_bounding_box()

points = [[bounding[0][0], bounding[0][1]]]
points.append([bounding[0][0], bounding[0][1] + (bounding[1][1] - bounding[0][1]) / 10])
points.append(
[
bounding[0][0] + (bounding[0][1] - bounding[0][0]) / 10,
bounding[0][1] + (bounding[1][1] - bounding[0][1]) / 10,
]
)
points.append([bounding[0][0] + (bounding[0][1] - bounding[0][0]) / 10, bounding[0][1]])
points.append([bounding[0][0], bounding[0][1]])
output = os.path.join(self.local_scratch.path, "cutout2.aedb")

assert self.edbapp.create_cutout_on_point_list(
points, nets_to_include=["GND"], output_aedb_path=output, open_cutout_at_end=False
)
assert os.path.exists(os.path.join(output, "edb.def"))

def test_56_rvalue(self):
Expand Down Expand Up @@ -552,7 +578,7 @@ def test_64_export_to_maxwell(self):
edb.close_edb()

def test_65_flatten_planes(self):
assert self.edbapp.core_primitives.unite_polygons_on_layer()
assert self.edbapp.core_primitives.unite_polygons_on_layer("TOP")

def test_66_create_solder_ball_on_component(self):
assert self.edbapp.core_components.set_solder_ball("U1A1")
Expand Down
6 changes: 5 additions & 1 deletion _unittest/test_07_Object3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ def test_14_translate_delete_self(self):
assert v1[0] == v0[0] + 1.0
assert v1[1] == v0[1]
assert v1[2] == v0[2]
assert o.move([1, 0, 0])

def test_15_duplicate_around_axis_and_unite(self):
turn = self.create_example_coil("single_turn")
Expand All @@ -344,7 +345,6 @@ def test_16_duplicate_around_axis_and_unite(self):
assert len(added_objects) == 2
assert "single_turn" in self.aedtapp.modeler.line_names

# TODO: Finish asserts anc check the boolean inputs - they are not present in the GUI ??
def test_17_section_object(self):
o = self.aedtapp.modeler.create_box([-10, 0, 0], [10, 10, 5], "SectionBox", "Copper")
o.section(plane="YZ", create_new=True, section_cross_object=False)
Expand All @@ -354,3 +354,7 @@ def test_18_create_spiral(self):
assert sp1
assert sp1.name == "ind"
assert len(sp1.points) == 78

def test_19_rotate(self):
o = self.aedtapp.modeler.create_box([-10, 0, 0], [10, 10, 5], "RotateBox", "Copper")
assert o.rotate(cs_axis="Y", angle=180)
18 changes: 17 additions & 1 deletion _unittest/test_12_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def test_01B_Field_Plot(self):
plot1 = self.aedtapp.post.create_fieldplot_cutplane(cutlist, quantity_name, setup_name, intrinsic)
plot1.IsoVal = "Tone"
assert plot1.change_plot_scale(min_value, "30000")
assert self.aedtapp.post.create_fieldplot_volume("inner", "Vector_E", setup_name, intrinsic)
assert self.aedtapp.post.create_fieldplot_surface(
self.aedtapp.modeler["outer"].faces[0].id, "Mag_E", setup_name, intrinsic
)

@pytest.mark.skipif(is_ironpython, reason="Not running in ironpython")
def test_01_Animate_plt(self):
Expand Down Expand Up @@ -216,7 +220,6 @@ def test_16_create_field_plot(self):
quantityName="Mag_E",
setup_name=self.aedtapp.nominal_adaptive,
intrinsincList={"Freq": "5GHz", "Phase": "0deg"},
objtype="Surface",
listtype="CutPlane",
)
assert plot
Expand All @@ -236,3 +239,16 @@ def test_51_get_efields(self):
def test_52_display(self):
img = self.aedtapp.post.nb_display(show_axis=True, show_grid=True, show_ruler=True)
assert isinstance(img, Image)

def test_53_line_plot(self):
udp1 = [0, 0, 0]
udp2 = [1, 0, 0]
setup_name = "Setup1 : LastAdaptive"
intrinsic = {"Freq": "5GHz", "Phase": "180deg"}
self.aedtapp.modeler.create_polyline([udp1, udp2], name="Poly1")
assert self.aedtapp.post.create_fieldplot_line("Poly1", "Mag_E", setup_name, intrinsic)

def test_54_reload(self):
self.aedtapp.save_project()
app2 = Hfss(self.aedtapp.project_name)
assert len(app2.post.field_plots) == len(self.aedtapp.post.field_plots)
8 changes: 4 additions & 4 deletions _unittest/test_14_AedtLogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_02_output_file_with_app_filter(self):
if not os.path.exists(logging_dir):
os.makedirs(logging_dir)
path = os.path.join(logging_dir, "test02.txt")
logger = AedtLogger(self.aedtapp._messenger, filename=path)
logger = AedtLogger(filename=path)
logger.info("Info for Global")
logger.debug("Debug for Global")
logger.warning("Warning for Global")
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_02_output_file_with_app_filter(self):
def test_03_stdout_with_app_filter(self):
capture = CaptureStdOut()
with capture:
logger = AedtLogger(self.aedtapp._messenger, to_stdout=True)
logger = AedtLogger(to_stdout=True)
logger.info("Info for Global")
logger.warning("Warning for Global")
logger.error("Error for Global")
Expand All @@ -186,7 +186,7 @@ def test_04_disable_output_file_handler(self):
path = os.path.join(logging_dir, "test04.txt")
if os.path.exists(path):
os.remove(path)
logger = AedtLogger(self.aedtapp._messenger, filename=path)
logger = AedtLogger(filename=path)
logger.info("Info for Global before disabling the log file handler.")
project_logger = logger.add_logger("Project")
project_logger.info("Info for Project before disabling the log file handler.")
Expand Down Expand Up @@ -255,7 +255,7 @@ def test_05_disable_stdout(self):
stream.write.side_effect = fp.write
sys.stdout = stream

logger = AedtLogger(self.aedtapp._messenger, to_stdout=True)
logger = AedtLogger(to_stdout=True)
logger.info("Info for Global")
logger.disable_stdout_log()
logger.info("Info after disabling the stdout handler.")
Expand Down
14 changes: 14 additions & 0 deletions _unittest/test_15_ibs_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,17 @@ def test_01_read_ibis(self):
assert ibis.components["MT47H64M4BP-3_25"].pins["A1_MT47H64M4BP-3_25_u26a_800_modified"].r_value == "44.3m"
assert ibis.components["MT47H64M4BP-3_25"].pins["A1_MT47H64M4BP-3_25_u26a_800_modified"].l_value == "1.99nH"
assert ibis.components["MT47H64M4BP-3_25"].pins["A1_MT47H64M4BP-3_25_u26a_800_modified"].c_value == "0.59pF"

# Add pin
ibis.components["MT47H32M8BP-3_25"].pins["A7_MT47H32M8BP-3_25_u26a_800_modified"].add()
pin = (
ibis.components["MT47H32M8BP-3_25"]
.pins["A7_MT47H32M8BP-3_25_u26a_800_modified"]
.insert(0.1016, 0.05334, 0.0)
)
assert pin.name == "CompInst@A7_MT47H32M8BP-3_25_u26a_800_modified"

# Add buffer
ibis.buffers["RDQS#_u26a_800_modified"].add()
buffer = ibis.buffers["RDQS#_u26a_800_modified"].insert(0.1016, 0.05334, 0.0)
assert buffer.name == "CompInst@RDQS#_u26a_800_modified"
8 changes: 8 additions & 0 deletions _unittest/test_21_Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,11 @@ def test_25_zoom_to_fit(self):
myres = self.aedtapp.modeler.components.create_resistor("R100", 50)
mycap = self.aedtapp.modeler.components.create_capacitor("C100", 1e-12)
self.aedtapp.modeler.zoom_to_fit()

def test_26_component_catalog(self):
comp_catalog = self.aedtapp.modeler.components.components_catalog
assert comp_catalog["Capacitors:Cap_"]
assert comp_catalog["capacitors:cAp_"]
assert isinstance(comp_catalog.find_components("cap"), list)
assert comp_catalog["LISN:CISPR25_LISN"].place("Lisn1")
assert not comp_catalog["Capacitors"]
25 changes: 25 additions & 0 deletions _unittest/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,22 @@ def test_26_create_udp(self):
name=my_udpName,
udptye="Solid",
)

assert udp
assert udp.name == "MyClawPoleCore"
assert "MyClawPoleCore" in udp._primitives.object_names
assert int(udp.bounding_dimension[2]) == 100

# Modify one of the 'MyClawPoleCore' udp properties.
assert self.aedtapp.modeler.update_udp(
object_name="MyClawPoleCore",
operation_name="CreateUserDefinedPart",
udp_parameters_list=[["Length", "110mm"]],
)

assert int(udp.bounding_dimension[0]) == 102
assert int(udp.bounding_dimension[1]) == 102
assert int(udp.bounding_dimension[2]) == 110

# Test udp with default name -None-.
second_udp = self.aedtapp.modeler.create_udp(
Expand All @@ -173,10 +186,22 @@ def test_26_create_udp(self):
upd_library="syslib",
udptye="Solid",
)

assert second_udp
assert second_udp.name == "ClawPoleCore"
assert "ClawPoleCore" in udp._primitives.object_names

# Modify two of the 'MyClawPoleCore' udp properties.
assert self.aedtapp.modeler.update_udp(
object_name="ClawPoleCore",
operation_name="CreateUserDefinedPart",
udp_parameters_list=[["Length", "110mm"], ["DiaGap", "125mm"]],
)

assert int(second_udp.bounding_dimension[0]) == 125
assert int(second_udp.bounding_dimension[1]) == 125
assert int(second_udp.bounding_dimension[2]) == 110

@pytest.mark.skipif(os.name == "posix", reason="Feature not supported in Linux")
def test_27_create_udm(self):
my_udmPairs = []
Expand Down
32 changes: 23 additions & 9 deletions _unittest/test_40_3dlayout_edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def setup_class(self):
os.path.join(self.local_scratch.path, test_project_name + ".aedb"),
)
self.aedtapp = Hfss3dLayout(self.test_project)
self.aedtapp.modeler.geometries

def teardown_class(self):
self.aedtapp._desktop.ClearMessages("", "", 3)
Expand All @@ -45,15 +46,23 @@ def test_01_get_components(self):
assert comp["L3A1"].get_part_type()
assert comp["L3A1"].set_property_value("Angle", "0deg")

def test_02_get_geometries(self):
geo = self.aedtapp.modeler.geometries
assert len(geo) > 0
assert geo["line_1983"].object_units == "mm"
assert geo["line_1983"].get_placement_layer()
assert geo["line_1983"].set_lock_position(True)
assert geo["line_1983"].set_lock_position(False)
assert geo["line_1983"].set_layer("PWR")
assert geo["line_1983"].set_net_name("VCC")
def test_02a_get_geometries(self):
line = self.aedtapp.modeler.geometries["line_1983"]
assert len(self.aedtapp.modeler.geometries) > 0

def test_02b_geo_units(self):
assert self.aedtapp.modeler.geometries["line_1983"].object_units == "mm"

def test_02c_geo_layer(self):
assert self.aedtapp.modeler.geometries["line_1983"].get_placement_layer()

def test_02d_geo_lock(self):
assert self.aedtapp.modeler.geometries["line_1983"].set_lock_position(True)
assert self.aedtapp.modeler.geometries["line_1983"].set_lock_position(False)

def test_02e_geo_setter(self):
assert self.aedtapp.modeler.geometries["line_1983"].set_layer("PWR")
assert self.aedtapp.modeler.geometries["line_1983"].set_net_name("VCC")

def test_03_get_pins(self):
pins = self.aedtapp.modeler.pins
Expand Down Expand Up @@ -82,3 +91,8 @@ def test_06_assign_spice_model(self):
assert self.aedtapp.modeler.set_spice_model(
component_name="C3A3", model_path=model_path, subcircuit_name="GRM32ER72A225KA35_25C_0V"
)

def test_07_nets(self):
nets = self.aedtapp.modeler.nets
assert nets["GND"].name == "GND"
assert len(nets) > 0
4 changes: 2 additions & 2 deletions _unittest_ironpython/conf_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def test_generator(test_obj, test_function):
def test(self):
try:
return getattr(test_obj, test_function)()
except AssertionError:
return self.assertTrue(False)
except AssertionError as e:
return self.assertTrue(False, msg=e)

return test

Expand Down
2 changes: 1 addition & 1 deletion doc/source/API/Constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Example of constants usage:
from pyaedt import constants
ipk = Icepak()
# Use of AXIS Constant
cylinder = ipk.modeler.primitives.create_cylinder(constants.AXIS.X, [0,0,0],10,3)
cylinder = ipk.modeler.create_cylinder(constants.AXIS.X, [0,0,0],10,3)
# Use of PLANE Constant
ipk.modeler.split(cylinder, constants.PLANE.YZ, sides="Both")
...
Expand Down
Loading

0 comments on commit 420cb6d

Please sign in to comment.