ansys / pymapdl

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

PyMAPDL cannot access element solution with PRESOL #1650

Closed Jalmenara closed 1 year ago

Jalmenara commented 1 year ago

Before submitting the issue

Description of the bug

When I run a static analysis in MAPDL I can access the element forces of the shell elements. See the screenshot below. Please notice the chain of commands on the ANSYS Command Window (right):

image

See 0_main.inp ``` FINISH /CLEAR jobname = 'MAPDL_shell_forces_postprocess' /FILNAME, '%jobname%', 1 SAVE ! Plate dimensions LX = 2 LY = 0.5 thickness = 0.005 /PREP7 ! Create keypoints -- Plate corners K, ,0,LY/2,0 K, ,LX,LY/2,0 K, ,LX,-LY/2,0 K, ,0,-LY/2,0 ! Create an area A,1,2,3,4 ! Create ELEMENT TYPE, MATERIAL and SECTION properties to be assigned to ! the subsequently meshed elements ! Select the element type ET,1,SHELL181 ! Create material 1 MP, EX, 1,2e9 MP, DENS, 1,7.8e3 ! Create shell section SECTYPE,1,SHELL ! Assign the thickness that section SECDATA,thickness ! Select the number of divisions at the free edge freeEdgeNDivs = 5 LESIZE, 2, ,,freeEdgeNDivs LESIZE, 4, ,,freeEdgeNDivs LESIZE, 1, ,,LX/LY*freeEdgeNDivs LESIZE, 3, ,,LX/LY*freeEdgeNDivs ! Mesh the area TYPE, 1 MAT, 1 SECNUM, 1 MSHAPE, 0, 2D ! Force the usage of quadrilateral elements AMESH,1 ! Setup boundary conditions targetStress = 100 ! MPa = N/mm2 FT = targetStress*thickness*LY*1e6 ! Clamp the left edge NSEL,S,LOC,X,0 D,ALL,ALL ! Apply an axial force at the free edge (FT/all the nodes) NSEL,S,LOC,X,LX *GET, numnodes, NODE, 0, COUNT F, ALL, FX, FT/numnodes SAVE ! Solve the static analysis FINISH /SOLU ANTYPE,STATIC, NEW SOLVE FINISH SAVE ```

Problem when running in PyMAPDL

However, when running using PyMAPDL, the following error appears

image

Steps To Reproduce

Run 1_post.py (below) with 0_main.inp available at the working directory (please copy-paste from the description above)

from ansys.mapdl.core import launch_mapdl
import os
curdir = os.getcwd()
mapdl = launch_mapdl(run_location=curdir, override=True)
print(mapdl)

mapdl.input("0_main.inp")
mapdl.save()
# mapdl.vup("","Z")
# 
# mapdl.post1()
mapdl.nsel("S","LOC","X",0)
# mapdl.nplot(nnum=True) 
edgenodes = mapdl.mesh.nnum

mapdl.esln()
edgeelems = mapdl.mesh.enum

mapdl.post1()
mapdl.presol("F") ## Esto no funciona por alguna razón que no entendemos

mapdl.exit()

Which Operating System are you using?

Linux

Which Python version are you using?

3.8

PyMAPDL Report

Show the Report! ```text (env_JAR) [mechauser@tasmania MAPDL_shell_forces_postprocess]$ python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" ------------------------------------------------------------------------------- PyMAPDL Software and Environment Report Packages Requirements ********************* Core packages ------------- ansys.mapdl.core : 0.63.3 numpy : 1.23.5 appdirs : 1.4.4 scipy : 1.9.3 grpc : Package not found ansys.api.mapdl.v0 : Package not found ansys.mapdl.reader : 0.52.3 google.protobuf : Package not found pexpect : 4.8.0 Optional packages ----------------- matplotlib : 3.6.2 pyvista : 0.37.0 pyiges : 0.2.1 tqdm : 4.64.1 ansys_corba : 0.1.1 Ansys Installation ****************** Version Location ------------------ 170 /ansys_inc/v170 195 /ansys_inc/v195 212 /ansys_inc/v212 Ansys Environment Variables *************************** AWP_ROOT212 /usr/ansys_inc/v212/ ANSYS_DPF_PATH /usr/ansys_inc/v212/ ```

Installed packages

Show the installed packages! ```text aiohttp==3.8.3 aiosignal==1.3.1 ansys-api-mapdl==0.5.1 ansys-api-platform-instancemanagement==1.0.0b3 ansys-corba==0.1.1 ansys-dpf-core==0.6.2 ansys-dpf-gate==0.2.3 ansys-dpf-gatebin==0.2.3 ansys-dpf-post==0.2.5 ansys-grpc-dpf==0.3.0 ansys-mapdl-core==0.63.3 ansys-mapdl-reader==0.52.3 ansys-platform-instancemanagement==1.0.2 appdirs==1.4.4 asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1667325728359/work async-timeout==4.0.2 attrs==22.1.0 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 cachetools==5.2.0 certifi==2022.9.24 charset-normalizer==2.1.1 comm @ file:///home/conda/feedstock_root/build_artifacts/comm_1668713578881/work contourpy==1.0.6 cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1635519461629/work debugpy @ file:///home/conda/feedstock_root/build_artifacts/debugpy_1666826399851/work decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1641555617451/work entrypoints @ file:///home/conda/feedstock_root/build_artifacts/entrypoints_1643888246732/work executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1667317341051/work fonttools==4.38.0 frozenlist==1.3.3 geomdl==5.3.1 git-filter-repo @ file:///home/conda/feedstock_root/build_artifacts/git-filter-repo_1642678241140/work google-api-core==2.10.2 google-api-python-client==2.66.0 google-auth==2.14.1 google-auth-httplib2==0.1.0 googleapis-common-protos==1.57.0 grpcio==1.50.0 httplib2==0.21.0 idna==3.4 imageio==2.22.4 importlib-metadata==5.1.0 ipykernel @ file:///home/conda/feedstock_root/build_artifacts/ipykernel_1669056400400/work ipython @ file:///home/conda/feedstock_root/build_artifacts/ipython_1667140637743/work jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1659959867326/work jupyter_client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1668623095912/work jupyter_core @ file:///home/conda/feedstock_root/build_artifacts/jupyter_core_1668030817979/work kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1666805766046/work matplotlib==3.6.2 matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1660814786464/work multidict==6.0.2 nest-asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1664684991461/work numpy==1.23.5 packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1637239678211/work parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1638334955874/work pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1667297516076/work pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work Pillow==9.3.0 platformdirs @ file:///home/conda/feedstock_root/build_artifacts/platformdirs_1657729053205/work pooch==1.6.0 prompt-toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1669057097528/work protobuf==3.20.3 protoc-gen-swagger==0.1.0 psutil @ file:///home/conda/feedstock_root/build_artifacts/psutil_1667885878918/work ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1609419310487/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl pure-eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1642875951954/work pyasn1==0.4.8 pyasn1-modules==0.2.8 Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1660666458521/work pyiges==0.2.1 pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1652235407899/work python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work pyvista==0.37.0 pyzmq @ file:///home/conda/feedstock_root/build_artifacts/pyzmq_1666828534876/work requests==2.28.1 rsa==4.9 scipy==1.9.3 scooby==0.7.0 six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work stack-data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1668260892666/work tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1666788592778/work tqdm==4.64.1 traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1666115969632/work uritemplate==4.1.1 urllib3==1.26.13 vtk==9.2.2 wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1600965781394/work wslink==1.9.1 yarl==1.8.1 zipp==3.10.0 ```
mikerife commented 1 year ago

Hi @Jalmenara What version of MAPDL are you using and did you launch MAPDL Interactive in SMP or DMP parallel mode? The MAPDL instance PyMAPDL launched is DMP (default) if the version is relatively new. And DMP MAPDL does not keep results in memory (after a solve) so a SET command is needed to read the results from the result file to memory. Please add the following to 1_post.py after entering /POST1:

mapdl.set('last')

Mike

Jalmenara commented 1 year ago

Hi @Jalmenara What version of MAPDL are you using and did you launch MAPDL Interactive in SMP or DMP parallel mode? The MAPDL instance PyMAPDL launched is DMP (default) if the version is relatively new. And DMP MAPDL does not keep results in memory (after a solve) so a SET command is needed to read the results from the result file to memory. Please add the following to 1_post.py after entering /POST1:

mapdl.set('last')

Mike

Problem solved. Please close this issue #1650.

Thank you!