Extract Von Mises stress from OP2

208 views
Skip to first unread message

L D

unread,
Apr 19, 2021, 4:13:39 AM4/19/21
to pyNastran Discuss
Hello,

Firstly, thanks for this great open-source tool.

I'm trying to extract from an OP2 file the von Mises stress. 

Firstly, I simply tried to run the example given in the documentation:
However, I get the following error:
AttributeError : 'RealCompositePlateStressArray' object has no attribute 'element_node'
at the line 
for (eid, node), vm, ms in zip(stress.element_node, von_mises, max_shear)
NB: I replaced 
stress = model.ctetra_stress[isubcase]
By
stress = model.ctria3_composite_stress[isubcase]
Because the first returned me a "KeyError: 1" (and there was no tetra in the get OP2 stats, but there was a ctria3, in addition to only composite_stress instead of stress)

Secondly, I tried this example, also presented in the documentation:

And the same problem occurs: either I leave the line
stress = model.ctetra_stress[subcase_id]
And I get a KeyError:1
If I change it to 
stress = model.ctria3_composite_stress[isubcase]
I get the same error as previously: 
AttributeError : 'RealCompositePlateStressArray' object has no attribute 'element_node'

Would anyone know how to solve this?

Thank you for your help!

Best,

Laurène

Steven Doyle

unread,
Apr 19, 2021, 9:21:55 AM4/19/21
to pynastra...@googlegroups.com
Laurène,

I guess my first question is what element types do you have?

The op2 is basically the same as the f06, but faster.  Composite results for shells return a stress/strain only at the centroid and 1 value per layer.  I think the attribute you’re looking for is element_layer.

--
You received this message because you are subscribed to the Google Groups "pyNastran Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pynastran-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pynastran-discuss/ae1988d2-ce29-4ca3-aa9e-46d99ac5430dn%40googlegroups.com.

L D

unread,
Apr 19, 2021, 9:52:04 AM4/19/21
to pyNastran Discuss
Hello Steve,

Thank you for your quick answer. 

I apologize if I wasn't clear, I'm not an expert in Nastran. 
For the script of the second example (https://pynastran-git.readthedocs.io/en/latest/quick_start/op2_demo_numpy1.html#finding-the-centroidal-vm-stress-for-a-set-of-elements , screenshot of script below), this is the output of get_op2_stats:

runfile('C:/Users/extractvonmises.py', wdir='C:/Users/python')

INFO:    op2_scalar.py:1556           op2_filename = 'C:\\Users\\python\\TRAM.op2'

WARNING: op2_reader.py:268            No mode was set, assuming 'msc'

params:

  GRDPNT = 0

  K6ROT = 1.0

op2_results.gpdt: GPDT(nid_cp_cd_ps, xyz); nnodes=40103

op2_results.bgpdt: BGPDT(cd, xyz); nnodes=40103

op2_results.force.celas2_force[1]

  type=RealSpringForceArray nelements=18; table_name='OEF1X'

  data: [1, nelements, 1] where 1=[spring_force]

  data.shape = (1, 18, 1)

  element.shape = (18,)

  element type: CELAS2

  sort1

  loadIDs = [1]

 

op2_results.force.cbeam_force[1]

  type=RealCBeamForceArray nelements=759; table_name='OEF1X'

  data: [ntimes, nelements, 8] where 8=[sd, bending_moment1, bending_moment2, shear1, shear2, axial_force, total_torque, warping_torque]

  data.shape = (1, 1518, 8)

  element.shape = (1518,)

  element_node.shape = (1518, 2)

  is_sort1=True is_sort2=False

  CBEAM

  sort1

  loadIDs = [1]

 

op2_results.force.ctria3_force[1]

  type=RealPlateForceArray nelements=1193

  data: [1, nelements, 8] where 8=[mx, my, mxy, bmx, bmy, bmxy, tx, ty]

  data.shape = (1, 1193, 8)

  element.shape = (1193,)

  element type: CTRIA3

  sort1

  loadIDs = [1]

 

op2_results.force.cquad4_force[1]

  type=RealPlateForceArray nelements=23403

  data: [1, nelements, 8] where 8=[mx, my, mxy, bmx, bmy, bmxy, tx, ty]

  data.shape = (1, 23403, 8)

  element.shape = (23403,)

  element type: CQUAD4

  sort1

  loadIDs = [1]

 

op2_results.stress.celas2_stress[1]

  type=RealSpringStressArray nelements=18

  eType

  data: [1, nelements, 1] where 1=[spring_stress]

  element.shape = (18,)

  data.shape = (1, 18, 1)

  element type: CELAS2

  sort1

  lsdvmns = [1]

 

op2_results.stress.cpenta_stress[1]

  type=RealSolidStressArray nelements=2320 nnodes=16240

  nodes_per_element=7 (including centroid)

  eType, cid

  data: [1, nnodes, 10] where 10=[oxx, oyy, ozz, txy, tyz, txz, omax, omid, omin, von_mises]

  element_node.shape = (16240, 2)

  element_cid.shape = (2320, 2)

  data.shape = (1, 16240, 10)

  element name: CPENTA

  sort1

  lsdvmns = [1]

 

op2_results.stress.chexa_stress[1]

  type=RealSolidStressArray nelements=15056 nnodes=135504

  nodes_per_element=9 (including centroid)

  eType, cid

  data: [1, nnodes, 10] where 10=[oxx, oyy, ozz, txy, tyz, txz, omax, omid, omin, von_mises]

  element_node.shape = (135504, 2)

  element_cid.shape = (15056, 2)

  data.shape = (1, 135504, 10)

  element name: CHEXA

  sort1

  lsdvmns = [1]

 

op2_results.failure_indices.cquad4_composite_force[1]

  type=FailureIndicesArray nelements=51589; table_name='OEFIT'

  data: [1, nelements, 3] where 3=[failure_index_for_ply (direct stress/strain), failure_index_for_bonding (interlaminar stresss), max_value]

  data.shape = (1, 51589, 3)

  element type: QUAD4LC-composite

  sort1

  loadIDs = [1]

 

op2_results.failure_indices.ctria3_composite_force[1]

  type=FailureIndicesArray nelements=1895; table_name='OEFIT'

  data: [1, nelements, 3] where 3=[failure_index_for_ply (direct stress/strain), failure_index_for_bonding (interlaminar stresss), max_value]

  data.shape = (1, 1895, 3)

  element type: TRIA3LC-composite

  sort1

  loadIDs = [1]

 

displacements[1]

  isubcase = 1

  type=RealDisplacementArray nnodes=40103, table_name=BOUGV1

  data: [t1, t2, t3, r1, r2, r3] shape=[1, 40103, 6] dtype=float32

  node_gridtype.shape = (40103, 2)

  sort1

  lsdvmns = [1]

 

spc_forces[1]

  isubcase = 1

  type=RealSPCForcesArray nnodes=40103, table_name=OQG1

  data: [t1, t2, t3, r1, r2, r3] shape=[1, 40103, 6] dtype=float32

  node_gridtype.shape = (40103, 2)

  sort1

  lsdvmns = [1]

 

cbeam_stress[1]

  type=RealBeamStressArray nelements=834 nnodes_per_element=10 ntotal=8349

  data: [1, ntotal, 8] where 8=[sxc, sxd, sxe, sxf, smax, smin, MS_tension, MS_compression]

  element_node.shape = (1518, 2)

  xxb.shape = (1518,)

  data.shape = (1, 1518, 8)

  element type: CBEAM

  sort1

  lsdvmns = [1]

 

ctria3_stress[1]

  type=RealPlateStressArray nelements=316 nnodes_per_element=1 nlayers=2 ntotal=632

  data: [1, ntotal, 8] where 8=[fiber_distance, oxx, oyy, txy, angle, omax, omin, von_mises]

  element_node.shape = (632, 2)

  data.shape=(1, 632, 8)

  element type: CTRIA3

  s_code: 1

  sort1

  lsdvmns = [1]

 

cquad4_stress[1]

  type=RealPlateStressArray nelements=2228 nnodes_per_element=1 nlayers=2 ntotal=4456

  data: [1, ntotal, 8] where 8=[fiber_distance, oxx, oyy, txy, angle, omax, omin, von_mises]

  element_node.shape = (4456, 2)

  data.shape=(1, 4456, 8)

  element type: CQUAD4

  s_code: 1

  sort1

  lsdvmns = [1]

 

cquad4_composite_stress[1]

  type=RealCompositePlateStressArray nelements=21175 ntotal=51589

  data: [1, ntotal, 9] where 9=[o11, o22, t12, t1z, t2z, angle, major, minor, max_shear]

  element_layer.shape = (51589, 2)

  data.shape = (1, 51589, 9)

  element type: QUAD4LC-composite

  sort1

  lsdvmns = [1]

 

ctria3_composite_stress[1]

  type=RealCompositePlateStressArray nelements=877 ntotal=1895

  data: [1, ntotal, 9] where 9=[o11, o22, t12, t1z, t2z, angle, major, minor, max_shear]

  element_layer.shape = (1895, 2)

  data.shape = (1, 1895, 9)

  element type: TRIA3LC-composite

  sort1

  lsdvmns = [1]

 

 

stress_headers = ['o11', 'o22', 't12', 't1z', 't2z', 'angle', 'major', 'minor', 'max_shear']

Traceback (most recent call last):

 

  File "<ipython-input-6-fb1b1ba02490>", line 1, in <module>

    runfile('C:/Users/python/extractvonmises.py', wdir='C:/Users/python')

 

  File "C:\Applications\Anaconda3.7\envs\py37nastran\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile

    execfile(filename, namespace)

 

  File "C:\Applications\Anaconda3.7\envs\py37nastran\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile

    exec(compile(f.read(), filename, 'exec'), namespace)

 

  File "C:/Users/python/extractvonmises.py", line 33, in <module>

    element_node = stress.element_node

 

AttributeError: 'RealCompositePlateStressArray' object has no attribute 'element_node'



This makes me think that the OP2 file is uploaded correctly.

As you suggested, I tried replacing element_node by element_layer, but got an "AssertionError" on line 43 (sasert np;array_equal(ueids, ueids_slow).


Thank you for your help.


Best,


Laurène  



scriptVM[9066].PNGerrorVM[9065].PNG

Steven Doyle

unread,
Apr 19, 2021, 10:56:55 AM4/19/21
to pyNastran Discuss
That example uses a CTETRA bar, which has a stress for each of the 4 nodes and the centroid (even though it uses TET10 elements).  The model doesn't have any composite elements.

You have: 

ctria3_composite_stress[1]

  type=RealCompositePlateStressArray nelements=877 ntotal=1895

  data: [1, ntotal, 9] where 9=[o11, o22, t12, t1z, t2z, angle, major, minor, max_shear]   # max shear stress

  element_layer.shape = (1895, 2)    #  the parameter I think you want

  data.shape = (1, 1895, 9)

  element type: TRIA3LC-composite

  sort1

  lsdvmns = [1]


You have requested max shear stress.  Based on the STRESS=ALL flag you use, you get max shear or von Mises, but sometimes it ignores you.  I'm not even totally sure von Mises stress is for a composite element, so I'm not sure if you really want it, but you can calculate it.


Steve


L D

unread,
Apr 20, 2021, 2:57:18 AM4/20/21
to pyNastran Discuss
Steve,

Thank you very much for taking the time to answer me.
With your advice, I solved my issue and manage to get the VM stress!

Have a great day,

Laurène

Reply all
Reply to author
Forward
0 new messages