예제 #1
0
 def mnCurve(self,xRatio=[0.16,0.2,0.3,0.4,0.5,0.8,0.9,1,1E99],n_layers=100,epsU=-0.0035,reverseMoment=False):
     F=[]
     M=[]
     xRatio=[i*self.h for i in xRatio]
     f_tot,m_tot,f_s,f_con,eps_s,sigma_s=self.calcX0(eps0=self.reinf.epsilon_u,x_NA=1E99, plotting=False, n_layers=n_layers)
     F.append(int(f_tot/1E3))
     M.append(int(m_tot/1E6))
     for i in xRatio:
         #print(i)
         f_tot,m_tot,f_s,f_con,eps_s,sigma_s=self.calcX0(eps0=epsU,x_NA=i, plotting=False, n_layers=n_layers)
         F.append(int(f_tot/1E3))
         M.append(int(m_tot/1E6))
     #for i in xRatio[:-1]:
     for i in xRatio[-2::-1]:
         #print(-i)
         f_tot,m_tot,f_s,f_con,eps_s,sigma_s=self.calcXH(epsH=epsU,x_NA=i, plotting=False, n_layers=n_layers)
         F.append(int(f_tot/1E3))
         M.append(int(m_tot/1E6))
     f_tot,m_tot,f_s,f_con,eps_s,sigma_s=self.calcX0(eps0=self.reinf.epsilon_u,x_NA=1E99, plotting=False, n_layers=n_layers)
     F.append(int(f_tot/1E3))
     M.append(int(m_tot/1E6))
     mnInteraction = pd.DataFrame(np.array([F,M]).T,columns=['F','M'])#.sort_values(by=['x'])
     if reverseMoment:
         mnInteraction['M']=-mnInteraction['M']
     fig,ax = utils.plotBase()
     ax.plot(mnInteraction['M'],mnInteraction['F'],'-o', linewidth=2, markersize=5)
     ax.set_title('M-N interaction diagram')
     ax.set_xlabel('Moment [kNm]')
     ax.set_ylabel('Axial load [kN]')
     plt.show()
     return mnInteraction
def plotStress(self,
               curve,
               title="",
               lbl="",
               xlim=(None, None),
               ylim=(None, None),
               plotting=True,
               legend=True):
    if plotting:
        fig, ax = utils.plotBase()
        ax.plot(curve['strain'],
                curve['stress'],
                '-',
                linewidth=2,
                markersize=5,
                label=lbl)
        if legend:
            ax.legend(loc='lower right')
        ax.set_title(title)
        ax.set_xlabel('Strain [ε]')
        ax.set_ylabel('Stress [MPa]')
        ax.set_xlim(xlim)
        ax.set_ylim(ylim)
        plt.show()
    return curve['strain'], curve['stress']
예제 #3
0
def plotStress(curve,title="",xlim=(None,None),ylim=(None,None)):
    fig,ax = utils.plotBase()
    ax.plot(curve[0],curve[1],'-', linewidth=2, markersize=5)
    ax.set_title(title)
    ax.set_xlabel('Strain [ε]')
    ax.set_ylabel('Stress [MPa]')
    ax.set_xlim(xlim)
    ax.set_ylim(ylim)
    plt.show()
예제 #4
0
 def plot_deformed(self,
                   disp_magn=10,
                   title='deformed shape',
                   markersize=10,
                   grid=True,
                   figsize=(6, 4)):
     displacements = self.nodes.copy()
     for i in range(len(self.nodes)):
         displacements.at[
             i, 'x'] = self.nodes['x'][i] + self.disp[i * 2] * disp_magn
         displacements.at[
             i, 'y'] = self.nodes['y'][i] + self.disp[i * 2 + 1] * disp_magn
     fig, ax = utils.plotBase(grid=grid, figsize=figsize)
     for i in range(len(self.elements)):
         x1, x2, y1, y2 = elmCoord(self.elements, self.nodes, i)
         ax.plot([x1, x2], [y1, y2],
                 '-',
                 linewidth=2,
                 markersize=5,
                 color='b')
     for i in range(len(self.elements)):
         x1, x2, y1, y2 = elmCoord(self.elements, displacements, i)
         ax.plot([x1, x2], [y1, y2],
                 '-',
                 linewidth=2,
                 markersize=5,
                 color='r')
     for i in range(len(self.restraints)):
         x = utils.df_value(self.nodes, self.restraints['node'][i], 'name',
                            'x')
         y = utils.df_value(self.nodes, self.restraints['node'][i], 'name',
                            'y')
         if self.restraints['x'][i] == 1 and self.restraints['y'][i] == 1:
             ax.plot(x,
                     y,
                     's',
                     linewidth=2,
                     markersize=markersize,
                     color='k')
         if self.restraints['x'][i] == 1 and self.restraints['y'][i] == 0:
             ax.plot(x,
                     y,
                     '>',
                     linewidth=2,
                     markersize=markersize,
                     color='k')
         if self.restraints['x'][i] == 0 and self.restraints['y'][i] == 1:
             ax.plot(x,
                     y,
                     '^',
                     linewidth=2,
                     markersize=markersize,
                     color='k')
     ax.set_title(title)
     plt.axis('equal')
     plt.show()
예제 #5
0
 def epsilonBuildEps(self,epsH,eps0,plotting=False):
     if plotting:
             fig,ax = utils.plotBase()
             ax.plot([0,self.h],[eps0,epsH],'-', linewidth=2, markersize=5)
             ax.plot([0,self.h],[0,0],'-', linewidth=2, markersize=5,color='black')
             ax.set_title('Strain distribution within section')
             ax.set_xlabel('Distance [mm]')
             ax.set_ylabel('Strain []')
             ax.set_xlim(0,self.h)
             ax.set_ylim(None,None)
             plt.show()
     return np.array([[0,self.h],[eps0,epsH]])
예제 #6
0
 def plotStress(self,
                curve,
                title="",
                lbl="",
                xlim=(None, None),
                ylim=(None, None),
                plotting=True):
     if plotting:
         fig, ax = utils.plotBase()
         ax.plot(curve['strain'],
                 curve['stress'],
                 '-',
                 linewidth=2,
                 markersize=5,
                 label=lbl)
         ax.legend(loc='lower right')
         ax.set_title(title)
         ax.set_xlabel('Strain')
         ax.set_ylabel('Stress [MPa]')
         ax.set_xlim(xlim)
         ax.set_ylim(ylim)
         plt.show()
     return curve['strain'], curve['stress']
     if plotting:
         fig, ax = utils.plotBase()
         ax.plot([0, h], [eps0, epsH], '-', linewidth=2, markersize=5)
         ax.plot([0, h], [0, 0],
                 '-',
                 linewidth=2,
                 markersize=5,
                 color='black')
         ax.set_title('Strain distribution within section')
         ax.set_xlabel('Distance [mm]')
         ax.set_ylabel('Strain []')
         ax.set_xlim(0, h)
         ax.set_ylim(None, None)
         plt.show()
     return np.array([[0, h], [eps0, epsH]])
예제 #7
0
 def mnCurve(self,xRatio=[0.16,0.2,0.3,0.4,0.5,0.8,0.9,1,1E99],n_layers=100,epsU=-0.0035,reverseMoment=False,points=None,r2kPath=None,legend=False,labels=None,title='M-N interaction diagram'):
     F=[]
     M=[]
     xRatio=[i*self.h for i in xRatio]
     f_tot,m_tot=self.calcX0(eps0=self.reinf.epsilon_u,x_NA=1E99, plotting=False, n_layers=n_layers)
     F.append(int(f_tot/1E3))
     M.append(int(m_tot/1E6))
     for i in xRatio:
         #print(i)
         f_tot,m_tot=self.calcX0(eps0=epsU,x_NA=i, plotting=False, n_layers=n_layers)
         F.append(int(f_tot/1E3))
         M.append(int(m_tot/1E6))
     # pure compression
     # f_tot,m_tot,f_s,f_con,eps_s,sigma_s=self.calc(eps0=epsc1,epsH=epsc1, plotting=False,n_layers=n_layers)
     # F.append(int(f_tot/1E3))
     # M.append(int(m_tot/1E6))
     for i in xRatio[-2::-1]:
         #print(-i)
         f_tot,m_tot=self.calcXH(epsH=epsU,x_NA=i, plotting=False, n_layers=n_layers)
         F.append(int(f_tot/1E3))
         M.append(int(m_tot/1E6))
     f_tot,m_tot=self.calcX0(eps0=self.reinf.epsilon_u,x_NA=1E99, plotting=False, n_layers=n_layers)
     F.append(int(f_tot/1E3))
     M.append(int(m_tot/1E6))
     mnInteraction = pd.DataFrame(np.array([F,M]).T,columns=['F','M'])#.sort_values(by=['x'])
     if reverseMoment:
         mnInteraction['M']=-mnInteraction['M']
     fig,ax = utils.plotBase()
     if labels!=None: ax.plot(mnInteraction['M'],mnInteraction['F'],'-o', linewidth=2, markersize=5,label=labels[0])
     else: ax.plot(mnInteraction['M'],mnInteraction['F'],'-o', linewidth=2, markersize=5,label='MN curve')
     if r2kPath != None:
         response2k = pd.read_csv(r2kPath)
         response2k=np.array(response2k).T
         if labels!=None: ax.plot(response2k[0],response2k[1],'-', linewidth=2, markersize=5,label=labels[1])
         else: ax.plot(response2k[0],response2k[1],'-', linewidth=2, markersize=5,label='Response2k')
     if points != None:
         for i in range(len(points)):
             M_Ed,F_Ed=points[i][0],points[i][1]
             if labels!=None: ax.plot(M_Ed,F_Ed,marker='+', color=utils.colours[i+3],mew=3, markersize=10,label=labels[i+2])
             else: ax.plot(M_Ed,F_Ed,'r+', mew=3, markersize=10,label='Design load')
     if legend:
         ax.legend()
     ax.set_title(title)
     ax.set_xlabel('Moment [kNm]')
     ax.set_ylabel('Axial load [kN]')
     plt.show()
     return mnInteraction
예제 #8
0
 def plot_var(self,
              var,
              disp_magn=10,
              title='variable',
              markersize=10,
              grid=True,
              scale=1,
              figsize=(6, 4)):
     fig, ax = utils.plotBase(grid=grid, figsize=figsize)
     var = np.array(getattr(self, var)) * scale
     norm = plt.Normalize(np.min(var), np.max(var))
     cmap = plt.get_cmap('seismic')
     c = cmap(norm(var))
     for i in range(len(self.elements)):
         x1, x2, y1, y2 = elmCoord(self.elements, self.nodes, i)
         ax.plot([x1, x2], [y1, y2], '-', linewidth=2, markersize=5, c=c[i])
     for i in range(len(self.restraints)):
         x = utils.df_value(self.nodes, self.restraints['node'][i], 'name',
                            'x')
         y = utils.df_value(self.nodes, self.restraints['node'][i], 'name',
                            'y')
         if self.restraints['x'][i] == 1 and self.restraints['y'][i] == 1:
             ax.plot(x,
                     y,
                     's',
                     linewidth=2,
                     markersize=markersize,
                     color='k')
         if self.restraints['x'][i] == 1 and self.restraints['y'][i] == 0:
             ax.plot(x,
                     y,
                     '>',
                     linewidth=2,
                     markersize=markersize,
                     color='k')
         if self.restraints['x'][i] == 0 and self.restraints['y'][i] == 1:
             ax.plot(x,
                     y,
                     '^',
                     linewidth=2,
                     markersize=markersize,
                     color='k')
     fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap), ax=ax, ticks=var)
     plt.axis('equal')
     ax.set_title(title)
     plt.show()
    def plot(self,
             strain,
             retn='stress',
             title='con1',
             lineType='-',
             legend=True,
             lbl='stmdl2',
             xlim=(None, None),
             ylim=(None, None),
             ylabel='Stress [MPa]',
             xlabel='Strain',
             pseto='',
             crkso=''):
        # strain=np.arange(-np.absolute(self.strnc1),np.absolute(self.strnt1),0.0001)
        fig, ax = utils.plotBase()
        stress, etan = [], []
        for j, i in enumerate(strain):
            if crkso != '': self.crks = crkso
            if pseto != '': self.pset = pseto
            self.stress(i)
            stress.append(self.stres)
            etan.append(self.etan)


#             if j>2:
#                 X=strain[-3:-1]
#                 Y=stress[-3:-1]
#                 print('step: {0}, etan: {1}, slope_intercept: {2}'.format(j,self.etan,self.slope_intercept(X,Y)[0]))
        stress = np.array(stress)
        etan = np.array(etan)
        strain = strain.reshape(len(strain), 1)
        stress = stress.reshape(len(stress), 1)
        etan = etan.reshape(len(etan), 1)
        self.df = pd.DataFrame(np.hstack((stress, strain, etan)),
                               columns=['stress', 'strain', 'etan'])
        if 'etan' in retn:
            if retn == 'etan' or retn == 'etan1':
                ax.plot(self.df['strain'],
                        self.df['etan'],
                        lineType,
                        linewidth=2,
                        markersize=5,
                        label=lbl)
            if retn == 'etan' or retn == 'etan2':
                slope = self.slope_intercept(strain, stress)
                ax.plot(strain[:-1],
                        slope,
                        lineType,
                        linewidth=2,
                        markersize=5,
                        label='slope')
        else:
            ax.plot(self.df['strain'],
                    self.df['stress'],
                    lineType,
                    linewidth=2,
                    markersize=5,
                    label=lbl)
        if legend: ax.legend()
        ax.set_title(title)
        ax.set_xlabel(xlabel)
        ax.set_ylabel(ylabel)
        ax.set_xlim(xlim)
        ax.set_ylim(ylim)
        plt.show()
예제 #10
0
    def calc(self, eps0, epsH, plotting=False, n_layers=100):
        epsilon = self.epsilonBuildEps(eps0=eps0, epsH=epsH, plotting=plotting)
        #strain_conLim=.0035
        h_i = self.h / n_layers

        # Steel
        f_s = []
        m_s = 0
        sigma_s = []
        eps_s = []
        x_s = np.array(self.section.reinf_sect).T[2]
        for i in self.section.reinf_sect:
            eps = self.epsilonFunc(i[2], epsilon)
            eps_s.append(eps)
            sigma = findPointZero(self.reinf.np, eps)
            sigma_s.append(sigma)
            A = np.pi * i[1]**2 / 4 * i[0]
            f_s_i = sigma * A
            f_s.append(f_s_i)
            m_s += f_s_i * i[2]
        # Steel stress distribution
        sigma_sEnv = []
        x_sEnv = []
        for i in range(n_layers):
            x_i = i * h_i
            x_sEnv.append(x_i)
            b_i = self.section.width(x_i)
            e = self.epsilonFunc(x_i, epsilon)
            s = findPointZero(self.reinf.np, e)
            sigma_sEnv.append(s)
        if plotting:
            fig, ax = utils.plotBase()
            ax.bar(x_s, sigma_s, width=5)
            ax.plot(x_sEnv, sigma_sEnv, '--', linewidth=2, markersize=5)
            ax.plot([0, self.h], [0, 0],
                    '-',
                    linewidth=2,
                    markersize=5,
                    color='black')
            ax.set_title('Steel stress distribution within section')
            ax.set_xlabel('Distance [mm]')
            ax.set_ylabel('Stress [MPa]')
            ax.set_xlim(0, self.h)
            ax.set_ylim(None, None)
            plt.show()

        # Concrete
        sigma_con = []
        x_con = []
        f_con = []
        m_con = 0
        for i in range(n_layers):
            x_i = i * h_i
            x_con.append(x_i)
            b_i = self.section.width(x_i)
            e = self.epsilonFunc(x_i, epsilon)
            s = findPointZero(self.concr.np, e)
            sigma_con.append(s)
            f_con_i = s * b_i * h_i
            f_con.append(f_con_i)
            m_con += f_con_i * x_i
            #print('e: {0}, s: {1}'.format(e,s))
        if plotting:
            fig, ax = utils.plotBase()
            ax.plot(x_con, sigma_con, '-', linewidth=2, markersize=5)
            ax.plot([0, self.h], [0, 0],
                    '-',
                    linewidth=2,
                    markersize=5,
                    color='black')
            ax.set_title('Concrete stress distribution within section')
            ax.set_xlabel('Distance [mm]')
            ax.set_ylabel('Stress [MPa]')
            ax.set_xlim(0, self.h)
            ax.set_ylim(None, None)
            plt.show()
        f_tot = sum(f_con) + sum(f_s)
        m_tot = m_con + m_s - 0.5 * f_tot * self.h
        if plotting:
            print('Total axial force: {} kN'.format(int(f_tot / 1E3)))
            print('Total moment: {} kNm'.format(int(m_tot / 1E6)))
        return f_tot, m_tot  #,f_s,f_con,eps_s,sigma_s