ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
419 stars 117 forks source link

tbplot() not impelemented via pyvista #1304

Open natter1 opened 1 year ago

natter1 commented 1 year ago

Before submitting the issue

Description of the bug

tbplot() does not plot any material model. Either impelement a plotting e.g. via generall_plotter() or add some warning when calling tbplot() and also in the doc-string.

Steps To Reproduce

Call mapdl.tbplot()

Which Operating System are you using?

Windows

Which Python version are you using?

3.9

Installed packages

aiohttp==3.8.1 aiosignal==1.2.0 ansys-api-mapdl==0.5.1 ansys-api-platform-instancemanagement==1.0.0b3 ansys-mapdl-core==0.62.2 ansys-mapdl-reader==0.51.14 ansys-platform-instancemanagement==1.0.2 appdirs==1.4.4 async-timeout==4.0.2 atomicwrites==1.4.1 attrs==21.4.0 build==0.8.0 charset-normalizer==2.1.0 colorama==0.4.5 cycler==0.11.0 fonttools==4.34.4 frozenlist==1.3.0 geomdl==5.3.1 googleapis-common-protos==1.56.4 grpcio==1.47.0 idna==3.3 imageio==2.19.5 importlib-metadata==4.12.0 iniconfig==1.1.1 kiwisolver==1.4.4 matplotlib==3.5.2 multidict==6.0.2 numpy==1.23.1 packaging==21.3 pep517==0.12.0 Pillow==9.2.0 pluggy==1.0.0 protobuf==3.20.1 protoc-gen-swagger==0.1.0 py==1.11.0 pyiges==0.2.1 pyparsing==3.0.9 pytest==7.1.2 python-dateutil==2.8.2 pyvista==0.35.2 scipy==1.8.1 scooby==0.5.12 six==1.16.0 tomli==2.0.1 tqdm==4.64.0 vtk==9.1.0 wslink==1.6.6 yarl==1.7.2 zipp==3.8.1

mikerife commented 1 year ago

Hi @natter1 an empty tbplot() should do nothing...it needs some input arguments. Also I'd like to take a step back for two reasons:

1 I'm not sure that PyVista would be the appropriate solution here since the data is X/Y data points and not a mesh etc.
2 Not all material models that TB can define can be plotted via TBPLOT.

I think that TBPLOT was only ever intended for MAPDL interactive as there does not seem to be an easy way to find out the specific TB material model for any given material ID. So that would need to be provided, or exposed if a hidden feature, by the MAPDL developers first. Then we could come probably come up with a straight-forward "get the material model type, data, and XY plot the data" routine. Maybe utilizing Plotly or Pandas.

I can open an Enhancement Request for this. If you are an Ansys customer can you email me directly? Customer votes (done by customer number) carry more weight than my vote alone! michael.rife@ansys.com

Mike

natter1 commented 1 year ago

@mikerife you are right, pyvista might not be the best solution for a 2D plot. On the other hand, using e.g. matplotlib would bring an additional dependency, which might also be a problem. I think its fine to add some kind of warning to tbplot instead of adding the plot-functionality. As you said, the more important thing would be a "a straight-forward get the material model type, data".

as there does not seem to be an easy way to find out the specific TB material model for any given material ID

Yeah, thats the reason, I tried tbplot in the first place. I was writing a test-function and had trouble to get the material data using get_array(). I wanted to look how it is solved in pymapdl for tbplot. In the end I had to do something like this:

    # the returned array is 1D and has the stress-strain values at odd/even positions
    tb_kinh_data_raw = mapdl.get_array("KINH", mat_id, item1="TEMP", it1num=0, item2="CONST", it2num=0, kloop=6)

    strain = tb_kinh_data_raw[np.arange(0, len(tb_kinh_data_raw), 2)]
    stress = tb_kinh_data_raw[np.arange(1, len(tb_kinh_data_raw), 2)]
    strain = strain[strain != 0]
    stress = stress[stress != 0]

Thats not something I like to have in a supposedly simple and easy to read test-function. And thats still the simple case, because I knew what material model I expected. It would be really nice to have a different interface to material data, but I can understand that this might be hard to sell. As a university staff I'm not sure if I could provide additional weight with a customer number, but I will have a look into it.

akaszynski commented 1 year ago

using e.g. matplotlib would bring an additional dependency

As far back as 9.0.0, pyvista requires matplotlib. I think it's fine to have and even ideal in many cases. We can always make it an optional requirement and add it in with ansys-mapdl-core[vis] of ansys-mapdl-core[all] to install optional dependencies.