Karana.FEMBridge.Nastran#

Classes and functions used to convert a NASTRAN model into a flexible body model.

The flexible body model can then be transformed into a PhysicalModalBody with a single line. This is the easiest and recommended way to bring NASTRAN models into Karana Dynamics simulations.

Classes#

ModalAnalysisDS

Parameters used for modal analysis.

StressRecoveryDS

Parameters used for stress recovery.

RVDOF

Defines degrees-of-freedom in the residual vector set.

NastranModalAnalysis

Convert NASTRAN models into flexible body models.

NastranStressRecovery

Recover stress from a kdflex sim.

Functions#

writeMdfFile(→ None)

Write an MDF file given flex body simulation data.

Module Contents#

class Karana.FEMBridge.Nastran.ModalAnalysisDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

Parameters used for modal analysis.

Parameters:
  • input_file (FilePath) – Input NASTRAN run deck or bulk data file.

  • analysis_dir (Path) – Analysis directory. If a path is not is not specified, will use analysis_INPUT_FILE_NAME.

  • output_file (Path) – Output HDF5 file.

  • grdpnt (Annotated[int, Field(ge=0)]) – Reference point. If 0, then use the origin of the basic coordinate system.

  • n_modes (Optional[Annotated[int, Field(ge=1)]]) – Number of modes to keep. The Nastran QRG specifies how this parameter works with the frequency lower bound and upper bound.

  • rigid_mode_cutoff (NonNegativeFloat) – The rigid mode cuttoff to use in radians.

  • freq_lb (Optional[NonNegativeFloat]) – Lower bound for modes.

  • freq_ub (Optional[NonNegativeFloat]) – Upper bound for modes.

  • aset (dict[NonNegativeInt, int]) – Nodes to include in the aset.

  • rvdof (dict[NonNegativeInt, int]) – Nodes to include in the aset.

  • output_cs (Optional[int]) – Number of the output coordinate system. This will be assigned to the CD field of the GRDSET card.

  • stress_recovery_op2 (bool) – If True, then add commands to produce an op2 file that can be used to recover stress. Note, that at the time this is written, pyNastran cannot read these op2 files. Hence, for stress recovery, one must run the analysis twice. Once in stres recovery mode and once in regular mode.

input_file: pydantic.FilePath#
analysis_dir: pathlib.Path#
output_file: pathlib.Path#
grdpnt: Karana.KUtils.Ktyping.NonNegativeInt = 0#
n_modes: Annotated[int, Field(ge=1)] | None = None#
rigid_mode_cutoff: Karana.KUtils.Ktyping.NonNegativeFloat = 0.001#
freq_lb: Karana.KUtils.Ktyping.NonNegativeFloat | None = None#
freq_ub: Karana.KUtils.Ktyping.NonNegativeFloat | None = None#
aset: dict[Karana.KUtils.Ktyping.NonNegativeInt, int]#
rvdof: dict[Karana.KUtils.Ktyping.NonNegativeInt, int]#
output_cs: int | None = None#
stress_recovery_op2: bool = False#
postValidate()[source]#

Ensure the upper frequency bound is >= the lower frequency bound.

property output_bdf: pathlib.Path#

Retrieve the transformed bulk data filepath as a Path.

property output_f06: str#

Retrieve the output F06 file as a Path.

property output_op2: pathlib.Path#

Retrieve the output OP2 file as a string.

property n_modes_minus_aset: int | None#

The number of modes the user requests will be augmented aset modes.

We use this to fix that issue by subracting off, so the user gets the number of modes that they want.

property n_modes_w_rv: int | None#

Retrive the number of modes + the number of residual vectors.

class Karana.FEMBridge.Nastran.StressRecoveryDS(/, **data: Any)[source]#

Bases: Karana.KUtils.DataStruct.DataStruct

Parameters used for stress recovery.

Parameters:
  • input_bdf_file (Path) – The modified BDF produced by NastranModalAnalysis when running with stress_recovery_op2 enabled.

  • input_mdf_file (Path) – The input modal deformation file. TODO: Describe how to produce this.

  • input_op2_file (Path) – The op2 file produced by NastranModalAnalysis when running with stress_recovery_op2 enabled.

  • output_op2_file (Path) – The name of the output op2 file. This is the file that will contain the recovered stress data.

  • analysis_dir (Path) – Analysis directory. If a path is not is not specified, will use analysis_INPUT_FILE_NAME.

input_bdf_file: pathlib.Path#
input_mdf_file: pathlib.Path#
input_op2_file: pathlib.Path#
output_op2_file: pathlib.Path#
analysis_dir: pathlib.Path#
postValidate()[source]#

Set the analysis directory if not specified.

property output_bdf: pathlib.Path#

Retrieve the transformed bulk data filepath as a Path.

property output_f06: str#

Retrieve the output F06 file as a Path.

property input_mdf_file_rel: pathlib.Path#

Input MDF file relative to the analysis_dir.

property input_op2_file_rel: pathlib.Path#

Input MDF file relative to the analysis_dir.

class Karana.FEMBridge.Nastran.RVDOF(ids, components: list[str], comment='')[source]#

Bases: pyNastran.bdf.cards.bdf_sets.ABCQSet

Defines degrees-of-freedom in the residual vector set.

type = 'RVDOF'#
class Karana.FEMBridge.Nastran.NastranModalAnalysis(config: ModalAnalysisDS)[source]#

Convert NASTRAN models into flexible body models.

This class processes a NASTRAN model in the following way: * Using user-defined parameters, modify the NASTRAN run deck to retrieve the appropriate

mode shapes. These mode shapes are component mode shapes obtained using the Craig Bampton method.

  • Extra parameters such as residual vectors or modal integrals can also be obtained by setting the appropriate parameters.

  • Run NASTRAN on the modified run deck and save the results into an HDF5 file. This file contains all of the critical data needed to create a PhysicalModalBody.

nastran_executable = 'nastran'#
writeNewFile()[source]#

Modify the original run deck using the user-provided configuration.

runNastran()[source]#

Run NASTRAN on the output file. Must be run after writeNewFile.

processOP2()[source]#

Process the OP2 file and save the results to the H5 file.

class Karana.FEMBridge.Nastran.NastranStressRecovery(config: StressRecoveryDS)[source]#

Recover stress from a kdflex sim.

This class uses files produced by NastranModalAnalysis plus a modal deformation file from a kdflex simulation, and combines them to recover the stresses on a body during said simulation.

nastran_executable = 'nastran'#
writeNewFile()[source]#

Modify the given run deck using the user-provided configuration.

runNastran()[source]#

Run NASTRAN on the output file. Must be run after writeNewFile.

Karana.FEMBridge.Nastran.writeMdfFile(ds: h5py.Dataset, output_mdf_file: pathlib.Path | str) None[source]#

Write an MDF file given flex body simulation data.

Parameters:
  • ds (h5py.Group) – The group that contains the flexible body information.

  • output_mdf_file (Path | str) – The file to write the MDF data to.