Git Product home page Git Product logo

pyaedt's Introduction

PyAEDT


English | δΈ­ζ–‡

PyAnsys pypi PyPIact PythonVersion GH-CI codecov MITblackAnaconda

pre-commit

What is PyAEDT?

PyAEDT is a Python library that interacts directly with the API for Ansys Electronics Desktop (AEDT) to make scripting simpler. The architecture for PyAEDT can be reused for all AEDT 3D products (HFSS, Icepak, Maxwell 3D, and Q3D Extractor), 2D tools, and Ansys Mechanical. PyAEDT also provides support for circuit tools like Nexxim and system simulation tools like Twin Builder. Finally, PyAEDT provides scripting capabilities in Ansys layout tools like HFSS 3D Layout and EDB. The PyAEDT class and method structures simplify operation while reusing information as much as possible across the API.

Install on CPython from PyPI

You can install PyAEDT on CPython 3.7 through 3.10 from PyPI with this command:

  pip install pyaedt

Install PyAEDT with all extra packages (matplotlib, numpy, pandas, pyvista):

  pip install pyaedt[all]

You can also install PyAEDT from Conda-Forge with this command:

  conda install -c conda-forge pyaedt

PyAEDT remains compatible with IronPython and can be still used in the AEDT Framework.

About PyAnsys

PyAEDT is part of the larger PyAnsys effort to facilitate the use of Ansys technologies directly from Python.

PyAEDT is intended to consolidate and extend all existing functionalities around scripting for AEDT to allow reuse of existing code, sharing of best practices, and increased collaboration.

About AEDT

AEDT is a platform that enables true electronics system design. AEDT provides access to the Ansys gold-standard electro-magnetics simulation solutions, such as Ansys HFSS, Ansys Maxwell, Ansys Q3D Extractor, Ansys Siwave, and Ansys Icepak using electrical CAD (ECAD) and Mechanical CAD (MCAD) workflows.

In addition, AEDT includes direct links to the complete Ansys portfolio of thermal, fluid, and mechanical solvers for comprehensive multiphysics analysis. Tight integration among these solutions provides unprecedented ease of use for setup and faster resolution of complex simulations for design and optimization.

PyAEDT is licensed under the MIT License

PyAEDT includes functionality for interacting with the following AEDT tools and Ansys products:

  • HFSS and HFSS 3D Layout
  • Icepak
  • Maxwell 2D, Maxwell 3D, and RMXprt
  • 2D Extractor and Q3D Extractor
  • Mechanical
  • Nexxim
  • EDB
  • Twin Builder
  • EMIT

Documentation and issues

Documentation for the latest stable release of PyAEDT is hosted at PyAEDT documentation.

In the upper right corner of the documentation's title bar, there is an option for switching from viewing the documentation for the latest stable release to viewing the documentation for the development version or previously released versions.

You can also view or download PyAEDT cheat sheets, which are one-page references providing syntax rules and commands for using the PyAEDT API and PyEDB API:

On the PyAEDT Issues page, you can create issues to report bugs and request new features. On the PyAEDT Discussions page or the Discussions page on the Ansys Developer portal, you can post questions, share ideas, and get community feedback.

To reach the project support team, email [email protected].

Dependencies

To run PyAEDT, you must have a local licenced copy of AEDT. PyAEDT supports AEDT versions 2022 R1 or newer.

Student version

PyAEDT supports AEDT Student versions 2022 R1 and later. For more information, see the Ansys Electronics Desktop Student - Free Software Download page on the Ansys website.

Why PyAEDT?

A quick and easy approach for automating a simple operation in the 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.
  • Recorded scripts are difficult to reuse and adapt.
  • Complex coding is required by many global users of AEDT.

The main advantages of PyAEDT are:

  • Automatic initialization of all AEDT objects, such as desktop objects like the editor and boundaries
  • Error management
  • Log management
  • Variable management
  • Compatibility with IronPython and CPython
  • Simplification of complex API syntax using data objects while maintaining PEP8 compliance.
  • Code reusability across different solvers
  • Clear documentation on functions and API
  • Unit tests of code to increase quality across different AEDT versions

Example workflow

  1. Initialize the Desktop class with the version of AEDT to use.
  2. Initialize the application to use within AEDT.

Connect to AEDT from Python IDE

PyAEDT works both inside AEDT and as a standalone application. This Python library automatically detects whether it is running in an IronPython or CPython environment and initializes AEDT accordingly. PyAEDT also provides advanced error management. Usage examples follow.

Explicit AEDT declaration and error management

    # Launch AEDT 2022 R2 in non-graphical mode

    from pyaedt import Desktop, Circuit
    with Desktop(specified_version="2022.2",
                 non_graphical=False, new_desktop_session=True,
                 close_on_exit=True, student_version=False):
        circuit = Circuit()
        ...
        # Any error here will be caught by Desktop.
        ...

    # Desktop is automatically released here.

Implicit AEDT declaration and error management

    # Launch the latest installed version of AEDT in graphical mode

    from pyaedt import Circuit
    with Circuit(specified_version="2022.2",
                 non_graphical=False) as circuit:
        ...
        # Any error here will be caught by Desktop.
        ...

    # Desktop is automatically released here.

Remote application call

You can make a remote application call on a CPython server or any Windows client machine.

On a CPython Server:

    # Launch PyAEDT remote server on CPython

    from pyaedt.common_rpc import pyaedt_service_manager
    pyaedt_service_manager()

On any Windows client machine:

    from pyaedt.common_rpc import create_session
    cl1 = create_session("server_name")
    cl1.aedt(port=50000, non_graphical=False)
    hfss = Hfss(machine="server_name", port=50000)
    # your code here

Variables

    from pyaedt.HFSS import HFSS
    with HFSS as hfss:
         hfss["dim"] = "1mm"   # design variable
         hfss["$dim"] = "1mm"  # project variable

Modeler

    # Create a box, assign variables, and assign materials.

    from pyaedt.hfss import Hfss
    with Hfss as hfss:
         hfss.modeler.create_box([0, 0, 0], [10, "dim", 10],
                                 "mybox", "aluminum")

License

PyAEDT is licensed under the MIT license.

PyAEDT makes no commercial claim over Ansys whatsoever. This library extends the functionality of AEDT by adding a Python interface to AEDT without changing the core behavior or license of the original software. The use of PyAEDT requires a legally licensed local copy of AEDT.

To get a copy of AEDT, see the Ansys Electronics page on the Ansys website.

back to top

Indices and tables

pyaedt's People

Contributors

akaszynski avatar alberto-dm avatar amichel0205 avatar apollo-crum avatar beliaev-maksim avatar dcrawforatansys avatar dependabot[bot] avatar gmalinve avatar irenewoyna avatar isaacansys avatar jeremich41 avatar jleonatti avatar jsalant22 avatar kbhagat-ansys avatar lorenzovecchietti avatar madelinecoleman1 avatar maxcapodi78 avatar maxjprey avatar myoung301 avatar nnetake avatar pipkat avatar pre-commit-ci[bot] avatar revathyvenugopal162 avatar ring630 avatar samuelopez-ansys avatar siva-krishnaswamy avatar smoraisansys avatar sushobhitgupt avatar svandenb-dev avatar voss70 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyaedt's Issues

function Maxwell2d.assign_current does not work on Magnetostatic solver

Hallo,

since it asks for a phase, that function is not accepted by the Magnetostatic solver. I could find an equivalent function performing the job, so I relied on the old APIs as follows:

my_current_list = [
		"NAME:Current1",
		"Objects:="		, ["Rectangle1"],
		"Current:="		, "1A",
		"IsPositive:="		, True
	]

my_omodule = m2d.odesign.GetModule("BoundarySetup")
my_omodule.AssignCurrent(my_current_list)

Thank you,
Tiziana

Test3DLayoutEDB stability

Seeing consistent failures on the following unit tests:

  • test_3dlayout_edb.Test3DLayoutEDB.test_get_components
  • test_3dlayout_edb.Test3DLayoutEDB.test_get_geometries
  • test_3dlayout_edb.Test3DLayoutEDB.test_get_pins

Should we continue to get failures on these, we should consider implementing an xfail. See https://docs.pytest.org/en/6.2.x/skipping.html

Variable Enahncement

@voss70 One potential refactor could be the possibity to add to Variable manager also Output/PostProcessing Variables. Not sure if it applies to all tools or only few of them

analyse versus analyze

In hfss.py (and likely other files), some methods use analyse_ and others use analyze_. We should always use analyze as we are to use American spellings. Also, in hfss.py, we are missing an "in" in assign in this method: assig_voltage_source_to_sheet

Discussion: examples folder

Is there any guidance established about what does/does not go into an examples folder? Any thoughts on Jupyter notebooks (I see there are none).

Failed Test: test_06z_validate_setup

Getting a consistent failure oftest_06z_validate_setup on _unittest\test_HFSS.py:

================================================== FAILURES ==================================================
______________________________________ TestHFSS.test_06z_validate_setup ______________________________________

self = <_unittest.test_HFSS.TestHFSS object at 0x00000172B5087190>

    def test_06z_validate_setup(self):
        list, ok = self.aedtapp.validate_full_design(ports=5)
>       assert ok
E       assert False

_unittest\test_HFSS.py:120: AssertionError
...
************************************************************
Info: ** No Design Validation File found **
--------------------------------------------- Captured log call ----------------------------------------------
ERROR    pyaedt.generic.general_methods:general_methods.py:72 (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024381), None)
ERROR    pyaedt.generic.general_methods:general_methods.py:79   File "C:\Users\akaszyns\source\pyaedt\pyaedt\application\Design.py", line 2083, in validate_simple
ERROR    pyaedt.generic.general_methods:general_methods.py:79     return self._odesign.ValidateDesign(logfile)
ERROR    pyaedt.generic.general_methods:general_methods.py:79

Fresh install of pyaedt via a clone and pip install .

Using AnsysEM21.1 on Windows with Python 3.8.5

Analysis RMxprt methods to check consistency not used

https://github.com/pyansys/PyAEDT/blob/5dd9780ad0c3dc23ce1e2c09fc341ab857f3334e/pyaedt/application/AnalysisRMxprt.py#L113-L128

The two methods above are not referenced. Can they be removed?

Also, there are several places where multiple methods are commented out like here:
https://github.com/pyansys/PyAEDT/blob/5dd9780ad0c3dc23ce1e2c09fc341ab857f3334e/pyaedt/application/AnalysisRMxprt.py#L105-L112
Is it okay to remove these or are they needed?

Rename documentation directory

For consistency, rename doc_generator to doc to maintain consistency with numpy, scipy, and pandas.

Additionally, Sphinx_AEDTLib should be renamed to source (same consistency).

The returned string is "10WWatt". It should be "10W" or "10Watts"

Hi @maxcapodi78 and @PipKat
I saw a small issue in the following code.
https://github.com/pyansys/PyAEDT/blob/7db32e4ad317a7ed94b363bf7ab454484b01c105/pyaedt/hfss.py#L2099-L2100

We can expect to get either:
Setting up power to Eigenmode 10W
or
Setting up power to Eigenmode 10Watts

To fix it, either we update the keyword argument powerin or we update the line:
self._messenger.add_info_message("Setting up power to Eigenmode " + powerin + "Watt")
to be self._messenger.add_info_message("Setting up power to Eigenmode " + powerin)

Please tell me what is the more appropriate and I will fix it accordingly.

Parameters posx and posy versus ypos and xpos

In some of the "Primitives" py files in modeler, there are a few parameter name occurrences of posx and posy. Most parameters names are xpos and ypos. Shouldn't they be consistent. It seems confusing as is.

edb.core_components.components[REFDES1] generate a new dictionary for every indexing

A test code is as below. It takes 0.3 seconds to generate component dictionary everything it is used. If I assign component dictionary to variable comp_dict. The dictionary indexing takes zero time.

REFDES1 = "U3A1"

# Case 1
PT.Initialization()
for i in np.arange(3):
    start = time.time()
    x = PT.edb.core_components.components[REFDES1]
    timer(start)
PT.close_edb()

Case 2
PT.Initialization()
comp_dict = PT.edb.core_components.components
for i in np.arange(3):
    start = time.time()
    x = comp_dict[REFDES1]
    timer(start)
PT.close_edb()

Result Case 1

Configuring EDB environment for release 2021.1
Initialized finished
elapsed time = 0.3190014362335205
elapsed time = 0.32599806785583496
elapsed time = 0.30100107192993164

Reault Case 2
Configuring EDB environment for release 2021.1
Initialized finished
elapsed time = 0.0
elapsed time = 0.0
elapsed time = 0.0

Add full doc build to the CI/CD

Right now we just have the API build in the nightly doc build, we need to add the examples too as Massimo added it in our tagged builds.

Unitest fails

Unitest fails on my PC. The log is attached as below. Is it expected?

`Testing started at 17:23 ...
C:\Anaconda3\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2020.1.1\plugins\python-ce\helpers\pycharm_jb_pytest_runner.py" --path C:/Users/hzhou/PyAEDT/_unittest/test_01EDB.py
Launching pytest with arguments C:/Users/hzhou/PyAEDT/_unittest/test_01EDB.py in C:\Users\hzhou\PyAEDT

============================= test session starts =============================
platform win32 -- Python 3.8.5, pytest-6.1.1, py-1.9.0, pluggy-0.13.1 -- C:\Anaconda3\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\hzhou\PyAEDT
collecting ... collected 59 items

_unittest/test_01EDB.py::TestEDB::test_find_by_name
_unittest/test_01EDB.py::TestEDB::test_get_properties
_unittest/test_01EDB.py::TestEDB::test_get_primitives
_unittest/test_01EDB.py::TestEDB::test_get_stackup
_unittest/test_01EDB.py::TestEDB::test_component_lists
_unittest/test_01EDB.py::TestEDB::test_vias_creation
_unittest/test_01EDB.py::TestEDB::test_nets_query
_unittest/test_01EDB.py::TestEDB::test_assign_rlc
_unittest/test_01EDB.py::TestEDB::test_add_layer
_unittest/test_01EDB.py::TestEDB::test_add_dielectric
_unittest/test_01EDB.py::TestEDB::test_add_conductor
_unittest/test_01EDB.py::TestEDB::test_add_djordievic
_unittest/test_01EDB.py::TestEDB::test_add_debye
_unittest/test_01EDB.py::TestEDB::test_update_layer
_unittest/test_01EDB.py::TestEDB::test_remove_layer
_unittest/test_01EDB.py::TestEDB::test_components
_unittest/test_01EDB.py::TestEDB::test_components_from_net
_unittest/test_01EDB.py::TestEDB::test_resistors
_unittest/test_01EDB.py::TestEDB::test_capacitors
_unittest/test_01EDB.py::TestEDB::test_inductors
_unittest/test_01EDB.py::TestEDB::test_ICs
_unittest/test_01EDB.py::TestEDB::test_IOs
_unittest/test_01EDB.py::TestEDB::test_Others
_unittest/test_01EDB.py::TestEDB::test_Components_by_PartName
_unittest/test_01EDB.py::TestEDB::test_get_through_resistor_list
_unittest/test_01EDB.py::TestEDB::test_get_rats
_unittest/test_01EDB.py::TestEDB::test_get_component_connections
_unittest/test_01EDB.py::TestEDB::test_get_power_tree
_unittest/test_01EDB.py::TestEDB::test_aedt_pinname_pin_position
_unittest/test_01EDB.py::TestEDB::test_get_pins_name_from_net
_unittest/test_01EDB.py::TestEDB::test_delete_single_pin_rlc
_unittest/test_01EDB.py::TestEDB::test_component_rlc
_unittest/test_01EDB.py::TestEDB::test_disable_component
_unittest/test_01EDB.py::TestEDB::test_delete_component
_unittest/test_01EDB.py::TestEDB::test_create_coax_port
_unittest/test_01EDB.py::TestEDB::test_create_siwave_circuit_port
_unittest/test_01EDB.py::TestEDB::test_create_siwave_voltage_source
_unittest/test_01EDB.py::TestEDB::test_create_siwave_current_source
_unittest/test_01EDB.py::TestEDB::test_create_siwave_ac_analsyis
_unittest/test_01EDB.py::TestEDB::test_create_siwave_dc_analsyis
_unittest/test_01EDB.py::TestEDB::test_get_nets_from_pin_list
_unittest/test_01EDB.py::TestEDB::test_mesh_operations
_unittest/test_01EDB.py::TestEDB::test_assign_model
_unittest/test_01EDB.py::TestEDB::test_delete_net
_unittest/test_01EDB.py::TestEDB::test_get_polygons_bounding
_unittest/test_01EDB.py::TestEDB::test_get_polygons_bbylayerandnets
_unittest/test_01EDB.py::TestEDB::test_get_polygons_points
_unittest/test_01EDB.py::TestEDB::test_get_padstack
_unittest/test_01EDB.py::TestEDB::test_set_padstack
_unittest/test_01EDB.py::TestEDB::test_save_edb_as
_unittest/test_01EDB.py::TestEDB::test_parametrize_layout
_unittest/test_01EDB.py::TestEDB::test_import_bom
_unittest/test_01EDB.py::TestEDB::test_create_component_from_pins
_unittest/test_01EDB.py::TestEDB::test_create_cutout
_unittest/test_01EDB.py::TestEDB::test_rvalue
_unittest/test_01EDB.py::TestEDB::test_stackup_limits
_unittest/test_01EDB.py::TestEDB::test_create_polygon
_unittest/test_01EDB.py::TestEDB::test_create_path
_unittest/test_01EDB.py::TestEDB::test_create_edb

============================== warnings summary ===============================
......\Anaconda3\lib\site-packages\pyreadline\py3k_compat.py:8
C:\Anaconda3\lib\site-packages\pyreadline\py3k_compat.py:8: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
return isinstance(x, collections.Callable)

pyaedt\modules\AdvancedPostProcessing.py:25
C:\Users\hzhou\PyAEDT\pyaedt\modules\AdvancedPostProcessing.py:25: UserWarning: The PyVista module required to run some functionalities of PostProcess.
Install with

pip install pyvista

Requires CPython
warnings.warn("The PyVista module required to run some functionalities of PostProcess.\n"

pyaedt\application\AnalysisIcepak.py:261
C:\Users\hzhou\PyAEDT\pyaedt\application\AnalysisIcepak.py:261: DeprecationWarning: invalid escape sequence \d
[float(re.findall("[-+]?[.]?[\d]+(?:,\d\d\d)[.]?\d(?:[eE][-+]?\d+)?", a)[0]) for a in

-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================= 59 passed, 3 warnings in 44.95s =======================
Windows fatal exception: code 0x800706ba

Current thread 0x00001710 (most recent call first):

Windows fatal exception: code 0x800706ba

Current thread 0x00001710 (most recent call first):

Process finished with exit code 0
Launching AEDT installation C:\Program Files\AnsysEM\AnsysEM21.1\Win64

pyaedt Info: pyaedt v0.3.dev0
pyaedt Info: Python version 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
C:\Users\hzhou\AppData\Local\Temp\tmphcm5j4ct\scratchSJKQLY\Galileo.aedb
2021.1
False
['init_dlls', 'self']
opening from EDBLib
Configuring EDB environment for release 2021.1
PASSED [ 1%]PASSED [ 3%]PASSED [ 5%]Primitives Updated
PASSED [ 6%]PASSED [ 8%]PASSED [ 10%]PASSED [ 11%]PASSED [ 13%]PASSED [ 15%]PASSED [ 16%]PASSED [ 18%]PASSED [ 20%]PASSED [ 22%]PASSED [ 23%]PASSED [ 25%]PASSED [ 27%]PASSED [ 28%]PASSED [ 30%]PASSED [ 32%]PASSED [ 33%]PASSED [ 35%]PASSED [ 37%]PASSED [ 38%]PASSED [ 40%]PASSED [ 42%]PASSED [ 44%]PASSED [ 45%]PASSED [ 47%]PASSED [ 49%]PASSED [ 50%]PASSED [ 52%]PASSED [ 54%]PASSED [ 55%]PASSED [ 57%]PASSED [ 59%]PASSED [ 61%]PASSED [ 62%]Windows fatal exception: access violation

Current thread 0x00001710 (most recent call first):
File "C:\Users\hzhou\PyAEDT\pyaedt\edb_core\siwave.py", line 597 in create_pin_group_terminal
File "C:\Users\hzhou\PyAEDT\pyaedt\generic\general_methods.py", line 118 in inner_function
File "C:\Users\hzhou\PyAEDT\pyaedt\edb_core\siwave.py", line 430 in create_current_source
File "C:\Users\hzhou\PyAEDT\pyaedt\generic\general_methods.py", line 118 in inner_function
File "C:\Users\hzhou\PyAEDT_unittest\test_01EDB.py", line 232 in test_create_siwave_current_source
File "C:\Anaconda3\lib\site-packages_pytest\python.py", line 184 in pytest_pyfunc_call
File "C:\Anaconda3\lib\site-packages\pluggy\callers.py", line 187 in _multicall
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 84 in
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
File "C:\Anaconda3\lib\site-packages\pluggy\hooks.py", line 286 in call
File "C:\Anaconda3\lib\site-packages_pytest\python.py", line 1627 in runtest
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 163 in pytest_runtest_call
File "C:\Anaconda3\lib\site-packages\pluggy\callers.py", line 187 in _multicall
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 84 in
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
File "C:\Anaconda3\lib\site-packages\pluggy\hooks.py", line 286 in call
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 256 in
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 310 in from_call
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 255 in call_runtest_hook
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 216 in call_and_report
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 127 in runtestprotocol
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 110 in pytest_runtest_protocol
File "C:\Anaconda3\lib\site-packages\pluggy\callers.py", line 187 in _multicall
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 84 in
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
File "C:\Anaconda3\lib\site-packages\pluggy\hooks.py", line 286 in call
File "C:\Anaconda3\lib\site-packages_pytest\main.py", line 338 in pytest_runtestloop
File "C:\Anaconda3\lib\site-packages\pluggy\callers.py", line 187 in _multicall
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 84 in
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
File "C:\Anaconda3\lib\site-packages\pluggy\hooks.py", line 286 in call
File "C:\Anaconda3\lib\site-packages_pytest\main.py", line 313 in _main
File "C:\Anaconda3\lib\site-packages_pytest\main.py", line 257 in wrap_session
File "C:\Anaconda3\lib\site-packages_pytest\main.py", line 306 in pytest_cmdline_main
File "C:\Anaconda3\lib\site-packages\pluggy\callers.py", line 187 in _multicall
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 84 in
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 93 in hookexec
File "C:\Anaconda3\lib\site-packages\pluggy\hooks.py", line 286 in call
File "C:\Anaconda3\lib\site-packages_pytest\config_init
.py", line 164 in main
File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.1.1\plugins\python-ce\helpers\pycharm_jb_pytest_runner.py", line 43 in
Windows fatal exception: access violation

Current thread 0x00001710 (most recent call first):
File "C:\Users\hzhou\PyAEDT\pyaedt\edb_core\siwave.py", line 597 in create_pin_group_terminal
File "C:\Users\hzhou\PyAEDT\pyaedt\generic\general_methods.py", line 118 in inner_function
File "C:\Users\hzhou\PyAEDT\pyaedt\edb_core\siwave.py", line 430 in create_current_source
File "C:\Users\hzhou\PyAEDT\pyaedt\generic\general_methods.py", line 118 in inner_function
File "C:\Users\hzhou\PyAEDT_unittest\test_01EDB.py", line 232 in test_create_siwave_current_source
File "C:\Anaconda3\lib\site-packages_pytest\python.py", line 184 in pytest_pyfunc_call
File "C:\Anaconda3\lib\site-packages\pluggy\callers.py", line 187 in _multicall
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 84 in
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
File "C:\Anaconda3\lib\site-packages\pluggy\hooks.py", line 286 in call
File "C:\Anaconda3\lib\site-packages_pytest\python.py", line 1627 in runtest
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 163 in pytest_runtest_call
File "C:\Anaconda3\lib\site-packages\pluggy\callers.py", line 187 in _multicall
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 84 in
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
File "C:\Anaconda3\lib\site-packages\pluggy\hooks.py", line 286 in call
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 256 in
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 310 in from_call
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 255 in call_runtest_hook
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 216 in call_and_report
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 127 in runtestprotocol
File "C:\Anaconda3\lib\site-packages_pytest\runner.py", line 110 in pytest_runtest_protocol
File "C:\Anaconda3\lib\site-packages\pluggy\callers.py", line 187 in _multicall
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 84 in
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
File "C:\Anaconda3\lib\site-packages\pluggy\hooks.py", line 286 in call
File "C:\Anaconda3\lib\site-packages_pytest\main.py", line 338 in pytest_runtestloop
File "C:\Anaconda3\lib\site-packages\pluggy\callers.py", line 187 in _multicall
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 84 in
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
File "C:\Anaconda3\lib\site-packages\pluggy\hooks.py", line 286 in call
File "C:\Anaconda3\lib\site-packages_pytest\main.py", line 313 in _main
File "C:\Anaconda3\lib\site-packages_pytest\main.py", line 257 in wrap_session
File "C:\Anaconda3\lib\site-packages_pytest\main.py", line 306 in pytest_cmdline_main
File "C:\Anaconda3\lib\site-packages\pluggy\callers.py", line 187 in _multicall
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 84 in
File "C:\Anaconda3\lib\site-packages\pluggy\manager.py", line 93 in hookexec
File "C:\Anaconda3\lib\site-packages\pluggy\hooks.py", line 286 in call
File "C:\Anaconda3\lib\site-packages_pytest\config_init
.py", line 164 in main
File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.1.1\plugins\python-ce\helpers\pycharm_jb_pytest_runner.py", line 43 in
PASSED [ 64%]**************************************************************
pyaedt Error on Method create_pin_group_terminal: General or AEDT Error. Please Check again
Arguments Provided:
source = <pyaedt.edb_core.siwave.CurrentSource object at 0x0000026D46DA5310>

Object reference not set to an instance of an object.
at Ansys.Ansoft.Edb.Cell.Terminal.PinGroupTerminal.Create(Layout layout, Net net, String name, PinGroup pinGroup, Boolean isRef)
File "C:\Users\hzhou\PyAEDT\pyaedt\edb_core\siwave.py", line 597, in create_pin_group_terminal
neg_pingroup_terminal = self.edb.Cell.Terminal.PinGroupTerminal.Create(self.active_layout,neg_node_net,neg_pingroup_term_name , neg_pin_group[1], False)

Method Docstring:

None


PASSED [ 66%]PASSED [ 67%]PASSED [ 69%]PASSED [ 71%]PASSED [ 72%]PASSED [ 74%]PASSED [ 76%]PASSED [ 77%]PASSED [ 79%]PASSED [ 81%]PASSED [ 83%]PASSED [ 84%]PASSED [ 86%]PASSED [ 88%]PASSED [ 89%]PASSED [ 91%]PASSED [ 93%]PASSED [ 94%]PASSED [ 96%]Primitives Updated
PASSED [ 98%]Primitives Updated
PASSED [100%]active cell set
`

Refactor Desktop handling

If the Desktop option AlwaysNew=False is set, then an existing Desktop will be used even if the non-graphical setting is not as defined by the NG setting. We need to identify when a session is running in graphical/non-graphical mode and open a new session if the NG of the existign session is not as desired

Docstring Style: Add Examples

There's a variety of discussions about this online, but I personally feel that the numpydoc style is more readable. For example:

https://github.com/pyansys/PyAEDT/blob/76d2b68f2319a136bc0ae8823a74b9e0e150bf0d/pyaedt/maxwell.py#L196-L203

Converted to:

"""Assign voltage source to face list.

Parameters
----------
face_list : list
    List of faces.
amplitude : float
    Voltage amplitude in mV
name : str
    Boundary name.

Returns
-------
:class:`BoundaryObject`
    Boundary object.

Examples
--------
>>> ...
"""

Assigning design variable to parameter "amplitude" Maxwell2d.assign_current() does not work.

Running the following line of code runs successfully:

m2d = Maxwell2d(designname=design_name, NG=True, solution_type=solution) m2d.modeler.model_units = "mm" current_boundary = m2d.assign_current([coil], amplitude=10, phase="0deg", solid=True, swap_direction=False, name="Current1").

A current condition on the coil object is created with an amplitude of 10A. However, when a an existing design variable is assigned to the amplitude parameter, the code runs but the variable is not assigned to the current condition.

m2d["I1"] = "10A" current_boundary = m2d.assign_current([coil], amplitude="I1", phase="0deg", solid=True, swap_direction=False, name="Current1")

No exception or error is caught.

A reference code is attached in this issue.
PyAEDT_M2D_DesignVariable_AssignCurrent.zip
PyAEDT_M2D_DesignVariable_AssignCurrent.txt

Thanks and best regards
ganett

Maxwell 2D example in Example gallery does not work in PyCharm

Hallo,

some functions in this example gave me errors, i.e:

  1. function: duplicate_along_line is no longer an attribute of rect1 as in the example:
    added = rect1.duplicate_along_line([14,0,0])
  2. edge list no longer exists as attribute as in the example:
    m2d.assign_balloon(region.edges)
  3. the function:
    m2d.save_project(pName+'.aedt')
    did not save

below you can find how I corrected the script.
Thank you
Tiziana



import os
from pyaedt import Maxwell2d

NonGraphical = False

pathN = "C:\\MyFolder\\"
pName = "Example"
dName = "MyMaxwell2DDesign1"
sName = "MySetupAuto"
sType = "TransientXY"

m2d=Maxwell2d(projectname=pathN+pName,designname=dName,solution_type="TransientXY", specified_version="2021.1",NG=False)


rect1 = m2d.modeler.primitives.create_rectangle([0,0,0],[20,10],"Rectangle1", "copper")
m2d.modeler.duplicate_along_line("Rectangle1",[14,0,0],nclones=2,attachObject=False)
region = m2d.modeler.primitives.create_region([100,100,100,100,100,100])


region_edge_list = m2d.modeler.primitives.get_object_edges("Region")
m2d.assign_balloon(region_edge_list,bound_name= "MyBalloon")

m2d.assign_winding(["Rectangle1","Rectangle1_1"],winding_type="Current",current_value=2, parallel_branches=1, name="PH_A")

setup = m2d.create_setup(setupname="MySetupAuto")
setup.props["StopTime"] ="0.02s"
setup.props["TimeStep"] = "0.0002s"
setup.props["SaveFieldsType"] = "Every N Steps"
setup.props["N Steps"] = "1"
setup.props["Steps From"] ="0s"
setup.props["Steps To"] = "0.002s"
setup.update()

m2d.post.create_rectangular_plot("InputCurrent(PH_A)",primary_sweep_variable="Time", families_dict={"Time":["All"]}, plotname="Winding Plot 1")
m2d.analyze_setup("MySetupAuto")

PyAEDT create setup Error

Hi
I'm trying to use PyAEDT but I had this error when I want to create Setup (Maxwell 2D Coil Analysis)
by the way this link (https://github.com/pyansys/PyAEDT/issues) don't work, that's why I post this here.
(I'm using AEDT 2019R1 and anaconda)

**************************************************************
pyaedt Error on Method create:  General or AEDT Error. Please Check again
Arguments Provided: 

(-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024381), None)
  File "d:\Anaconda3\lib\site-packages\pyaedt\modules\SolveSetup.py", line 147, in create
    self.omodule.InsertSetup(soltype, arg)



Method Docstring: 

Insert a new Setup based on Class settings into the AEDT Application
        
        :return: the argument list

        Parameters
        ----------

        Returns
        -------

        
************************************************************
**************************************************************
pyaedt Error on Method create_setup:  Index Error. Please Check again
Arguments Provided: 
    setupname = None 
    setuptype = None 
    props = None 

list index out of range
  File "d:\Anaconda3\lib\site-packages\pyaedt\application\Analysis.py", line 693, in create_setup
    self.analysis_setup = name



Method Docstring: 

Create a new Setup.

        Parameters
        ----------
        setupname :
            optional, name of the new setup (Default value = "MySetupAuto")
        setuptype :
            optional, setup type. if None, default type will be applied
        props :
            optional dictionary of properties with values (Default value = {})

        Returns
        -------
        Setup
            setup object

        
************************************************************

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-05484889c7a9> in <module>
      1 Setup = M3D.create_setup()
----> 2 Setup.props["MaximumPasses"] = 12
      3 Setup.props["MinimumPasses"] = 2
      4 Setup.props["MinimumConvergedPasses"] = 1
      5 Setup.props["PercentRefinement"] = 30

AttributeError: 'bool' object has no attribute 'props'

EdBSiwave versus EdbSiwave

Possible capitalization error. EdBSiwave likely should be EdbSiwave, This might mean some refactoring throughout the package.

Provide update method for Design Class

At present, the following functions call the Design.init() function due to the lack of an appropriate update function.

insert_design
set_active_design
copy_design_from
duplicate_design

It is proposed to develop an update() function to avoid losing the pointer to Design due to the constructor call

parameter solution_type versus solutiontype

In the FieldAnalysis3D class (pyaedt/application/Analysis3D), solutiontype (with no hyphen) is used. In the FieldAnalysis2D class (Analysis2D in the same folder), (and in most other places, solution_type is used.

Additional README.rst Sections

Since our docs are shared on PyPi and GitHub, we need to add two sections:

  • Documentation
  • Installation

Both should be very short, but we need to give users enough to get started, especially from PyPi.

Expliticilty versus explicitly

In modeler.py, we have the method explicitiyly_subtract that but explicitiyly is misspelled. It should be explicitly.

Possibly redundant methods in Q2d.py

The Q2d.py file has two methods with the same descriptions:
analyse_from_initial_mesh
analyse_nominal

Only analyse_nominal appears in Q3d.py.
Perhaps the descriptions are wrong in Q2d.py?

Discussion: copyright boilerplate

Module boilerplate may not be necessary. We're waiting on direction from legal, but DPF and PyMAPDL have copyright and licencing all within the MIT license.

Disclaimer
==================================================
**Copyright (c) 1986-2021, ANSYS Inc. unauthorised use, distribution or duplication is prohibited**

**This tool release is unofficial and not covered by standard Ansys Support license.**

Parameter "axisdir"

The parameter "axisdir" descriptions do not always seem to be correct. For example, within the file HFSS.py, it is described as string with a default value of XYNE. However, most of the time, the function signature shows a default of 0. Alex indicated that this didn't seem to make sense and that you should look at it.
In one case, the description for "axisdir" is "Position of the VS." What is VS. We should spell out abbreviations and acronyms or provide more hints if the terminology isn't well know. Alex said he thought VS might the voltage of a transistor's source terminal, but he wasn't certain.

Command get_component_from_net() reports error


pyaedt Error on Method get_component_from_net: Attribute Error. Please Check again
Arguments Provided:
net_name = V1P0_S0

'0, Culture=neutral, PublicKeyToken=null]]' object has no attribute 'GetComponent'
File "C:\Users\hzhou\PyAEDT\pyaedt\edb_core\nets.py", line 201, in get_component_from_net
return list(set([net for net in edb_net.Terminals.GetComponent().GetName()]))

Method Docstring:

None


Parameter questions/issues

Hffs.py file contains parameter descriptions that are a bit confusing or different from other files. We'd like to strive for consistency.

Lumped--The HFSS has a few function functions and parameter descriptions with lumped in them. Some of these seem like they might need to be rewritten.

For the parameter "sweeptype," choices are listed here have initial captial letters. I know in another file, I saw them as lower case. Can they standardized. If so, which form is preferred. Alex said that there may be an API variation between the different products.

For one occurrence, the description for the parameter "startobj" has this additional sentence: This is typically the reference plane.
Should this sentence be added to the description of all occurrences of "startobj"?

Add doc coverage CI/CD

Add CI/CD unit test discovery/coverage.

  1. Loops through all modules in the pyaedt directory. Record if classes, modules, and functions have a doctest example section. Skip private methods.
  2. Produce a text report indicating module coverage. For example:
Name                                         Methods   Miss  Cover
------------------------------------------------------------------
pyaedt/hfss.py                                    53     16    70%
pyaedt/<other_module>.py                         200    200     0%
  1. Add this to CI/CD in github within the doctest in ci-build.yml as a "always run" step.

closing project closes application

To reproduce

  1. Start AEDT 21.2 manually.
  2. Launch a Python kernel and create an instance of an Hfss() app.
  3. Insert a new project/design
  4. Close the HFSS project without saving it
    -> The AEDT desktop closes.

Example EDB_Create_VIA broken

Ran into an issue on main when attempting documentation build on Python 3.8

File "C:\Users\ansys\source\PyAEDT\examples\00-basic-examples\EDB_Create_VIA.py", line 37, in <module>
    path = edb.core_primitives.Shape('polygon', points=points)
TypeError: Shape() takes no arguments

JobManager.py in Application folder

def update_config_name(self, name, machinename):
"""Update the name of the machine.

I believe there is an error here (line 144) as this is supposed to be for updating the name of the configuration file yet asks for the name of the machine. There was already a method for updating the machine name.

Also, I don't see this page appearing yet in the API Doc.

UDP Parametrization needs expanding to handle Version and NoOfParameters fields

This is a recorded version of drawing an RMxprt UDP. In our pyaedt implementation of primitives.create_udp we do not supply the parameters Version of NoOfParameters. This causes the RMXprt/PMCore upd to fail.
oEditor.CreateUserDefinedPart(
[
"NAME:UserDefinedPrimitiveParameters",
"DllName:=" , "RMxprt/PMCore.dll",
"Version:=" , "12.0",
"NoOfParameters:=" , 13,
"Library:=" , "syslib",
[
"NAME:ParamVector",
[
"NAME:Pair",
"Name:=" , "DiaGap",
"Value:=" , "RotorDia"
],

unwanted prefix in source/sink names

When source name is defined as below
self.edbapp.core_siwave.create_voltage_source("U2A5","V1P5_S3","U2A5","GND",3.3,0, source_name="U2A5-V1P5_S3")

The actual source name created is V1P5_S3_U2A5-V1P5_S3.

create_voltage_source() automatically adds net name as prefiex. It is desired to be able to remove the prefix.

create_current_source() has the same issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.