ansys / pymapdl

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

Unable to use explicit dynamics command section of PyMAPDL #2494

Closed Vamsi-IITI closed 9 months ago

Vamsi-IITI commented 9 months ago

🤓 Before submitting the issue

🔍 Description of the bug

I had to simulate a bullet fired on a sandwich honeycomb panel. For that , I generated required geometry of sandwich structure and bullet ; and meshed it . When I came to applying boundary condition. I use mapdl.edpvel command for applying velocity to bullet but it throws error " The capability LsDyna was either not ordered with this Ansys installation or the appropriate product was not selected for this session. "

🕵️ Steps To Reproduce

## Main parameters
cell_size = 0.006
cell_wall_thickness = 0.002
node_length = 0.004
facesheet_thickness = 0.005

# Fixed constants
structure_length = 0.1
structure_breadth = 0.1

L =  0.0034641016151377548
offset_x =  0.008
offset_y =  0.0069282032302755096
Nx =  13
Ny =  15

## Create geometry of honeycomb core
mapdl.block(0, structure_length, 0, structure_breadth, 0, node_length)
for i in range(0,Nx):                                                                                   ## column number
    for j in range(0,Ny):
        if j%2 == 0:                                                                                    ## even row number
            mapdl.rpr4(6, i*offset_x , j*offset_y, L, 90, node_length)
        else:                                                                                           ## odd row number
            mapdl.rpr4(6, i*offset_x + offset_x/2 , j*offset_y, L, 90, node_length)
mapdl.vsbv(1,'all')
honeycomb_core = mapdl.cm("CORE", "VOLU")

## Generate geometry of facesheets
front_facesheet = mapdl.block(0, structure_length, 0, structure_breadth, node_length, node_length + facesheet_thickness)  ## Top facesheet
rear_facesheet = mapdl.block(0, structure_length, 0, structure_breadth, -1*facesheet_thickness, 0)                        ## Bottom facesheet

mapdl.clocal( 11, 0, structure_length/2, structure_breadth/2, 0)                                         ## Making local coordinate system
mapdl.wpcsys('', 11,)                                                                                    ## Shift working plane

initial_distance = node_length + facesheet_thickness + 0.02                                              ## 20 mm from center of front facesheet of sandwich panel

# Generate Geometry of 0.44 Remington Magnum Bullet
mapdl.cone(0.0052, 0.005486, initial_distance , initial_distance + 0.00825)
mapdl.cone(0.00569, 0.005805, initial_distance + 0.00825 , initial_distance + 0.04089 )
mapdl.vadd(3,4)
bullet = mapdl.cm("BULLET","VOLU")

mapdl.vplot('all')

## Define material properties
mapdl.mp("EX", 1, 2e5)  # Youngs modulus
mapdl.mp("PRXY", 1, 0.3367)  # Poissons ratio

## Define element attributes
mapdl.et(1, "SOLID185") # 3D 8-Node Layered Solid

## Define mesh controls

mapdl.lesize("ALL", 0.001, layer1=1)
# mapdl.smrtsize(1)

# Mesh facesheets
mapdl.mshape(0, "3D")    # mesh the volume with 3D Hexahedral elements
mapdl.mshkey(1)          # mapped mesh
mapdl.vmesh('2')
mapdl.mshape(0, "3D")    # mesh the volume with 3D Hexahedral elements
mapdl.mshkey(1)          # mapped mesh
mapdl.vmesh('1')

# Mesh honeycomb core
mapdl.mshape(1, "3D")    # mesh the volume with 3D Tetrahedral elements
mapdl.mshkey(0)          # free mesh
mapdl.vmesh('CORE')

# Mesh bullet
mapdl.mshape(1, "3D")    # mesh the volume with 3D Tetrahedral elements
mapdl.mshkey(0)          # free mesh
mapdl.vmesh('BULLET')

### Make the lateral sides of the panel as fixed support i.e. set displacement of nodes to zero

# Select all nodes at the x = 0 end of the sandwich panel
mapdl.nsel("S", "LOC", "X", 0)
# Remove all degrees of freedom for all nodes in the selection
mapdl.d("all", "all")

# Select all nodes at the x = structure_length end of the sandwich panel
mapdl.nsel("S", "LOC", "X", structure_length)
# Remove all degrees of freedom for all nodes in the selection
mapdl.d("all", "all")

# Select all nodes at the y = 0 end of the sandwich panel
mapdl.nsel("S", "LOC", "Y", 0)
# Remove all degrees of freedom for all nodes in the selection
mapdl.d("all", "all")

# Select all nodes at the y = structure_breadth end of the sandwich panel
mapdl.nsel("S", "LOC", "Y", structure_breadth)
# Remove all degrees of freedom for all nodes in the selection
mapdl.d("all", "all")

mapdl.edpvel('VELO', 'BULLET', vz='-400')   ### Produces error

💻 Which Operating System are you using?

Windows

🐍 Which Python version are you using?

3.11

📝 PyMAPDL Report


PyMAPDL Software and Environment Report

Packages Requirements


Core packages

ansys.mapdl.core : 0.64.0 numpy : 1.24.3 appdirs : 1.4.4 scipy : 1.10.1 grpc : Package not found ansys.api.mapdl.v0 : Package not found ansys.mapdl.reader : 0.52.13 google.protobuf : Package not found

Optional packages

matplotlib : 3.6.2 pyvista : 0.37.0 pyiges : 0.2.1 tqdm : 4.65.0

Ansys Installation


Version Location

231 C:\Program Files\ANSYS Inc\v231

Ansys Environment Variables


ANSYS231_DIR C:\Program Files\ANSYS Inc\v231\ANSYS ANSYSLIC_DIR C:\Program Files\ANSYS Inc\Shared Files\Licensing AWP_LOCALE231 en-us AWP_ROOT231 C:\Program Files\ANSYS Inc\v231 CADOE_LIBDIR231 C:\Program Files\ANSYS Inc\v231\CommonFiles\Language\en-us

📝 Installed packages

ansys-api-fluent==0.3.12 ansys-api-mapdl==0.5.1 ansys-api-mechanical==0.1.0 ansys-api-meshing-prime==0.1.1 ansys-api-platform-instancemanagement==1.0.0 ansys-api-pyensight==0.3.0 ansys-api-sherlock==0.1.14 ansys-api-systemcoupling==0.1.0 ansys-dpf-gatebin==0.4.1 ansys-fluent-core==0.14.0 ansys-meshing-prime==0.4.0 ansys-motorcad-core==0.1.3 ansys-optislang-core==0.2.1 ansys-platform-instancemanagement==1.1.1 ansys-pyensight-core==0.5.3 ansys-pythonnet==3.1.0rc1 ansys-seascape==0.2.0 ansys-sherlock-core==0.2.0 ansys-systemcoupling-core==0.1.3 appdirs==1.4.4 asgiref==3.7.2 asttokens==2.4.0 backcall==0.2.0 bleach==6.0.0 build==1.0.0 cachetools==5.3.1 certifi==2023.7.22 cffi==1.15.1 charset-normalizer==3.2.0 click==8.1.7 clr-loader==0.2.6 colorama==0.4.6 comm==0.1.4 contourpy==1.1.0 cryptography==41.0.3 cycler==0.11.0 debugpy==1.7.0 decorator==5.1.1 Django==4.2.5 docutils==0.20.1 executing==1.2.0 filelock==3.12.3 fonttools==4.42.1 google-api-core==2.11.1 google-auth==2.22.0 google-auth-httplib2==0.1.0 googleapis-common-protos==1.60.0 grpcio==1.57.0 grpcio-status==1.48.2 h5py==3.9.0 httplib2==0.22.0 idna==3.4 importlib-metadata==6.8.0 ipykernel==6.25.2 ipython==8.15.0 jaraco.classes==3.3.0 jedi==0.19.0 jupyter_client==8.3.1 jupyter_core==5.3.1 keyring==24.2.0 kiwisolver==1.4.5 lxml==4.9.3 markdown-it-py==3.0.0 matplotlib==3.7.2 matplotlib-inline==0.1.6 mdurl==0.1.2 more-itertools==10.1.0 nest-asyncio==1.5.7 numpy==1.25.2 packaging==23.1 pandas==2.1.0 parso==0.8.3 pickleshare==0.7.5 Pillow==10.0.0 pkginfo==1.9.6 platformdirs==3.10.0 plumbum==1.8.2 pooch==1.7.0 prompt-toolkit==3.0.39 protobuf==3.20.3 psutil==5.9.5 pure-eval==0.2.2 pyansys-docker==5.0.4 pyansys-tools-versioning==0.4.0 pyasn1==0.5.0 pyasn1-modules==0.3.0 pycparser==2.21 Pygments==2.16.1 pyiges==0.3.1 pyparsing==3.0.9 pypiwin32==223 pypng==0.20220715.0 pyproject_hooks==1.0.0 pyspnego==0.9.2 python-dateutil==2.8.2 pythonnet==3.0.1 pytwin==0.3.0 pytz==2023.3.post1 pywin32==306 pywin32-ctypes==0.2.2 PyYAML==6.0.1 pyzmq==25.1.1 readme-renderer==41.0 requests==2.31.0 requests-negotiate-sspi==0.5.2 requests-toolbelt==1.0.0 rfc3986==2.0.0 rich==13.5.2 rpyc==5.3.1 rsa==4.9 scipy==1.11.2 scooby==0.7.2 six==1.16.0 sqlparse==0.4.4 stack-data==0.6.2 tornado==6.3.3 tqdm==4.66.1 traitlets==5.9.0 twine==4.0.2 typing==3.7.4.3 typing_extensions==4.7.1 tzdata==2023.3 uritemplate==4.1.1 urllib3==1.26.16 vtk==9.2.6 wcwidth==0.2.6 webencodings==0.5.1 websocket-client==1.6.2 zipp==3.16.2

📝 Logger output file

Show the logger output file. ```text # PASTE HERE THE CONTENT OF THE LOGGER OUTPUT FILE. ```
Vamsi-IITI commented 9 months ago

please guide me if i am using commands in wrong manner, I don't know how to perform an explicit dynamics simulation using pymapdl.

germa89 commented 9 months ago

Hi @Vamsi-IITI, I believe this is a license issue. Please make sure you have a valid license for LS-Dyna, and that is not being used by someone else.

mikerife commented 9 months ago

Hi @Vamsi-IITI & @germa89 This is not an licensing issue. Mechanical APDL does not now support pre and post processing of LS-Dyna models. The "EDPVEL" command was specific to pre-processing models in MAPDL for the LS-Dyna solver back when MAPDL supported that. It's use, and all the other old LS-Dyna specific APDL commands, are still error checked.

What are the units in the model? Are you up to using other PyAnsys applications?

Mike

Vamsi-IITI commented 9 months ago

Hi @mikerife, thanks for the information. Can you guide me how one can perform explicit dynamics simulation via python. I basically want to do parametric design analysis and optimization. How can I use the meshed geometry for further simulation and getting result.

Vamsi-IITI commented 9 months ago

I am using SI units . ( mapdl.units('SI') # SI unit system )

pmaroneh commented 9 months ago

Hi @mikerife, thanks for the information. Can you guide me how one can perform explicit dynamics simulation via python. I basically want to do parametric design analysis and optimization. How can I use the meshed geometry for further simulation and getting result.

PyDyna would be the way to go: https://github.com/ansys/pydyna

GitHub
GitHub - ansys/pydyna: Python interface to the LS-DYNA solver
Python interface to the LS-DYNA solver. Contribute to ansys/pydyna development by creating an account on GitHub.
mikerife commented 9 months ago

Hi @Vamsi-IITI & @pmaroneh Pernelle has forgotton more about scripting than I know, but I think I have to slightly disagree with her here. PyDyna, for now, assumes that a k file with nodes, elements and parts (I think parts is a requirement) is available. And PyPrimeMesh does not yet have the ability to export out LS-Dyna K format mesh, though it is in development.

I think right now the only end-to-end solution is PyGeometry + PyMechanical.

I thought that MeshIO might be a solution (to translate the mesh) but it does not look like it supports LS-Dyna.

Well, I suppose we could go PyMAPDL for geometry, PyMechanical for meshing, material, and part definition, then onto PyDyna.

Vamsi-IITI what licenses do you have access to?

mike

Vamsi-IITI commented 9 months ago

Hi @mikerife, I am an undergraduate student. Our college has an institutional license for ansys workbench covering ansys fluent, ansys ls dyna, mechanical, etc. Some lab PC have Workbench 2018 and some have workbench 2023. I am really thankful to all of you for spending your time on my query. I will soon check if I can figure out a solution with pymechanical and pydyna. Will post any further query or progress here.

Vamsi-IITI commented 9 months ago

Hi @mikerife , can you guide me on how to transition from one solver to other . Like how to transfer generated geometry to pymechanical , mesh it it and send it again to ls dyna solver

mikerife commented 9 months ago

Hi @Vamsi-IITI Let me see if I can either find or create an example. In the meantime you can start by reviewing the PyMechanical site:

https://mechanical.docs.pyansys.com/version/stable/index.html

Since we can do explicit dynamic analysis in WB Mechanical with the LS-Dyna solver we may not need to go out to PyDyna. In Mechanical you can show Automation -> Scripting. Then in the scripting tool turn on the recording and perform some Mechanical UI operations. And the Mech script will be captured. You can use this to see what would be required in the PyMechanical script...and record an example to use as a template.

Mike

PyMechanical documentation 0.10.4 — PyMechanical
Vamsi-IITI commented 9 months ago

Hi @mikerife , I reviewed the documentation of Pymechanical, also recorded an example to get template code. I am going through this way : Creating geometry in MAPDL -> Saving it in IGES format using mapdl.cdwrite command -> Starting Mechanical and giving the path of geometry file as geometry_path to be loaded. Though I don't have complete understanding of Pymechanical library. For static structural , there is this command : STAT_STRUC.Solution.Solve , what is command for explicit dynamics solution ? And where do i assign material and its failure properties? I looked in MAPDL , but couldn't find the plasticity model I needed ( Johnson Cook Plasticity and Damage model ) . ANy solution for this ? Thank you in advance.

Vamsi-IITI commented 9 months ago

Thanks you to everyone. Shifting to PyMechanical worked. Closing this issue.