-
Hello All, I am new to using Pyansys, I am trying to run a small simulation using PyMAPDL. The simulation is solving when I open in Ansys Mechanical APDL GUI I can see the results of stress, deformation etc, but when I read .rst file using Pymreader or dpf.post it is giving me Here is the basic code I am using to run and save the files import time
from typing import Union, Any
from ansys.mapdl.core import launch_mapdl
import os
import time # to use the clock function in calculating time delays
for i in r_list:
r = i
for j in t_list:
t=j
start_time = time.time()
mapdl = launch_mapdl(additional_switches='-smp',nproc=12)
mapdl.clear()
mapdl.prep7()
mapdl.units('USER') # User system (mm, MPa, N,kg, s, K).
E=110
nu=0.6
Directory_Counter = f'Simulation_results'
path_APDL = 'D:/Projects/ANSYS/' + str(
Directory_Counter) # adds 'test' directory to this path
if os.path.exists(path_APDL):
shutil.rmtree(path_APDL)
os.mkdir(path_APDL)
else:
os.mkdir(path_APDL)
mapdl.cwd(path_APDL)
os.chdir(path_APDL)
path_Python = os.getcwd()
print(path_Python)
"""
Some geometry code
"""
#set the material props
mapdl.et(1, "BEAM189")
mapdl.mp('EX', 1, E) #setting youngs modulus in all direction
mapdl.mp('NUXY', 1, nu) #setting poissons ratio
mapdl.secnum(1)
mapdl.allsel()
mapdl.lesize('ALL', "", "", 10)
mapdl.lmesh("All")
mapdl.finish()
#mapdl.run('/SOLU')
mapdl.slashsolu()
mapdl.antype("STATIC")
mapdl.allsel()
# write out all results at all substeps to the result file
mapdl.outres("ALL", "ALL")
# Enter post-processor
mapdl.post1()
#mapdl.set(lstep=1,sbstep=101) # Select the first load step
print(mapdl.set("list") )
max_eqv_stress = np.max(mapdl.post_processing.nodal_eqv_stress())
all_dof = mapdl.mesh.nnum_all
num_dof = all_dof.size
print(num_dof)
print(max_eqv_stress)
print(len(mapdl.post_processing.nodal_eqv_stress()))
result = mapdl.result
number_of_results = result.n_results
print(number_of_results)
nnum, stress = result.principal_nodal_stress(0)
print(len(stress))
mapdl.save()
mapdl.finish()
end_time = time.time()
mapdl.exit() Even in here when I do result = mapdl.result it is giving me the same error. I don't know what's happening. Can some one help.
This is how I am trying to read the results |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @vig720 Beam elements do not store data like other element types. The cross sections are defined by internal nodes and hold result data. The connectivity nodes, which you are trying to retrieve results for, don't store the stress result data. So programs like WB Mechanical or Mechanical APDL have to do some data wrangling behind the scenes to give a single value at a connectivity node. Remove the Python comment characeter, #, from in front of the mapd.set command. Then list the element solution and not the nodal solution. Something like this: mapdl.post1()
mapdl.set('last')
print(mapdl.presol('s', 'comp').to_dataframe()) By default MAPDL stores the data for just the corner section nodes, so the second column of section node numbers will have gaps. But that is the result data. Check out the result section of that help link; there is a discussion on 'linearized stress' results which are traditionally used in beam design. These you can retrieve at each elements end node by a specific smisc number. SMISC results can be retrieved by mapdl.post_processing.element_values given the item/comp pair given in the etable command...bit of a run-around looking all this up in the help! Mike |
Beta Was this translation helpful? Give feedback.
Hi @vig720
If you are not a commercial customer please see here for the publically available help on beam189.
Beam elements do not store data like other element types. The cross sections are defined by internal nodes and hold result data. The connectivity nodes, which you are trying to retrieve results for, don't store the stress result data. So programs like WB Mechanical or Mechanical APDL have to do some data wrangling behind the scenes to give a single value at a connectivity node.
Remove the Python comment characeter, #, from in front of the mapd.set command.
Then list the element solution and not the nodal solution. Something like this: