ansys / pyaedt

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

Bug located in AdvancedPostProcessing.PostProcessor.create_fieldplot_surface() #1350

Closed obrienpja closed 2 years ago

obrienpja commented 2 years ago

Before submitting the issue

Description of the bug

I am trying to plot the electric vector field for a device using pyaedt, like how I have plotted it with the GUI as shown in the following picture: Screen Shot 2022-07-01 at 11 37 25 AM I cannot find the proper API call to plot the electric vector field, so I am wondering if there is a bug with AdvancedPostProcessing.PostProcessor.create_fieldplot_surface(). I get the following error when trying to create the fieldplot: design.post.create_fieldplot_surface(objlist=[design._modeler.object_list[0].faces[0]], quantityName='Vector_E1', setup_name='Setup') 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: pyaedt-sample, Design: Readout (Eigenmode), [error] Script macro error: Plot definition data is not valid for this defintion type. (11:08:02 AM Jul 01, 2022)

Project: pyaedt-sample, Design: Readout (Eigenmode), [error] Script macro error: Plot definition data is not valid for this defintion type. (11:08:02 AM Jul 01, 2022)

pyaedt error: Arguments Provided: Arguments Provided: pyaedt error: Error in : File "C:\Users\patrick.obrien\AppData\Roaming\Python\Python39\site-packages\pyaedt\modules\PostProcessor.py", line 1811, in create Error in : File "C:\Users\patrick.obrien\AppData\Roaming\Python\Python39\site-packages\pyaedt\modules\PostProcessor.py", line 1811, 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 False pydevd warning: Getting attribute FacePrimitive.normal was slow (took 0.23s)

The key part here is that no matter what I try, I am always getting the error: Project: pyaedt-sample, Design: Readout (Eigenmode), [error] Script macro error: Plot definition data is not valid for this defintion type. (11:08:02 AM Jul 01, 2022)

Steps To Reproduce

Create an HFSS Eigenmode design, and solve for a mode, then run the following script:

import pyaedt import os

desktopVersion = "2021.2" NewThread = False non_graphical = os.getenv("PYAEDT_NON_GRAPHICAL", "False").lower() in ("true", "1", "t") desktop = pyaedt.Desktop(desktopVersion, non_graphical=non_graphical, new_desktop_session=NewThread)

design = pyaedt.Hfss('pyaedt-sample', 'Readout') design.post.create_fieldplot_surface(objlist=[design._modeler.object_list[0].faces[0]], quantityName='Vector_E1', setup_name='Setup')

Which Operating System are you using?

Windows

Which Python version are you using?

3.9

Installed packages

addict @ file:///home/conda/feedstock_root/build_artifacts/addict_1636818143388/work aiohttp==3.8.1 aiosignal==1.2.0 alabaster==0.7.12 anyio==3.6.1 appdirs==1.4.4 argon2-cffi @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi_1640817743617/work argon2-cffi-bindings @ file:///D:/bld/argon2-cffi-bindings_1640855319298/work asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1618968359944/work async-timeout==4.0.2 attrdict==2.0.1 attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1640799537051/work Babel @ file:///home/conda/feedstock_root/build_artifacts/babel_1619719576210/work backcall @ file:///home/conda/feedstock_root/build_artifacts/backcall_1592338393461/work backports.functools-lru-cache @ file:///home/conda/feedstock_root/build_artifacts/backports.functools_lru_cache_1618230623929/work beautifulsoup4==4.11.1 bleach @ file:///home/conda/feedstock_root/build_artifacts/bleach_1629908509068/work branca @ file:///home/conda/feedstock_root/build_artifacts/branca_1609346930842/work brotlipy @ file:///D:/bld/brotlipy_1636012392748/work cached-property @ file:///home/conda/feedstock_root/build_artifacts/cached_property_1615209429212/work certifi==2021.10.8 cffi @ file:///D:/bld/cffi_1636046278333/work charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1644853463426/work click @ file:///D:/bld/click_1645238380970/work click-plugins==1.1.1 cligj @ file:///home/conda/feedstock_root/build_artifacts/cligj_1633637764473/work colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1602866480661/work cryptography @ file:///D:/bld/cryptography_1639699435873/work cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1635519461629/work Cython @ file:///D:/bld/cython_1645125674910/work debugpy @ file:///D:/bld/debugpy_1636043436560/work decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1641555617451/work defusedxml @ file:///home/conda/feedstock_root/build_artifacts/defusedxml_1615232257335/work descartes==1.1.0 docutils @ file:///D:/bld/docutils_1637111416553/work entrypoints @ file:///home/conda/feedstock_root/build_artifacts/entrypoints_1643888246732/work executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1646044401614/work fastjsonschema==2.15.3 Fiona==1.8.20 flit_core @ file:///home/conda/feedstock_root/build_artifacts/flit-core_1645629044586/work/source/flit_core folium @ file:///home/conda/feedstock_root/build_artifacts/folium_1638560701663/work fonttools @ file:///D:/bld/fonttools_1646922212616/work frozenlist==1.3.0 GDAL==3.4.0 gdspy @ file:///D:/bld/gdspy_1642165494955/work geopandas @ file:///home/conda/feedstock_root/build_artifacts/geopandas_1638382567988/work h5py @ file:///D:/bld/h5py_1637964127763/work idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1642433548627/work imageio==2.19.3 imagesize @ file:///home/conda/feedstock_root/build_artifacts/imagesize_1636492669893/work importlib-metadata @ file:///D:/bld/importlib-metadata_1646003705675/work importlib-resources @ file:///home/conda/feedstock_root/build_artifacts/importlib_resources_1635615662634/work ipykernel @ file:///D:/bld/ipykernel_1644980088950/work/dist/ipykernel-6.9.1-py3-none-any.whl ipython @ file:///D:/bld/ipython_1646325032429/work ipython-genutils==0.2.0 ipywidgets @ file:///home/conda/feedstock_root/build_artifacts/ipywidgets_1631590360471/work jedi @ file:///D:/bld/jedi_1637175252639/work Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1636510082894/work joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1633637554808/work json5==0.9.8 jsonschema @ file:///home/conda/feedstock_root/build_artifacts/jsonschema-meta_1642000296051/work jupyter @ file:///D:/bld/jupyter_1637233338215/work jupyter-client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1642858610849/work jupyter-console @ file:///home/conda/feedstock_root/build_artifacts/jupyter_console_1646669715337/work jupyter-core @ file:///D:/bld/jupyter_core_1645024665167/work jupyter-server==1.17.1 jupyterlab==3.4.3 jupyterlab-pygments @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_pygments_1601375948261/work jupyterlab-server==2.14.0 jupyterlab-widgets @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_widgets_1631590465624/work kiwisolver @ file:///D:/bld/kiwisolver_1635836893295/work mapclassify @ file:///home/conda/feedstock_root/build_artifacts/mapclassify_1627363180059/work MarkupSafe @ file:///D:/bld/markupsafe_1646594904184/work matplotlib @ file:///D:/bld/matplotlib-suite_1639359208125/work matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1631080358261/work mistune @ file:///D:/bld/mistune_1635844891406/work mpmath @ file:///home/conda/feedstock_root/build_artifacts/mpmath_1612895720168/work multidict==6.0.2 munch==2.5.0 munkres==1.1.4 nbclassic==0.3.7 nbclient @ file:///home/conda/feedstock_root/build_artifacts/nbclient_1646594625097/work nbconvert==6.5.0 nbformat==5.4.0 nest-asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1638419302549/work networkx @ file:///home/conda/feedstock_root/build_artifacts/networkx_1646497321764/work notebook @ file:///home/conda/feedstock_root/build_artifacts/notebook_1643149609895/work notebook-shim==0.1.0 numpy @ file:///D:/bld/numpy_1646717418487/work packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1637239678211/work pandas @ file:///D:/bld/pandas_1644670226603/work pandocfilters @ file:///home/conda/feedstock_root/build_artifacts/pandocfilters_1631603243851/work parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1638334955874/work patsy @ file:///home/conda/feedstock_root/build_artifacts/patsy_1632667180946/work pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work Pillow @ file:///D:/bld/pillow_1645323413835/work Pint @ file:///home/conda/feedstock_root/build_artifacts/pint_1635280347517/work plumbum==1.7.2 prometheus-client @ file:///home/conda/feedstock_root/build_artifacts/prometheus_client_1643395600215/work prompt-toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1644497866770/work psutil==5.9.1 pure-eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1642875951954/work pyaedt==0.4.83 pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work pyEPR-quantum @ file:///home/conda/feedstock_root/build_artifacts/pyepr-quantum_1644532426628/work Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1641580240686/work pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1643496850550/work pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1642753572664/work pyproj @ file:///D:/bld/pyproj_1637204025520/work PyQt5==5.12.3 PyQt5_sip==4.19.18 PyQtChart==5.12 PyQtWebEngine==5.12.1 pyrsistent @ file:///D:/bld/pyrsistent_1642534576025/work PySocks @ file:///D:/bld/pysocks_1635862562854/work python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work pythonnet @ https://github.com/pyansys/PyAEDT/raw/release/0.3/pythonnet-2.5.2-cp39-cp39-win_amd64.whl pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1633452062248/work pyvista==0.34.1 pywin32==303 pywinpty @ file:///D:/bld/pywinpty_1646497765404/work/target/wheels/pywinpty-2.0.5-cp39-none-win_amd64.whl pyzmq @ file:///D:/bld/pyzmq_1635877415276/work -e git+ssh://git@github.com/Qiskit/qiskit-metal.git@0443cfc1e73aa607333efbd35a631fd8f6c8bcc4#egg=qiskit_metal qtconsole @ file:///home/conda/feedstock_root/build_artifacts/qtconsole-base_1640876679830/work QtPy @ file:///home/conda/feedstock_root/build_artifacts/qtpy_1643828301492/work qutip==4.6.3 requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1641580202195/work rpyc==5.0.1 Rtree @ file:///D:/bld/rtree_1637430982672/work scikit-learn @ file:///D:/bld/scikit-learn_1640464393983/work scipy @ file:///C:/bld/scipy_1644357595180/work scooby==0.5.12 scqubits @ file:///D:/bld/scqubits_1631102535941/work seaborn @ file:///home/conda/feedstock_root/build_artifacts/seaborn-split_1629095986539/work Send2Trash @ file:///home/conda/feedstock_root/build_artifacts/send2trash_1628511208346/work Shapely==1.8.0 six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work sniffio==1.2.0 snowballstemmer @ file:///home/conda/feedstock_root/build_artifacts/snowballstemmer_1637143057757/work soupsieve==2.3.2.post1 Sphinx @ file:///home/conda/feedstock_root/build_artifacts/sphinx_1642707669519/work sphinx-rtd-theme @ file:///home/conda/feedstock_root/build_artifacts/sphinx_rtd_theme_1631863601352/work sphinxcontrib-applehelp==1.0.2 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-htmlhelp_1621704829796/work sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-serializinghtml_1637000050264/work stack-data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1644872665635/work statsmodels @ file:///D:/bld/statsmodels_1644535868573/work sympy @ file:///D:/bld/sympy_1646599698375/work terminado @ file:///D:/bld/terminado_1646684769523/work testpath @ file:///home/conda/feedstock_root/build_artifacts/testpath_1645693042223/work threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1643647933166/work tinycss2==1.1.1 tornado @ file:///D:/bld/tornado_1635819745510/work tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1646031859244/work traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1635260543454/work typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1644850595256/work unicodedata2 @ file:///D:/bld/unicodedata2_1640031227379/work urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1641584929973/work vtk==9.1.0 wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1600965781394/work webencodings==0.5.1 websocket-client==1.3.2 widgetsnbextension @ file:///D:/bld/widgetsnbextension_1637174379490/work win-inet-pton @ file:///D:/bld/win_inet_pton_1635832858406/work wslink==1.6.5 xarray @ file:///home/conda/feedstock_root/build_artifacts/xarray_1646254587173/work xyzservices @ file:///home/conda/feedstock_root/build_artifacts/xyzservices_1646849493349/work yarl==1.7.2 zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1643828507773/work

obrienpja commented 2 years ago

While this is an issue involving create_fieldplot_surface(), I was wondering if it is possible to get error messages that are more specific? I am happy to open another issue on that if necessary. We are really looking forward to migrating our code to pyaedt, and giving more specific error messages will facilitate this migration. Thank you!

maxcapodi78 commented 2 years ago

Hi @obrienpja this is not a bug. The working method should be

""" design.post.create_fieldplot_surface(objlist=[design._modeler.object_list[0].faces[0]], quantityName='Vector_E', setup_name='Setup') """

The quantity to plot is Vector_E. Vector_E1 is the name of the plot given by default by AEDT. Regarding your second topic, yes, please feel free to open a discussion, we always are open to improve the code.

obrienpja commented 2 years ago

I will try the syntax you posted. Thank you very much!

maxcapodi78 commented 2 years ago

@obrienpja have you tried the following syntax?

from pyaedt import settings settings.enable_debug_logger=True

your code here

this flag will make your log much more verbose and log every method you will run. that will make easier the debug but longer log.