ansys / pymechanical

Pythonic interface to Ansys Mechanical ™
https://mechanical.docs.pyansys.com/
MIT License
32 stars 16 forks source link

Unit system of imported geometry is not converted to active unit system #633

Closed JimmyHe0527 closed 5 months ago

JimmyHe0527 commented 5 months ago

🔍 Before submitting the issue

🐞 Description of the bug

I observed two issues with importing geometry files whose length unit is mm in an embedded instance of Mechanical:

  1. When importing the file following documentation examples (e.g., https://embedding.examples.mechanical.docs.pyansys.com/examples/basic/steady_state_thermal_analysis.html#sphx-glr-examples-basic-steady-state-thermal-analysis-py), the dimensions are interpreted into the active unit system instead of being converted. Manually setting the active unit system with "ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardNMM" seems to force a conversion, but I was told that this is not the best practice.

  2. After conversion, the displayed image shows the model in correct dimension (converted to m): image However, after adding a dummy load and displaying the state of the system again, the unit system becomes incorrect: image

📝 Steps to reproduce

Run the jupyter notebook script attached here. Example geometry file is also included. pyMech_example.zip

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

23R2, but can use other versions.

🐍 Which Python version are you using?

3.10

📦 Installed packages

(venv) C:\Users\jhe>python -m pip freeze
WARNING: Ignoring invalid distribution -rpcio (c:\users\jhe\.ansys_python_venvs\venv\lib\site-packages)
WARNING: Ignoring invalid distribution -rotobuf (c:\users\jhe\.ansys_python_venvs\venv\lib\site-packages)
absl-py==2.1.0
altair==5.2.0
annotated-types==0.6.0
ansys-api-mechanical==0.1.1
ansys-api-platform-instancemanagement==1.0.0
ansys-mechanical-core==0.10.7
ansys-mechanical-env==0.1.3
ansys-platform-instancemanagement==1.1.2
ansys-pythonnet==3.1.0rc3
ansys-simai-core==0.1.3
ansys-tools-path==0.4.1
anyio==4.3.0
appdirs==1.4.4
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==2.4.1
astunparse==1.6.3
async-lru==2.0.4
attrs==23.2.0
Babel==2.14.0
beautifulsoup4==4.12.3
bleach==6.1.0
blinker==1.7.0
bokeh==3.3.4
cachetools==5.3.2
certifi==2024.2.2
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
debugpy==1.8.1
decorator==5.1.1
DeepXDE==1.11.0
defusedxml==0.7.1
dm-tree==0.1.8
exceptiongroup==1.2.0
executing==2.0.1
fastjsonschema==2.19.1
filelock==3.13.1
flatbuffers==23.5.26
fonttools==4.48.1
fqdn==1.5.1
fsspec==2024.2.0
gast==0.5.4
gitdb==4.0.11
GitPython==3.1.42
google-auth==2.28.1
google-auth-oauthlib==1.2.0
google-pasta==0.2.0
graphviz==0.20.1
grpcio==1.62.1
h11==0.14.0
h5py==3.10.0
httpcore==1.0.4
httplib2==0.22.0
httpx==0.27.0
idna==3.6
importlib-metadata==7.0.1
ipykernel==6.29.3
ipython==8.22.2
isoduration==20.11.0
jedi==0.19.1
Jinja2==3.1.3
joblib==1.3.2
json5==0.9.22
jsonpointer==2.4
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
jupyter-events==0.9.0
jupyter-lsp==2.2.4
jupyter_client==8.6.0
jupyter_core==5.7.1
jupyter_server==2.13.0
jupyter_server_terminals==0.5.2
jupyterlab==4.1.4
jupyterlab_pygments==0.3.0
jupyterlab_server==2.25.3
keras==2.15.0
kiwisolver==1.4.5
libclang==16.0.6
linkify-it-py==2.0.3
Markdown==3.5.2
markdown-it-py==3.0.0
MarkupSafe==2.1.5
matplotlib==3.8.3
matplotlib-inline==0.1.6
mdit-py-plugins==0.4.0
mdurl==0.1.2
mistune==3.0.2
ml-dtypes==0.2.0
mpmath==1.3.0
nbclient==0.9.0
nbconvert==7.16.2
nbformat==5.9.2
nest-asyncio==1.6.0
networkx==3.2.1
notebook_shim==0.2.4
numpy==1.26.4
oauthlib==3.2.2
opt-einsum==3.3.0
overrides==7.7.0
packaging==23.2
pandas==2.2.0
pandocfilters==1.5.1
panel==1.3.8
param==2.0.2
parso==0.8.3
pillow==10.2.0
platformdirs==4.2.0
plotly==5.19.0
pooch==1.8.0
prometheus_client==0.20.0
prompt-toolkit==3.0.43
protobuf==4.25.3
psutil==5.9.8
pure-eval==0.2.2
pyaml==23.12.0
pyarrow==15.0.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycparser==2.21
pydantic==2.6.1
pydantic_core==2.16.2
pydeck==0.8.1b0
Pygments==2.17.2
pyparsing==3.1.1
python-dateutil==2.8.2
python-json-logger==2.0.7
pytz==2024.1
pyvista==0.43.3
pyviz_comms==3.0.1
pywin32==306
pywinpty==2.0.13
PyYAML==6.0.1
pyzmq==25.1.2
referencing==0.33.0
requests==2.31.0
requests-oauthlib==1.3.1
requests-toolbelt==1.0.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.7.0
rpds-py==0.18.0
rsa==4.9
scikit-learn==1.4.1.post1
scikit-optimize==0.9.0
scipy==1.12.0
scooby==0.9.2
semver==3.0.2
Send2Trash==1.8.2
six==1.16.0
smmap==5.0.1
sniffio==1.3.1
soupsieve==2.5
sseclient-py==1.8.0
stack-data==0.6.3
stpyvista==0.0.15
streamlit==1.31.1
sympy==1.12
tenacity==8.2.3
tensorboard==2.15.2
tensorboard-data-server==0.7.2
tensorflow==2.15.0
tensorflow-estimator==2.15.0
tensorflow-intel==2.15.0
tensorflow-io-gcs-filesystem==0.31.0
tensorflow-probability==0.23.0
termcolor==2.4.0
terminado==0.18.0
tf-siren==0.0.5
threadpoolctl==3.3.0
tinycss2==1.2.1
toml==0.10.2
tomli==2.0.1
toolz==0.12.1
torch==2.2.0
torchviz==0.0.2
tornado==6.4
tqdm==4.66.2
traitlets==5.14.1
types-python-dateutil==2.8.19.20240106
typing_extensions==4.9.0
tzdata==2024.1
tzlocal==5.2
uc-micro-py==1.0.3
uri-template==1.3.0
uritemplate==4.1.1
urllib3==2.2.0
validators==0.22.0
vtk==9.3.0
wakepy==0.7.2
watchdog==4.0.0
wcwidth==0.2.13
webcolors==1.13
webencodings==0.5.1
websocket-client==1.7.0
Werkzeug==3.0.1
wrapt==1.14.1
xyzservices==2023.10.1
zipp==3.17.0
dipinknair commented 5 months ago

@JimmyHe0527 This is a graphics issue which is only with 232. I have tried with 242 and its not reproducible. To verify it is only a graphics issue you can use

print(ExtAPI.Application.ActiveUnitSystem)
print(Model.Geometry.Children[0].Volume)

which gives same volume ( 25 [mm mm mm]) after geometry import and adding heat flux in 232. I am attaching images with above lines added in you example below

232

image image

and here is the image after adding heatflux with 241 with graphics displaying correct scale

image