ansys / pyaedt

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

Bug located in function `_expression_cache` in SolveSetup.py #4215

Open kjwcoo opened 9 months ago

kjwcoo commented 9 months ago

Before submitting the issue

Description of the bug

I was trying to add an expression "if(Q(1)>Q(2), Q(1), Q(2))" to the solution using the enable_expression_cache function but to no avail. However, when I put the expression "Q(1)", the function worked.

It seems like the hard-coded character replacement in _expression_cache had failed to replace special characters like ">", "<", or "==".

Steps To Reproduce

setup.enable_expression_cache( expressions="if(Q(1)>Q(2),Q(1),Q(2))", report_type="Eigenmode Parameters", isconvergence=True, isrelativeconvergence=False, conv_criteria=10, use_cache_for_pass=True, use_cache_for_freq=False )

Which Operating System are you using?

Windows

Which Python version are you using?

3.10

Installed packages

ansys-pythonnet==3.1.0rc3 anyio==4.2.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 asteval==0.9.31 asttokens==2.4.1 async-lru==2.0.4 attrs==23.2.0 Babel==2.14.0 beautifulsoup4==4.12.3 bleach==6.1.0 certifi==2023.11.17 cffi==1.16.0 charset-normalizer==3.3.2 click==8.1.7 cloudpickle==3.0.0 clr-loader==0.2.6 colorama==0.4.6 comm==0.2.1 contourpy==1.2.0 cycler==0.12.1 dask==2024.1.0 debugpy==1.8.0 decorator==5.1.1 defusedxml==0.7.1 executing==2.0.1 fastjsonschema==2.19.1 fonttools==4.47.2 fpdf2==2.7.7 fqdn==1.5.1 fsspec==2023.12.2 future==0.18.3

Editable Git install with no remote (gds-sim==0.0.1)

-e z:\materials\ki parametricswap\autotune gdspy==1.6.13 h5py==3.10.0 idna==3.6 importlib-metadata==7.0.1 ipykernel==6.29.0 ipython==8.20.0 ipywidgets==8.1.1 isoduration==20.11.0 jedi==0.19.1 Jinja2==3.1.3 joblib==1.3.2 json5==0.9.14 jsonpointer==2.4 jsonschema==4.21.1 jsonschema-specifications==2023.12.1 jupyter==1.0.0 jupyter-console==6.6.3 jupyter-events==0.9.0 jupyter-lsp==2.2.2 jupyter_client==8.6.0 jupyter_core==5.7.1 jupyter_server==2.12.5 jupyter_server_terminals==0.5.1 jupyterlab==4.0.11 jupyterlab-widgets==3.0.9 jupyterlab_pygments==0.3.0 jupyterlab_server==2.25.2 kiwisolver==1.4.5 lmfit==1.2.2 locket==1.0.0 MarkupSafe==2.1.4 matplotlib==3.8.2 matplotlib-inline==0.1.6 mistune==3.0.2 nbclient==0.9.0 nbconvert==7.14.2 nbformat==5.9.2 nest-asyncio==1.5.9 notebook==7.0.7 notebook_shim==0.2.3 numpy==1.26.3 overrides==7.6.0 packaging @ file:///C:/Users/dev-admin/perseverance-python-buildout/croot/packaging_1699472459356/work pandas==2.2.0 pandocfilters==1.5.1 parso==0.8.3 partd==1.4.1 pillow==10.2.0 platformdirs==4.1.0 plottr==0.13.0 plumbum==1.8.2 ply @ file:///C:/Users/dev-admin/perseverance-python-buildout/croot/ply_1699473999871/work pooch==1.8.0 prometheus-client==0.19.0 prompt-toolkit==3.0.43 psutil==5.9.8 pure-eval==0.2.2 pyaedt==0.7.10 pycparser==2.21 Pygments==2.17.2 pyparsing==3.1.1 PyQt5==5.15.10 PyQt5-sip @ file:///C:/Users/dev-admin/perseverance-python-buildout/croot/pyqt-split_1699478669290/work/pyqt_sip pyqtgraph==0.13.3 python-dateutil==2.8.2 python-json-logger==2.0.7 pytz==2023.3.post1 pyvista==0.43.2 pywin32==306 pywinpty==2.0.12 PyYAML==6.0.1 pyzmq==25.1.2 qtconsole==5.5.1 QtPy==2.4.1 referencing==0.32.1 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rpds-py==0.17.1 rpyc==5.3.1 scikit-learn==1.4.0 scipy==1.12.0 scooby==0.9.2 seaborn==0.13.1 Send2Trash==1.8.2 setuptools==68.2.2 sip @ file:///C:/Users/dev-admin/perseverance-python-buildout/croot/sip_1699475590677/work six==1.16.0 sniffio==1.3.0 soupsieve==2.5 stack-data==0.6.3 terminado==0.18.0 threadpoolctl==3.2.0 tinycss2==1.2.1 toolz==0.12.0 tornado==6.4 traitlets==5.14.1 types-python-dateutil==2.8.19.20240106 typing_extensions==4.9.0 tzdata==2023.4 uncertainties==3.1.7 uri-template==1.3.0 urllib3==2.1.0 versioningit==3.0.0 vtk==9.3.0 watchdog==3.0.0 wcwidth==0.2.13 webcolors==1.13 webencodings==0.5.1 websocket-client==1.7.0 wheel==0.41.2 widgetsnbextension==4.0.9 xarray==2024.1.0 xhistogram==0.3.2 zipp==3.17.0

Samuelopez-ansys commented 8 months ago

Hi @kjwcoo , Please share a project to reproduce this issue.