Solver for 2D-frame Question (pyfacade.pyeng)

Module pyfacade.pyeng provides full-functional methods for 2D beam model analysis, which are encapsulated to 2 classes:

class pyfacade.pyeng.Beam2(start_node, end_node, section_area, moment_of_inertia, modulus_of_elasticity, node_list)

Finite element represents a two-dimensional beam in structural model.

Parameters:
  • start_node – int, index of start node of specified beam in node_list.

  • end_node – int, index of end node of specified beam in node_list.

  • section_area – float, cross section area of beam, unit=mm 2.

  • moment_of_inertia – float, moment of inertia of beam section, unit=mm 4.

  • modulus_of_elasticity – float, modulus of elasticity of beam material, unit=N/mm 2.

  • node_list – nested list as [[x0,y0],[x1,y1],…], list of coordinates of all nodes in structural model. Unit=mm.

eval()

Establish necessary structural parameters for finite element analyze.

Note

Run this method once after initialization or any changing on initial parameters.

property length

Length of beam. unit=mm.

property angle

Angle between beam axial direction and +x direction, unit=rad.

property T

The translate matrix from global coordinates to beam local coordinates.

property K

The standard stiffness matrix of beam element.

property nodef

Equivalent applied force at node, in the form of [N_start, V_start, M_start, N_end, V_end, M_end], unit=N or N*mm.

fill_GK(Global_Matrix)

Insert element stiffness into Global Stiffness Matrix of the model.

Parameters:

Global_Matrix – numpy.ndarray, target matrix.

Returns:

None

fill_GR(Global_Matrix)

Insert equivalent node into Global Node Force Matrix of the model.

Parameters:

Global_Matrix – numpy.ndarray, target matrix.

Returns:

None

solve(Global_D)

Import solved results from global model to beam element.

Parameters:

Global_D – numpy.ndarray, target matrix

Returns:

None

endforce()

Output solved end force of beam element in the form of [[N_start, V_start, M_start, N_end, V_end, M_end] unit=N or N*mm.

enddisp()

Output local displacement at both end of beam element in the form of [axial_start, translation_start, rotation_start, axial_end, translation_end, rotation_end], unit=mm or rad

get_N(samp, *samps)

Calculate axial force at specified position on beam element.

Parameters:
  • samp – float, relative position along the element length, from 0 to 1.

  • samps – float, other relative positions along the element length, from 0 to 1.

Returns:

float or list. Unit=N, Positive value is tension.

extre_N()

Find the extreme value of axial force on the element.

Returns:

tuple ((position_occurs_min, min_value), (position_occurs_max, max_value)), unit of axial force=N.

plot_N(sn=5, scale=1, deci=4)

Show axial force curve of the element.

Parameters:
  • sn – int. Number of slice when plotting the curve. More slice provides more smooth appearance of curve.

  • scale – float, zoom-out scales when plotting the curve.

  • deci – int, number of decimal places kept when plotting values on curve.

Returns:

tuple (min_axial_force, max_axial_force), unit=N.

get_V(samp, *samps)

Calculate shear force at specified position on beam element.

Parameters:
  • samp – float, relative position along the element length, from 0 to 1.

  • samps – float, other relative positions along the element length, from 0 to 1.

Returns:

float or list. Unit=N.

extre_V()

Find the extreme value of shear force on the element.

Returns:

tuple ((position_occurs_min, min_value), (position_occurs_max, max_value)), unit of shear force=N.

plot_V(sn=5, scale=1, deci=4)

Show shear force curve of the element.

Parameters:
  • sn – int. Number of slice when plotting the curve. More slice provides more smooth appearance of curve.

  • scale – float, zoom-out scales when plotting the curve.

  • deci – int, number of decimal places kept when plotting values on curve.

Returns:

tuple (min_shear_force, max_shear_force), unit=N.

get_M(samp, *samps)

Calculate bending moment at specified position on beam element.

Parameters:
  • samp – float, relative position along the element length, from 0 to 1.

  • samps – float, other relative positions along the element length, from 0 to 1.

Returns:

float or list. Unit=N*mm.

extre_M()

Find the extreme value of bending moment on the element.

Returns:

tuple ((position_occurs_min, min_value), (position_occurs_max, max_value)), unit of moment = N*mm.

plot_M(sn=10, scale=1, deci=4)

Show moment curve of the element.

Parameters:
  • sn – int. Number of slice when plotting the curve. More slice provides more smooth appearance of curve.

  • scale – float, zoom-out scales when plotting the curve.

  • deci – int, number of decimal places kept when plotting values on curve.

Returns:

tuple (min_bending_moment, max_bending_moment), unit=N*mm.

get_Defy(samp, *samps)

Calculate transverse deflection at specified position on beam element.

Parameters:
  • samp – float, relative position along the element length, from 0 to 1.

  • samps – float, other relative positions along the element length, from 0 to 1.

Returns:

float or list. Unit=mm.

get_Defx(samp, *samps)

Calculate longitudinal displacement at specified position on beam element.

Parameters:
  • samp – float, relative position along the element length, from 0 to 1.

  • samps – float, other relative positions along the element length, from 0 to 1.

Returns:

float or list. Unit=mm.

get_Defxy(samp, *samps, resultant=True)

Calculate resultant displacement at specified position on beam element. return longitudinal deflection and transverse deflection respectively when resultant=False.

Parameters:
  • samp – float, relative position along the element length, from 0 to 1.

  • samps – float, other relative positions along the element length, from 0 to 1.

  • resultant – bool, return resultant deflection

Returns:

float or list of float if resultant =True, numpy.ndarray [def_x, def_y] or list of numpy.ndarray if resultant =False. Unit=mm

extre_Defy()

Find the extreme value of transverse deflection on the element.

Returns:

tuple ((position_occurs_min, min_value), (position_occurs_max, max_value)), unit of deflection = mm.

extre_Defx()

Find the extreme value of longitudinal displacement of the element.

Returns:

tuple ((position_occurs_min, min_value), (position_occurs_max, max_value)), unit of displacement = mm.

extre_Defxy()

Find the extreme value of resultant displacement on the element.

Returns:

tuple ((position_occurs_min, min_value), (position_occurs_max, max_value)), unit of displacement = mm.

plot_Def(sn=10, scale=1, deci=4, def_type='transverse')

Show deflection curve of the element.

Parameters:
  • sn – int, Number of slice when plotting the curve. More slice provides more smooth appearance of curve.

  • scale – float, zoom-out scales when plotting the curve.

  • deci – int, number of decimal places kept when plotting values on curve.

  • def_type

    int or string, type of deflection to be shown, acceptable indicator:

    • 0, ‘xy’, ‘resultant’ - resultant deflection.

    • 1, ‘x’, ‘axial’ - longitudinal deformation.

    • 2, ‘y’, ‘transverse’ - transverse deflection.

Returns:

tuple (min_deflection, max_deflection), unit=mm.

Note

Methods fill_GK, fill_GR and solve are manual operating apis kept for Interactive Mode. For general purpose of a FEM study, they are automatically called by running Bsolver.solve()

class pyfacade.pyeng.Bsolver(b2objs, node_coord, restrain_dict, beam_release={}, distributed_load={}, node_forces={})

FEM solver for beam model.

Parameters:
  • b2objs – list of Beam2 objects involved in the model.

  • node_coord – nested list as [[x0,y0],[x1,y1],…], list of coordinates of all nodes in structural model. Unit=mm.

  • restrain_dict – dict. Definition of structural restrain in the form of {node_no:[res_condition_x, res_condition_y, res_condition_rotate], …}, where: 0=released and 1=restrained.

  • beam_release – dict. Definition of release conditions of beams in the form of {beam_no:[(axial_condition_start, rotation_condition_start), (axial_condition_end, rotation_condition_end)],…}, where: 0=fixed and 1=released.

  • distributed_load – dict. Definition of applied Uniformly Distributed Load on model in the form of {beam_no:(axial_force, transverse_force),…}. Unit=N/mm.

  • node_forces – dict. Definition of applied Concentrated Load on model in the form of {node:[Fx, Fy, Mz]…}. Unit=N or N*mm.

solve()

Solve the model.

Returns:

Matrix of global node displacement.

Warning

Once being called successfully, solved results (such as member force, deflection, etc.) will be automatically assigned to related beam objects. Any existing result in those objects will be hence overridden.

get_react()

Output matrix of node reactions in the form of [[Rx_0, Ry_0, M_0], [Rx_1, Ry_1, M_1], …]. Unit = N or N*mm.

get_endf()

Output overall matrix of beam end forces. Unit = N or N*mm.

get_enddisp()

Output overall matrix of beam end displacements. Unit = mm or rad.

get_summary(datatype, envelop=False)

Output extreme value of specified data.

Parameters:
  • datatype

    int or str. indicator of required data type.

    0

    ’Axial Force’

    1

    ’Shear’

    2

    ’Moment’

    3

    ’Deflection’

    4

    ’Axial Displacement’

    5

    ’Resultant Displacement’

  • envelop – bool, output the extreme value of entire model. Extreme value for each beam element is listed when envelop = False

Returns:

tuple (min_value, max_value) if envelop = True. or list of tuple [(min_value_beam0, max_value_beam0), (min_value_beam1, max_value_beam1), …]

show_mdl(node_num=True, beam_num=True, size=(8, 6), save=False, path=None)

Plot model figure.

Parameters:
  • node_num – bool, show node number on figure.

  • beam_num – bool, show beam number on figure.

  • size – tuple (size_x, size_y), size of the plotted figure.

  • save – bool, save model figure.

  • path – str, path to save the model figure. Current working directory is used if path = None (default).

Returns:

None

show_diag(ptype, Size=(8, 6), ShowEnve=True, DivN=5, Scale=1, Accr=4, save=False, path=None)

Plot the diagram showing specified results.

Parameters:
  • ptype – str, type of required results, is one of ‘Axial Force’, ‘Shear’, ‘Moment’, ‘Deflection’, ‘Axial Displacement’ and ‘Resultant Displacement’

  • Size – tuple (size_x, size_y), size of the plotted figure.

  • ShowEnve – bool, show min/max value in figure.

  • DivN – int, Number of slice when plotting the curve.

  • Scale – float, zoom-out scales when plotting the curve.

  • Accr – int, number of decimal places kept when marking values on diagram.

  • save – bool, save diagram figure.

  • path – str, path to save the diagram figure. Current working directory is used if path = None (default).

Returns:

None

out_csv(datatype=0, path=None)

Output results to CSV file.

Parameters:
  • datatype

    int, indicator of required data type to be output.

    • 1 - output reaction data.

    • 2 - output member force and deflection data.

    • 0 - output all data.

  • path – str, path to save the CSV file. Current working directory is used if path = None (default).

Returns:

None