Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

materials dictionary in pymadl reader result #151

Closed
2 tasks done
agrishin opened this issue Aug 23, 2022 · 18 comments · Fixed by #150
Closed
2 tasks done

materials dictionary in pymadl reader result #151

agrishin opened this issue Aug 23, 2022 · 18 comments · Fixed by #150
Assignees
Labels
enhancement New feature or request

Comments

@agrishin
Copy link

agrishin commented Aug 23, 2022

Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

Description of the bug

Issuing the following:

from ansys.mapdl import reader as pymapdl.reader
result = pymapdl.reader.read_binary(‘file.rth’)
mats = result.materials

results in the following materials dictionary after reading in thermal model

{'EX': None, 'NUXY': None, 'ALPX': None, 'DENS': None, 'KXX': None, 'C': None}

The materials in that model have temperature dependent properties.

Steps To Reproduce

See above

Which Operating System are you using?

No response

Which Python version are you using?

No response

PyMAPDL Report

-------------------------------------------------------------------------------


PyMAPDL Software and Environment Report


Packages Requirements
*********************

Core packages
-------------
ansys.mapdl.core    : 0.63.1
numpy               : 1.23.0
appdirs             : 1.4.4
scipy               : 1.8.1
grpc                : Package not found
ansys.api.mapdl.v0  : Package not found
ansys.mapdl.reader  : 0.51.14
google.protobuf     : Package not found

Optional packages
-----------------
matplotlib          : 3.5.2
pyvista             : 0.35.1
pyiges              : 0.2.1
tqdm                : 4.64.0
ansys_corba         : 0.1.1


Ansys Installation
******************
Version   Location
------------------
202       C:\Program Files\ANSYS Inc\v202
211       C:\Program Files\ANSYS Inc\v211
212       C:\Program Files\ANSYS Inc\v212
221       C:\Program Files\ANSYS Inc\v221


Ansys Environment Variables
***************************
ANSYS201_DIR                   C:\Program Files\ANSYS Inc\v201\ANSYS
ANSYS202_DIR                   C:\Program Files\ANSYS Inc\v202\ANSYS
ANSYS211_DIR                   C:\Program Files\ANSYS Inc\v211\ANSYS
ANSYS212_DIR                   C:\Program Files\ANSYS Inc\v212\ANSYS
ANSYS221_DIR                   C:\Program Files\ANSYS Inc\v221\ANSYS
ANSYS222_DIR                   C:\Program Files\ANSYS Inc\v222\ANSYS
ANSYSLIC_DIR                   C:\Program Files\ANSYS Inc\Shared Files\Licensing
ANSYS_SYSDIR                   winx64
AWP_LOCALE201                  en-us
AWP_LOCALE202                  en-us
AWP_LOCALE211                  en-us
AWP_LOCALE212                  en-us
AWP_LOCALE221                  en-us
AWP_LOCALE222                  en-us
AWP_ROOT201                    C:\Program Files\ANSYS Inc\v201
AWP_ROOT202                    C:\Program Files\ANSYS Inc\v202
AWP_ROOT211                    C:\Program Files\ANSYS Inc\v211
AWP_ROOT212                    C:\Program Files\ANSYS Inc\v212
AWP_ROOT221                    C:\Program Files\ANSYS Inc\v221
AWP_ROOT222                    C:\Program Files\ANSYS Inc\v222
CADOE_LIBDIR201                C:\Program Files\ANSYS Inc\v201\CommonFiles\Language\en-us
CADOE_LIBDIR202                C:\Program Files\ANSYS Inc\v202\CommonFiles\Language\en-us
CADOE_LIBDIR211                C:\Program Files\ANSYS Inc\v211\CommonFiles\Language\en-us
CADOE_LIBDIR212                C:\Program Files\ANSYS Inc\v212\CommonFiles\Language\en-us
CADOE_LIBDIR221                C:\Program Files\ANSYS Inc\v221\CommonFiles\Language\en-us
CADOE_LIBDIR222                C:\Program Files\ANSYS Inc\v222\CommonFiles\Language\en-us

Installed packages

aiohttp==3.8.1
aiosignal==1.2.0
alabaster==0.7.12
ansys-api-mapdl==0.5.1
ansys-api-platform-instancemanagement==1.0.0b3
ansys-corba==0.1.1
ansys-dpf-core==0.4.2
ansys-dpf-post==0.2.2
ansys-grpc-dpf==0.4.0
ansys-mapdl-core==0.63.1
ansys-mapdl-reader==0.51.14
ansys-platform-instancemanagement==1.0.2
appdirs==1.4.4
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arrow==1.2.2
astroid==2.11.6
asttokens==2.0.5
async-timeout==4.0.2
atomicwrites==1.4.1
attrs==21.4.0
autobahn==22.6.1
Automat==20.2.0
autopep8==1.6.0
Babel==2.10.3
backcall==0.2.0
bcrypt==3.2.2
beautifulsoup4==4.11.1
binaryornot==0.4.4
black==22.6.0
bleach==5.0.1
cachetools==5.2.0
certifi==2022.6.15
cffi==1.15.1
chardet==5.0.0
charset-normalizer==2.1.0
click==8.1.3
cloudpickle==2.1.0
colorama==0.4.5
constantly==15.1.0
cookiecutter==2.1.1
cryptography==37.0.4
cycler==0.11.0
debugpy==1.6.2
decorator==5.1.1
defusedxml==0.7.1
diff-match-patch==20200713
dill==0.3.5.1
docutils==0.18.1
entrypoints==0.4
executing==0.8.3
fastjsonschema==2.15.3
flake8==4.0.1
fonttools==4.34.4
frozenlist==1.3.0
geomdl==5.3.1
google-api-core==2.8.2
google-api-python-client==2.52.0
google-auth==2.9.0
google-auth-httplib2==0.1.0
googleapis-common-protos==1.56.3
grpcio==1.47.0
httplib2==0.20.4
hyperlink==21.0.0
idna==3.3
imageio==2.19.3
imagesize==1.4.1
importlib-metadata==4.12.0
importlib-resources==5.8.0
incremental==21.3.0
inflection==0.5.1
intervaltree==3.1.0
ipykernel==6.15.1
ipython==7.34.0
ipython-genutils==0.2.0
ipywidgets==7.7.1
isort==5.10.1
jedi==0.18.1
jellyfish==0.9.0
Jinja2==3.1.2
jinja2-time==0.2.0
jsonschema==4.6.2
jupyter==1.0.0
jupyter-client==7.3.4
jupyter-console==6.4.4
jupyter-core==4.11.1
jupyterlab-pygments==0.2.2
jupyterlab-widgets==1.1.1
keyring==23.6.0
kiwisolver==1.4.3
lazy-object-proxy==1.7.1
MarkupSafe==2.1.1
matplotlib==3.5.2
matplotlib-inline==0.1.3
mccabe==0.6.1
mistune==0.8.4
multidict==6.0.2
mypy-extensions==0.4.3
nbclient==0.6.6
nbconvert==6.5.0
nbformat==5.4.0
nest-asyncio==1.5.5
notebook==6.4.12
numpy==1.23.0
numpydoc==1.4.0
packaging==21.3
pandocfilters==1.5.0
paramiko==2.11.0
parso==0.8.3
pathspec==0.9.0
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.2.0
platformdirs==2.5.2
pluggy==1.0.0
progressbar2==4.0.0
prometheus-client==0.14.1
prompt-toolkit==3.0.30
protobuf==3.20.0
protoc-gen-swagger==0.1.0
psutil==5.9.1
ptyprocess==0.7.0
pure-eval==0.2.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.8.0
pycparser==2.21
pydocstyle==6.1.1
pyflakes==2.4.0
Pygments==2.12.0
pyiges==0.2.1
pylint==2.14.4
pyls-spyder==0.4.0
PyNaCl==1.5.0
pyparsing==3.0.9
PyQt5==5.15.7
PyQt5-Qt5==5.15.2
PyQt5-sip==12.11.0
PyQtWebEngine==5.15.6
PyQtWebEngine-Qt5==5.15.2
pyrsistent==0.18.1
python-dateutil==2.8.2
python-lsp-black==1.2.1
python-lsp-jsonrpc==1.0.0
python-lsp-server==1.4.1
python-slugify==6.1.2
python-utils==3.3.3
pytoolconfig==1.2.1
pytz==2022.1
pyvista==0.35.1
pywin32==304
pywin32-ctypes==0.2.0
pywinpty==2.0.6
PyYAML==6.0
pyzmq==23.2.0
QDarkStyle==3.0.3
qstylizer==0.2.1
QtAwesome==1.1.1
qtconsole==5.3.1
QtPy==2.1.0
requests==2.28.1
rope==1.2.0
rsa==4.8
Rtree==1.0.0
scipy==1.8.1
scooby==0.5.12
Send2Trash==1.8.0
six==1.16.0
snowballstemmer==2.2.0
sortedcontainers==2.4.0
soupsieve==2.3.2.post1
Sphinx==5.0.2
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
spyder==5.3.1
spyder-kernels==2.3.2
stack-data==0.3.0
style==1.1.0
terminado==0.15.0
text-unidecode==1.3
textdistance==4.3.0
three-merge==0.1.1
tinycss2==1.1.1
toml==0.10.2
tomli==2.0.1
tomlkit==0.11.1
tornado==6.2
tqdm==4.64.0
traitlets==5.3.0
Twisted==22.4.0
twisted-iocpsupport==1.0.2
txaio==22.2.1
typing_extensions==4.3.0
ujson==5.4.0
update==0.0.1
uritemplate==4.1.1
urllib3==1.26.10
vtk==9.0.3
watchdog==2.1.9
wcwidth==0.2.5
webencodings==0.5.1
widgetsnbextension==3.6.1
wrapt==1.14.1
wslink==1.6.6
yapf==0.32.0
yarl==1.7.2
zipp==3.8.0
zope.interface==5.4.0
@akaszynski
Copy link
Collaborator

@germa89, this is an easy one. Please make this a high priority.

@germa89 germa89 self-assigned this Aug 23, 2022
@germa89 germa89 added the enhancement New feature or request label Aug 23, 2022
@germa89
Copy link
Contributor

germa89 commented Aug 23, 2022

It would really speed up the things if he could share file.rth. Would it be that possible @agrishin ??

@germa89
Copy link
Contributor

germa89 commented Aug 23, 2022

I need more details, because running VM271 (Convection Treatment Problem for a Hollow Cylinder with Fluid Flow), I got the right results:

>>> from ansys.mapdl.core import launch_mapdl
>>> from ansys.mapdl.core.examples import vmfiles

>>> mapdl = launch_mapdl()

>>> mapdl.input(vmfiles['vm271'])

>>> import os
>>> from ansys.mapdl import reader
>>> result = reader.read_binary(os.path.join(mapdl.directory, 'file.rth'))
>>> mats = result.materials
>>> mats
{1: {'KXX': 1e-16, 'C': 0.5374}, 3: {'KXX': 10000.0}}

@mikerife
Copy link

mikerife commented Aug 23, 2022

Hi @germa89 Attached is a sample MAPDL thermal result file with temperature dependent properties. Mike
rth-file.zip

The materials have temperature dependent thermal conductivity and electrical resistivity, but constant value other properties. So the output of the results.materials will look like:
Capture

@germa89 germa89 transferred this issue from ansys/pymapdl Aug 23, 2022
@akaszynski
Copy link
Collaborator

akaszynski commented Aug 23, 2022

@germa89, feel free to use the example thermal file @mikerife provided here in #150 and include it in tests/testfiles.

@mikerife
Copy link

@germa89 Here is a simpler version of that rth file with one material model but the same two properties are temperature dependent.
rth-file.zip

@agrishin
Copy link
Author

Ok, guys. Please download the link below. I think you'll see the problem...
https://padtinc.sharefile.com/d-s0adb0d2b54a34686913a70e2ea31fa25

@germa89
Copy link
Contributor

germa89 commented Aug 24, 2022

Ok, guys. Please download the link below. I think you'll see the problem... https://padtinc.sharefile.com/d-s0adb0d2b54a34686913a70e2ea31fa25

That is quite a big file. I'll be using @mikerife 's one for the unit tests.

@akaszynski
Copy link
Collaborator

That is quite a big file. I'll be using @mikerife 's one for the unit tests.

Validate with @agrishin and let me know if it works. I'll approve #150 after verification.

@germa89
Copy link
Contributor

germa89 commented Aug 25, 2022

It seems to (partially) work. See thermal expansion coefficients.

I unzipped the wbpz file (it is a zip at the end of the day). And I open the rth file under sr_1390_mat_import_files\dp0\SYS\MECH using:

import os
from ansys.mapdl import reader

rth = r"C:\Users\gayuso\Downloads\sr_1390_mat_import\sr_1390_mat_import_files\dp0\SYS\MECH\file.rth"
result = reader.read_binary(rth)
mats = result.materials
mats

Then I'm double checking some properties.

Density

image

mats[1]['DENS']
Out[7]:
array([[ 23.88888889,  93.33333333, 204.44444444, 315.55555556,
        426.66666667, 537.77777778],
       [ 15.14041241,  14.70782919,  15.57299562,  15.14041241,
         15.35670401,  15.14041241]])

Isotropic elasticity

image

In [8]: mats[1]['EX']
Out[8]:
array([[2.38888889e+01, 9.33333333e+01, 2.04444444e+02, 3.15555556e+02,
        4.26666667e+02, 5.37777778e+02],
       [1.58659579e+11, 1.51705345e+11, 1.56278224e+11, 1.47408713e+11,
        1.44618804e+11, 1.37456782e+11]])

Specific heat

image

In [6]: mats[1]['C']
Out[6]:
array([[2.38888889e+01, 9.33333333e+01, 2.04444444e+02, 3.15555556e+02,
        4.26666667e+02, 5.37777778e+02],
       [1.15391104e+05, 1.15913937e+05, 1.28279898e+05, 1.28764077e+05,
        1.34280990e+05, 1.37857159e+05]])

Thermal expansion

image

Temperature (C)	Coefficient of Thermal Expansion (C^-1)
23.88888888888868	8.3607534359999938E-06
93.333333333333229	8.2196497223999933E-06
204.44444444444386	8.9205327215999915E-06
315.55555555555623	8.9127672479999918E-06
426.66666666666686	9.2849506487999919E-06
537.777777777778	9.4293763199999936E-06
In [9]: mats[1]['ALPX']
Out[9]: 
array([[2.38888889e+01, 9.33333333e+01, 2.04444444e+02, 3.15555556e+02,
        4.26666667e+02, 5.37777778e+02],
       [8.36075344e-06, 8.24988623e-06, 8.86577170e-06, 8.87778046e-06,
        9.24162890e-06, 9.38963415e-06]])

This is different!!
I'm not sure why so any feedback is appreciated.

Others

The rest of them, are the same. Only ALPX is different.

In [10]: mats[1]
Out[10]:
{'EX': array([[2.38888889e+01, 9.33333333e+01, 2.04444444e+02, 3.15555556e+02,
         4.26666667e+02, 5.37777778e+02],
        [1.58659579e+11, 1.51705345e+11, 1.56278224e+11, 1.47408713e+11,
         1.44618804e+11, 1.37456782e+11]]),
 'NUXY': array([[2.38888889e+01, 9.33333333e+01, 2.04444444e+02, 3.15555556e+02,        
         4.26666667e+02, 5.37777778e+02],
        [3.00000000e-01, 3.00000000e-01, 3.00000000e-01, 3.00000000e-01,
         3.00000000e-01, 3.00000000e-01]]),
 'ALPX': array([[2.38888889e+01, 9.33333333e+01, 2.04444444e+02, 3.15555556e+02,        
         4.26666667e+02, 5.37777778e+02],
        [8.36075344e-06, 8.24988623e-06, 8.86577170e-06, 8.87778046e-06,
         9.24162890e-06, 9.38963415e-06]]),
 'DENS': array([[ 23.88888889,  93.33333333, 204.44444444, 315.55555556,
         426.66666667, 537.77777778],
        [ 15.14041241,  14.70782919,  15.57299562,  15.14041241,
          15.35670401,  15.14041241]]),
 'KXX': array([[ 23.88888889,  93.33333333, 204.44444444, 315.55555556,
         426.66666667, 537.77777778],
        [  6.86676143,   7.23487363,   8.79421257,   9.58342212,
          10.90236955,  12.27092866]]),
 'C': array([[2.38888889e+01, 9.33333333e+01, 2.04444444e+02, 3.15555556e+02,
         4.26666667e+02, 5.37777778e+02],
        [1.15391104e+05, 1.15913937e+05, 1.28279898e+05, 1.28764077e+05,
         1.34280990e+05, 1.37857159e+05]])}

Notes

  • The units between the wbpz file and the rth file might be different!!
  • The isotropic hardening is not shown in the material properties read by the pymapdl reader.

@germa89
Copy link
Contributor

germa89 commented Aug 25, 2022

Thinking about the possible reason for the differences between workbench and the reader... Thinking a bit out loud here.

The first value is the same:

8.3607534359999938E-06 == 8.36075344e-06

But then it start to diverge, it is like the "secant" has a different slope.

The first value is also the closest to the reference temperature (20 in workbench, unknown in the reader), so if it is an issue with the temperature reference it makes sense that this first value match.

@germa89
Copy link
Contributor

germa89 commented Aug 25, 2022

I opened the rth file with the good old Mechanical APDL GUI, and guess what....

image

The reader is right!!

Interestingly, the reference temperature is blank. I believe Workbench is doing some conversion on the data when saved (maybe referencing the temp to 0), I really still don't see how that will change the slope... but I cannot really think any other reason (expect for a workbench bug).

Extra

For further info, the thermal coefficient expansion graph (Workbench data based)

image

@mikerife
Copy link

Hi @germa89 I'm OoO for a few days and will look into what WB and MAPDL are doing here when I get back. Mike

@germa89
Copy link
Contributor

germa89 commented Aug 25, 2022

Sure thing. No rush!

@akaszynski
Copy link
Collaborator

Thanks for digging through this @germa89. Let's wait until @mikerife has something to say about why MAPDL/reader disagree with Mechanical.

@mikerife
Copy link

Hi @germa89 @akaszynski @agrishin Well, all three programs are correct. We just need to look at the material data in a certain way.

The material specific strain free temperature is given in the Engineering Data here:
WB-Mat

And TREF the general reference temperature is given here:

Mech-Mat

Note that since thermal analyses do not use TREF, the command is not written to the input file. But it is on the structural model input file.

Since the models 'MAT1' has different material specific and global strain free temperatures, MPAMOD is written which flags the solver to adjust the secant thermal expansion coefficients to match global strain free temperatures. See the MAPDL Help, theory guide equation 2-40. The adjustment is pretty small given the temperature difference of only 2 degrees C on the structural side. TREF defaults to zero if the command is not issued, so on the thermal analysis side the adjustment is a little bigger.

Mike

@germa89
Copy link
Contributor

germa89 commented Aug 30, 2022

Great comment @mikerife. Thank you very much for your detailed work.

I presume then we can conclude Reader data is correct and proceed to approve #150 @akaszynski

@agrishin
Copy link
Author

agrishin commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants