Controlling ANSYSCreate an instance of ANSYS and interactively send commands to it. This is a direct interface and does not rely on writing a temporary script file.
You can also generate plots using matplotlib. Import os import pyansys path = os. Getcwd ansys = pyansys. Mapdl ( runlocation = path, interactiveplotting = True ) # create a square area using keypoints ansys.
Prep7 ansys. K ( 1, 0, 0, 0 ) ansys. K ( 2, 1, 0, 0 ) ansys. K ( 3, 1, 1, 0 ) ansys. K ( 4, 0, 1, 0 ) ansys. L ( 1, 2 ) ansys.
L ( 2, 3 ) ansys. L ( 3, 4 ) ansys. L ( 4, 1 ) ansys. Al ( 1, 2, 3, 4 ) ansys. Aplot ansys. Save ansys.
Loading and Plotting an ANSYS Archive FileANSYS archive files containing solid elements (both legacy and current), can be loaded using Archive and then converted to a vtk object. Import pyansys from pyansys import examples # Sample.cdb filename = examples. Hexarchivefile # Read ansys archive file archive = pyansys. Archive ( filename ) # Print raw data from cdb for key in archive. Raw: print ( '%s:%s '% ( key, archive.
Export Cdb Ansys Apdl
Raw key )) # Create a vtk unstructured grid from the raw data and plot it grid = archive. Parsevtk ( forcelinear = True ) grid. Plot ( color = 'w', showedges = True ) # write this as a vtk xml file grid. Save ( 'hex.vtu' ) # or as a vtk binary grid.
Save ( 'hex.vtk' ). Loading the Result FileThis example reads in binary results from a modal analysis of a beam from ANSYS. # Load the reader from pyansys import pyansys from pyansys import examples # Sample result file rstfile = examples.
Rstfile # Create result object by loading the result file result = pyansys. Readbinary ( rstfile ) # Beam natural frequencies freqs = result. Timevalues print ( freq ) 739 739 3664 9456 9457 9035 # Get the 1st bending mode shape. Results are ordered based on the sorted # node numbering.
Import Cdb File Ansys: Full Version Software For Free
Note that results are zero indexed nnum, disp = result. Nodalsolution ( 0 ) print ( disp ) 2.89623914e+01 - 2.82480489e+01 - 3.09226692e-01 2.89489249e+01 - 2.82342416e+01 2.47536161e+01 2.89177130e+01 - 2.82745126e+01 6.05151053e+00 2.88715048e+01 - 2.82764960e+01 1.22913304e+01 2.89221536e+01 - 2.82479511e+01 1.84965333e+01 2.89623914e+01 - 2.82480489e+01 3.09226692e-01. Results can be plotted non-interactively and screenshots saved by setting up the camera and saving the result.
This can help with the visualization and post-processing of a batch result.First, get the camera position from an interactive plot: cpos = result. Plotnodalsolution ( 0 ) print ( cpos ) ( 5.979345, 4.76047, 36036483 ), ( 0.5, 0.5, 2.5 ), ( - 0.509593, 0.887077, - 0.8049733 )Then generate the plot: result.
Plotnodalsolution ( 0, 'x', label = 'Displacement', cpos = cpos, screenshot = 'hexbeamdisp.png', windowsize = 800, 600 , interactive = False )Stress can be plotted as well using the below code. The nodal stress is computed in the same manner that ANSYS uses by to determine the stress at each node by averaging the stress evaluated at that node for all attached elements. For now, only component stresses can be displayed.
# Display node averaged stress in x direction for result 6 result. Plotnodalstress ( 5, 'Sx' ). Download filesDownload the file for your platform. If you're not sure which to choose, learn more about.