""" Quick OP2 diagnostic script """ from pyNastran.op2.op2 import OP2 from pathlib import Path op2_path = Path("examples/bracket/bracket_sim1-solution_1.op2") print("="*60) print("OP2 FILE DIAGNOSTIC") print("="*60) print(f"File: {op2_path}") op2 = OP2() op2.read_op2(str(op2_path)) print("\n--- AVAILABLE DATA ---") print(f"Has displacements: {hasattr(op2, 'displacements') and bool(op2.displacements)}") print(f"Has velocities: {hasattr(op2, 'velocities') and bool(op2.velocities)}") print(f"Has accelerations: {hasattr(op2, 'accelerations') and bool(op2.accelerations)}") # Check stress tables stress_tables = { 'cquad4_stress': 'CQUAD4 elements', 'ctria3_stress': 'CTRIA3 elements', 'ctetra_stress': 'CTETRA elements', 'chexa_stress': 'CHEXA elements', 'cbar_stress': 'CBAR elements' } print("\n--- STRESS TABLES ---") has_stress = False for table, desc in stress_tables.items(): if hasattr(op2, table): table_obj = getattr(op2, table) if table_obj: has_stress = True subcases = list(table_obj.keys()) print(f"\n{table} ({desc}): Subcases {subcases}") # Show data from first subcase if subcases: data = table_obj[subcases[0]] print(f" Data shape: {data.data.shape}") print(f" Data dimensions: timesteps={data.data.shape[0]}, elements={data.data.shape[1]}, values={data.data.shape[2]}") print(f" All data min: {data.data.min():.6f}") print(f" All data max: {data.data.max():.6f}") # Check each column print(f" Column-wise max values:") for col in range(data.data.shape[2]): col_max = data.data[0, :, col].max() print(f" Column {col}: {col_max:.6f}") # Find max von Mises (usually last column) von_mises_col = data.data[0, :, -1] max_vm = von_mises_col.max() max_idx = von_mises_col.argmax() print(f" Von Mises (last column):") print(f" Max: {max_vm:.6f} at element index {max_idx}") if not has_stress: print("NO STRESS DATA FOUND") # Check displacements if hasattr(op2, 'displacements') and op2.displacements: print("\n--- DISPLACEMENTS ---") subcases = list(op2.displacements.keys()) print(f"Subcases: {subcases}") for subcase in subcases: disp = op2.displacements[subcase] print(f"Subcase {subcase}:") print(f" Shape: {disp.data.shape}") print(f" Max displacement: {disp.data.max():.6f}") # Check grid point weight (mass) if hasattr(op2, 'grid_point_weight') and op2.grid_point_weight: print("\n--- GRID POINT WEIGHT (MASS) ---") gpw = op2.grid_point_weight print(f"Total mass: {gpw.mass.sum():.6f}") else: print("\n--- GRID POINT WEIGHT (MASS) ---") print("NOT AVAILABLE - Add PARAM,GRDPNT,0 to Nastran deck") print("\n" + "="*60)