visualdynamics.io.nastran¶
nastran
¶
Read and write Nastran bulk data decks (.bdf, .dat, .nas) as geometry.
The bulk data card formats are documented in every Nastran vendor's reference guide, and this reader is written from those card layouts. INCLUDE files are read relative to the deck. Lines before BEGIN BULK (executive and case control) and after ENDDATA are ignored; a file with neither marker is read as all bulk data. Small-field, large-field and free-field (comma) cards are all read.
What is read:
- GRID points, with their definition (CP) and displacement (CD) coordinate systems. Positions are converted to the basic frame.
- CORD2R, CORD2C and CORD2S coordinate systems, with chains of references resolved. A system defined in a cylindrical or spherical system is refused.
- The connection elements CROD, CBAR, CBEAM, CTRIA3, CTRIA6, CQUAD4, CQUAD8, CTETRA, CPENTA, CHEXA and CPYRAM, one element group per property id. The node count picks the variant (CTETRA with 4 grids is a tet4, with 10 a tet10).
- PSOLID, PSHELL and MAT1, as the properties of each element group: the material, and a shell's thickness. A group whose cards are not all in the deck has no properties.
- CONM2 point masses, one element group per distinct mass. A CONM2 with an offset or inertia is read as an element with no properties.
- CELAS1 (with its PELAS) and CELAS2 springs, one element group per distinct stiffness and direction. A spring joining two different components, or acting on a scalar point, is refused.
- SPC and SPC1 supports, one ground group per distinct set of components. A deck with more than one SPC set, or an SPC that enforces a displacement, is refused.
- PLOTEL, Nastran's display-only line, as one drawn line.
What is not read:
- Loads, other property and material cards, and control cards. These describe the analysis, not the mesh, and are skipped by card name without a note.
- Rigid elements (RBE1, RBE2, RBE3, RBAR, RBAR1, RROD, RTRPLT, RSPLINE), which are constraints with no mesh, and are skipped.
- CORD1R, CORD1C and CORD1S (systems defined by grid points) are refused with an error that says to redefine them as CORD2 cards, since a guessed frame would place every node in it wrongly.
- Any other
Ccard shaped like an element is refused with its name, so an element is never dropped without a word.
A deck has no units, so positions and properties are read as written,
and the geometry is marked as a deck's (Geometry.from_deck).
length_unit declares the length the deck is written in and mass_unit
its mass, with seconds: the consistent system a deck uses, from which
force, stress and density follow (mm with tonnes is N and MPa, inches
with lbf·s²/in is lbf and psi). The mass unit may be left out for the
usual one with that length (geometry.DECK_MASS_UNITS). Declared here or
later on the geometry (Geometry.define_units), the coordinates and every
property value are converted to SI together.
save writes coordinate systems as CORD2 cards, grids as large-field
GRID* cards (full precision, where a small field holds about five
digits), elements on their own cards and drawn lines as PLOTEL chains.
The deck is geometry for interchange: it opens in viewers and
preprocessors, and needs property and material cards added before
Nastran will run it.
Functions:
| Name | Description |
|---|---|
save |
Write a geometry as a bulk deck. |
Classes¶
Functions:¶
save
¶
save(geometry: Geometry, path: str | PathLike, unit_system: Any = None) -> None
Write a geometry as a bulk deck.
The deck is geometry for interchange, not a runnable analysis. The elements have PID 1 and no PSHELL, PSOLID or MAT cards are written, because properties are the analyst's statement about the structure and writing made-up ones would put a wrong stiffness in a real deck. Masses, springs and supports are written, since their values are part of the geometry: a point mass is a CONM2 with its element group's mass (0.0 when the group has none), a group of springs is one CELAS2 per element and direction with its stiffness, and a ground group is SPC1 cards (set 1) of its components. Grids are written large-field in the coordinate system each one is defined in, for full precision, and drawn lines are written as PLOTEL chains.
Values are written as the geometry stores them: SI when its units are
defined. unit_system is accepted and not used.
Raises ValueError for an element type with no bulk card.
Source code in src/visualdynamics/io/nastran.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 | |