pyNastran Documentation

repository·main·Indexed 19 days ago

https://github.com/stevedoyle2/pynastran

An interface library for Nastran file formats (BDF, OP2, OP4) used for reading, editing, writing, and viewing geometry and results. It includes a GUI for model visualization, HDF5 support for efficient data import/export and memory reduction for large OP2 files, and a CLI for running BDF jobs (introduced in version 1.5.0). The library supports various Nastran versions including msc, nx, optistruct, mystran, and zona.

Tokens
77.4K
Snippets
212
Records
403
Agent score
65%

What's inside pyNastran

  1. Overview of pyNastran core features and requirements

    main

    pyNastran is a Python-based library for handling Nastran files. Core features include support for Python 3.9-3.12 and the ability to be imported from within MATLAB. The library has limited package requirements for basic BDF, OP2, and F06 file handling, but additional functionality is available through optional dependencies:

    • BDF/OP2 Support:
      • h5py: Enables HDF5 input/output support.
      • PyQt5/PyQt6/PySide2/PySide6/tk/wxpython: Provides file loading pop-up interfaces.
      • QScintilla & pygments: Enables a scripting code editor.
    • OP2 Support:
      • pandas: Used for handling results and matrices, specifically for use in Jupyter Notebooks.
    • F06 Support:
      • matplotlib: Enables plotting capabilities.
    • GUI Support:
      • Supports PyQt5, PySide2, and VTK 9.
    • Logging:
      • Uses cpylog for logging.
      • colorama: Enables colorized console logging.
      • Supports HTML logging for Jupyter Notebooks.
      • Automatically removes markup when piping output to a file.
      • Allows users to overwrite the logger object with their own user-defined logger.
  2. What is pyNastran?

    main

    pyNastran is an API (Application Programming Interface) designed to interface with legacy NASTRAN file formats. It allows developers to programmatically interact with structural, thermal, aerodynamic, and dynamics problem data stored in standard Nastran files.

    Supported file formats include:

    • BDF: Bulk Data File
    • F06: Text output file
    • OP2: Binary output file
    • OP4: Binary output file
    • PCH: Punch file
  3. Overview of the mesh_utils package

    main

    The pyNastran.bdf.mesh_utils package provides a comprehensive suite of utility functions for manipulating and analyzing BDF (Bulk Data File) models. The package is organized into several functional categories:

    • Mesh Editing: Tools for modifying mesh topology, such as adding/removing mesh, breaking elements, collapsing bad quads, cleaning up models, mirroring, refining, and shifting.
    • Merge / Renumber / Diff: Utilities for comparing BDF files (bdf_diff), merging models (bdf_merge), renumbering IDs (bdf_renumber), and removing unused or specific cards.
    • Loads & Forces: Functions to convert or manage loads, including force_to_pressure and forces_moments.
    • Properties & Mass: Tools for calculating mass properties, breaking down properties, and listing CONM2 entries.
    • Geometry Queries: Functions to query the geometric state of the model, such as finding free edges/faces, extracting bodies, or finding the closest nodes.
    • Aero: Specialized utilities for aerodynamic workflows, including export_caero_mesh and export_mcids.
    • Constraints & Connections: Tools for managing MPC dependencies, RBE tools, and solid degrees of freedom (solid_dof).
    • Optimization & Jobs: Utilities for optimization tasks (dvxrel) and managing job execution (run_jobs, host_jobs).
  4. Overview of pyNastran capabilities

    main

    pyNastran is a software interface for Nastran input and output files, providing simplified methods to read, edit, and write various Nastran formats. It is compatible with Windows, Linux, and Mac.

    Key capabilities include:

    • BDF reader/writer: Supports 406 cards (including coordinate systems). Card objects provide methods to access data like Mass and Area. The writer produces small field formatted files using the 8-character Nastran field and supports OpenMDAO BDF parametrization syntax.
    • OP2 reader/writer: Supports static and transient results (excluding frequency response data). It supports OP2/F06 Writing for most objects. Supported results include displacement, velocity, acceleration, temperature, eigenvectors, eigenvalues, SPC forces, MPC forces, grid point forces, load vectors, applied loads, strain energy, stress, and strain.
    • Python OP4 reader/writer: Supports reading ASCII/binary sparse and dense matrices, and writing ASCII matrices.
    • GUI: A simple graphical interface is available to view BDF models and display static/dynamic displacement/eigenvectors (real/complex) and stress/strain (real) results from OP2 files. It also provides partial support for AVUS, Cart3d, Usm3d, Tetgen, STL, and Panair.
  5. Overview of pyNastran GUI features

    main

    The pyNastran GUI provides several major and minor features for visualizing and interacting with engineering models:

    Major Features

    • Fringe Plot Support: Visualizes elemental/nodal results and custom CSV results.
    • Result Types: Supports deflection and force results.
    • Interface: Command line interface (CLI), scripting capability, and high-resolution screenshots.
    • Visibility: Show/hide elements and edit geometry properties (color, opacity, size) via View -> Edit Geometry Properties....
    • Menus: Legend, animation, and save/load view menus.

    Minor Features

    • Navigation: Snap to axis and clipping customization.
    • Visuals: Change background color, label color/size, and flip edges via menu.
    • Custom Data:
      • Attach custom geometry using the -user_geom option or Load CSV User Geometry.
      • Add additional points using the --user_points option or Load CSV User Points.
  6. How to work with BDF files in pyNastran

    main

    The BDF (Bulk Data File) documentation provides guides for managing Nastran input files using pyNastran. Key workflows include:

    • Headers: Managing BDF file headers.
    • Model Groups: Organizing and manipulating model groups within a BDF.
    • Mass Properties: Calculating and accessing mass properties.
    • Running Jobs: Executing Nastran jobs via pyNastran.
    • Code Organization: Understanding how BDF data is structured in Python objects.
    • Read/Write Operations: Loading BDF files into pyNastran and writing them back to disk.
    • Equivalence: Checking if two BDF models are equivalent.
    • Renumbering: Automatically renumbering entries in a BDF to ensure consistency.
  7. Access the opg_appliedLoads package modules

    main

    The opg_appliedLoads package in pyNastran.op2.tables provides access to applied load data from OP2 files. It is organized into several specialized modules:

    • opg: The main module for applied loads.
    • opg_load_vector: Handles load vector data.
    • opg_objects: Contains the underlying data objects for applied loads.
    • opnl_force_vector: Handles force vector data.

    You can import these modules to inspect or manipulate applied load information extracted from an OP2 file.

  8. Use the shabp package for SHABP file conversion

    main

    The pyNastran.converters.shabp package provides tools for handling SHABP (Structural Health Assessment and Behavior Prediction) files. It is organized into three primary modules:

    1. shabp: Contains the core converter logic and classes for processing SHABP data.
    2. shabp_io: Handles Input/Output operations, specifically for reading and writing SHABP files.
    3. shabp_results: Manages the processing and representation of results extracted from SHABP files.

    To use these features, import the relevant module based on whether you are performing a conversion, managing file I/O, or analyzing results.

  9. Explore the pyNastran.op2.tables.geom package

    main

    The pyNastran.op2.tables.geom package contains modules for handling geometric data tables within OP2 files. It is organized into several sub-modules based on the specific type of geometric data being processed.

    Key sub-modules include:

    • dit: Likely related to displacement or specific geometric data types.
    • dynamics: Geometric data related to dynamic analysis.
    • geom1, geom2, geom3, geom4: Specific geometric table formats (e.g., standard Nastran geometry formats).
    • ept: Likely related to EPT (Element Property Table) geometry.
    • mpt: Likely related to MPT (Material Property Table) geometry.

    For common utilities used across these geometric modules, refer to the pyNastran.op2.tables.geom.geom_common module.

  10. Use the oee_energy package for energy data

    main

    The pyNastran.op2.tables.oee_energy package is used to handle energy-related data from OP2 files. It is organized into two primary modules:

    1. oee_objects: Contains the core data objects and structures representing energy information.
    2. onr: Contains modules related to the ONR (Output Node Results) data structures within the energy context.

    Developers should explore oee_objects to find the specific data containers needed for energy analysis and onr for node-specific energy results.