Skip to main content

Nastran BDF/F06/OP2/OP4 File reader/editor/writer/viewer

Project description

Version Docs Status
PyPi Version docs Build Status Coverage Status
Master Documentation Status Linux Status Coverage Status

v1.2.1

Download GUI (latest is from 2019/5/24)

Also, check out the:

for more detailed information.

Overview

pyNastran is an interface library to the various Nastran file formats (BDF, OP2, OP4). Using the BDF interface, you can read/edit/write Nastran geometry without worrying about field formatting. Many checks are also performed to verify that your model is correct. Using the OP2 interface, you can read large result files quickly and efficiently. Additionally, you can also extract a subset of the result data and write OP2/F06 result files. For a more detailed list of features, see:

Using the pyNastran GUI, you can read in Nastran models and quickly view results for a model. While it's no FEMAP/Patran, it can replace many tasks that would otherwise require a commercial program.

GUI

News

pyNastran v1.2.1 has been released (2019/5/24)

I keep saying to myself there's not much to add, but Nastran is huge. Beyond HDF5 support in the BDF, I'm a huge fan of the new ability to keep track of which include file a card came from and write it as a separate file. It's limited in usefulness, but very handy in certain cases. There's a new (still preliminary) superelement capability. I'm far from a superelement expert, but it's probably useful.

The OP2 reader now supports SORT2 along with much improved random results reading. If you're using 60+ GB OP2s, you probably have had issues with RAM usage in the past. With the new ability to dump the OP2 directly to HDF5, this should not be an as much of an issue. It's not 100% implemented, so let me know if you need it for another result.

Regarding the GUI, there are also some new features. Groups work a bit better, but aren't quite perfect. Logging has been dramatically sped up so the GUI loads faster and you can load Nastran models even faster if you disable additional results (e.g., element quality).

Finally, Python 2.7 is end of life. Numpy, scipy, and matplotlib have all dropped Python 2.7 support. It's time for pyNastran to as well. The OP2 reader is 30% faster in Python 3.6+ than Python 2.7, so it's not all bad!

Programmatics:

  • This is the last Python 2.7 release.
  • Dropping Python 3.5 support
  • Supports Python 2.7, 3.6-3.7
  • GUI is compatible with PyQt4/PyQt5 as well as PySide/PySide2
  • improved testing of old versions of packages

BDF:

  • 373 cards supported (up from 343)

  • added abiltity to write models to separate include files

    >>> model = BDF()
    >>> model.read_bdf(bdf_filename, save_file_structure=True)
    
    out_filenames = {
        bdf_filename : bdf_filename_new,
        include_filename : include_filename_new,
    }
    >>> model.write_bdfs(out_filenames, relative_dirname=None, is_windows=None)
    >>> ifile = model.grids[1].ifile
    
  • HDF5 import/export

    >>> model = read_bdf(bdf_filename)
    >>> model.export_hdf5_filename(hdf5_filename)
    >>> model_new = OP2()
    >>> model_new.load_hdf5_filename(hdf5_filename)
    
  • preliminary superelement support

    >>> model.read_bdf(bdf_filename)
    >>> model.superelement_models[1].nodes
    

OP2:

  • reorganization of random op2 results into op2.results.psd (or ato, no, crm, rms) to aide in finding data

  • reorganization of op2 class to reduce number of functions in the object. This affects any custom table reading.

  • improved optimzation response reading

  • limited SORT2 support

  • fixed CD transformation bug for BOUGV1 and BOPHIG1 tables

  • Improved HDF5 export/import support (e.g., matrices, random results)

  • Can optionally save directly to HDF5 instead of numpy (limited).

  • Loading OP2s to an HDF5 file to decrease memory usage

    >>> op2_model = OP2()
    >>> op2_model.load_as_h5 = True
    >>> op2_model.read_op2(op2_filename)
    

OP2Geom:

  • HDF5 support
  • reading EQEXIN/S, GPT, GPDT, CSTM/S tables (recovery of nodes & coordinate with OP2Geom)
  • fixed theta/mcid reading for CTRIA3/CQUAD4
  • fixed CQUAD8 bug

GUI:

  • sped up HTML logging
  • much improved groups menu
  • options for Nastran in preferences menu to speed up loading/limit memory usage
  • pyNastran BDF pickle reading
  • pyNastran OP2 HDF5 reading (not MSC's format)
  • visualization when pickling nodes/elements
  • min/max labels
  • highlight menu
  • Patran-style colors
  • custom force vectors
  • AVL support

Known issues:

  • Transient Pandas Dataframes will fail for newer versions of numpy/pandas. If anyone knows how to use a MultiIndex, this is probably pretty easy to fix.

pyNastran v1.2.0 has been released (2019/5/21)

This result has been superseeded by 1.2.1. See release notes for details.

pyNastran v1.1.0 has been released (2018/6/26)

Version Docs Status
PyPi Version Build Status Coverage Status

It's been roughly a year and ~100 tickets closed since the last version, so it's probably time for another release! I want to thank everybody who helped with this release, especially Michael Redmond. He is working on h5Nastran, which which ties in with pyNastran. It's not quite ready yet, but it offers the possibility of major speedups for large models.

Regarding features, the focus has again been on robustness and testing. There has been a 10% increase in the testing coverage (the same as v0.8 to v1.0). There are a few changes (mainly in the BDF) though. The GUI now also supports PyQt4, PyQt5, and Pyside with the same API, so it's a bit easier to install from source as simplifying licensing issues as PyQt is GPL.

Programmatics:

  • Dropping Python 3.4 support
  • Supports Python 2.7, 3.5-3.6
  • dropping VTK 5/6 suppoprt for the GUI

BDF:

  • 343 cards supported (up from 312)
  • cross-referencing is now more straightforward to new users (much of v1.0 works using the _ref option)
    • *_ref attributes are cross-referenced
      • element.nodes is not cross-referenced
      • element.nodes_ref is cross-referenced
  • pickling to reload your deck ~5x faster
  • decreased time required for Case Control Deck with large SETs and many load cases
  • improved optimization checks

OP2:

  • HDF5 export/import support
    >>> op2_model = read_op2(op2_filename)
    >>> op2_model.export_hdf5_filename(hdf5_filename)
    >>> op2_model_new = OP2()
    >>> op2_model_new.load_hdf5_filename(hdf5_filename, combine=True)
    
  • pandas support for matrices
  • couple more results vectorized (e.g., complex strain energy, DMIG strain energy, some forces)
  • grid_point_stressses supported (disabled since v0.7)
  • fixed sparse matrices being stored as dense matrices

GUI:

  • preliminary support for PySide
  • can now mix and match fringe/displacement/vector results (e.g., max principal stress shown on a displaced model)
  • improved animation menu
    • in gui animation
    • more animation profiles
  • bar profile visualzation
  • nominal geometry (useful for deflection plots)
  • improved optimization support
  • improved picking display
  • better PSHELL/PCOMP distinction

Known issues:

  • Transient Pandas Dataframes will fail for newer versions of numpy/pandas. If anyone knows how to use a MultiIndex, this is probably pretty easy to fix.

pyNastran v1.0.0 has been released (2017/5/25)

See v1.0.0 for information regarding enhancements.

pyNastran v0.8.0 has been released (2016/8/21)

Version Docs
v0.8.0 Documentation Status

See v0.8.0 for information regarding enhancements.

pyNastran v0.7.2 has been Released (2015/4/25)

See v0.7.2 for information regarding enhancements.

Version 0.6.1 has been released (2013/6)

Version 0.6 improves BDF reading. The reader is more robust and also requires proper BDF field formatting (e.g. a integer field can't be a float). Additionally, cards also have a comment() method.

Marcin Gąsiorek participated in the latest pyNastran under the European Space Agency's (ESA) "Summer of Code In Space" SOCIS program. The program provides a stipend to students to work on open-source projects. He did a great job of simplifying code and creating nicer documentation.

More Information

If you like it/want to help leave some feedback:

If you have a bug/want a new feature or card, leave some feedback on the Issue Tracker

Release Notes

v1.3.0 (2020/4/8)

With Python 2 now officially dead, it's time for a new feature to encourage people to switch.

There is now support for writing OP2 files! They're difficult to create from scratch, but modifying an existing is easy. This also includes geometry support.

In addition, many new OP2 results have been added. Modern NX Nastran should work much better.

Programmatics:

  • Supports Python 3.7 and 3.8
  • Dropping Python 2.7 and 3.6 support
  • GUI is compatible with PyQt5 and PySide2
  • improved testing of old versions of packages

BDF:

  • enhancements
    • 405 cards supported (up from 373)
    • improved mesh utilities
      • bdf mirror, bdf convert, bdf export_caero_mesh
      • additional bdf scale, which takes arbitrary mass, length, time, pressure, or velocity scale factors (3 of 5) to apply a scaling law
    • added deck guessing with punch=None
    • better parser for test_bdf
    • PCOMPG now supports DVPRELx
    • added get_position for SPOINT
    • added inertia for PBARL/L
    • bdf mirror:
      • added PLOTEL, RROD, RBAR, RBAR1, RBE1, AELIST, AESURF support
    • bdf_equivalence:
      • method='new' no longer requires neq_max
      • use method='old' for old behavior (deprecated)
  • bug fixes:
  • new cards:
    • DTI besides UNITS are now supported
    • PBEAM3, TEMPB3
  • minor enhancements:
    • handling ;; in DEQATN
    • support for SURF cid=None in _get_forces_moments_array
    • added check for number of loads = nscale factors for LOAD
    • more PARAM validation
  • changes:
    • warning on RBAR dof check instead of RuntimeError

OP2:

  • enhancements:
    • OP2 write support
    • fixed most pandas deprecation warnings/added support for pandas 0.25
    • much improved NX 2019.2 support
  • minor enhancements:
    • more hdf5 results
    • a few more cards supported in the OP2 geometry reader
    • preliminary NX 64-bit support
    • more MSC versions supported
    • sped up R1TABRG (optimization) reading
    • various geometry cards added
    • supports more PARAM reading
  • new results:
    • composite failure indicies (OEFIT)
    • sensitivity support (DSCMCOL)
    • Cambpell diagrams (CDDATA)
    • eigenvectors (BOPHIGF)
    • grid point forces SORT2 (OGPFB2)
    • stress/strain/force
      • random stress/strain (OESVM1/2, OESVM1C, OSTRVM1/2, OSTRVM2, OESXRM1C, OESXNO1, OESXNO1C)
      • real/complex stress/strain/force output for centroidal CQUADR/CTRIAR
      • complex CBEAR forces
      • real CFAST, CWELD forces
      • nonlinear cbush stress/strain/force
    • other
      • XSOP2DIR
      • PSDs
      • optimization
        • convergence table
        • design variables
        • weight response
        • displacement response
        • stress response
        • strain response
        • force response
        • composite stress response
        • composite strain response
        • fractional mass response
    • SOL 401/402 results:
      • eigenvalue_fluid (LAMAF, LAMAS)
      • eigenvectors (BOPHIGF, BOPHIGS)
      • temperature (OTEMP1)
      • solution set
        • results: displacement, velocity, acceleration, eigenvectors:
        • tables: OUXY1, OUXY2, OPHSA
  • API:
    • reorganized output results to use op2_results object to simply interface
      • backwards compatibility for stress, strain, forces, strain energy
      • model.cbar_force -> model.op2_results.force.cbar_force
      • model.cbar_stress -> model.op2_results.stress.cbar_stress
      • model.cbar_strain -> model.op2_results.strain.cbar_strain
      • model.cbar_strain_energy -> model.op2_results.strain_energy.cbar_strain_energy
  • TODO: linear/nonlinear hyperelastic solids
  • TODO: stress transforms. This is probably a bit of work.
  • TODO: preliminary NX 64-bit support
  • TODO: CD transforms for cylindrical/spherical displacement, velocity, acceleration, forces. This shouldn't be terrible.

GUI:

  • enhancements:
    • Can now load custom fringe/displacement/force results with an incorrect number of nodes/elements. It's assumed that the node/element id in the first column should be the same as the id for the model. Thus, you just filter out extra nodes/elements or you set some blank nodes/elements.
      • For integer results, no masking is applied.
      • For float results, masking is applied and nan corresponds to no color.
    • animation now supports complex fringe
    • result case description now shows the min/max value as well as the location
    • result case description now shows the mode/time/frequency
    • map centroidal to nodal option
    • adding node/element highlight menu
    • adding node/element mark/label menu
    • result case description now shows the min/max value as well as the location
    • result case description now shows the mode/time/frequency
  • minor enhancements:
    • added export result option to right-click menu
    • legend supports unicode
    • more keyboard shortcuts
  • nastran:
    • geometry:
      • added preferences for geometry/results to speed up model loading
      • element & material coordinate systems
    • results
      • added acoustic displacements (OUG1F)
      • real/complex stress/strain/force results
        • plate by upper/lower, composite plates by ply, bars, rods, springs, cbush, cdamp
      • fractional mass response

F06:

  • KE support for plot_145

Bug fixes:

  • BDF:
    • fixing bug in set_param
    • PBARL & PBEAML DBOX now has defaults for DIM5-DIM10
    • added AECOMPL, DEFORM to bdf attributes
    • added RHO to MAT10 updater
    • Better case control SET parser (can now handle 1,THRU,10,EXCEPT,7,8, which doesn't have spaces that makes parsing easier). It's also orders of magnitude faster on large problems.
    • Fixed NDDL bug in MONPNT2
    • Added check for DVPRELx to prevent referencing property fields when another similar property is used (e.g., a DVPRELx references a PCOMPG, but the PCOMP field id numbers are used to update the card).
    • added some missing hdf5 object support
    • fixing DEQATN bug caused by using python builtin
    • fixed missing variable in mass properties error message
    • aero
      • fixed issue where CAERO1 didn't set the xyz1 and xyz4 points to arrays when loading an HDF5 file
      • caero2 now sets box ids
    • elements/properties
      • added I12, J to PBEAM updater; fixed error message
      • fixed Area calculation for PBARL/CHAN, HAT1, DBOX
      • fixed PBAR optimization treating I12 as I1; added J
    • convert better handles:
      • T1-T4 in quad shells
      • fixed bug in CGAP x/g0
    • bdf mirror:
      • fixed bug where max element id is less than max rigid_element id
      • fixed bug with shells that have blanks (e.g., CTRIA6, CQUAD8)
      • plane is now case insensitive and auto-sorted
      • CAERO1 now supports lspan/lchord and Cp
      • CAERO1 handles xy plane properly now (doesn't assume it's xz)

OP2:

  • geom bug fixes:
    • fixed reading bugs for QHBDY and SPCOFF
    • better identifing duplicate property id (PBCOMP -> PBEAM)
    • fixed CONVM error (it can be 6 or 7 fields, not only 6)
    • fixed ACCEL key
  • bug fixes:
    • R1TABRG now stores response_types as strings (instead of bytes for Python 3)
    • f06 writer now writes CDAMP3/4 names correctly

GUI:

  • bug fixes:
    • better argument handling
    • fixed coordinate system scaling bug
    • added check on highlight menu for model existance
    • fixed import for new version download menu
    • improved command line error message
    • fixed support for CAEROx models without elements
    • export_cases now supports integers

v1.2.1 (2019/5/24)

OP2:

  • fixed bug with OUGV1PAT table

v1.2.0 (2019/5/21)

Programmatics:

  • This is the last Python 2.7 release.
  • Dropping Python 3.5 support
  • Supports Python 2.7, 3.6-3.7
  • GUI is compatible with PyQt4/PyQt5 as well as PySide/PySide2
  • improved testing of old versions of packages

BDF:

  • 373 cards supported (up from 343)

  • added abiltity to write models to separate include files

    >>> model = BDF()
    >>> model.read_bdf(bdf_filename, save_file_structure=True)
    
    out_filenames = {
        bdf_filename : bdf_filename_new,
        include_filename : include_filename_new,
    }
    >>> model.write_bdfs(out_filenames, relative_dirname=None, is_windows=None)
    >>> ifile = model.grids[1].ifile
    
  • HDF5 import/export

    >>> model = read_bdf(bdf_filename)
    >>> model.export_hdf5_filename(hdf5_filename)
    >>> model_new = OP2()
    >>> model_new.load_hdf5_filename(hdf5_filename)
    
  • preliminary superelement support

    >>> model.read_bdf(bdf_filename)
    >>> model.superelement_models[1].nodes
    

OP2:

  • reorganization of random op2 results into op2.results.psd (or ato, no, crm, rms) to aide in finding data

  • reorganization of op2 class to reduce number of functions in the object. This affects any custom table reading.

  • improved optimzation response reading

  • limited SORT2 support

  • fixed CD transformation bug for BOUGV1 and BOPHIG1 tables

  • Improved HDF5 export/import support (e.g., matrices, random results)

  • Can optionally save directly to HDF5 instead of numpy (limited).

  • Loading OP2s to an HDF5 file to decrease memory usage

    >>> op2_model = OP2()
    >>> op2_model.load_as_h5 = True
    >>> op2_model.read_op2(op2_filename)
    

OP2Geom:

  • HDF5 support
  • reading EQEXIN/S, GPT, GPDT, CSTM/S tables (recovery of nodes & coordinate with OP2Geom)
  • fixed theta/mcid reading for CTRIA3/CQUAD4
  • fixed CQUAD8 bug

GUI:

  • sped up HTML logging
  • much improved groups menu
  • options for Nastran in preferences menu to speed up loading/limit memory usage
  • pyNastran BDF pickle reading
  • pyNastran OP2 HDF5 reading (not MSC's format)
  • visualization when pickling nodes/elements
  • min/max labels
  • highlight menu
  • Patran-style colors
  • custom force vectors
  • AVL support

Known issues:

  • Transient Pandas Dataframes will fail for newer versions of numpy/pandas. If anyone knows how to use a MultiIndex, this is probably pretty easy to fix.

v1.1.0 (2018/6/26)

Programmatics:

  • Added support for numpy 1.14
  • Dropping support for Python 3.4 (2.7, 3.5, 3.6 are supported)
  • Dropping support for VTK 5/6 (7/8 are supported)

BDF:

  • model may be pickled (model.save('model.obj') and model.load('model.obj')
  • simplified cross-referencing

OP2:

  • model may be pickled (model.save('model.obj') and model.load('model.obj')
  • Added support for exporting OP2 to HDF5 (uses pyNastran format, not MSC)
  • real sparse matrices take much less memory now; were being converted to dense matrices

GUI:

  • improved animations
  • improved labels

BDF (detailed):

  • New features:

    • model.get_reduced_loads(load_id)
    • model.get_reduced_dloads(dload_id)
    • card1 == card2 now supported
    • PBARL/PBEAML support the NX TUBE2 type
    • added FREQ3, FREQ5, CAERO5, PAERO5, MATT3, SPLINE3, RSSCON, OMIT1
    • more xref
    • added model.clear_attributes()
    • renumbering:
      • bdf_renumber now supports renumbers SETs and SPLINEx cards
      • SPOINTs/EPOINTs now use dictionaries to enable SPOINT/EPOINT renumbering
      • caero sub-panels ids are now renumbered
      • renumbering mapper object returned now
    • improved removed_unused card support
    • improved mirroring
    • read_bdf StringIO option now parses pyNastran header
    • subcase copying speedup (helps with SETs)
    • preliminary ZONA loading
    • added atmosphere2.make_flfacts_eas_sweep, make_flfacts_mach_sweep, and make_flfacts_alt_sweep with an EAS (equivalent airspeed) limiter
    • rotate_v_wa_wb for CBAR/CBEAM to determine element vectors
  • Bug fixes:

    • more add_card documentation (e.g., add_grid, add_ctria3)
    • fixed NSMADD card type (was SPCADD)
    • fixed CPLTSTN3 card type (was CTRIA3)
    • fixed CPLTSTS3 card type (was CTRIA3)
    • fixed shell MCIDs not renumbering
    • fixed FREQx renumbering crash
    • model may be pickled again (model.save('model.obj') and model.load('model.obj')
    • fixed PBARL/PBEAML DBOX error
    • fixed PositionWRT bug
    • fixed LOAD card messing up load ids after cross referencing
    • fixed TRIM default on aeqr (was 0.0/rigid; should be 1.0/elastic)
    • NLPCI now gets written when there are no other dynamic cards
    • fixed CBUSH cid=0 bug
    • fixed TABLED4/TABLEM4 stopping error
  • API changes:

    • model.Node(nid, allow_empty_nodes=False msg='') no longer supports allow_empty_nodes. Use: model.EmptyNode(nid, msg='') instead for that model.Node(nid, msg='') is the new form
    • model.Nodes(nid, allow_empty_nodes=False msg='') no longer supports allow_empty_nodes. Use: model.EmptyNodes(nid, msg='') instead for that model.Nodes(nid, msg='') is the new form
    • PCOMPG.validate() now checks that global ply ids are unique
    • xref_nodes_with_elements now creates a list instead of a set (fixes a Python 3.x bug)
    • get_MPCx_node_ids_c1 is now get_MPCx_node_ids_c1 (was inconsistent with what it does)
    • get_MPCx_node_ids_c1 created
    • xref'd objects now use _ref globally
    • aestat.id is now aestat.aestat_id
    • aeparm.id is now aeparm.aeparm_id
    • model.add_aset1/aset (also bset/cset/qset/uset) now a consistent set of function arguments and call the same function. The card will be created based on your data instead of necessarily what you asked for.
    • LOAD cards are now stored in model.load_combinations instead of model.loads
  • Known bugs:

    • dynamic loads cross-referencing is buggy; reject the cards if there is a problem
    • PBEAM defaults with ENDA are slightly incorrect.

OP2 (detailed):

  • New features:

    • added model.set_additional_generalized_tables_to_read(tables) to create custom OP2 readers
    • added complex/average strain energy
    • save/load hdf5 support
    • EIGRL support
  • Bug fixes:

    • improved table skipping
    • fixed RealCShearForceArray f06 writing
    • fixed CEN/3, CEN/4 writing for RealPlateBilinearForceArray
    • improved geometry table reading
    • real sparse matrices take much less memory now; were being converted to dense matrices
    • added RBAR on NX vs. MSC
    • fixed RBE2 with alpha bug
    • fixed CREEP bug
    • fixed RBE3 bug
    • fixed PBCOMP bug
  • API changes:

    • xlsx exporter removed
  • Known bugs:

    • pandas fails on some decks (numpy<1.13 is fine)
    • a large number of PSOLIDs will crash the read_op2/read_op2_geom; use PARAM,OGEOM,NO
    • transform_gpforce_to_global doesn't work properly with cylindrical or spherical coordinate systems

GUI (detailed):

  • New features:

    • control surfaces now get labels (label size doesn't resize properly)
    • in-gui animation
    • delete secondary actor support
    • delete result cases support
    • improved view buttons
    • preferences menu
    • right click support on results sidebar to apply fringe/displacement/veactor results
  • Bug fixes:

    • displays control surfaces again (aesurf)
    • changing secondary actor color works again
    • fixing random crash
    • "Show/Hide CAERO panels" updates the "Edit Geometry Properties" menu
    • "Toggle CAERO Subpanels" updates the "Edit Geometry Properties" menu
    • "Toggle CONM2s" updates the "Edit Geometry Properties" menu
    • fixing Windows taskbar icon bug
    • fixing first launch bug
    • qscintilla works in pyqt5
  • Known bugs:

    • after animating a model from within the GUI, the mouse behavior changes

OP4 bug fixes:

  • fixed Python 3 bytes bug

Applictions:

  • removed due to excessively amount of unmaintained code

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pyNastran-1.3.0-py3-none-any.whl (3.2 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page