ansys / pyaedt

AEDT Python Client Package
https://aedt.docs.pyansys.com
MIT License
185 stars 101 forks source link

Cannot choose the coordinate system when using `Hfss.assign_primary` #1286

Closed tgoncalv closed 2 years ago

tgoncalv commented 2 years ago

Before submitting the issue

Description of the bug

Hfss.assign_primary() allows to add a primary boundary in HFSS. To do so, we need to create a vector U by specifying the coordinates of its starting and ending point.

In HFSS, we can specify these points by using a specific coordinate system: image

There is also a parameter called coord_name in Hfss.assign_primary() which should allow us to choose a specific coordinate system. However, this parameter doesn't work for me....

Steps To Reproduce

from pyaedt import Hfss

app = Hfss(non_graphical=True)
box = app.modeler.create_box([0, 0, 0], [2, 2, 2])
box_face = box.faces[0]

cs = app.modeler.create_face_coordinate_system(
        face=box_face,
        origin=box_face,
        axis_position=box_face.edges[0],
        name='face_cs',
)

app.assign_primary(
        face=box_face,
        u_start=[0, 0, 0],
        u_end=[0.5, 0, 0],
        coord_name=cs.name,
)

Error obtained when running this script:

pyaedt error: Method create Failed:  General or AEDT Error. Please Check again
Method create Failed:  General or AEDT Error. Please Check again
pyaedt error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024381), None)
(-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024381), None)
pyaedt error: Project: Project53, Design: HFSS_VAX (DrivenModal), [error] Script macro error: Boundary 'Primary_C1525F': The U Vector for the coordinate system must lie in the plane of the boundary face. (10:06:54 AM  Jun 15, 2022)

Project: Project53, Design: HFSS_VAX (DrivenModal), [error] Script macro error: Boundary 'Primary_C1525F': The U Vector for the coordinate system must lie in the plane of the boundary face. (10:06:54 AM  Jun 15, 2022)

pyaedt error: Arguments Provided:
Arguments Provided:
pyaedt error: Error in :   File "C:\Users\tgoncalv\AppData\Local\pypoetry\Cache\virtualenvs\quick-eH6UxcaV-py3.9\lib\site-packages\pyaedt\modules\Boundary.py", line 345, in create
Error in :   File "C:\Users\tgoncalv\AppData\Local\pypoetry\Cache\virtualenvs\quick-eH6UxcaV-py3.9\lib\site-packages\pyaedt\modules\Boundary.py", line 345, in create
pyaedt error: Check Online documentation on: https://aedtdocs.pyansys.com/search.html?q=create
Check Online documentation on: https://aedtdocs.pyansys.com/search.html?q=create
pyaedt error: Error in boundary creation for Primary Primary_C1525F.
Error in boundary creation for Primary Primary_C1525F.

Please note that I don't get this error when I change assign_primary by this:

app.assign_primary(
        face=box_face,
        u_start=[1, 1, 2],
        u_end=[1.5, 1, 2],
        coord_name=cs.name,
)

Here, u_start and u_end is located with regard to the Global coordinate system, despite that I explicitly say that I want to use another coordinate system.

Which Operating System are you using?

Windows

Which Python version are you using?

3.9

Installed packages

aiohttp 3.8.1 Async http client/server framework (asyncio) aiosignal 1.2.0 aiosignal: a list of registered asynchronous callbacks appdirs 1.4.4 A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir". argon2-cffi 21.3.0 The secure Argon2 password hashing algorithm. argon2-cffi-bindings 21.2.0 Low-level CFFI bindings for Argon2 astroid 2.11.6 An abstract syntax tree for Python with inference support. async-timeout 4.0.2 Timeout context manager for asyncio programs atomicwrites 1.4.0 Atomic file writes. attrs 21.4.0 Classes Without Boilerplate backcall 0.2.0 Specifications for callback functions passed in to an API beautifulsoup4 4.11.1 Screen-scraping library black 22.3.0 The uncompromising code formatter. bleach 5.0.0 An easy safelist-based HTML-sanitizing tool. cffi 1.15.0 Foreign Function Interface for Python calling C code. charset-normalizer 2.0.12 The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet. click 8.1.3 Composable command line interface toolkit codespell 2.1.0 Codespell colorama 0.4.4 Cross-platform colored terminal text. coverage 6.4.1 Code coverage measurement for Python cycler 0.11.0 Composable style cycles debugpy 1.6.0 An implementation of the Debug Adapter Protocol for Python decorator 5.1.1 Decorators for Humans defusedxml 0.7.1 XML bomb protection for Python stdlib modules dill 0.3.5.1 serialize all of python entrypoints 0.4 Discover and load entry points from installed packages. fastjsonschema 2.15.3 Fastest Python implementation of JSON schema flake8 3.9.2 the modular source code checker: pep8 pyflakes and co flake8-quotes 3.3.1 Flake8 lint for quotes. fonttools 4.33.3 Tools to manipulate font files frozenlist 1.3.0 A list-like structure which implements collections.abc.MutableSequence ghp-import 2.1.0 Copy your docs directly to the gh-pages branch. griffe 0.20.0 Signatures for entire Python programs. Extract the structure, the frame, the skeleton of your project, to generate API documentation or find breaking changes in ...
idna 3.3 Internationalized Domain Names in Applications (IDNA) imageio 2.19.3 Library for reading and writing a wide range of image, video, scientific, and volumetric data formats. importlib-metadata 4.11.4 Read metadata from Python packages iniconfig 1.1.1 iniconfig: brain-dead simple config-ini parsing ipykernel 6.14.0 IPython Kernel for Jupyter ipython 7.34.0 IPython: Productive Interactive Computing ipython-genutils 0.2.0 Vestigial utilities from IPython isort 5.10.1 A Python utility / library to sort Python imports. jedi 0.18.1 An autocompletion tool for Python that can be used for text editors. jinja2 3.1.2 A very fast and expressive template engine. jsonschema 4.6.0 An implementation of JSON Schema validation for Python jupyter-client 7.3.4 Jupyter protocol implementation and client libraries jupyter-core 4.10.0 Jupyter core package. A base package on which Jupyter projects rely. jupyterlab-pygments 0.2.2 Pygments theme using JupyterLab CSS variables jupyterlab-server (!) 2.14.0 A set of server components for JupyterLab and JupyterLab like applications. kiwisolver 1.4.3 A fast implementation of the Cassowary constraint solver lazy-object-proxy 1.7.1 A fast and thorough lazy object proxy. markdown 3.3.7 Python implementation of Markdown. markupsafe 2.1.1 Safely add untrusted strings to HTML/XML markup. matplotlib 3.5.2 Python plotting package matplotlib-inline 0.1.3 Inline Matplotlib backend for Jupyter mccabe 0.6.1 McCabe checker, plugin for flake8 mergedeep 1.3.4 A deep merge function for 🐍. mistune 0.8.4 The fastest markdown parser in pure Python mkdocs 1.3.0 Project documentation with Markdown. mkdocs-autorefs 0.4.1 Automatically link across pages in MkDocs. mkdocs-material 8.3.5 Documentation that simply works mkdocs-material-extensions 1.0.3 Extension pack for Python Markdown. mkdocstrings 0.18.1 Automatic documentation from sources, for MkDocs. mkdocstrings-python 0.6.6 A Python handler for mkdocstrings. mkdocstrings-python-legacy 0.2.2 A legacy Python handler for mkdocstrings. mpmath 1.2.1 Python library for arbitrary-precision floating-point arithmetic multidict 6.0.2 multidict implementation mypy 0.901 Optional static typing for Python mypy-extensions 0.4.3 Experimental type system extensions for programs checked with the mypy typechecker. nbclient 0.6.4 A client library for executing notebooks. Formerly nbconvert's ExecutePreprocessor. nbconvert 6.5.0 Converting Jupyter Notebooks nbformat 5.4.0 The Jupyter Notebook format nest-asyncio 1.5.5 Patch asyncio to allow nested event loops notebook 6.4.12 A web-based notebook environment for interactive computing numpy 1.22.4 NumPy is the fundamental package for array computing with Python. packaging 21.3 Core utilities for Python packages pandocfilters 1.5.0 Utilities for writing pandoc filters in python parso 0.8.3 A Python Parser pastel 0.2.1 Bring colors to your terminal. pathspec 0.9.0 Utility library for gitignore style pattern matching of file paths. pickleshare 0.7.5 Tiny 'shelve'-like database with concurrency support pillow 9.1.1 Python Imaging Library (Fork) platformdirs 2.5.2 A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir". pluggy 1.0.0 plugin and hook calling mechanisms for python plumbum 1.7.2 Plumbum: shell combinators library poethepoet 0.10.0 A task runner that works well with poetry. prometheus-client 0.14.1 Python client for the Prometheus monitoring system. prompt-toolkit 3.0.29 Library for building powerful interactive command lines in Python psutil 5.9.1 Cross-platform lib for process and system monitoring in Python. py 1.11.0 library with cross-python path, ini-parsing, io, code, log facilities pyaedt 0.4.83 Higher-Level Pythonic Ansys Electronics Desktop Framework pycodestyle 2.7.0 Python style guide checker pycparser 2.21 C parser in Python pyflakes 2.3.1 passive checker of Python programs pygments 2.12.0 Pygments is a syntax highlighting package written in Python. pylint 2.14.2 python code static checker pymdown-extensions 9.5 Extension pack for Python Markdown. pyparsing 3.0.9 pyparsing module - Classes and methods to define and execute parsing grammars pyrsistent 0.18.1 Persistent/Functional/Immutable data structures pytest 6.2.5 pytest: simple powerful testing with Python pytest-sugar 0.9.4 pytest-sugar is a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show tests that fail instantly). python-dateutil 2.8.2 Extensions to the standard Python datetime module pythonnet 2.5.2 .Net and Mono integration for Python pytkdocs 0.16.1 Load Python objects documentation. pyvista 0.34.1 Easier Pythonic interface to VTK pywin32 304 Python for Window Extensions pywinpty 2.0.5 Pseudo terminal support for Windows from Python. pyyaml 6.0 YAML parser and emitter for Python pyyaml-env-tag 0.1 A custom YAML tag for referencing environment variables in YAML files. pyzmq 23.1.0 Python bindings for 0MQ rpyc 5.0.1 Remote Python Call (RPyC), a transparent and symmetric RPC library scooby 0.5.12 A Great Dane turned Python environment detective send2trash 1.8.0 Send file to trash natively under Mac OS X, Windows and Linux. setuptools-scm 6.4.2 the blessed package to manage your versions by scm tags shapely 1.8.2 Geometric objects, predicates, and operations six 1.16.0 Python 2 and 3 compatibility utilities soupsieve 2.3.2.post1 A modern CSS selector implementation for Beautiful Soup. sympy 1.10.1 Computer algebra system (CAS) in Python termcolor 1.1.0 ANSII Color formatting for output in terminal. terminado 0.15.0 Tornado websocket backend for the Xterm.js Javascript terminal emulator library. tinycss2 1.1.1 A tiny CSS parser toml 0.10.2 Python Library for Tom's Obvious, Minimal Language tomli 2.0.1 A lil' TOML parser tomlkit 0.11.0 Style preserving TOML library tornado 6.1 Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed. traitlets 5.2.2.post1 typing-extensions 4.2.0 Backported and Experimental Type Hints for Python 3.7+ vtk 9.1.0 VTK is an open-source toolkit for 3D computer graphics, image processing, and visualization watchdog 2.1.9 Filesystem events monitoring wcwidth 0.2.5 Measures the displayed width of unicode strings in a terminal webencodings 0.5.1 Character encoding aliases for legacy web content wrapt 1.14.1 Module for decorators, wrappers and monkey patching. wslink 1.6.5 Python/JavaScript library for communicating over WebSocket yarl 1.7.2 Yet another URL library zipp 3.8.0 Backport of pathlib-compatible object wrapper for zip files

Samuelopez-ansys commented 2 years ago

Hi @tgoncalv ,

I have tested my machine with python 3.7 and 3.9 and AEDT 2022r1 and it works. The only difference could be the AEDT version, which one are you using?

You could debug and go to "assign_primary" method and check what is inside "props: image

tgoncalv commented 2 years ago

Hi @Samuelopez-ansys , Thanks for your comment, I was using AEDT 2021r1 but I upgraded it to 2022r2 and this feature now works.