Read Structural Model Data (.k file)#

To get the data (effective properties) from the output file (.k), use the sgio.readOutputModel() function.

import sgio

model = sgio.readOutputModel(
    file_name,    # Name of the output file.
    file_format,  # Format of the output file.
    model_type,   # Type of the structural model.
)

file_name includes the .k extension. file_format can be ‘vabs’ for VABS output or ‘sc’/’swiftcomp’ for SwiftComp output. model_type should be chosen from a list of built-in keywords indicating the type of the structural model. See Section Material and Structural Models for more details.

The function returns a structural model (Model).

Get Timoshenko Beam Properties from a VABS Output File#

Consider the following VABS output file (sgio/examples/files/cs_box_t_vabs41.sg.K):

 
 The 6X6 Mass Matrix
 ========================================================
 
     5.8177756375E+00    0.0000000000E+00    0.0000000000E+00    0.0000000000E+00    3.7260617944E-01   -9.5280621981E+01
     0.0000000000E+00    5.8177756375E+00    0.0000000000E+00   -3.7260617944E-01    0.0000000000E+00    0.0000000000E+00
     0.0000000000E+00    0.0000000000E+00    5.8177756375E+00    9.5280621981E+01    0.0000000000E+00    0.0000000000E+00
     0.0000000000E+00   -3.7260617944E-01    9.5280621981E+01    1.7135907226E+03    0.0000000000E+00    0.0000000000E+00
     3.7260617944E-01    0.0000000000E+00    0.0000000000E+00    0.0000000000E+00    1.0380909063E+00   -4.9410599903E+00
    -9.5280621981E+01    0.0000000000E+00    0.0000000000E+00    0.0000000000E+00   -4.9410599903E+00    1.7125526316E+03
 
 The Mass Center of the Cross Section
 ========================================================
 
     1.6377500254E+01    6.4046158301E-02
 
 The 6X6 Mass Matrix at the Mass Center
 ========================================================
 
   5.817775637474E+00  0.000000000000E+00  0.000000000000E+00  0.000000000000E+00  0.000000000000E+00  0.000000000000E+00
   0.000000000000E+00  5.817775637474E+00  0.000000000000E+00  0.000000000000E+00  0.000000000000E+00  0.000000000000E+00
   0.000000000000E+00  0.000000000000E+00  5.817775637474E+00  0.000000000000E+00  0.000000000000E+00  0.000000000000E+00
   0.000000000000E+00  0.000000000000E+00  0.000000000000E+00  1.531084478603E+02  0.000000000000E+00  0.000000000000E+00
   0.000000000000E+00  0.000000000000E+00  0.000000000000E+00  0.000000000000E+00  1.014226911963E+00  1.161297808140E+00
   0.000000000000E+00  0.000000000000E+00  0.000000000000E+00  0.000000000000E+00  1.161297808140E+00  1.520942209484E+02
 
 The Mass Properties with respect to Principal Inertial Axes
 ========================================================
 
 Mass per unit span                     =    5.8177756375E+00
 Mass moment of inertia i11             =    1.5310844786E+02
 Principal mass moments of inertia i22  =    1.0053009590E+00
 Principal mass moments of inertia i33  =    1.5210314690E+02
 The principal inertial axes rotated from user coordinate system by 
   179.559622552555      degrees about the positive direction of x1 axis.
 The mass-weighted radius of gyration   =    5.1300440301E+00
 
 The Geometric Center of the Cross Section
 ========================================================
 
     1.1161263263E+01    1.1933318248E-01
 
 The Area of the Cross Section
 ========================================================
 
 Area =    1.9601033633E+01
 
 Classical Stiffness Matrix (1-extension; 2-twist; 3,4-bending)
 ========================================================
 
     3.0720493126E+08   -3.9135812366E+05    4.6917399239E+07   -4.2834130803E+09
    -3.9135812366E+05    1.9429803967E+08   -6.4940288267E+04    5.6954183423E+06
     4.6917399239E+07   -6.4940288267E+04    2.1613620627E+08   -6.7167229189E+08
    -4.2834130803E+09    5.6954183423E+06   -6.7167229189E+08    6.3377360845E+10
 
 Classical Compliance Matrix (1-extension; 2-twist; 3,4-bending)
 ========================================================
 
     5.6510846844E-08    1.8599837341E-12   -4.1145399917E-10    3.8149731147E-09
     1.8599837341E-12    5.1467459391E-09    9.9241222590E-14   -3.3575293615E-13
    -4.1145399917E-10    9.9241222590E-14    4.7872765472E-09    2.2927003963E-11
     3.8149731147E-09   -3.3575293615E-13    2.2927003963E-11    2.7385973248E-10
 
 The Tension Center of the Cross Section
 ========================================================
 
     1.3943176570E+01    1.5272342352E-01
 
 The extension stiffness EA           3.0720414298E+08
 The torsional stiffness GJ           1.9429752543E+08
 Principal bending stiffness EI22     2.0888195275E+08
 Principal bending stiffness EI33     3.6530578162E+09
 The principal bending axes rotated from the user coordinate system by 
  0.291037904417929      degrees about the positive direction of x1 axis.

The following code (sgio/examples/read_vabs_output_h.py) shows how to read the output file and get some Timoshenko beam properties:

"""Example: Read VABS Homogenized Output (Beam Properties)

This example demonstrates how to read VABS homogenized output to obtain
the effective beam properties (stiffness matrix, mass matrix, etc.).

The example reads a VABS 4.1 output file (.K file) for a Timoshenko beam model.
"""
import sgio
from pathlib import Path

# Define the output file path
# Note: The .K file contains homogenized beam properties
output_file = Path(__file__).parent / 'files' / 'cs_box_t_vabs41.sg.K'

# Check if file exists
if not output_file.exists():
    print(f"Error: Output file not found: {output_file}")
    print("Please run VABS analysis first to generate the .K file")
    print("Or use a different example file from examples/files/")
    exit(1)

# Read the VABS homogenized output
# - file_format='vabs': Specifies VABS format
# - model_type='BM2': Timoshenko beam model (includes shear deformation)
model = sgio.readOutputModel(
    str(output_file),
    file_format='vabs',
    model_type='BM2'
)

# Extract beam properties using the .get() method
ea = model.get('ea')      # Axial stiffness
gj = model.get('gj')      # Torsional stiffness
ei22 = model.get('ei22')  # Bending stiffness about axis 2
ei33 = model.get('ei33')  # Bending stiffness about axis 3

# Display beam properties
print("=" * 60)
print("VABS Homogenized Beam Properties")
print("=" * 60)
print(f"File: {output_file.name}")
print(f"Model Type: {model.label}")
print(f"Model Name: {model.model_name}")
print("=" * 60)

print("\nStiffness Properties:")
print(f'  EA (Axial stiffness):      {ea:.6e}')
print(f'  GJ (Torsional stiffness):  {gj:.6e}')
print(f'  EI22 (Bending stiffness):  {ei22:.6e}')
print(f'  EI33 (Bending stiffness):  {ei33:.6e}')

# Display mass properties if available
mu = model.get('mu')
if mu is not None:
    print(f'\nMass Properties:')
    print(f'  μ (Mass per unit length):  {mu:.6e}')

print("=" * 60)

The output should be:

EA = 1653700.125
GJ = 6322.4210975
EI22 = 79466.796504
EI33 = 200742.66655

Checkout sgio.model.TimoshenkoBeamModel.get() for more information on the properties that can be retrieved.