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 committed Jan 25, 2022
2 parents 30002e4 + ea4e351 commit d93f026
Show file tree
Hide file tree
Showing 23 changed files with 11,625 additions and 204 deletions.
10,910 changes: 10,910 additions & 0 deletions _unittest/example_models/PlanarTransformer.aedt

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions _unittest/test_00_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def test_01B_get_vias_from_nets(self):
assert self.edbapp.core_padstack.get_via_instance_from_net("GND")
assert not self.edbapp.core_padstack.get_via_instance_from_net(["GND2"])

def tesCt_01_flip_layer_stackup(self):
assert self.edbapp.core_stackup.place_in_layout()

def test_02_get_properties(self):
assert len(self.edbapp.core_components.components) > 0
assert len(self.edbapp.core_components.inductors) > 0
Expand Down Expand Up @@ -555,13 +558,10 @@ def test_67_add_void(self):
void = self.edbapp.core_primitives.create_path(path, layer_name="TOP", width="0.1mm")
assert self.edbapp.core_primitives.add_void(plane, void)

def test_68_flip_layer_stackup(self):
assert self.edbapp.core_stackup.flip_stackup_and_apply_transform()

def test_69_create_solder_balls_on_component(self):
assert self.edbapp.core_components.set_solder_ball("U2A5")

@pytest.mark.skipif(is_ironpython, reason="This Test uses Ironpython")
@pytest.mark.skipif(is_ironpython, reason="This Test uses Matplotlib that is not supported by Ironpython")
def test_70_plot_on_matplotlib(self):
local_png = os.path.join(self.local_scratch.path, "test.png")
self.edbapp.core_nets.plot(None, None, save_plot=local_png)
Expand Down
5 changes: 5 additions & 0 deletions _unittest/test_07_Object3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ def test_01_bounding_box(self):
bb = o.bounding_box
assert len(bb) == 6

def test_01_bounding_dimension(self):
o = self.create_copper_box()
bd = o.bounding_dimension
assert len(bd) == 3

def test_01_delete_object(self):
o = self.create_copper_box("DeleteBox")
name = o.name
Expand Down
5 changes: 4 additions & 1 deletion _unittest/test_20_HFSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,19 @@ def test_05_create_wave_port_from_sheets(self):
o5 = self.aedtapp.modeler.primitives.create_circle(self.aedtapp.PLANE.YZ, udp, 10, name="sheet1")
self.aedtapp.solution_type = "Terminal"
port = self.aedtapp.create_wave_port_from_sheet(
o5, 5, self.aedtapp.AxisDir.XNeg, 40, 2, "sheet1_Port", True, terminal_references=["outer"]
o5, 5, self.aedtapp.AxisDir.XNeg, 40, 2, "sheet1_Port", renorm=False, terminal_references=["outer"]
)
assert port.name == "sheet1_Port"
assert port.name in [i.name for i in self.aedtapp.boundaries]
assert port.props["RenormalizeAllTerminals"] is False

self.aedtapp.solution_type = "Modal"
udp = self.aedtapp.modeler.Position(200, 0, 0)
o6 = self.aedtapp.modeler.primitives.create_circle(self.aedtapp.PLANE.YZ, udp, 10, name="sheet2")
port = self.aedtapp.create_wave_port_from_sheet(o6, 5, self.aedtapp.AxisDir.XPos, 40, 2, "sheet2_Port", True)
assert port.name == "sheet2_Port"
assert port.name in [i.name for i in self.aedtapp.boundaries]
assert port.props["RenormalizeAllTerminals"] is True

id6 = self.aedtapp.modeler.primitives.create_box([20, 20, 20], [10, 10, 2], matname="Copper", name="My_Box")
id7 = self.aedtapp.modeler.primitives.create_box([20, 25, 30], [10, 2, 2], matname="Copper")
Expand Down
7 changes: 7 additions & 0 deletions _unittest/test_21_Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,10 @@ def test_25_import_model(self):
assert len(t1.pins) == 6
t2 = self.aedtapp.modeler.schematic.create_touchsthone_component(touch)
assert t2

def test_25_zoom_to_fit(self):
self.aedtapp.insert_design("zoom_test")
myind = self.aedtapp.modeler.schematic.create_inductor("L100", 1e-9)
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()
19 changes: 18 additions & 1 deletion _unittest/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Setup paths for module imports
from _unittest.conftest import scratch_path
from _unittest.conftest import scratch_path, local_path
import os

# Import required modules
Expand Down Expand Up @@ -223,3 +223,20 @@ def test_30_assign_movement(self):
bound = self.aedtapp.assign_translate_motion("Outer_Box", mechanical_transient=True, velocity=1)
assert bound
assert bound.props["Velocity"] == "1m_per_sec"

def test_31_core_losses(self):
core_loss_file = "PlanarTransformer.aedt"
example_project = os.path.join(local_path, "example_models", core_loss_file)
file_path = self.local_scratch.copyfile(example_project)
m3d1 = Maxwell3d(file_path)
assert m3d1.set_core_losses(["PQ_Core_Bottom", "PQ_Core_Top"])
assert m3d1.set_core_losses(["PQ_Core_Bottom"], False)
self.aedtapp.close_project(m3d1.project_name)

def test_32_matrix(self):
core_loss_file = "PlanarTransformer.aedt"
example_project = os.path.join(local_path, "example_models", core_loss_file)
file_path = self.local_scratch.copyfile(example_project)
m3d1 = Maxwell3d(file_path)
assert m3d1.assign_matrix("pri", "mymatrix") == "mymatrix"
self.aedtapp.close_project(m3d1.project_name, False)
32 changes: 32 additions & 0 deletions doc/source/API/ClientServer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,35 @@ As an alternative, the user can upload the script to run to the server and run i
upload(local_script, remote_script, "servername")
ansysem = "/path/to/AnsysEMxxx/Linux64"
my_client.root.run_script(remote_script, ansysem_path=ansysem)
CPython on Linux with Client-Server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To bypass current IronPython limits, you can launch PyAEDT on a Linux machine:

1. Using pip, install PyAEDT 0.4.23 or later on a Linux machine.
2. Launche CPython and run PyAEDT.

.. code:: python
# Launch the latest installed version of PyAEDT in graphical mode.
from pyaedt.common_rpc import launch_ironpython_server
client = launch_ironpython_server(ansysem_path="/path/to/ansys/executable/folder", non_graphical=True, port=18000)
hfss = client.root.hfss()
# put your code here
3. If the method returns a list or dictionary, use the following method to work around an
issue with CPython handling:

.. code:: python
box1 = hfss.modeler.create_box([0,0,0],[1,1,])
# convert_remote_object method convert remote ironpython list to local cpython.
faces = client.convert_remote_object(box1.faces)
.. image:: Resources/IronPython2Cpython.png
:width: 800
:alt: Electronics Desktop Launched
Binary file added doc/source/Resources/IronPython2Cpython.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 25 additions & 38 deletions examples/07-TwinBuilder/01-RC_Circuit_Example.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,47 @@
"""
RC Circuit Schematic Creation and Analysis
------------------------------------------
RC Circuit Design in Twin Builder
---------------------------------
This example shows how you can use PyAEDT to create a Twin Builder design
and run a Twin Builder time-domain simulation.
"""

from pyaedt import TwinBuilder
from pyaedt import Desktop
###############################################################################
# Import Required Packages for Twin Builder
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import os
import matplotlib.pyplot as plt
from pyaedt import TwinBuilder

###############################################################################
# Launch Twin Builder
# ~~~~~~~~~~~~~~~~~~~
# Select Version and Launch Options
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This example launches Twin Builder 2021.2 in graphical mode.

# This example uses SI units.

desktop_version = "2021.2"

###############################################################################
# Launch Twin Builder in Non-Graphical Mode
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# You can change the Boolean parameter ``non_graphical`` to ``False`` to launch
# Twin Builder in graphical mode.
# You can change the Boolean parameter ``non_graphical`` to ``True`` to launch
# Twin Builder in non graphical mode.
# You can change the Boolean parameter ``new_thread`` to ``False`` to launch
# Twin Builder in existing Desktop Session, if any.

desktop_version = "2021.2"
non_graphical = False
new_thread = True

###############################################################################
# Launch Twin Builder
# ~~~~~~~~~~~~~~~~~~~
# The :class:`pyaedt.Desktop` class initializes AEDT and starts it on a specified version in
# a specified graphical mode. The Boolean parameter ``new_thread`` defines whether
# to create a new instance of AEDT or try to connect to existing instance of it.

desktop = Desktop(desktop_version, non_graphical, new_thread)
# Use implicit declaration to launch Twin Builder Application

# Add a new Twin Builder design with a default setup

tb = TwinBuilder()

tb = TwinBuilder(specified_version=desktop_version, non_graphical=non_graphical, new_desktop_session=new_thread)

###############################################################################
# Create Components for a RC circuit driven by a pulse voltage source
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#

# Define the Grid Distance
# Define the Grid Distance for ease in calculations

G = 0.00254

Expand All @@ -62,14 +54,14 @@
###############################################################################
# Create a Ground
# ~~~~~~~~~~~~~~~
# This method create a ground, which is needed for a twin builder analog analysis.
# This method creates a ground, which is needed for a twin builder analog analysis.

gnd = tb.modeler.components.create_gnd([0, -10 * G])

###############################################################################
# Connect Components
# ~~~~~~~~~~~~~~~~~~
# This method connects components with wires.
# This method connects components with pageports.

source.pins[1].connect_to_component(resistor.pins[0])
resistor.pins[1].connect_to_component(capacitor.pins[0])
Expand All @@ -91,35 +83,30 @@
tb.analyze_setup("TR")


################################################################
# Get Report Data and plot it on matplotlib.
#
###############################################################################
# Get Report Data and plot it on matplotlib
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Get the values for the voltage on the Pulse voltage source
# Get the values for the voltage on the capacitor in the RC Circuit

E_Value = "E1.V"
x = tb.post.get_report_data(E_Value, "TR", "Time", {"Time": ["All"]})
plt.plot(x.sweeps["Time"], x.data_real(E_Value))

################################################################
# Get the values for the voltage on the capacitor in the RC Circuit

C_Value = "C1.V"
x = tb.post.get_report_data(C_Value, "TR", "Time", {"Time": ["All"]})
plt.plot(x.sweeps["Time"], x.data_real(C_Value))


plt.grid()
plt.xlabel("Time")
plt.ylabel("C1.V vs E1.V")
plt.ylabel("Capacitor Voltage vs Input Pulse")
plt.show()

plt.clf()

###############################################################################
# Close Twin Builder
# ~~~~~~~~~~~~~~~~~~
# After the simulaton is completed, you can close Twin Builder or release it using the
# :func:`pyaedt.Desktop.force_close_desktop` method.
# After the simulaton is completed, you can close Twin Builder or release it
# All methods provide for saving the project before exiting.

if os.name != "posix":
desktop.release_desktop()
tb.release_desktop()
Loading

0 comments on commit d93f026

Please sign in to comment.