SteveDoyle2 / pyNastran

A Python-based interface tool for Nastran's file formats
Other
393 stars 154 forks source link

OP2 reading of flutter 145 solution #338

Closed alby3z closed 8 years ago

alby3z commented 8 years ago

I've encountered an error when reading the eigenvalues of a SOL145 flutter solution.

The error output by pyNastran (v 8.0) is the following:

op2.eigenvalues Traceback (most recent call last):

File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\core\formatters.py", line 699, in call printer.pretty(obj)

File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\lib\pretty.py", line 368, in pretty return self.type_pprinters[cls](obj, self, cycle)

File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\lib\pretty.py", line 623, in inner p.pretty(obj[key])

File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\lib\pretty.py", line 383, in pretty return _default_pprint(obj, self, cycle)

File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\lib\pretty.py", line 503, in _default_pprint _repr_pprint(obj, p, cycle)

File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\lib\pretty.py", line 694, in _repr_pprint output = repr(obj)

File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\pynastran-0.8.0-py3.5.egg\pyNastran\op2\tables\lama_eigenvalues\lama_objects.py", line 237, in repr eigenvalue[0], eigenvalue[1], cycle, damping)

TypeError: 'complex' object is not subscriptable

In the zip file attached you find the bdf files and the op2 obtained with nastran 2012:

BAH_PLANE.zip

alby3z commented 8 years ago

Moreover, in the f06 NASTRAN gives not only the nodal eigenvectors but also the modal eigenvector. Is it possible to have the latter in the op2?

SteveDoyle2 commented 8 years ago

The bug is fixed. However, since you're using Jupyter, I recommend using the following, so it looks better:

model.eigenvectors['BAH PLANE'].data_frame

By chance, do you know how to tell if you're running from Jupyter? The build_dataframe should probably default to true for Jupyter, and the reprs should write the dataframe.

Moreover, in the f06 NASTRAN gives not only the nodal eigenvectors but also the modal eigenvector. Is it possible to have the latter in the op2?

I don't understand the question. Eigenvectors are calculated at the nodes and are the modes. I think I'd need to see an example.

alby3z commented 8 years ago

I am not an expert, anyway I am using spider IDE that is part of the Anaconda installation.

What does do the command "model.eigenvectors['BAH PLANE'].data_frame"? I will try the next week because I have python on the work pc.

You're right, I haven't been precise. I was talking about the modal participation that NASTRAN (for example) output in the f06 when performing a SOL145 solution. This array has a number of elements equal to the number of modes used in the flutter analysis.

SteveDoyle2 commented 8 years ago

If you ran with build_dataframe=True, you'll get

model.eigenvectors['BAH PLANE'].data_frame

alternatively:

model.eigenvectors['BAH PLANE'].build_dataframe()
model.eigenvectors['BAH PLANE'].data_frame

That'll make an HTML viewable pandas dataframe.

alby3z commented 8 years ago

Now I get both eigenvectors and eigenvalues.

What I do not understand is why the op2.flutter_response field is empty (NoneType). The relevant code is in op2_scalar, as reported below:

' elif Type == 84: # FLUTTER (iii, label, mode, (Ma, V, rho), flutter_id, fff) out = unpack(self._endian + 'iii 8s iii fff i fff', data) mode = out[6] mach = out[7] velocity = out[8] density = out[9] flutter_id = out[10] msg = 'FLUTTER - _count=%s label=%r region=%s subcase=%s mode=%s mach=%s velocity=%s density=%s flutter_id=%s' % ( self._count, response_label, region, subcase, mode, mach, velocity, density, flutter_id) self.flutter_response.append(internal_id, dresp_id, response_label, region, subcase, type_flag, seid, mode, mach, velocity, density, flutter_id) '

alby3z commented 8 years ago

The other issue that I've encountered is that creating the op2 using NASTRAN 2012, pyNastran outputs the following error:

op2.read_op2(BAH_Plane2012.op2');
DEBUG:     fname=op2.py                    lineNo=369    combine=True
DEBUG:     fname=op2.py                    lineNo=370    -------- reading op2 with read_mode=1 --------
INFO:      fname=op2_scalar.py             lineNo=1176   op2_filename = 'BAH_Plane2012.op2'
DEBUG:     fname=op2_scalar.py             lineNo=1364     table_name=b'PVT0'
DEBUG:     fname=op2_scalar.py             lineNo=1364     table_name=b'CSTM'
DEBUG:     fname=op2_scalar.py             lineNo=1364     table_name=b'GPL'
DEBUG:     fname=op2_scalar.py             lineNo=1981   table_name = b'GPL'
DEBUG:     fname=op2_scalar.py             lineNo=1364     table_name=b'GPDT'
DEBUG:     fname=op2_scalar.py             lineNo=1364     table_name=b'EPT'
DEBUG:     fname=op2_scalar.py             lineNo=1364     table_name=b'MPT'
DEBUG:     fname=op2_scalar.py             lineNo=1364     table_name=b'GEOM2'
DEBUG:     fname=op2_scalar.py             lineNo=1364     table_name=b'GEOM4'
DEBUG:     fname=op2_scalar.py             lineNo=1364     table_name=b'GEOM1'
DEBUG:     fname=op2_scalar.py             lineNo=1364     table_name=b'BGPDT'
DEBUG:     fname=op2_scalar.py             lineNo=1364     table_name=b'DITS'
Traceback (most recent call last):

  File "<ipython-input-91-dd52fe82eec4>", line 1, in <module>
    op2.read_op2(BAH_Plane2012.op2');

  File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\pynastran-0.9.0+dev.no.checksum.error-py3.5.egg\pyNastran\op2\op2.py", line 375, in read_op2
    OP2_Scalar.read_op2(self, op2_filename=op2_filename)

  File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\pynastran-0.9.0+dev.no.checksum.error-py3.5.egg\pyNastran\op2\op2_scalar.py", line 1300, in read_op2
    table_names = self._read_tables(table_name)

  File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\pynastran-0.9.0+dev.no.checksum.error-py3.5.egg\pyNastran\op2\op2_scalar.py", line 1410, in _read_tables
    raise NotImplementedError(msg)

NotImplementedError: geom/results split: b'DITS'

If you have matrices that you want to read, see:
  model.set_additional_matrices(matrices)

Attached the op2: BAH_Plane2012.zip

SteveDoyle2 commented 8 years ago

The op2.flutter_response is an optimization output.

I do a lot of aero analysis in Nastran and as far as I know you cannot create the vast majority of the aero outputs (e.g. stability derivative/aero pressure/flutter tables). It's written only to the F06.

The DITS table is now skipped.

On Mon, Sep 12, 2016 at 6:19 AM, alby3z notifications@github.com wrote:

The other issue that I've encountered is that creating the op2 using NASTRAN 2012, pyNastran outputs the following error:

op2.read_op2(BAH_Plane2012.op2'); DEBUG: fname=op2.py lineNo=369 combine=True DEBUG: fname=op2.py lineNo=370 -------- reading op2 with read_mode=1 -------- INFO: fname=op2_scalar.py lineNo=1176 op2_filename = 'A:\Archive\Trezzini\AW609\FE_MODELLING\FIXED_WING_FLUTTER\PYNASTRAN_READ_FLUTTER\BAH_Plane\BAH_PLANE\BAH_Plane2012.op2' DEBUG: fname=op2_scalar.py lineNo=1364 table_name=b'PVT0' DEBUG: fname=op2_scalar.py lineNo=1364 table_name=b'CSTM' DEBUG: fname=op2_scalar.py lineNo=1364 table_name=b'GPL' DEBUG: fname=op2_scalar.py lineNo=1981 table_name = b'GPL' DEBUG: fname=op2_scalar.py lineNo=1364 table_name=b'GPDT' DEBUG: fname=op2_scalar.py lineNo=1364 table_name=b'EPT' DEBUG: fname=op2_scalar.py lineNo=1364 table_name=b'MPT' DEBUG: fname=op2_scalar.py lineNo=1364 table_name=b'GEOM2' DEBUG: fname=op2_scalar.py lineNo=1364 table_name=b'GEOM4' DEBUG: fname=op2_scalar.py lineNo=1364 table_name=b'GEOM1' DEBUG: fname=op2_scalar.py lineNo=1364 table_name=b'BGPDT' DEBUG: fname=op2_scalar.py lineNo=1364 table_name=b'DITS' Traceback (most recent call last):

File "", line 1, in op2.read_op2(BAH_Plane2012.op2');

File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\pynastran-0.9.0+dev.no.checksum.error-py3.5.egg\pyNastran\op2\op2.py", line 375, in read_op2 OP2_Scalar.read_op2(self, op2_filename=op2_filename)

File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\pynastran-0.9.0+dev.no.checksum.error-py3.5.egg\pyNastran\op2\op2_scalar.py", line 1300, in read_op2 table_names = self._read_tables(table_name)

File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\pynastran-0.9.0+dev.no.checksum.error-py3.5.egg\pyNastran\op2\op2_scalar.py", line 1410, in _read_tables raise NotImplementedError(msg)

NotImplementedError: geom/results split: b'DITS'

If you have matrices that you want to read, see: model.set_additional_matrices(matrices)

Attached the op2: BAH_Plane2012.zip https://github.com/SteveDoyle2/pyNastran/files/467383/BAH_Plane2012.zip

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SteveDoyle2/pyNastran/issues/338#issuecomment-246344497, or mute the thread https://github.com/notifications/unsubscribe-auth/ABAqWaGi5GuSh8QEpR3-XS_R5FXyM4p8ks5qpVF6gaJpZM4J4x3E .

alby3z commented 8 years ago

Wouldn't be worth to add an f06 parser for the flutter solution?! 😉

For what concern the flutter solution, using the PK method and requesting negative velocity in the FLFACT(3), I have been able to output all the eigenvalues for all the loops defined in the FLUTTER card. Unfortunately Nastran doesn't associate the n-th loop (mach, density, velocity) with the relevant eigenvalues/eigenvectors, but simply output a list of modes that is equal to the number of required modes multiplied by the total number of permutation of the value written in the three FLFACT cards.

I have also output the V-g table in a pch file and tried to parse it with the bdf reader (with the punch file option set to True), but it gave me an error.

SteveDoyle2 commented 8 years ago

Wouldn't be worth to add an f06 parser for the flutter solution?!

I actually do have one, but it's proprietary at the moment.

I killed the whole F06 parsing because it's just so hard to make a robust F06 parser. It works better to have standalone scripts that do one thing (e.g. parse flutter results, get the mass, get stability derivatives). SOL 200 with multiple cases with poorly formatted headers becomes a nightmare. The OP2 is just easier for 99.9% of things. I figured most people have their own F06 parsing scripts.

Unfortunately Nastran doesn't associate the n-th loop (mach, density, velocity) with the relevant eigenvalues/eigenvectors, but simply output a list of modes that is equal to the number of required modes multiplied by the total number of permutation of the value written in the three FLFACT cards.

Try using only 1 point and 1 subcase. Nastran is dumber than bricks and overwrites the modes.

Go to the F06, find the Mach, V, rho (I use PKNL, so use whatever the PK method uses) where flutter is, and make new FLFACT cards. Then rerun the analysis with DISP(PLOT)=ALL to get the flutter mode. You'll need to go back through the F06 to find what mode flutter occurs for because mode switching messes with the table.

I have also output the V-g table in a pch file and tried to parse it with the bdf reader (with the punch file option set to True), but it gave me an error.

There are 2 types of PCH files. One is a SOL 200 output and looks like a BDF (e.g. it has PSHELLs and MAT1s), but without an executive control deck and case control deck. The other is a results file with the same data as you'd find in the F06/OP2 (so displacements, stress, etc.). They are not the same.

Can you send me an example of how you made a Vg-Vf plot in the PCH file (e.g. the BDF)?

On Mon, Sep 12, 2016 at 1:39 PM, alby3z notifications@github.com wrote:

Wouldn't be worth to add an f06 parser for the flutter solution?! 😉

For what concern the flutter solution, using the PK method and requesting negative velocity in the FLFACT(3), I have been able to output all the eigenvalues for all the loops defined in the FLUTTER card. Unfortunately Nastran doesn't associate the n-th loop (mach, density, velocity) with the relevant eigenvalues/eigenvectors, but simply output a list of modes that is equal to the number of required modes multiplied by the total number of permutation of the value written in the three FLFACT cards.

I have also output the V-g table in a pch file and tried to parse it with the bdf reader (with the punch file option set to True), but it gave me an error.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SteveDoyle2/pyNastran/issues/338#issuecomment-246484566, or mute the thread https://github.com/notifications/unsubscribe-auth/ABAqWbILlj844QijwW7t6TwA0iDSfWeOks5qpbhpgaJpZM4J4x3E .

alby3z commented 8 years ago

To obtain the V-g table in the punch file, I simply add the following statement in the case:

OUTPUT(XYPLOT) XYPUNCH,VG / 1(G,F), 2(G,F), 3(G,F), 4(G,F), 5(G,F), 6(G,F), 7(G,F) / 8(G,F), 9(G,F),10(G,F)

Meaning that I require for the loops from 1 to 10, the damping (G) and frequency (F)

SteveDoyle2 commented 8 years ago

Thanks for that. Not your fault, but I find that overly complicated.

I added pyNastran/f06/parse_flutter.py. It still needs work, so at this point if you want to use it you'll probably need to hack on it a little (e.g. to set the units).

I prefer PKNL to the PK method because typically you do match point flutter analysis and can extract quantities like equivalent airspeed and altitude. However, PK is supported and PKNL (and other methods) are not because it's easier.

At the moment, it doesn't handle:

It does handle:

alby3z commented 8 years ago

Thanks for the update, I will test it tomorrow!

What I am doing at the moment is using PK with a set of negative velocity and loading in MATLAB both the op2 and the bdf with pyNastran. At this point, with some manipulation of the FLFACT cards, I've created the correct permutation sequence that NASTRAN uses for the flutter loop in order to associate the n-th eigenvalue/eigenvector with the proper flutter point. I have only the limitation to use RESVEC=NO, in such a way that the number of modes used in the flutter calculation are exactly those requested in the EIGR card.

This may sounds extremely complicated, but actually I simply need one run to get the complete set of the eigenvector.

SteveDoyle2 commented 8 years ago

I've seen, but never messed around with the RESVEC parameter? What does it do?

​Also, can you show a Matlab-pyNastran example?

alby3z commented 8 years ago

RESVEC = BOTh enables the residualization at low frequencies of the higher frequencies modes (those mode that are truncated) during the eigenvalue solution evaluation (in the SOL145 is the default).

Typically the residualization is useful to enhance the stress recovery in analysis of dynamic responses and not so crucial in stability evaluations.

Tomorrow I will post the MATLAB function that I'm using to load the op2.

alby3z commented 8 years ago

To be more pragmatic, in the f06 nastran output a first table of eigenvalues with a number of modes depending on the definition of the eigr card, then if RESVECT!=NO outputs a second table (with the label:AFTER THE RESIDUALIZATION or something like that) that has an augmented number of modes with respect to the previous.

alby3z commented 8 years ago

With the parse_flutter function I receive an error:

from pyNastran.f06 import parse_flutter as flutter

flutter.plot_flutter_f06(r'A:\Archive\Trezzini\AW609\FE_MODELLING\FIXED_WING_FLUTTER\PYNASTRAN_READ_FLUTTER\BAH_Plane\BAH_PLANE\BAH_Plane.f06')

Traceback (most recent call last):

  File "<ipython-input-24-867be0aa940c>", line 1, in <module>
    flutter.plot_flutter_f06(r'BAH_Plane.f06')

  File "C:\Users\10758\AppData\Local\Continuum\Anaconda3\lib\site-packages\pynastran-0.9.0+dev.no.checksum.error-py3.5.egg\pyNastran\f06\parse_flutter.py", line 591, in plot_flutter_f06
    flutter = FlutterResponse(subcase, configuration, xysym, xzsym,

UnboundLocalError: local variable 'configuration' referenced before assignment
alby3z commented 8 years ago

For what concern RESVEC, below an excerpt from the dynamic analysis user's guide:

Calculation of Residual Vectors

Modal solutions are commonly used to reduce large-size models to relatively smaller representations that include the important dynamics of the original model. In addition to reducing the model size, modal reduction has the added advantage of producing diagonal mass and stiffness matrices for solution calculation. Although modal reduction may capture most of the dynamic response of the structure, the static response may not be complete. This ‘error’ is due to modal truncation of higher frequency modes that may contribute ‘statically’ to the total response. Residual vectors are used to improve the results of modal solutions by attempting to account for the response of these higher frequency modes. Residual vectors can be determined from any set of base vectors. Base vectors are the raw material used to generate the residual vectors in MSC Nastran. Although any vector can be used as a residual vector, as long as it is partially independent of the modal vectors, it may produce coupling with the modal vectors when added to the modes for matrix reduction. This coupling destroys the diagonal properties of the reduced mass and stiffness matrices. To ensure that the residual vector used in the reduction process result in diagonal matrices, and better results, the following steps are performed.

  1. Ensure that loads are linearly independent with the modal inertial forces.
  2. Determine base vectors from static response due to loads.
  3. Ensure that base vectors are linearly independent.
  4. Orthogonalize the base vectors with respect to the modal vectors to produce residual vectors. These vectors will result in diagonal mass and stiffness matrices.

The closer the base vectors approximate the actual deformation due to the load, the better the residual vectors and the better the results. For this reason, base vectors in MSC Nastran are determined from the static response of the structure to the following loads: • Inertial forces due to rigid-body motion • Applied loads • Structural, viscous, and inertial forces due to enforced motion • Forces at user specified discrete degrees of freedom (RVDOFi entries) • Discrete damping forces due to viscous elements (CDAMPi and CVISC entries)

alby3z commented 8 years ago

Attached you find a zip file containing an example of use of pyNastran in MATLAB.

The main.m is the file to run.

The file get_eigenvalues_eigenvectors.m loads the modes from the op2, get_flutter_bdf.m reads the FLFACT cards from the bdf file in order to create the set of velocity, mach, density to be used to associate the n-th mode to the flutter point.

pyNastran_in_MATLAB_example.zip

ps: For some strange reason I experience trouble when opening MATLAB and trying to load the pyNastran libraries. I have found a simple work-around to cope with this: From the Matlab command line:

  1. type: import py.pyNastran.op2.op2.OP2.*
  2. then: clear import
  3. now the main.m scripts runs perfectly for the rest of the MATLAB session. O.o
SteveDoyle2 commented 8 years ago

Very cool on the Matlab thing. I need to try it out.

Another limitation on the flutter script. It requires an explicitly called out subcase in the case control deck (the default is 1, but the F06 doesn't know that). For flutter typically I do 10_mach (or altitude_1000). Then I'll add 1 to each FLFACT, so i quickly know what it means.

There's a lot of work left to do that and of course the elephant in the room, which is calculating flutter speed when you have mode switching.

alby3z commented 8 years ago

Did the flutter_parser error that I post before was due to the unnamed subcase? Have I understood correctly?

I am not completely sure to have also caught where do you put the "1" in the FLFACT. Sorry but I am dumber than NASTRAN... ;)

alby3z commented 8 years ago

Have you implemented in the flutter_parser also the flutter speed evaluation routine?

Do you track the eigenvalues after having load them, or you simply rely on the fact that Nastran does not switch the modes?

SteveDoyle2 commented 8 years ago

Flutter speed calculation is not supported yet. There will probably be multiple methods, but eigenvalue tracking will be the default. I won't have time to work on it for a week or so, so this is as good as it gets for now.

The version of bah plane that I was using to test is found in _models/aero/bahplane.

Regarding the process, the code first looks for a subcase, then looks for a flutter summary table, then reads the PK table, then loops back looking for another flutter summary table. It breaks out if it finds a new subcase or hits the end of the file.

Then it builds the flutter object and plots the data.

On Fri, Sep 16, 2016 at 10:18 AM, alby3z notifications@github.com wrote:

Have you implemented in the flutter_parser also the flutter speed evaluation routine?

Do you track the eigenvalues after having load them, or you simply rely on the fact that Nastran does not switch the modes?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SteveDoyle2/pyNastran/issues/338#issuecomment-247657063, or mute the thread https://github.com/notifications/unsubscribe-auth/ABAqWSJG9Ii3wxeHC03WWhzS1bY4QOezks5qqs9zgaJpZM4J4x3E .

alby3z commented 8 years ago

I have tried to load the flutter f06 in the folder _models/aero/bahplane but I got the following error:

from pyNastran.f06 import parse_flutter as flut
flut.plot_flutter_f06(r'C:\Users\alby\Downloads\pyNastran-master (3)\pyNastran-master\models\aero\bah_plane\bah_plane.f06',plot_vg = True)
1 0.0000 1.0000E+00 PK
2 0.0000 1.0000E+00 PK
3 0.0000 1.0000E+00 PK
4 0.0000 1.0000E+00 PK
5 0.0000 1.0000E+00 PK
6 0.0000 1.0000E+00 PK
7 0.0000 1.0000E+00 PK
8 0.0000 1.0000E+00 PK
9 0.0000 1.0000E+00 PK
10 0.0000 1.0000E+00 PK
1 0.2000 1.0000E+00 PK
found existing mode...
new_subcase =  1
Traceback (most recent call last):

  File "<ipython-input-7-ac539194bedf>", line 1, in <module>
    flut.plot_flutter_f06(r'C:\Users\alby\Downloads\pyNastran-master (3)\pyNastran-master\models\aero\bah_plane\bah_plane.f06',plot_vg = True)

  File "C:\Anaconda3\lib\site-packages\pynastran-0.9.0+dev.no.checksum.error-py3.5.egg\pyNastran\f06\parse_flutter.py", line 597, in plot_flutter_f06
    if plot:

NameError: name 'plot' is not defined
SteveDoyle2 commented 8 years ago

That bug is at least fixed. There will be more. Single subcase works. Multi-subcase sort of works, but still needs some work. SOL 200 will be wrong.

SteveDoyle2 commented 8 years ago

Closing because this thread has gotten too long and the OP2 issues have been fixed. It's just easier to manage that way.