Portal Frame – Incremental Method#
|
Running the incremental stability method on a published portal frame benchmark (Schneider, Bautabellen für Ingenieure) and reading the results of each load increment:
Keywords:
nonlinear stability incremental method load increment critical load factor second-order analysis imperfection |
"""
Nonlinear stability analysis of a portal frame (incremental method).
Benchmark: portal frame under second-order theory with the reference solution
from Schneider, Bautabellen fuer Ingenieure, 19th edition, Werner Verlag 2010.
A frame with fixed column bases carries a roof load q, two column loads F and a
horizontal load H. The columns lean by the initial sway imperfection
psi0 = 1/200 (25 mm at the top). Second-order theory gives the moments and the
sway that Schneider tabulates.
The incremental method starts at load factor 1.0, so load increment 1 is exactly
this design state and can be checked against the benchmark. The analysis then
increases the load until the frame becomes unstable.
The example reads the results with get_result_table():
- the summary table, which states the critical load factor
- member forces and nodal deformations of load increment 1 (load_increment_no),
compared with the benchmark values
- the same tables for every load increment, giving the load-deflection path
Reference values for the critical load factor:
- closed form, sway buckling of a fixed-base frame (stability functions) -> 2.89
- RFEM eigenvalue method -> 2.89
- RFEM incremental method (this example), with the sway imperfection -> 2.82
The incremental limit lies slightly below the bifurcation load, because the
imperfect frame sways from the start and its stiffness drops before it.
"""
from math import inf
import grpc
import pandas as pd
from dlubal.api import rfem, common
# --- Benchmark input -------------------------------------------------------
SPAN = 6.0 # m
HEIGHT = 5.0 # m
IMPERFECTION = HEIGHT / 200 # m, psi0 = 1/200 -> 25 mm at the column tops
ROOF_LOAD = 10_000.0 # N/m, q
COLUMN_LOAD = 400_000.0 # N, F at each column top
HORIZONTAL_LOAD = 20_000.0 # N, H at the left column top
# Bending stiffness of the benchmark: columns EI = 4000 kNm2, beam EI = 6000 kNm2.
# Solid rectangles in S235 (E = 210 GPa) give these values within 0.03 %.
COLUMN_SECTION = 'R_M1 100/131.73'
BEAM_SECTION = 'R_M1 100/150.80'
# Schneider, Bautabellen fuer Ingenieure: second-order moments [kNm] and sway [mm]
REFERENCE = {
'M1 base left [kNm]': 38.2,
'M2 top left [kNm]': 22.5,
'M3 top right [kNm]': 58.1,
'M4 base right [kNm]': 58.8,
'sway [mm]': 65.3,
}
def define_structure() -> list:
"""Fixed-base frame in the XZ plane, column tops shifted by the imperfection."""
return [
rfem.structure_core.Material(no=1, name='S235'),
rfem.structure_core.CrossSection(no=1, name=COLUMN_SECTION, material=1, shear_stiffness_deactivated=True),
rfem.structure_core.CrossSection(no=2, name=BEAM_SECTION, material=1, shear_stiffness_deactivated=True),
# Global Z points down (RFEM default), so the column tops lie at Z = -HEIGHT
rfem.structure_core.Node(no=1, coordinate_1=0.0),
rfem.structure_core.Node(no=2, coordinate_1=SPAN),
rfem.structure_core.Node(no=3, coordinate_1=IMPERFECTION, coordinate_3=-HEIGHT),
rfem.structure_core.Node(no=4, coordinate_1=SPAN + IMPERFECTION, coordinate_3=-HEIGHT),
rfem.structure_core.Line(no=1, definition_nodes=[1, 3]),
rfem.structure_core.Line(no=2, definition_nodes=[3, 4]),
rfem.structure_core.Line(no=3, definition_nodes=[2, 4]),
rfem.structure_core.Member(no=1, line=1, cross_section_start=1), # left column
rfem.structure_core.Member(no=2, line=2, cross_section_start=2), # beam
rfem.structure_core.Member(no=3, line=3, cross_section_start=1), # right column
rfem.types_for_nodes.NodalSupport(
no=1,
nodes=[1, 2],
spring=common.Vector3d(x=inf, y=inf, z=inf),
rotational_restraint=common.Vector3d(x=inf, y=inf, z=inf),
),
# The benchmark is a plane frame: hold the column tops out of plane
rfem.types_for_nodes.NodalSupport(
no=2,
nodes=[3, 4],
spring=common.Vector3d(x=0, y=inf, z=0),
rotational_restraint=common.Vector3d(x=0, y=0, z=0),
),
]
def define_loading() -> list:
"""The benchmark load case, analysed with the incremental stability method."""
return [
rfem.loading.StaticAnalysisSettings(
no=1,
analysis_type=rfem.loading.StaticAnalysisSettings.ANALYSIS_TYPE_SECOND_ORDER_P_DELTA,
),
rfem.loading.StabilityAnalysisSettings(
no=1,
analysis_type=rfem.loading.StabilityAnalysisSettings.ANALYSIS_TYPE_INCREMENTALY_METHOD_WITHOUT_EIGENVALUE,
initial_load_factor=1.0, # increment 1 = benchmark load level
load_factor_increment=0.1,
refinement_of_the_last_load_increment=5,
maximum_number_of_load_increments=100,
save_results_of_all_increments=True, # required for load_increment_no
),
rfem.loading.LoadCase(
no=1,
name='Benchmark | q + F + H',
static_analysis_settings=1,
stability_analysis_settings=1,
calculate_critical_load=True,
self_weight_active=False,
),
rfem.loads.MemberLoad(
no=1,
load_case=1,
members=[2],
load_distribution=rfem.loads.MemberLoad.LOAD_DISTRIBUTION_UNIFORM,
magnitude=ROOF_LOAD,
),
rfem.loads.NodalLoad(
no=1,
load_case=1,
nodes=[3, 4],
load_direction=rfem.loads.NodalLoad.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_TRUE_LENGTH,
force_magnitude=COLUMN_LOAD,
),
rfem.loads.NodalLoad(
no=2,
load_case=1,
nodes=[3],
load_direction=rfem.loads.NodalLoad.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE_LENGTH,
force_magnitude=HORIZONTAL_LOAD,
),
]
def moment_at(forces: pd.DataFrame, member_no: int, node_no: int) -> float:
"""Bending moment M_y [kNm] of a member at one of its end nodes."""
row = forces[(forces['member_no'] == member_no) & (forces['node_no'] == node_no) & forces['tag'].isna()]
return abs(row['m_y'].iloc[0]) / 1000
with rfem.Application() as rfem_app:
# Step 1: Create a new model with the Structure Stability add-on
rfem_app.close_all_models(save_changes=False)
rfem_app.create_model(name='nonlinear_stability_portal_frame')
base_data = rfem_app.get_base_data()
base_data.addons.structure_stability_active = True
rfem_app.set_base_data(base_data=base_data)
# Step 2: Create the structure and the loading
rfem_app.delete_all_objects()
rfem_app.create_object_list(define_structure() + define_loading())
# Step 3: Run the incremental stability analysis
calculation = rfem_app.calculate_all(skip_warnings=True)
print(f"\nCalculation:\n{calculation}")
lc1 = rfem.ObjectId(no=1, object_type=rfem.OBJECT_TYPE_LOAD_CASE)
# Step 4: Summary - the critical load factor of the whole incremental run
summary = rfem_app.get_result_table(
table=rfem.results.ResultTable.NONLINEAR_STABILITY_ANALYSIS_SUMMARY_TABLE,
loading=lc1,
).data
critical_load_factor = float(summary.loc[summary['description'].str.lower() == 'critical load factor', 'value'].iloc[0])
print(f"\nCritical load factor: {critical_load_factor:.2f}")
# The summary does not depend on the load increment. Asking for one returns
# an empty table and a warning instead of an error.
summary_for_increment = rfem_app.get_result_table(
table=rfem.results.ResultTable.NONLINEAR_STABILITY_ANALYSIS_SUMMARY_TABLE,
loading=lc1,
load_increment_no=2,
)
print(f"Summary for increment 2: {len(summary_for_increment.data)} rows, warning: {summary_for_increment.warning}")
# Step 5: Load increment 1 is the benchmark load level - compare with Schneider
forces = rfem_app.get_result_table(
table=rfem.results.ResultTable.NONLINEAR_STABILITY_ANALYSIS_MEMBERS_INTERNAL_FORCES_TABLE,
loading=lc1,
load_increment_no=1,
).data
deformations = rfem_app.get_result_table(
table=rfem.results.ResultTable.NONLINEAR_STABILITY_ANALYSIS_NODES_GLOBAL_DEFORMATIONS_TABLE,
loading=lc1,
load_increment_no=1,
).data
rfem_values = {
'M1 base left [kNm]': moment_at(forces, member_no=1, node_no=1),
'M2 top left [kNm]': moment_at(forces, member_no=1, node_no=3),
'M3 top right [kNm]': moment_at(forces, member_no=3, node_no=4),
'M4 base right [kNm]': moment_at(forces, member_no=3, node_no=2),
'sway [mm]': deformations.loc[deformations['node_no'] == 3, 'u_x'].iloc[0] * 1000,
}
comparison = pd.DataFrame({'Schneider': REFERENCE, 'RFEM': rfem_values})
comparison['deviation [%]'] = (comparison['RFEM'] / comparison['Schneider'] - 1) * 100
print(f"\nLoad increment 1 vs. benchmark:\n{comparison.to_string(float_format='{:.2f}'.format)}")
# Step 6: Load-deflection path, one load increment at a time.
# load_increment_no starts at 1; a number past the last increment is rejected
# with INVALID_ARGUMENT, which ends the loop.
vertical_load = 2 * COLUMN_LOAD + ROOF_LOAD * SPAN
path = []
increment_no = 1
while True:
try:
support_forces = rfem_app.get_result_table(
table=rfem.results.ResultTable.NONLINEAR_STABILITY_ANALYSIS_NODES_SUPPORT_FORCES_TABLE,
loading=lc1,
load_increment_no=increment_no,
).data
except grpc.RpcError as error:
if error.code() == grpc.StatusCode.INVALID_ARGUMENT:
break
raise
deformations = rfem_app.get_result_table(
table=rfem.results.ResultTable.NONLINEAR_STABILITY_ANALYSIS_NODES_GLOBAL_DEFORMATIONS_TABLE,
loading=lc1,
load_increment_no=increment_no,
).data
forces = rfem_app.get_result_table(
table=rfem.results.ResultTable.NONLINEAR_STABILITY_ANALYSIS_MEMBERS_INTERNAL_FORCES_TABLE,
loading=lc1,
load_increment_no=increment_no,
).data
# The 'loads' row holds the load applied in this increment
applied_load = support_forces.loc[support_forces['specification'].str.lower() == 'loads', 'p_z'].iloc[0]
path.append({
'increment': increment_no,
'load factor': applied_load / vertical_load,
'sway [mm]': deformations.loc[deformations['node_no'] == 3, 'u_x'].iloc[0] * 1000,
'M4 base right [kNm]': moment_at(forces, member_no=3, node_no=2),
})
increment_no += 1
path = pd.DataFrame(path)
print(f"\nLoad-deflection path ({len(path)} increments):\n{path.to_string(index=False, float_format='{:.2f}'.format)}")
using System.Globalization;
using Google.Protobuf;
using Grpc.Core;
using Common = Dlubal.Api.Common;
using Rfem = Dlubal.Api.Rfem;
// -------------------------------------------------------
// Nonlinear stability analysis of a portal frame (incremental method).
//
// Benchmark: portal frame under second-order theory with the reference solution
// from Schneider, Bautabellen fuer Ingenieure, 19th edition, Werner Verlag 2010.
//
// A frame with fixed column bases carries a roof load q, two column loads F and a
// horizontal load H. The columns lean by the initial sway imperfection
// psi0 = 1/200 (25 mm at the top). Second-order theory gives the moments and the
// sway that Schneider tabulates.
//
// The incremental method starts at load factor 1.0, so load increment 1 is exactly
// this design state and can be checked against the benchmark. The analysis then
// increases the load until the frame becomes unstable.
//
// The example reads the results with get_result_table():
// - the summary table, which states the critical load factor
// - member forces and nodal deformations of load increment 1 (loadIncrementNo),
// compared with the benchmark values
// - the same tables for every load increment, giving the load-deflection path
//
// Reference values for the critical load factor:
// - closed form, sway buckling of a fixed-base frame (stability functions) -> 2.89
// - RFEM eigenvalue method -> 2.89
// - RFEM incremental method (this example), with the sway imperfection -> 2.82
// The incremental limit lies slightly below the bifurcation load, because the
// imperfect frame sways from the start and its stiffness drops before it.
// -------------------------------------------------------
// --- Benchmark input -----------------------------------
const double Span = 6.0; // m
const double Height = 5.0; // m
const double Imperfection = Height / 200; // m, psi0 = 1/200 -> 25 mm at the column tops
const double RoofLoad = 10_000.0; // N/m, q
const double ColumnLoad = 400_000.0; // N, F at each column top
const double HorizontalLoad = 20_000.0; // N, H at the left column top
// Bending stiffness of the benchmark: columns EI = 4000 kNm2, beam EI = 6000 kNm2.
// Solid rectangles in S235 (E = 210 GPa) give these values within 0.03 %.
const string ColumnSection = "R_M1 100/131.73";
const string BeamSection = "R_M1 100/150.80";
// Schneider, Bautabellen fuer Ingenieure: second-order moments [kNm] and sway [mm]
var reference = new Dictionary<string, double>
{
["M1 base left [kNm]"] = 38.2,
["M2 top left [kNm]"] = 22.5,
["M3 top right [kNm]"] = 58.1,
["M4 base right [kNm]"] = 58.8,
["sway [mm]"] = 65.3,
};
static List<IMessage> DefineStructure()
{
// Fixed-base frame in the XZ plane, column tops shifted by the imperfection.
// Global Z points down (RFEM default), so the column tops lie at Z = -Height.
return new List<IMessage>
{
new Rfem.StructureCore.Material { No = 1, Name = "S235" },
new Rfem.StructureCore.CrossSection { No = 1, Name = ColumnSection, Material = 1, ShearStiffnessDeactivated = true },
new Rfem.StructureCore.CrossSection { No = 2, Name = BeamSection, Material = 1, ShearStiffnessDeactivated = true },
new Rfem.StructureCore.Node { No = 1, Coordinate1 = 0.0 },
new Rfem.StructureCore.Node { No = 2, Coordinate1 = Span },
new Rfem.StructureCore.Node { No = 3, Coordinate1 = Imperfection, Coordinate3 = -Height },
new Rfem.StructureCore.Node { No = 4, Coordinate1 = Span + Imperfection, Coordinate3 = -Height },
new Rfem.StructureCore.Line { No = 1, DefinitionNodes = { 1, 3 } },
new Rfem.StructureCore.Line { No = 2, DefinitionNodes = { 3, 4 } },
new Rfem.StructureCore.Line { No = 3, DefinitionNodes = { 2, 4 } },
new Rfem.StructureCore.Member { No = 1, Line = 1, CrossSectionStart = 1 }, // left column
new Rfem.StructureCore.Member { No = 2, Line = 2, CrossSectionStart = 2 }, // beam
new Rfem.StructureCore.Member { No = 3, Line = 3, CrossSectionStart = 1 }, // right column
new Rfem.TypesForNodes.NodalSupport
{
No = 1,
Nodes = { 1, 2 },
Spring = new Common.Vector3d { X = double.PositiveInfinity, Y = double.PositiveInfinity, Z = double.PositiveInfinity },
RotationalRestraint = new Common.Vector3d { X = double.PositiveInfinity, Y = double.PositiveInfinity, Z = double.PositiveInfinity },
},
// The benchmark is a plane frame: hold the column tops out of plane
new Rfem.TypesForNodes.NodalSupport
{
No = 2,
Nodes = { 3, 4 },
Spring = new Common.Vector3d { X = 0, Y = double.PositiveInfinity, Z = 0 },
RotationalRestraint = new Common.Vector3d { X = 0, Y = 0, Z = 0 },
},
};
}
static List<IMessage> DefineLoading()
{
// The benchmark load case, analysed with the incremental stability method.
return new List<IMessage>
{
new Rfem.Loading.StaticAnalysisSettings
{
No = 1,
AnalysisType = Rfem.Loading.StaticAnalysisSettings.Types.AnalysisType.SecondOrderPDelta,
},
new Rfem.Loading.StabilityAnalysisSettings
{
No = 1,
AnalysisType = Rfem.Loading.StabilityAnalysisSettings.Types.AnalysisType.IncrementalyMethodWithoutEigenvalue,
InitialLoadFactor = 1.0, // increment 1 = benchmark load level
LoadFactorIncrement = 0.1,
RefinementOfTheLastLoadIncrement = 5,
MaximumNumberOfLoadIncrements = 100,
SaveResultsOfAllIncrements = true, // required for loadIncrementNo
},
new Rfem.Loading.LoadCase
{
No = 1,
Name = "Benchmark | q + F + H",
StaticAnalysisSettings = 1,
StabilityAnalysisSettings = 1,
CalculateCriticalLoad = true,
SelfWeightActive = false,
},
new Rfem.Loads.MemberLoad
{
No = 1,
LoadCase = 1,
Members = { 2 },
LoadDistribution = Rfem.Loads.MemberLoad.Types.LoadDistribution.Uniform,
Magnitude = RoofLoad,
},
new Rfem.Loads.NodalLoad
{
No = 1,
LoadCase = 1,
Nodes = { 3, 4 },
LoadDirection = Rfem.Loads.NodalLoad.Types.LoadDirection.GlobalZOrUserDefinedWTrueLength,
ForceMagnitude = ColumnLoad,
},
new Rfem.Loads.NodalLoad
{
No = 2,
LoadCase = 1,
Nodes = { 3 },
LoadDirection = Rfem.Loads.NodalLoad.Types.LoadDirection.GlobalXOrUserDefinedUTrueLength,
ForceMagnitude = HorizontalLoad,
},
};
}
static string Text(object? value) => Convert.ToString(value, CultureInfo.InvariantCulture) ?? "";
static double ParseDouble(object? value)
{
// Table cells are strings formatted with the current culture; fall back to the invariant one.
var text = Text(value);
if (double.TryParse(text, NumberStyles.Float, CultureInfo.CurrentCulture, out var parsed)) return parsed;
return double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out parsed) ? parsed : double.NaN;
}
static IEnumerable<Microsoft.Data.Analysis.DataFrameRow> RowsWhere(Common.Table table, string columnId, string value)
{
return table.Data.Rows.Where(row => string.Equals(Text(row[columnId]), value, StringComparison.OrdinalIgnoreCase));
}
static double MomentAt(Common.Table forces, int memberNo, int nodeNo)
{
// Bending moment M_y [kNm] of a member at one of its end nodes (rows without a tag).
var row = RowsWhere(forces, "member_no", memberNo.ToString(CultureInfo.InvariantCulture))
.FirstOrDefault(r => Text(r["node_no"]) == nodeNo.ToString(CultureInfo.InvariantCulture) && Text(r["tag"]) == "");
return row is null ? double.NaN : Math.Abs(ParseDouble(row["m_y"])) / 1000;
}
static double SwayAt(Common.Table deformations, int nodeNo)
{
// Horizontal displacement u_x [mm] of a node.
var row = RowsWhere(deformations, "node_no", nodeNo.ToString(CultureInfo.InvariantCulture)).FirstOrDefault();
return row is null ? double.NaN : ParseDouble(row["u_x"]) * 1000;
}
// -------------------------------------------------------
// MAIN SCRIPT
// -------------------------------------------------------
ApplicationRfem? rfemApp = null;
try
{
// Step 1: Create a new model with the Structure Stability add-on
rfemApp = new ApplicationRfem();
rfemApp.close_all_models(saveChanges: false);
rfemApp.create_model(name: "nonlinear_stability_portal_frame");
var baseData = rfemApp.get_base_data();
baseData.Addons.StructureStabilityActive = true;
rfemApp.set_base_data(baseData: baseData);
// Step 2: Create the structure and the loading
rfemApp.delete_all_objects();
var objects = DefineStructure();
objects.AddRange(DefineLoading());
rfemApp.create_object_list(objects);
// Step 3: Run the incremental stability analysis
var calculation = rfemApp.calculate_all(skipWarnings: true);
Console.WriteLine($"\nCalculation:\n{calculation}");
var lc1 = new Rfem.ObjectId { No = 1, ObjectType = Rfem.ObjectType.LoadCase };
// Step 4: Summary - the critical load factor of the whole incremental run
var summary = rfemApp.get_result_table(
table: Rfem.Results.ResultTable.NonlinearStabilityAnalysisSummaryTable,
loading: lc1);
var criticalRow = RowsWhere(summary, "description", "critical load factor").FirstOrDefault();
if (criticalRow is null) { Console.WriteLine("Critical load factor not found in the summary."); return; }
var criticalLoadFactor = ParseDouble(criticalRow["value"]);
Console.WriteLine($"\nCritical load factor: {criticalLoadFactor:F2}");
// Step 5: Load increment 1 is the benchmark load level - compare with Schneider
var forces = rfemApp.get_result_table(
table: Rfem.Results.ResultTable.NonlinearStabilityAnalysisMembersInternalForcesTable,
loading: lc1,
loadIncrementNo: 1);
var deformations = rfemApp.get_result_table(
table: Rfem.Results.ResultTable.NonlinearStabilityAnalysisNodesGlobalDeformationsTable,
loading: lc1,
loadIncrementNo: 1);
var rfemValues = new Dictionary<string, double>
{
["M1 base left [kNm]"] = MomentAt(forces, memberNo: 1, nodeNo: 1),
["M2 top left [kNm]"] = MomentAt(forces, memberNo: 1, nodeNo: 3),
["M3 top right [kNm]"] = MomentAt(forces, memberNo: 3, nodeNo: 4),
["M4 base right [kNm]"] = MomentAt(forces, memberNo: 3, nodeNo: 2),
["sway [mm]"] = SwayAt(deformations, nodeNo: 3),
};
Console.WriteLine("\nLoad increment 1 vs. benchmark:");
Console.WriteLine($"{"",-22}{"Schneider",10}{"RFEM",10}{"deviation [%]",15}");
foreach (var (name, referenceValue) in reference)
{
var rfemValue = rfemValues[name];
Console.WriteLine($"{name,-22}{referenceValue,10:F2}{rfemValue,10:F2}{(rfemValue / referenceValue - 1) * 100,15:F2}");
}
// Step 6: Load-deflection path, one load increment at a time.
// loadIncrementNo starts at 1; a number past the last increment is rejected
// with INVALID_ARGUMENT, which ends the loop.
const double VerticalLoad = 2 * ColumnLoad + RoofLoad * Span;
var path = new List<string>();
for (var incrementNo = 1; ; incrementNo++)
{
Common.Table supportForces;
try
{
supportForces = rfemApp.get_result_table(
table: Rfem.Results.ResultTable.NonlinearStabilityAnalysisNodesSupportForcesTable,
loading: lc1,
loadIncrementNo: incrementNo);
}
catch (RpcException ex) when (ex.StatusCode == StatusCode.InvalidArgument)
{
break;
}
var incrementDeformations = rfemApp.get_result_table(
table: Rfem.Results.ResultTable.NonlinearStabilityAnalysisNodesGlobalDeformationsTable,
loading: lc1,
loadIncrementNo: incrementNo);
var incrementForces = rfemApp.get_result_table(
table: Rfem.Results.ResultTable.NonlinearStabilityAnalysisMembersInternalForcesTable,
loading: lc1,
loadIncrementNo: incrementNo);
// The 'loads' row holds the load applied in this increment
var loadsRow = RowsWhere(supportForces, "specification", "loads").FirstOrDefault();
var loadFactor = loadsRow is null ? double.NaN : ParseDouble(loadsRow["p_z"]) / VerticalLoad;
path.Add($"{incrementNo,9}{loadFactor,13:F2}{SwayAt(incrementDeformations, nodeNo: 3),11:F2}{MomentAt(incrementForces, memberNo: 3, nodeNo: 2),21:F2}");
}
Console.WriteLine($"\nLoad-deflection path ({path.Count} increments):");
Console.WriteLine($"{"increment",9}{"load factor",13}{"sway [mm]",11}{"M4 base right [kNm]",21}");
path.ForEach(Console.WriteLine);
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
finally
{
if (rfemApp != null) rfemApp.close_connection();
}