OpenSeesPyAssistant 1.1
OpenSeesPy for everyone
Fibers Namespace Reference

Module for the fibers (rectangular, circular and I shape). More...

Classes

class  Fibers
 Parent abstract class for the storage and manipulation of a fiber's information (mechanical and geometrical parameters, etc) and initialisation in the model. More...
 
class  FibersCirc
 Class that stores funcions, material properties, geometric and mechanical parameters for a circular RC fiber section. More...
 
class  FibersCircRCCircShape
 Class that is the children of FibersCirc and combine the class RCCircShape (section) to retrieve the information needed. More...
 
class  FibersIShape
 Class that stores funcions, material properties, geometric and mechanical parameters for a steel I shape (non double symmetric) fiber section. More...
 
class  FibersIShapeSteelIShape
 Class that is the children of FibersIShape and combine the class SteelIShape (section) to retrieve the information needed. More...
 
class  FibersRect
 Class that stores funcions, material properties, geometric and mechanical parameters for a rectangular RC fiber section. More...
 
class  FibersRectRCRectShape
 Class that is the children of FibersRect and combine the class RCRectShape (section) to retrieve the information needed. More...
 

Functions

def create_fiber_section (fiber_info)
 Initialise fiber cross-section with OpenSeesPy commands. More...
 
def plot_fiber_section (fiber_info, fill_shapes=True, matcolor=['#808080', '#D3D3D3', 'r', 'b', 'g', 'y'])
 Plot fiber cross-section. More...
 

Detailed Description

Module for the fibers (rectangular, circular and I shape).

Carmine Schipani, 2021

Function Documentation

◆ create_fiber_section()

def Fibers.create_fiber_section (   fiber_info)

Initialise fiber cross-section with OpenSeesPy commands.

For examples, see plot_fiber_section. Inspired by fib_sec_list_to_cmds from ops_vis written by Seweryn Kokot

Parameters
fiber_info(list): List of lists (be careful with the local coordinate system!). The first list defines the fiber section:
['section', 'Fiber', ID, '-GJ', GJ]
The other lists have one of the following format (coordinate input: (y, z)!):
['layer', 'bar', mat_ID, A, y, z] # one bar
['layer', 'straight', mat_ID, n_bars, A, yI, zI, yJ, zJ] # line range of bars (with I = first bar, J = last bar)
['layer', 'circ', mat_ID, n_bars, A, yC, zC, r, (a0_deg), (a1_deg)] # circular range of bars (with C = center, r = radius)
['patch', 'rect', mat_ID, *discr, -yI, zI, yK, -zK] # rectangle (with yI = yK = d/2; zI = zK = b/2)
['patch', 'quad', mat_ID, *discr, yI, zI, yJ, zJ, yK, zK, yL, zL] # quadrilateral shaped (starting from bottom left, counterclockwise: I, J, K, L)
['patch', 'circ', mat_ID, *discr, yC, zC, ri, re, (a0), (a1)] # (with C = center, ri = internal radius, re = external radius)

Definition at line 857 of file Fibers.py.

857def create_fiber_section(fiber_info):
858 """
859 Initialise fiber cross-section with OpenSeesPy commands.
860 For examples, see plot_fiber_section.
861 Inspired by fib_sec_list_to_cmds from ops_vis written by Seweryn Kokot
862
863 @param fiber_info (list): List of lists (be careful with the local coordinate system!). The first list defines the fiber section: \n
864 ['section', 'Fiber', ID, '-GJ', GJ] \n
865 The other lists have one of the following format (coordinate input: (y, z)!): \n
866 ['layer', 'bar', mat_ID, A, y, z] # one bar \n
867 ['layer', 'straight', mat_ID, n_bars, A, yI, zI, yJ, zJ] # line range of bars (with I = first bar, J = last bar) \n
868 ['layer', 'circ', mat_ID, n_bars, A, yC, zC, r, (a0_deg), (a1_deg)] # circular range of bars (with C = center, r = radius) \n
869 ['patch', 'rect', mat_ID, *discr, -yI, zI, yK, -zK] # rectangle (with yI = yK = d/2; zI = zK = b/2) \n
870 ['patch', 'quad', mat_ID, *discr, yI, zI, yJ, zJ, yK, zK, yL, zL] # quadrilateral shaped (starting from bottom left, counterclockwise: I, J, K, L) \n
871 ['patch', 'circ', mat_ID, *discr, yC, zC, ri, re, (a0), (a1)] # (with C = center, ri = internal radius, re = external radius)
872 """
873 for dat in fiber_info:
874 if dat[0] == 'section':
875 fib_ID, GJ = dat[2], dat[4]
876 section('Fiber', fib_ID, 'GJ', GJ)
877
878 if dat[0] == 'layer':
879 mat_ID = dat[2]
880 if dat[1] == 'straight':
881 n_bars = dat[3]
882 As = dat[4]
883 Iy, Iz, Jy, Jz = dat[5], dat[6], dat[7], dat[8]
884 layer('straight', mat_ID, n_bars, As, Iy, Iz, Jy, Jz)
885 if dat[1] == 'bar':
886 As = dat[3]
887 Iy = dat[4]
888 Iz = dat[5]
889 fiber(Iy, Iz, As, mat_ID)
890 # layer('straight', mat_ID, 1, As, Iy, Iz, Iy, Iz)
891 if dat[1] == 'circ':
892 n_bars, As = dat[3], dat[4]
893 yC, zC, r = dat[5], dat[6], dat[7]
894 if len(dat) > 8:
895 a0_deg = dat[8]
896 else:
897 a0_deg = 0.
898 a1_deg = 360. - 360./n_bars + a0_deg
899 if len(dat) > 9: a1_deg = dat[9]
900 layer('circ', mat_ID, n_bars, As, yC, zC, r, a0_deg, a1_deg)
901
902 if dat[0] == 'patch':
903 mat_ID = dat[2]
904 nIJ = dat[4]
905 nJK = dat[3]
906
907 if dat[1] == 'quad' or dat[1] == 'quadr':
908 Iy, Iz, Jy, Jz = dat[5], dat[6], dat[7], dat[8]
909 Ky, Kz, Ly, Lz = dat[9], dat[10], dat[11], dat[12]
910 patch('quad', mat_ID, nIJ, nJK, Iy, Iz, Jy, Jz, Ky, Kz,
911 Ly, Lz)
912
913 if dat[1] == 'rect':
914 Iy, Iz, Ky, Kz = dat[5], dat[6], dat[7], dat[8]
915 patch('rect', mat_ID, nIJ, nJK, Iy, Iz, Ky, Kz)
916 # patch('rect', mat_ID, nIJ, nJK, Iy, Kz, Ky, Iz)
917
918 if dat[1] == 'circ':
919 mat_ID, nc, nr = dat[2], dat[3], dat[4]
920 yC, zC, ri, re = dat[5], dat[6], dat[7], dat[8]
921 if len(dat) > 9:
922 a0 = dat[9]
923 else:
924 a0 = 0.
925 a1 = 360. + a0
926 if len(dat) > 10: a1 = dat[10]
927 patch('circ', mat_ID, nc, nr, yC, zC, ri, re, a0, a1)
928
def create_fiber_section(fiber_info)
Initialise fiber cross-section with OpenSeesPy commands.
Definition: Fibers.py:857

◆ plot_fiber_section()

def Fibers.plot_fiber_section (   fiber_info,
  fill_shapes = True,
  matcolor = ['#808080', '#D3D3D3', 'r', 'b', 'g', 'y'] 
)

Plot fiber cross-section.

Coordinate system used: plotting coordinte = (x, y), fiber section coordinate (z, y) = (-x, y)
Inspired by plot_fiber_section from ops_vis written by Seweryn Kokot.

Parameters
fiber_info(list): List of lists (be careful with the local coordinate system!). The first list defines the fiber section:
['section', 'Fiber', ID, '-GJ', GJ]
The other lists have one of the following format (coordinate input: (y, z)!):
['layer', 'bar', mat_ID, A, y, z] # one bar
['layer', 'straight', mat_ID, n_bars, A, yI, zI, yJ, zJ] # line range of bars (with I = first bar, J = last bar)
['layer', 'circ', mat_ID, n_bars, A, yC, zC, r, (a0_deg), (a1_deg)] # circular range of bars (with C = center, r = radius)
['patch', 'rect', mat_ID, *discr, -yI, zI, yK, -zK] # rectangle (with yI = yK = d/2; zI = zK = b/2)
['patch', 'quad', mat_ID, *discr, yI, zI, yJ, zJ, yK, zK, yL, zL] # quadrilateral shaped (starting from bottom left, counterclockwise: I, J, K, L)
['patch', 'circ', mat_ID, *discr, yC, zC, ri, re, (a0), (a1)] # (with C = center, ri = internal radius, re = external radius)
fill_shapes(bool, optional): Option to fill fibers with color specified in matcolor. Defaults to True.
matcolor(list, optional): List of colors for various material IDs. Defaults to ['#808080', '#D3D3D3', 'r', 'b', 'g', 'y'].

Example 1: Simple rectangle with 2 rebars (D = diameter) on top (e distance from the top and from the lateral borders). Rectangle with first corner = I (bottom right) and second corner = K (top left); number of fibers = discr (list of 2) fib_sec = [['section', 'Fiber', ID, '-GJ', GJ], ['patch', 'rect', concrete_mat_ID, *discr, yI, zI, yK, zK], ['layer', 'bar', bars_mat_ID, Ay, yI-e-D/2, zI-e-D/2], # left rebar ['layer', 'bar', bars_mat_ID, Ay, yI-e-D/2, -(zI-e-D/2)]] # right rebar

Example 2: double symmetric I shape. Each rectangle (2 flanges and 1 web): first corner = I (bottom right) and second corner = K (top left); number of fibers = discr (list of 2) fib_sec = [['section', 'Fiber', ID, '-GJ', GJ], ['patch', 'rect', mat_ID, *discr, yI_tf, zI_tf, yK_tf, zK_tf], # top flange ['patch', 'rect', mat_ID, *discr, yI_bf, zI_bf, yK_bf, zK_bf], # bottom flange ['patch', 'rect', mat_ID, *discr, yI_w, zI_w, yK_w, zK_w]] # web

Definition at line 673 of file Fibers.py.

673def plot_fiber_section(fiber_info, fill_shapes = True, matcolor=['#808080', '#D3D3D3', 'r', 'b', 'g', 'y']):
674 """
675 Plot fiber cross-section. Coordinate system used: plotting coordinte = (x, y), fiber section coordinate (z, y) = (-x, y)
676 Inspired by plot_fiber_section from ops_vis written by Seweryn Kokot.
677
678 @param fiber_info (list): List of lists (be careful with the local coordinate system!). The first list defines the fiber section: \n
679 ['section', 'Fiber', ID, '-GJ', GJ] \n
680 The other lists have one of the following format (coordinate input: (y, z)!): \n
681 ['layer', 'bar', mat_ID, A, y, z] # one bar \n
682 ['layer', 'straight', mat_ID, n_bars, A, yI, zI, yJ, zJ] # line range of bars (with I = first bar, J = last bar) \n
683 ['layer', 'circ', mat_ID, n_bars, A, yC, zC, r, (a0_deg), (a1_deg)] # circular range of bars (with C = center, r = radius) \n
684 ['patch', 'rect', mat_ID, *discr, -yI, zI, yK, -zK] # rectangle (with yI = yK = d/2; zI = zK = b/2) \n
685 ['patch', 'quad', mat_ID, *discr, yI, zI, yJ, zJ, yK, zK, yL, zL] # quadrilateral shaped (starting from bottom left, counterclockwise: I, J, K, L) \n
686 ['patch', 'circ', mat_ID, *discr, yC, zC, ri, re, (a0), (a1)] # (with C = center, ri = internal radius, re = external radius)
687 @param fill_shapes (bool, optional): Option to fill fibers with color specified in matcolor. Defaults to True.
688 @param matcolor (list, optional): List of colors for various material IDs. Defaults to ['#808080', '#D3D3D3', 'r', 'b', 'g', 'y'].
689
690 Example 1: Simple rectangle with 2 rebars (D = diameter) on top (e distance from the top and from the lateral borders).
691 Rectangle with first corner = I (bottom right) and second corner = K (top left); number of fibers = discr (list of 2)
692 fib_sec = [['section', 'Fiber', ID, '-GJ', GJ],
693 ['patch', 'rect', concrete_mat_ID, *discr, yI, zI, yK, zK],
694 ['layer', 'bar', bars_mat_ID, Ay, yI-e-D/2, zI-e-D/2], # left rebar
695 ['layer', 'bar', bars_mat_ID, Ay, yI-e-D/2, -(zI-e-D/2)]] # right rebar
696
697 Example 2: double symmetric I shape.
698 Each rectangle (2 flanges and 1 web): first corner = I (bottom right) and second corner = K (top left); number of fibers = discr (list of 2)
699 fib_sec = [['section', 'Fiber', ID, '-GJ', GJ],
700 ['patch', 'rect', mat_ID, *discr, yI_tf, zI_tf, yK_tf, zK_tf], # top flange
701 ['patch', 'rect', mat_ID, *discr, yI_bf, zI_bf, yK_bf, zK_bf], # bottom flange
702 ['patch', 'rect', mat_ID, *discr, yI_w, zI_w, yK_w, zK_w]] # web
703 """
704
705 mat_to_col = {}
706 fig, ax = plt.subplots()
707 ax.grid(False)
708
709 for item in fiber_info:
710 if item[0] == 'section':
711 fib_ID = item[2]
712 if item[0] == 'layer':
713 matID = item[2]
714 mat_to_col = __assignColorToMat(matID, mat_to_col, matcolor)
715 if item[1] == 'bar':
716 As = item[3]
717 Iy = item[4]
718 Iz = item[5]
719 r = np.sqrt(As / np.pi)
720 bar = Circle((-Iz, Iy), r, ec='k', fc='k', zorder=10)
721 ax.add_patch(bar)
722 if item[1] == 'straight':
723 n_bars = item[3]
724 As = item[4]
725 Iy, Iz, Jy, Jz = item[5], item[6], item[7], item[8]
726 r = np.sqrt(As / np.pi)
727 Y = np.linspace(Iy, Jy, n_bars)
728 Z = np.linspace(Iz, Jz, n_bars)
729 for zi, yi in zip(Z, Y):
730 bar = Circle((-zi, yi), r, ec='k', fc=mat_to_col[matID], zorder=10)
731 ax.add_patch(bar)
732 if item[1] == 'circ':
733 n_bars, As = item[3], item[4]
734 yC, zC, r = item[5], item[6], item[7]
735 if len(item) > 8:
736 a0_deg = item[8]
737 else:
738 a0_deg = 0.
739 a1_deg = 360. - 360./n_bars + a0_deg
740 if len(item) > 9: a1_deg = item[9]
741
742 a0_rad, a1_rad = np.pi * a0_deg / 180., np.pi * a1_deg / 180.
743 r_bar = np.sqrt(As / np.pi)
744 thetas = np.linspace(a0_rad, a1_rad, n_bars)
745 Y = yC + r * np.cos(thetas)
746 Z = zC + r * np.sin(thetas)
747 for zi, yi in zip(Z, Y):
748 bar = Circle((-zi, yi), r_bar, ec='k', fc=mat_to_col[matID], zorder=10)
749 ax.add_patch(bar)
750
751 if (item[0] == 'patch' and (item[1] == 'quad' or item[1] == 'quadr' or
752 item[1] == 'rect')):
753 matID, nIJ, nJK = item[2], item[3], item[4]
754 mat_to_col = __assignColorToMat(matID, mat_to_col, matcolor)
755
756
757 if item[1] == 'quad' or item[1] == 'quadr':
758 Iy, Iz, Jy, Jz = item[5], item[6], item[7], item[8]
759 Ky, Kz, Ly, Lz = item[9], item[10], item[11], item[12]
760
761 if item[1] == 'rect':
762 Iy, Iz, Ky, Kz = item[5], item[6], item[7], item[8]
763 Jy, Jz, Ly, Lz = Iy, Kz, Ky, Iz
764 # check order of definition
765 if Kz-Iz < 0 or Ky-Iy < 0: print("!!!!!!! WARNING !!!!!!! The fiber is not defined bottom right, top left")
766
767 # check for convexity (vector products)
768 outIJxIK = (Jy-Iy)*(Kz-Iz) - (Ky-Iy)*(Jz-Iz)
769 outIKxIL = (Ky-Iy)*(Lz-Iz) - (Ly-Iy)*(Kz-Iz)
770 # check if I, J, L points are colinear
771 outIJxIL = (Jy-Iy)*(Lz-Iz) - (Ly-Iy)*(Jz-Iz)
772 # outJKxJL = (Ky-Jy)*(Lz-Jz) - (Ly-Jy)*(Kz-Jz)
773
774 if -outIJxIK <= 0 or -outIKxIL <= 0 or -outIJxIL <= 0:
775 print('!!!!!!! WARNING !!!!!!! Patch quad is non-convex or non-counter-clockwise defined or has at least 3 colinear points in line')
776
777 IJz, IJy = np.linspace(Iz, Jz, nIJ+1), np.linspace(Iy, Jy, nIJ+1)
778 JKz, JKy = np.linspace(Jz, Kz, nJK+1), np.linspace(Jy, Ky, nJK+1)
779 LKz, LKy = np.linspace(Lz, Kz, nIJ+1), np.linspace(Ly, Ky, nIJ+1)
780 ILz, ILy = np.linspace(Iz, Lz, nJK+1), np.linspace(Iy, Ly, nJK+1)
781
782 if fill_shapes:
783 Z = np.zeros((nIJ+1, nJK+1))
784 Y = np.zeros((nIJ+1, nJK+1))
785
786 for j in range(nIJ+1):
787 Z[j, :] = np.linspace(IJz[j], LKz[j], nJK+1)
788 Y[j, :] = np.linspace(IJy[j], LKy[j], nJK+1)
789
790 for j in range(nIJ):
791 for k in range(nJK):
792 zy = np.array([[-Z[j, k], Y[j, k]],
793 [-Z[j, k+1], Y[j, k+1]],
794 [-Z[j+1, k+1], Y[j+1, k+1]],
795 [-Z[j+1, k], Y[j+1, k]]])
796 poly = Polygon(zy, True, ec='k', fc=mat_to_col[matID])
797 ax.add_patch(poly)
798
799 else:
800 # horizontal lines
801 for az, bz, ay, by in zip(IJz, LKz, IJy, LKy):
802 plt.plot([-az, -bz], [ay, by], 'b-', zorder=1)
803
804 # vertical lines
805 for az, bz, ay, by in zip(JKz, ILz, JKy, ILy):
806 plt.plot([-az, -bz], [ay, by], 'b-', zorder=1)
807
808 if item[0] == 'patch' and item[1] == 'circ':
809 matID, nc, nr = item[2], item[3], item[4]
810 mat_to_col = __assignColorToMat(matID, mat_to_col, matcolor)
811
812 yC, zC, ri, re = item[5], item[6], item[7], item[8]
813 if len(item) > 9:
814 a0 = item[9]
815 else:
816 a0 = 0.
817 a1 = 360. + a0
818 if len(item) > 10: a1 = item[10]
819
820 dr = (re - ri) / nr
821 dth = (a1 - a0) / nc
822
823 for j in range(nr):
824 rj = ri + j * dr
825 rj1 = rj + dr
826
827 for i in range(nc):
828 thi = a0 + i * dth
829 thi1 = thi + dth
830 wedge = Wedge((-zC, yC), rj1, thi, thi1, width=dr, ec='k', #Seweryn Kokot: (yC, -zC), wrong??
831 lw=1, fc=mat_to_col[matID])
832 ax.add_patch(wedge)
833 ax.set(xlabel='x dimension [{}]'.format(length_unit), ylabel='y dimension [{}]'.format(length_unit),
834 title='Fiber section (ID = {})'.format(fib_ID))
835 ax.axis('equal')
836
837
def plot_fiber_section(fiber_info, fill_shapes=True, matcolor=['#808080', '#D3D3D3', 'r', 'b', 'g', 'y'])
Plot fiber cross-section.
Definition: Fibers.py:673