Reading in ESE results

25 views
Skip to first unread message

Daniel

unread,
Sep 15, 2025, 5:29:05 PM (12 days ago) Sep 15
to pyNastran Discuss
Hi Steve,

I am trying to read in elastic strain energy (ESE) results from a SOL 103 OP2 file. Typically when I read results from an OP2 file in the SORT1 format, it'll return the results in a dictionary, where the keys are the case numbers. For some reason, when I read in ESE data, pyNastran will store the data in a dictionary with keys like, `dict_keys([(1, 2, 1, 0, 0, '', ''), (1, 2, 2, 0, 0, '', '')])`. The first key is the data I want, but the second key is returning something I don't recognize. FWIW, I am using pyNastran version 1.4.1.

I guess I am wondering if this is intentional because I am writing a script that pulls data from op2 files, and it would be nice to have it behave similarly to the other data types. Here's an example op2 file: https://drive.google.com/file/d/1XVPV4aLPtrFYV9eryuBQP4Nw69-qlNzI/view?usp=sharing

Thank you!
-Daneil

Steven Doyle

unread,
Sep 16, 2025, 12:30:27 AM (12 days ago) Sep 16
to pynastra...@googlegroups.com
This link talks about the case key. The combine=Flse in read_op2 will alsways use the long form. The case key cannot be collapsed. https://pynastran-git.readthedocs.io/en/latest/quick_start/op2_pandas_multi_case.html#single-subcase-buckling-example

Are you using mixed SORT1 / SORT2?



--
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 visit https://groups.google.com/d/msgid/pynastran-discuss/1fa9eb6c-da83-45b4-af88-35816910e0aen%40googlegroups.com.

Daniel

unread,
Sep 16, 2025, 1:19:03 PM (11 days ago) Sep 16
to pyNastran Discuss
Hi Steve,

Thanks for the response. Below are my outputs in the Case Control block, where I am using just SORT1:

  $ Output requests
  MEFFMASS(PLOT,ALL) = YES
  DISP(PLOT,SORT1) = ALL
  ESE(PLOT,SORT1) = ALL

This is what I get when I call "get_result()" for the strain energy:

>>> op2.get_result("strain_energy.cquad4_strain_energy")                                      
{(1, 2, 1, 0, 0, '', ''):   type=RealStrainEnergyArray element_name='QUAD4' ntimes=10 nelements=37
  element: [ntimes, nelements]; eid=100000000 -> total
  data: [ntimes, nelements, 3] where 3=[strain_energy, percent, strain_energy_density]
  data.shape = (10, 37, 3)
  sort1
  modes = [ 1  2  3  4  5  6  7  8  9 10]; dtype=int32
  freqs = [ 54.84672928 102.2430191  102.2430191  122.57095337 215.83390808
 232.42959595 275.84429932 275.84429932 294.90597534 294.90597534]; dtype=float64
, (1, 2, 2, 0, 0, '', ''):   type=RealStrainEnergyArray element_name='QUAD4' ntimes=10 nelements=37
  element: [ntimes, nelements]; eid=100000000 -> total
  data: [ntimes, nelements, 3] where 3=[strain_energy, percent, strain_energy_density]
  data.shape = (10, 37, 3)
  sort1
  modes = [ 1  2  3  4  5  6  7  8  9 10]; dtype=int32
  eigrs = [773.33306885 773.33306885 773.33306885 773.33306885 773.33306885
 773.33306885 773.33306885 773.33306885 773.33306885 773.33306885]; dtype=float64
  mode_cycles = [1.35631823e-19 1.35631823e-19 1.35631823e-19 1.35631823e-19
 1.35631823e-19 1.35631823e-19 1.35631823e-19 1.35631823e-19
 1.35631823e-19 1.35631823e-19]; dtype=float64
}

I also wrote the strain energy to an F06 file to see if I can find what's being pulled from the OP2 database but couldn't trace that to anything. I am running a vanilla SOL 103 solution so I'm not expecting any kind of intermediate step in the results database. Below is the full run deck, for your reference.

Thank you,
Daniel



INIT MASTER(S)

$ ---------------------------------------------------------------------
$ EXECUTIVE CONTROL

ID MODES
SOL 103
GEOMCHECK NONE
CEND

$ ---------------------------------------------------------------------
$ CASE CONTROL

  TITLE = MODES
  METHOD = 10
  ECHO = NONE
 
  $ Define the SPC set ID to use in the analysis
  $     E.g. SPC = 1
  SPC = 1
 
  $ Output requests
  MEFFMASS(PLOT,ALL) = YES
  DISP(PLOT,SORT1) = ALL
  ESE(PLOT,SORT1) = ALL

$ ---------------------------------------------------------------------
$ Bulk Data

BEGIN BULK
PARAM,GRDPNT,0
PARAM,POST,-1
PARAM,AUTOSPC,NO    $ Don't auto-SPC singularities

$ Define the eigen solution space
$   EXAMPLE:
EIGRL         10     -1.              10       0                    MASS

$ Define constraints
$ E.G.:
$   SPC1,1,123456,1,THRU,4
SPC1           1  123456     134     137     146     149

$ ---------------------------------------------
$ Include any bulk Data

$ Femap Material 1 : Aluminum
MAT1           1 6.89+10  2.5+10     .33   2700.      0.      0.

PSHELL       101       1     .02       1    100.       1              0.
GRID         101       0      .5      0.      0.       0
GRID         102       0      1.      .5      0.       0
GRID         103       0      .5      1.      0.       0
GRID         104       0      0.      .5      0.       0
GRID         105       0      .5      .5      0.       0
GRID         106       0     1.5      0.      0.       0
GRID         107       0      2.      .5      0.       0
GRID         108       0     1.5      1.      0.       0
GRID         109       0     1.5      .5      0.       0
GRID         110       0     2.5      0.      0.       0
GRID         111       0      3.      .5      0.       0
GRID         112       0     2.5      1.      0.       0
GRID         113       0     2.5      .5      0.       0
GRID         114       0      1.     1.5      0.       0
GRID         115       0      .5      2.      0.       0
GRID         116       0      0.     1.5      0.       0
GRID         117       0      .5     1.5      0.       0
GRID         118       0      2.     1.5      0.       0
GRID         119       0     1.5      2.      0.       0
GRID         120       0     1.5     1.5      0.       0
GRID         121       0      3.     1.5      0.       0
GRID         122       0     2.5      2.      0.       0
GRID         123       0     2.5     1.5      0.       0
GRID         124       0      1.     2.5      0.       0
GRID         125       0      .5      3.      0.       0
GRID         126       0      0.     2.5      0.       0
GRID         127       0      .5     2.5      0.       0
GRID         128       0      2.     2.5      0.       0
GRID         129       0     1.5      3.      0.       0
GRID         130       0     1.5     2.5      0.       0
GRID         131       0      3.     2.5      0.       0
GRID         132       0     2.5      3.      0.       0
GRID         133       0     2.5     2.5      0.       0
GRID         134       0      0.      0.      0.       0
GRID         135       0      1.      0.      0.       0
GRID         136       0      2.      0.      0.       0
GRID         137       0      3.      0.      0.       0
GRID         138       0      0.      1.      0.       0
GRID         139       0      1.      1.      0.       0
GRID         140       0      2.      1.      0.       0
GRID         141       0      3.      1.      0.       0
GRID         142       0      0.      2.      0.       0
GRID         143       0      1.      2.      0.       0
GRID         144       0      2.      2.      0.       0
GRID         145       0      3.      2.      0.       0
GRID         146       0      0.      3.      0.       0
GRID         147       0      1.      3.      0.       0
GRID         148       0      2.      3.      0.       0
GRID         149       0      3.      3.      0.       0
CQUAD4       101     101     101     135     102     105                
CQUAD4       102     101     104     105     103     138                
CQUAD4       103     101     105     102     139     103                
CQUAD4       104     101     106     136     107     109                
CQUAD4       105     101     102     109     108     139                
CQUAD4       106     101     109     107     140     108                
CQUAD4       107     101     110     137     111     113                
CQUAD4       108     101     107     113     112     140                
CQUAD4       109     101     113     111     141     112                
CQUAD4       110     101     103     139     114     117                
CQUAD4       111     101     116     117     115     142                
CQUAD4       112     101     117     114     143     115                
CQUAD4       113     101     108     140     118     120                
CQUAD4       114     101     114     120     119     143                
CQUAD4       115     101     120     118     144     119                
CQUAD4       116     101     112     141     121     123                
CQUAD4       117     101     118     123     122     144                
CQUAD4       118     101     123     121     145     122                
CQUAD4       119     101     115     143     124     127                
CQUAD4       120     101     126     127     125     146                
CQUAD4       121     101     127     124     147     125                
CQUAD4       122     101     119     144     128     130                
CQUAD4       123     101     124     130     129     147                
CQUAD4       124     101     130     128     148     129                
CQUAD4       125     101     122     145     131     133                
CQUAD4       126     101     128     133     132     148                
CQUAD4       127     101     133     131     149     132                
CQUAD4       128     101     134     101     105     104                
CQUAD4       129     101     135     106     109     102                
CQUAD4       130     101     136     110     113     107                
CQUAD4       131     101     138     103     117     116                
CQUAD4       132     101     139     108     120     114                
CQUAD4       133     101     140     112     123     118                
CQUAD4       134     101     142     115     127     126                
CQUAD4       135     101     143     119     130     124                
CQUAD4       136     101     144     122     133     128

ENDDATA

Daniel

unread,
Sep 16, 2025, 8:51:40 PM (11 days ago) Sep 16
to pyNastran Discuss
After playing with this some more I found that excluding ESE but including EKE (or STRESS) caused the behavior to go back to case numbering the dictionary keys (not the long form). It's not clear why ESE data is causing pyNastran to store multiple data sets. I did find that the "percent" column of the strain_energy.cquad4_strain_energy result for the 2nd dictionary key is the same as the "percent" column for the kinetic_energy.cquad4_kinetic_energy result, see below. This suggests they may be related somehow (the data below are from two different databases, the top one only had ESE, while the bottom one had both ESE and EKE in Case Control).

>>> op2.get_result("strain_energy.cquad4_strain_energy")[(1, 2, 2, 0, 0, '', '')].dataframe
     Mode      Freq  Eigenvalue    Radians  ElementID  strain_energy     percent  strain_energy_density
0     1.0  4.425919  773.333069  27.808867        101       0.007859    1.571723               1.571723
1     1.0  4.425919  773.333069  27.808867        102       0.007859    1.571723               1.571723
2     1.0  4.425919  773.333069  27.808867        103       0.014712    2.942455               2.942455
3     1.0  4.425919  773.333069  27.808867        104       0.013018    2.603682               2.603682
4     1.0  4.425919  773.333069  27.808867        105       0.020153    4.030698               4.030698
..    ...       ...         ...        ...        ...            ...         ...                    ...
365  10.0  4.425919  773.333069  27.808867        133       0.015914    3.182881               3.182881
366  10.0  4.425919  773.333069  27.808867        134       0.012087    2.417426               2.417426
367  10.0  4.425919  773.333069  27.808867        135       0.014323    2.864643               2.864643
368  10.0  4.425919  773.333069  27.808867        136       0.016018    3.203581               3.203581
369  10.0  4.425919  773.333069  27.808867  100000000       0.500000  100.000000                    NaN

[370 rows x 8 columns]
>>> op2.get_result("kinetic_energy.cquad4_kinetic_energy")[(1, 2, 1, 0, 0, '', '')].dataframe
     Mode      Freq  Eigenvalue    Radians  ElementID  kinetic_energy     percent  kinetic_energy_density
0     1.0  4.425919  773.333069  27.808867        101    9.332696e+02    1.571723            1.866539e+05
1     1.0  4.425919  773.333069  27.808867        102    9.332696e+02    1.571723            1.866539e+05
2     1.0  4.425919  773.333069  27.808867        103    1.747193e+03    2.942455            3.494387e+05
3     1.0  4.425919  773.333069  27.808867        104    1.546035e+03    2.603682            3.092069e+05
4     1.0  4.425919  773.333069  27.808867        105    2.393379e+03    4.030698            4.786758e+05
..    ...       ...         ...        ...        ...             ...         ...                     ...
365  10.0  4.425919  773.333069  27.808867        133    5.464084e+04    3.182881            1.092817e+07
366  10.0  4.425919  773.333069  27.808867        134    4.150020e+04    2.417426            8.300038e+06
367  10.0  4.425919  773.333069  27.808867        135    4.917760e+04    2.864643            9.835520e+06
368  10.0  4.425919  773.333069  27.808867        136    5.499620e+04    3.203581            1.099924e+07
369  10.0  4.425919  773.333069  27.808867  100000000    1.716710e+06  100.000000                     NaN

[370 rows x 8 columns]


Also, the dev version of pyNastran doesn't seem to be storing Freq, Eigenvalue and Radians column data correctly for `strain_energy.cquad4_strain_energy` or `kinetic_energy.cquad4_kinetic_energy`. It just stores duplicate values that aren't associated with anything, from what I can tell. Below is a copy/paste from my console comparing the data read by the released pyNastran and dev version.

Release:

>>> import pyNastran                                                                      
>>> pyNastran.__version__
'1.4.1'
>>>
>>> op2 = OP2(debug=False, mode="nx")
>>> op2.read_op2(r"<path to file>", build_dataframe=True)
INFO:    op2_scalar.py:1963           op2_filename = ' <path to file> '
self.cannot apply column_names=['Mode', 'Freq'] to RealStrainEnergyArray: 'QUAD4'
self.cannot apply column_names=['Mode', 'EigenvalueReal'] to RealStrainEnergyArray: 'QUAD4'
>>>
>>> op2.get_result("strain_energy.cquad4_strain_energy")[(1, 2, 1, 0, 0, '', '')].dataframe
     Mode        Freq  ElementID  strain_energy     percent  strain_energy_density
0     1.0   54.846729        101   1.176521e+03    1.981382           2.353041e+05
1     1.0   54.846729        102   1.176521e+03    1.981382           2.353041e+05
2     1.0   54.846729        103   6.074477e+02    1.023005           1.214895e+05
3     1.0   54.846729        104   1.384967e+03    2.332429           2.769935e+05
4     1.0   54.846729        105   1.420850e+03    2.392859           2.841701e+05
..    ...         ...        ...            ...         ...                    ...
365  10.0  294.905975        133   1.500799e+04    0.874230           3.001599e+06
366  10.0  294.905975        134   2.654281e+04    1.546144           5.308562e+06
367  10.0  294.905975        135   2.068896e+04    1.205152           4.137792e+06
368  10.0  294.905975        136   7.018446e+03    0.408831           1.403689e+06
369  10.0  294.905975  100000000   1.716710e+06  100.000000                    NaN

[370 rows x 6 columns]


Dev:

>>> import pyNastran
>>> pyNastran.__version__
'1.5.0+dev.4d548e7c5'
>>>
>>> op2 = OP2(debug=False, mode="nx")
>>> op2.read_op2(r" <path to file> ", build_dataframe=True)
INFO:    op2_scalar.py:1960           op2_filename = ' <path to file> '
self.cannot apply column_names=['Mode', 'Freq', 'Eigenvalue', 'Radians'] to RealStrainEnergyArray: QUAD4
self.cannot apply column_names=['Mode', 'Freq', 'Eigenvalue', 'Radians'] to RealStrainEnergyArray: QUAD4
>>>
>>> op2.get_result("strain_energy.cquad4_strain_energy")[(1, 2, 1, 0, 0, '', '')].dataframe
     Mode      Freq  Eigenvalue    Radians  ElementID  strain_energy     percent  strain_energy_density
0     1.0  4.425919  773.333069  27.808867        101   1.176521e+03    1.981382           2.353041e+05
1     1.0  4.425919  773.333069  27.808867        102   1.176521e+03    1.981382           2.353041e+05
2     1.0  4.425919  773.333069  27.808867        103   6.074477e+02    1.023005           1.214895e+05
3     1.0  4.425919  773.333069  27.808867        104   1.384967e+03    2.332429           2.769935e+05
4     1.0  4.425919  773.333069  27.808867        105   1.420850e+03    2.392859           2.841701e+05
..    ...       ...         ...        ...        ...            ...         ...                    ...
365  10.0  4.425919  773.333069  27.808867        133   1.500799e+04    0.874230           3.001599e+06
366  10.0  4.425919  773.333069  27.808867        134   2.654281e+04    1.546144           5.308562e+06
367  10.0  4.425919  773.333069  27.808867        135   2.068896e+04    1.205152           4.137792e+06
368  10.0  4.425919  773.333069  27.808867        136   7.018446e+03    0.408831           1.403689e+06
369  10.0  4.425919  773.333069  27.808867  100000000   1.716710e+06  100.000000                    NaN

[370 rows x 8 columns]


Thanks again,
Daniel
Reply all
Reply to author
Forward
0 new messages