Skip to content

Commit

Permalink
REFACT: examples to use contant file
Browse files Browse the repository at this point in the history
  • Loading branch information
SMoraisAnsys committed Feb 19, 2024
1 parent 368f4d9 commit 248e3e1
Show file tree
Hide file tree
Showing 16 changed files with 154 additions and 31 deletions.
12 changes: 9 additions & 3 deletions example/00-EDB/00_EDB_Create_VIA.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@
# ## Import EDB layout object
# Import the EDB layout object and initialize it on version 2023 R2.

# +
import os
import tempfile

# +
from example.constants import EDB_VERSION
import pyaedt

temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
aedb_path = os.path.join(temp_dir.name, "create_via.aedb")
print(aedb_path)
edb = pyaedt.Edb(edbpath=aedb_path, edbversion="2023.2")
print(f"AEDB file path: {aedb_path}")

# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

edb = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version)
# -

# ## Add stackup layers
Expand Down
12 changes: 9 additions & 3 deletions example/00-EDB/01_edb_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import tempfile
import time

from example.constants import EDB_VERSION
import pyaedt

temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
Expand All @@ -21,13 +22,18 @@

# ## Launch Ansys Electronics Database (EDB)
#
# Instantiate an instance of the `pyaedt.Edb` class
# using EDB 2023 R2 and SI units.
# Instantiate an instance of the `pyaedt.Edb` class using SI units.

edb_version = "2023.2"
# +
if os.path.exists(aedt_file):
os.remove(aedt_file)

# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

edb = pyaedt.Edb(edbpath=targetfile, edbversion=edb_version)
# -

# ## Identify nets and components
#
Expand Down
24 changes: 17 additions & 7 deletions example/00-EDB/02_edb_to_ipc2581.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
#
# Perform required imports, which includes importing a section.

# +
import os
import tempfile

from example.constants import EDB_VERSION
import pyaedt

# Download the AEDB file and copy it in the temporary folder.
# -

# ## Download the AEDB file and copy it in the temporary folder.

temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
targetfile = pyaedt.downloads.download_file("edb/ANSYS-HSD_V1.aedb", destination=temp_dir.name)
Expand All @@ -21,15 +25,21 @@
# Launch the `pyaedt.Edb` class, using EDB 2023.
# > Note that length dimensions passed to EDB are in SI units.

edb = pyaedt.Edb(edbpath=targetfile, edbversion="2023.2")
# +
# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

edb = pyaedt.Edb(edbpath=targetfile, edbversion=edb_version)
# -

# Parametrize the width of a trace.
# ## Parametrize the width of a trace.

edb.modeler.parametrize_trace_width(
"A0_N", parameter_name=pyaedt.generate_unique_name("Par"), variable_value="0.4321mm"
)

# Create a cutout and plot it.
# ## Create a cutout and plot it.

signal_list = []
for net in edb.nets.netlist:
Expand All @@ -49,15 +59,15 @@
)
edb.nets.plot(None, None, color_by_net=True)

# Export the EDB to an IPC2581 file.
# ## Export the EDB to an IPC2581 file.

edb.export_to_ipc2581(ipc2581_file_name, "inch")
print("IPC2581 File has been saved to {}".format(ipc2581_file_name))

# Close EDB
# ## Close EDB

edb.close_edb()

# Clean up the temporary directory
# ## Clean up the temporary directory

temp_dir.cleanup()
16 changes: 14 additions & 2 deletions example/00-EDB/03_5G_antenna_example_parametrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
# Perform required imports, which includes importing the ``Hfss3dlayout`` object
# and initializing it on version 2023 R2.

# +
import os
import tempfile

from example.constants import EDB_VERSION
import pyaedt

# Set non-graphical mode
# -

# ## Set non-graphical mode

non_graphical = False

Expand Down Expand Up @@ -77,9 +81,17 @@ def points(self):
#
# PyAEDT.Edb allows to open existing Edb project or create a new empty project.

# +
temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
aedb_path = os.path.join(temp_dir.name, "linear_array.aedb")
edb = pyaedt.Edb(edbpath=aedb_path, edbversion="2023.2") # Create an instance of the Edb class.

# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

# Create an instance of the Edb class.
edb = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version)
# -

# Add stackup layers

Expand Down
15 changes: 13 additions & 2 deletions example/00-EDB/04_edb_parametrized_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,34 @@
#
# <img src="_static\pcb_transition_parameterized.png" width="500">

# +
import os
import tempfile

from example.constants import EDB_VERSION
import pyaedt

# -

# ## Set non-graphical mode
#
# Set non-graphical mode. The default is ``False``, which opens
# the AEDT UI.

non_graphical = False

# Launch EDB.
# ## Launch EDB.

# +
temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
aedb_path = os.path.join(temp_dir.name, "pcb.aedb")
edb = pyaedt.Edb(edbpath=aedb_path, edbversion="2023.2")

# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

edb = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version)
# -

# Define the parameters.

Expand Down
16 changes: 13 additions & 3 deletions example/00-EDB/05_Plot_nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,30 @@
#
# Perform required imports, which includes importing a section.

# +
import tempfile

from example.constants import EDB_VERSION
import pyaedt

# Download the EDB and copy it into the temporary folder.
# -

# ## Download the EDB and copy it into the temporary folder.

temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
targetfolder = pyaedt.downloads.download_file("edb/ANSYS-HSD_V1.aedb", destination=temp_dir.name)

# Create an instance of the Electronics Database using the `pyaedt.Edb` class.
# ## Create an instance of the Electronics Database using the `pyaedt.Edb` class.
#
# > Note that units are SI.

edb = pyaedt.Edb(edbpath=targetfolder, edbversion="2023.2")
# +
# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

edb = pyaedt.Edb(edbpath=targetfolder, edbversion=edb_version)
# -

# Display the nets on a layer. You can display the net geometry directly in Python using
# ``matplotlib`` from the ``pyaedt.Edb`` class.
Expand Down
9 changes: 8 additions & 1 deletion example/00-EDB/06_Advanced_EDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import tempfile

from example.constants import EDB_VERSION
import numpy as np
import pyaedt

Expand Down Expand Up @@ -35,7 +36,13 @@ def create_ground_planes(edb, layers):
# Create the EDB instance.
# If the path doesn't exist, PyAEDT automatically generates a new AEDB folder.

edb = pyaedt.Edb(edbpath=aedb_path, edbversion="2023.2")
# +
# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

edb = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version)
# -

# Insert the stackup layers.

Expand Down
10 changes: 9 additions & 1 deletion example/00-EDB/08_CPWG.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import os

from example.constants import EDB_VERSION
import numpy as np
import pyaedt

Expand All @@ -22,11 +23,18 @@

# ## Launch EDB

# +
aedb_path = os.path.join(
pyaedt.generate_unique_folder_name(), pyaedt.generate_unique_name("pcb") + ".aedb"
)
print(aedb_path)
edbapp = pyaedt.Edb(edbpath=aedb_path, edbversion="2023.2")

# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

edbapp = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version)
# -

# ## Define parameters

Expand Down
12 changes: 11 additions & 1 deletion example/00-EDB/09_Configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
# the 3D Layout editor in AEDT.
# on version 2023 R2.

# +
import os
import tempfile

from example.constants import EDB_VERSION
import pyaedt

# -

# Download the AEDB file and copy it to a temporary folder.

temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
Expand All @@ -25,7 +29,13 @@
#
# Launch the ``pyaedt.Edb`` class using EDB 2023 R2. Length units are SI.

edbapp = pyaedt.Edb(target_aedb, edbversion="2023.2")
# +
# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

edbapp = pyaedt.Edb(target_aedb, edbversion=edb_version)
# -

# ## Import definitions
#
Expand Down
12 changes: 11 additions & 1 deletion example/00-EDB/10_GDS_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@

# Perform imports.

# +
import os
import shutil
import tempfile

from example.constants import EDB_VERSION
import pyaedt
from pyaedt.edb_core.edb_data.control_file import ControlFile

# -

# ## Fetch Example Data
#
# Download the EDB folder and copy it to a temporary folder.
Expand Down Expand Up @@ -91,7 +95,13 @@
# +
from pyaedt import Edb

edb = Edb(gds_out, edbversion="2023.2", technology_file=os.path.join(temp_dir.name, "output.xml"))
# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

edb = Edb(
gds_out, edbversion=edb_version, technology_file=os.path.join(temp_dir.name, "output.xml")
)
# -

# ## Plot stackup
Expand Down
10 changes: 9 additions & 1 deletion example/00-EDB/11_post_layout_parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@

# Perform required imports.

# +
import os
import tempfile

from example.constants import EDB_VERSION
import pyaedt

temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")

# Download and open example layout file in edb format.

edb_path = pyaedt.downloads.download_file("edb/ANSYS-HSD_V1.aedb", destination=temp_dir.name)
edb = pyaedt.Edb(edb_path, edbversion="2023.2")

# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

edb = pyaedt.Edb(edb_path, edbversion=edb_version)
# -

# ## Create cutout
#
Expand Down
9 changes: 7 additions & 2 deletions example/00-EDB/12_edb_sma_connector_on_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,24 @@
import os
import tempfile

from example.constants import EDB_VERSION
import numpy as np
import pyaedt

# Create the EDB.

# +
ansys_version = "2023.2"
temp_dir = tempfile.TemporaryDirectory(suffix=".ansys")
working_folder = temp_dir.name

# Select EDB version (change it manually if needed, e.g. "2023.2")
edb_version = EDB_VERSION
print(f"EDB version: {edb_version}")

aedb_path = os.path.join(working_folder, "pcb.aedb")
edb = pyaedt.Edb(edbpath=aedb_path, edbversion=ansys_version)
print("AEDB file is located in {}".format(aedb_path))

edb = pyaedt.Edb(edbpath=aedb_path, edbversion=edb_version)
# -

# Add the FR4 dielectric for the PCB.
Expand Down
Loading

0 comments on commit 248e3e1

Please sign in to comment.