Ejemplo n.º 1
0
def k_COV_plots(k_arr, COV_arr):
    sig_max_arr = np.zeros((len(k_arr), len(COV_arr)))
    wmax_arr = np.zeros((len(k_arr), len(COV_arr)))
    mu_r, mu_tau = 0.01, 0.1
    for i, k in enumerate(k_arr):
        for j, cov in enumerate(COV_arr):
            Vf = Vf_k(k)
            loc_r = mu_r * (1 - cov * np.sqrt(3.0))
            scale_r = cov * 2 * np.sqrt(3.0) * mu_r
            loc_tau = mu_tau * (1 - cov * np.sqrt(3.0))
            scale_tau = cov * 2 * np.sqrt(3.0) * mu_tau
            reinf = ContinuousFibers(r=RV('uniform', loc=loc_r, scale=scale_r),
                                     tau=RV('uniform',
                                            loc=loc_tau,
                                            scale=scale_tau),
                                     xi=WeibullFibers(shape=7.0, sV0=0.003),
                                     V_f=Vf,
                                     E_f=200e3,
                                     n_int=100)
            ccb_view.model.reinforcement_lst = [reinf]
            sig_max, wmax = ccb_view.sigma_c_max
            sig_max_arr[i, j] = sig_max / Vf
            wmax_arr[i, j] = wmax
    ctrl_vars = orthogonalize([np.arange(len(k_arr)), np.arange(len(COV_arr))])
    print sig_max_arr
    print wmax_arr
    mlab.surf(ctrl_vars[0], ctrl_vars[1], sig_max_arr / np.max(sig_max_arr))
    mlab.surf(ctrl_vars[0], ctrl_vars[1], wmax_arr / np.max(wmax_arr))
    mlab.show()
Ejemplo n.º 2
0
    def plot():
        
        w_arr = np.linspace(0.0, 0.1, 20)
        ll = 2.0
        lr = 5.0
        x = np.linspace(-ll, lr, 51)
        #resm, resf = ccb_post.w_x_results(w_arr, x)
        #eps_vars = orthogonalize([w_arr * 100., x])
        #m.surf(eps_vars[0], eps_vars[1], resm * 500.)
        #m.surf(eps_vars[0], eps_vars[1], resf * 500.)
        #m.show()
        sigma = ir.load_sigma_c_arr

        eps_vars = orthogonalize([np.linspace(0.0, 0.0254229525299, len(sigma)) * 100., x])
        # mu_q_nisp = nisp(P, x, Ll, Lr)[0]
        mu_epsm = ir.interpolator_epsm(sigma, x, 100., 100.)
        mu_epsf = ir.interpolator_mu_epsf(sigma, x, 100., 100.)
        sig_c = ir.interpolator_mu_sigma_c(sigma, x, 100., 100.)
        #mu_q_isp2 = ir(sigma, x, Ll, Lr)

#        plt.plot(np.arange(len(sigma)), sigma/0.0103)
#        plt.plot(np.arange(len(sigma)), np.max(mu_q_isp,axis = 0))
#        plt.show()
        # n_mu_q_arr = mu_q_nisp / np.max(np.fabs(mu_q_nisp))
        m.surf(eps_vars[0], eps_vars[1], mu_epsm * 500.)
        m.surf(eps_vars[0], eps_vars[1], mu_epsf * 500.)
        m.surf(eps_vars[0], eps_vars[1], sig_c /(25e3*0.85 + 200e3*0.15)*500)
        m.show()
Ejemplo n.º 3
0
def k_COV_plots(k_arr, COV_arr):
    sig_max_arr = np.zeros((len(k_arr), len(COV_arr)))
    wmax_arr = np.zeros((len(k_arr), len(COV_arr)))
    mu_r, mu_tau = 0.01, 0.1
    for i, k in enumerate(k_arr):
        for j, cov in enumerate(COV_arr):
            Vf = Vf_k(k)
            loc_r = mu_r * (1 - cov * np.sqrt(3.0))
            scale_r = cov * 2 * np.sqrt(3.0) * mu_r
            loc_tau = mu_tau * (1 - cov * np.sqrt(3.0))
            scale_tau = cov * 2 * np.sqrt(3.0) * mu_tau
            reinf = ContinuousFibers(r=RV('uniform', loc=loc_r, scale=scale_r),
                                  tau=RV('uniform', loc=loc_tau, scale=scale_tau),
                                  xi=WeibullFibers(shape=7.0, sV0=0.003),
                                  V_f=Vf, E_f=200e3, n_int=100)
            ccb_view.model.reinforcement_lst = [reinf]
            sig_max, wmax = ccb_view.sigma_c_max
            sig_max_arr[i, j] = sig_max/Vf
            wmax_arr[i, j] = wmax
    ctrl_vars = orthogonalize([np.arange(len(k_arr)), np.arange(len(COV_arr))])
    print sig_max_arr
    print wmax_arr
    mlab.surf(ctrl_vars[0], ctrl_vars[1], sig_max_arr / np.max(sig_max_arr))
    mlab.surf(ctrl_vars[0], ctrl_vars[1], wmax_arr / np.max(wmax_arr))
    mlab.show()
Ejemplo n.º 4
0
def det_tau_r(E_f, V_f, m_list, mu_xi, dp_tau, dp_r, tau_range, r_range, sV0):
    w_arr = np.linspace(0, 20, 300)
    tau_arr = np.linspace(tau_range[0], tau_range[1], dp_tau)
    r_arr = np.linspace(r_range[0], r_range[1], dp_tau)
    e_arr = orthogonalize([tau_arr, r_arr])
    x_axis = e_arr[0]
    y_axis = e_arr[1]
    for mi in m_list:
            res_array = np.zeros((dp_tau, dp_r))
            for i_tau, taui in enumerate(tau_arr):
                    for i_r, ri in enumerate(r_arr):
                        s = get_scale(mu_xi, mi, taui, ri)
                        print s
                        #sV0 = float(s * (pi * mu_r ** 2) ** (1. / mi))
                        T = 2. * taui / ri
                        s0 = ((T * (mi + 1) * sV0 ** mi) / (2. * E_f * pi * ri ** 2)) ** (1. / (mi + 1))
                        print s0
                        k = np.sqrt(T / E_f)
                        ef0 = k * np.sqrt(w_arr)
                        G = 1 - np.exp(-(ef0 / s0) ** (mi + 1))
                        mu_int = ef0 * E_f * V_f * (1 - G)
                        I = s0 * gamma(1 + 1. / (mi + 1)) * gammainc(1 + 1. / (mi + 1), (ef0 / s0) ** (mi + 1))
                        mu_broken = E_f * V_f * I / (mi + 1)
                        result = mu_int + mu_broken
                        sigma_c = np.max(result)
                        if sigma_c == result[-1]:
                            print "w_arr too short"
                            pass
                        res_array[i_tau, i_r] = sigma_c
                    
            mlab.surf(x_axis, y_axis, res_array / 100.)
    mlab.xlabel("det tau")
    mlab.ylabel("det r")
    mlab.zlabel("sigma")
    mlab.show()
Ejemplo n.º 5
0
def rand_r_det_tau( E_f, V_f, tau_range, CoV_r_range, mu_r , dp_tau, dp_r, sV0 ):
    m = m_list[0]
    s0 = ( ( mu_tau * ( m + 1 ) * sV0 ** m ) / ( E_f * pi * mu_r ** 3 ) ) ** ( 1. / ( m + 1 ) )
    mu_xi = s0 * gamma( 1. + 1. / ( 1. + m ) )
    #loop with rand tau and rand r
    for mi in m_list:
        ##############
        Pf = RV( 'uniform', loc = 0.0, scale = 1.0 )
        w_arr = np.linspace( 0, 2.0, 30 )
        cb = CBResidual( include_pullout = True )
        tau_arr = np.linspace( tau_range[0], tau_range[1], dp_tau )
        CoV_r_arr = np.linspace( 0.0001, 0.5, dp_r )
        loc_r_arr = mu_r - CoV_r_arr * mu_r * 3 ** 0.5
        scale_r_arr = 2 * mu_r - 2 * loc_r_arr
        e_arr = orthogonalize( [tau_arr, CoV_r_arr] )
        x_axis = e_arr[0]
        y_axis = e_arr[1]
        stats_r = []
        for s in range( dp_r ):
            stats_r.append( RV( 'uniform', loc = loc_r_arr[s], scale = scale_r_arr[s] ) )
    
        #gen Tuple of [loc,scale]
    
        res_array = np.zeros( ( dp_tau, dp_r ) )
        for i_tau, taui in enumerate( tau_arr ):
    
                for i_r, ri in enumerate( stats_r ):
                    s0i = mu_xi / gamma( 1. + 1. / ( 1. + mi ) )
                    sV0i = ( ( s0i ** ( mi + 1 ) * E_f * pi * mu_r ** 3. ) / ( taui * ( mi + 1. ) ) ) ** ( 1. / mi )
                    total = SPIRRID( q = cb,
                            sampling_type = 'MCS',
                            evars = dict( w = w_arr ),
                            tvars = dict( tau = taui, E_f = E_f, V_f = V_f, r = ri,
                                       m = mi, sV0 = sV0i, Pf = Pf ),
                            n_int = 60 )
                    if isinstance( ri, RV ):
                        r_arr = np.linspace( ri.ppf( 0.001 ), ri.ppf( 0.999 ), 200 )
                        Er = np.trapz( r_arr ** 2 * ri.pdf( r_arr ), r_arr )
                    else:
                        Er = ri ** 2
                    result = total.mu_q_arr / Er
                    sigma_c = np.max( result )
                    if sigma_c == result[-1]:
                        print "w_arr too short"
                        pass
                    res_array[i_tau, i_r] = sigma_c
    
        #mayaviplot
        print np.max( res_array )
        mlab.surf( x_axis, y_axis, res_array )
        #
        mlab.view( 0., 0. )
        mlab.xlabel( "det tau" )
        mlab.ylabel( "rand r" )
        mlab.zlabel( "sigma" )
    mlab.show()
Ejemplo n.º 6
0
def rand_tau_det_r( E_f, V_f, CoV_tau_range, r_range, mu_tau , dp_tau, dp_r, sV0 ):
    m = m_list[0]
    s0 = ( ( mu_tau * ( m + 1 ) * sV0 ** m ) / ( E_f * pi * mu_r ** 3 ) ) ** ( 1. / ( m + 1 ) )
    mu_xi = s0 * gamma( 1. + 1. / ( 1. + m ) )
    for mi in m_list:
        #######################################
        Pf = RV( 'uniform', loc = 0.0, scale = 1.0 )
        w_arr = np.linspace( 0, 5, 300 )
        cb = CBResidual( include_pullout = True )
        # CoV generation
        CoV_tau_arr = np.linspace( CoV_tau_range[0], CoV_tau_range[1], dp_tau )
        loc_tau_arr = mu_tau - CoV_tau_arr * mu_tau * 3 ** 0.5
        scale_tau_arr = 2 * mu_tau - 2 * loc_tau_arr
        r_arr = np.linspace( r_range[0], r_range[1], dp_r )
        e_arr = orthogonalize( [CoV_tau_arr, r_arr] )
        x_axis = e_arr[0]
        y_axis = e_arr[1]
        #TAU gen Tuple of [loc,scale]
        stats_tau = []
        for s in range( dp_tau ):
            stats_tau.append( RV( 'uniform', loc = loc_tau_arr[s], scale = scale_tau_arr[s] ) )
    
        #r gen Tuple of [loc,scale]
        res_array = np.zeros( ( dp_tau, dp_r ) )
        for i_tau, taui in enumerate( stats_tau ): 
                for i_r, ri in enumerate( r_arr ):
                    print i_tau, i_r
                    s0i = mu_xi / gamma( 1. + 1. / ( 1. + mi ) )
                    sV0i = ( ( s0i ** ( mi + 1 ) * E_f * pi * ri ** 3. ) / ( mu_tau * ( mi + 1. ) ) ) ** ( 1. / mi )
                    total = SPIRRID( q = cb,
                            sampling_type = 'MCS',
                            evars = dict( w = w_arr ),
                            tvars = dict( tau = taui, E_f = E_f, V_f = V_f, r = ri,
                                       m = mi, sV0 = sV0i, Pf = Pf ),
                            n_int = 60 )
                    if isinstance( ri, RV ):
                        r_arr = np.linspace( ri.ppf( 0.001 ), ri.ppf( 0.999 ), 200 )
                        Er = np.trapz( r_arr ** 2 * ri.pdf( r_arr ), r_arr )
                    else:
                        Er = ri ** 2
                    #total(evars=dict(w=[3.]))
                    x = [2.]
                    x = np.array( x )
                    
                    result = total.mu_q_arr / Er
                    sigma_c = np.max( result )
                    if sigma_c == result[-1]:
                        print "w_arr too short"
                    res_array[i_tau, i_r] = sigma_c
        #mayaviplot
        mlab.surf( x_axis, y_axis * 50, res_array, warpscale = 0.1 )
        mlab.view( 0., 0. )
        mlab.xlabel( "rand tau" )
        mlab.ylabel( "det r" )
        mlab.zlabel( "sigma" )
    mlab.show()
Ejemplo n.º 7
0
 def m_effect():
     m_xi_arr = np.linspace(1., 20., 15)
     m_tau_arr = np.linspace(0.3, 5.0, 10)
     try:
         res_file = open('res_m.pkl', 'rb')
         res_arr = pickle.load(res_file)
         res_file.close()
         #            for res_part in res_arr:
         #                plt.plot(m_xi_arr, res_part)
         #            plt.show()
         eps_vars = orthogonalize([np.arange(15), np.arange(10)])
         resCB = np.ones_like(res_arr)
         resMC = res_arr
         mlab.surf(eps_vars[0], eps_vars[1], resCB * 10)
         mlab.surf(eps_vars[0], eps_vars[1], resMC * 10)
         mlab.show()
     except:
         res_arr = []
         for m_tau in m_tau_arr:
             strength_CB = []
             strength_MC = []
             for m_xi in m_xi_arr:
                 wmCB, smCB = maxsigma(
                     1000.,
                     RV('weibull_min', shape=m_tau, scale=0.1, loc=0.0),
                     m_xi)
                 wmMC, smMC = maxsigma(
                     1., RV('weibull_min', shape=m_tau, scale=0.1, loc=0.0),
                     m_xi)
                 #            w_CB = np.linspace(0.0,100./m**2,200)
                 #            w_MC = np.linspace(0.0,1.5/m**2,200)
                 #            plt.plot(wmCB, smCB, 'ro')
                 #            plt.plot(wmMC, smMC, 'bo')
                 #            sigma_c_CB = sigmac(w_CB, 1000., RV('weibull_min', shape=3.0, scale=0.1, loc=0.0), m)
                 #            sigma_c_MC = sigmac(w_MC, 1.0, RV('weibull_min', shape=3.0, scale=0.1, loc=0.0), m)
                 #            plt.plot(w_CB, sigma_c_CB, label='CB')
                 #            plt.plot(w_MC, sigma_c_MC, label='MC')
                 #            plt.show()
                 strength_CB.append(smCB)
                 strength_MC.append(smMC)
             CB_arr = np.ones_like(np.array([strength_CB]))
             MC_arr = np.array([strength_MC]) / np.array([strength_CB])
             res_arr.append(MC_arr.flatten())
             plt.plot(m_xi_arr, CB_arr.flatten(), lw=2., color='black')
             plt.plot(m_xi_arr, MC_arr.flatten(), label=str(m_tau) + ' MC')
         res_arr = np.array(res_arr)
         file_res = open('res_m.pkl', 'wb')
         pickle.dump(res_arr, file_res, -1)
         file_res.close()
         plt.legend(loc='best')
         plt.ylim(0)
         plt.show()
Ejemplo n.º 8
0
def random_domain(w):
    Ef = 70e3
    Fxi = weibull_min(5., scale = 0.02)
    r = np.linspace(0.001, 0.005, 100)
    tau = np.linspace(0., 1., 100)
    e_arr = orthogonalize([np.arange(len(r)), np.arange(len(tau))])

    tau = tau.reshape(1, len(tau))
    r = r.reshape(len(r), 1)
    eps0 = np.sqrt(w * 2 * tau / r / Ef)
    F = Fxi.cdf(eps0)
    a = r * Ef / 2. / tau
    m.surf(e_arr[0], e_arr[1], 50 * F / np.max(F))
    m.surf(e_arr[0], e_arr[1], 50 * eps0 / np.max(eps0))
    m.surf(e_arr[0], e_arr[1], np.nan_to_num(a) / 100.)
    m.show()
Ejemplo n.º 9
0
    def m_effect():
        m_xi_arr = np.linspace(1., 20., 15)
        m_tau_arr = np.linspace(0.3, 5.0, 10)
        try:
            res_file = open('res_m.pkl', 'rb')
            res_arr = pickle.load(res_file)
            res_file.close()
#            for res_part in res_arr:
#                plt.plot(m_xi_arr, res_part)
#            plt.show()
            eps_vars = orthogonalize([np.arange(15), np.arange(10)])
            resCB = np.ones_like(res_arr)
            resMC = res_arr
            mlab.surf(eps_vars[0], eps_vars[1], resCB * 10)
            mlab.surf(eps_vars[0], eps_vars[1], resMC * 10)
            mlab.show()
        except:
            res_arr = []
            for m_tau in m_tau_arr:
                strength_CB = []
                strength_MC = []
                for m_xi in m_xi_arr:
                    wmCB, smCB = maxsigma(1000., RV('weibull_min', shape=m_tau, scale=0.1, loc=0.0), m_xi)
                    wmMC, smMC = maxsigma(1., RV('weibull_min', shape=m_tau, scale=0.1, loc=0.0), m_xi)
        #            w_CB = np.linspace(0.0,100./m**2,200)
        #            w_MC = np.linspace(0.0,1.5/m**2,200)
        #            plt.plot(wmCB, smCB, 'ro')
        #            plt.plot(wmMC, smMC, 'bo')
        #            sigma_c_CB = sigmac(w_CB, 1000., RV('weibull_min', shape=3.0, scale=0.1, loc=0.0), m)
        #            sigma_c_MC = sigmac(w_MC, 1.0, RV('weibull_min', shape=3.0, scale=0.1, loc=0.0), m)
        #            plt.plot(w_CB, sigma_c_CB, label='CB')
        #            plt.plot(w_MC, sigma_c_MC, label='MC')
        #            plt.show()
                    strength_CB.append(smCB)
                    strength_MC.append(smMC)
                CB_arr = np.ones_like(np.array([strength_CB]))
                MC_arr = np.array([strength_MC]) / np.array([strength_CB])
                res_arr.append(MC_arr.flatten())
                plt.plot(m_xi_arr, CB_arr.flatten(), lw=2., color='black')
                plt.plot(m_xi_arr, MC_arr.flatten(), label=str(m_tau) + ' MC')
            res_arr = np.array(res_arr)
            file_res = open('res_m.pkl', 'wb')
            pickle.dump(res_arr, file_res, -1)
            file_res.close()
            plt.legend(loc='best')
            plt.ylim(0)
            plt.show()
Ejemplo n.º 10
0
    def plot():
        sigma = isp.adaption.load_sigma_c
        Ll = 50.
        Lr = 50.
        x = np.linspace(-Ll, Lr, 201)

        eps_vars = orthogonalize([np.arange(len(sigma)), np.arange(len(x))])
        # mu_q_nisp = nisp(P, x, Ll, Lr)[0]
        mu_q_isp = isp(sigma, x, 1., 14.)
        mu_q_isp2 = isp(sigma, x, Ll, Lr)

        #        plt.plot(np.arange(len(sigma)), sigma/0.0103)
        #        plt.plot(np.arange(len(sigma)), np.max(mu_q_isp,axis = 0))
        #        plt.show()
        # n_mu_q_arr = mu_q_nisp / np.max(np.fabs(mu_q_nisp))
        mlab.surf(eps_vars[0], eps_vars[1], mu_q_isp / 10.)
        mlab.surf(eps_vars[0], eps_vars[1], mu_q_isp2 / 10.)
        mlab.show()
    def plot():
        sigma = isp.adaption.load_sigma_c
        Ll = 50.
        Lr = 50.
        x = np.linspace(-Ll, Lr, 201)

        eps_vars = orthogonalize([np.arange(len(sigma)), np.arange(len(x))])
        # mu_q_nisp = nisp(P, x, Ll, Lr)[0]
        mu_q_isp = isp(sigma, x, 1., 14.)
        mu_q_isp2 = isp(sigma, x, Ll, Lr)

#        plt.plot(np.arange(len(sigma)), sigma/0.0103)
#        plt.plot(np.arange(len(sigma)), np.max(mu_q_isp,axis = 0))
#        plt.show()
        # n_mu_q_arr = mu_q_nisp / np.max(np.fabs(mu_q_nisp))
        mlab.surf(eps_vars[0], eps_vars[1], mu_q_isp / 10.)
        mlab.surf(eps_vars[0], eps_vars[1], mu_q_isp2 / 10.)
        mlab.show()
Ejemplo n.º 12
0
def det_tau_r( E_f, V_f, m_list, dp_tau, dp_r, tau_range, r_range, sV0 ):
    m = m_list[0]
    s0 = ( ( mu_tau * ( m + 1 ) * sV0 ** m ) / ( E_f * pi * mu_r ** 3 ) ) ** ( 1. / ( m + 1 ) )
    mu_xi = s0 * gamma( 1. + 1. / ( 1. + m ) )
    ################
    w_arr = np.linspace( 0, 100, 300 )
    tau_arr = np.linspace( tau_range[0], tau_range[1], dp_tau )
    r_arr = np.linspace( r_range[0], r_range[1], dp_tau )
    e_arr = orthogonalize( [tau_arr, r_arr] )
    x_axis = e_arr[0]
    y_axis = e_arr[1]
    for i_m, mi in enumerate( m_list ):
            res_array = np.zeros( ( dp_tau, dp_r ) )
            for i_tau, taui in enumerate( tau_arr ):
                    for i_r, ri in enumerate( r_arr ):
                        s0i = mu_xi / gamma( 1. + 1. / ( 1. + mi ) )
                        sV0i = ( ( s0i ** ( mi + 1 ) * E_f * pi * ri ** 3. ) / ( taui * ( mi + 1. ) ) ) ** ( 1. / mi )
                        T = 2. * taui / ri
                        s0 = ( ( T * ( mi + 1 ) * sV0i ** mi ) / ( 2. * E_f * pi * ri ** 2 ) ) ** ( 1. / ( mi + 1 ) )
                        k = np.sqrt( T / E_f )
                        ef0 = k * np.sqrt( w_arr )
                        G = 1 - np.exp( -( ef0 / s0 ) ** ( mi + 1 ) )
                        mu_int = ef0 * E_f * V_f * ( 1 - G )
                        I = s0 * gamma( 1 + 1. / ( mi + 1 ) ) * gammainc( 1 + 1. / ( mi + 1 ), ( ef0 / s0 ) ** ( mi + 1 ) )
                        mu_broken = E_f * V_f * I / ( mi + 1 )
                        result = mu_int + mu_broken
                        sigma_c = np.max( result )
                        if sigma_c == result[-1]:
                            print "w_arr too short"
                            pass
                        res_array[i_tau, i_r] = sigma_c
            mlab.surf( x_axis, y_axis, res_array / 100. )
    mlab.xlabel( "det tau" )
    mlab.ylabel( "det r" )
    mlab.zlabel( "sigma" )
    mlab.show()
    x = np.linspace(0, 20, 20000)
    #print x[35]
    x -= x[70]
    
    #print x
    #crack_x = x -
    #x = np.linspace( -10 , 10 , 100 )
#    eps = sb.get_eps_x_reinf( x )
#
#    plt.plot( x, eps, lw = 2, color = 'black' )
#    plt.show()

    import enthought.mayavi.mlab as m
    from stats.spirrid import orthogonalize

    resolution = 200
    profiles_list = []
    forces_arr = np.linspace(0, 6200, resolution)
    for i, p in enumerate(forces_arr):
        sb.P = p
        profiles_list.append(sb.get_eps_x_reinf(x))

    profiles_arr = np.array(profiles_list)

    param_arr = orthogonalize([x, forces_arr])
    norm_param_arr = [ e / np.max(np.fabs(e)) for e in param_arr ]

    norm_profiles_arr = profiles_arr / np.max(np.fabs(profiles_arr))
    m.surf(norm_param_arr[0], norm_param_arr[1], norm_profiles_arr)
    m.show()
Ejemplo n.º 14
0
from stats.spirrid import make_ogrid as orthogonalize
import numpy as np
from etsproxy.mayavi import mlab
import mayavi

#x,y data generation
CoV_tau_range = [1e-7, 0.5]
CoV_r_range = [1e-7, 0.5]
dp_tau = 20
dp_r = 20
CoV_tau_arr = np.linspace(CoV_tau_range[0], CoV_tau_range[1], dp_tau)
#CoV_tau_arr = CoV_tau_arr[::-1]
CoV_r_arr = np.linspace(CoV_r_range[0], CoV_r_range[1], dp_r)
e_arr = orthogonalize([CoV_tau_arr, CoV_r_arr])
x_axis1 = e_arr[0]
y_axis1 = e_arr[1]
list(CoV_tau_arr)

#x,y,z plot


# -------------------------------------------
def sigma_m(m):
    dataname = "sigmaOPT20_with_m{}.npy".format(m)
    res = np.load(dataname)
    from mayavi.api import Engine
    engine = Engine()
    engine.start()
    if len(engine.scenes) == 0:
        engine.new_scene()
    mlab.surf(x_axis1, y_axis1, res, representation='wireframe')
Ejemplo n.º 15
0
def rand_tau_r(E_f, V_f, mu_tau, mu_r, mu_xi, m_list, CoV_tau_range, CoV_r_range, dp_tau, dp_r, sV0):
    #rand tau and rand r
    for mi in m_list:
        s = get_scale(mu_xi, mi, mu_tau, mu_r)
        sV0 = float(s * (pi * mu_r ** 2) ** (1. / mi))
        Pf = RV('uniform', loc=0.0, scale=1.0)
        w_arr = np.linspace(0, 1.2, 30)
        cb = CBResidual(include_pullout=True)
        # loc scale generation for specific CoV
        #CoVtau
        CoV_tau_arr = np.linspace(CoV_tau_range[0], CoV_tau_range[1], dp_tau)
        loc_tau_arr = mu_tau - CoV_tau_arr * mu_tau * 3 ** 0.5
        scale_tau_arr = 2 * mu_tau - 2 * loc_tau_arr
        #CoVr
        CoV_r_arr = np.linspace(CoV_r_range[0], CoV_r_range[1], dp_r)
        loc_r_arr = mu_r - CoV_r_arr * mu_r * 3 ** 0.5
        scale_r_arr = 2 * mu_r - 2 * loc_r_arr
        #shaping for mayavi
        e_arr = orthogonalize([CoV_tau_arr, CoV_r_arr])
        x_axis = e_arr[0]
        y_axis = e_arr[1]
        #TAU gen Tuple of [loc,scale]
        stats_tau = []
        for s in range(dp_tau):
            stats_tau.append(RV('uniform', loc=loc_tau_arr[s], scale=scale_tau_arr[s]))
    
        stats_r = []
        for s in range(dp_r):
            stats_r.append(RV('uniform', loc=loc_r_arr[s], scale=scale_r_arr[s]))
             
        #r gen Tuple of [loc,scale]
        
        res_array = np.zeros((dp_tau, dp_r))
        for i_tau, taui in enumerate(stats_tau): 
            
                for i_r, ri in enumerate(stats_r):
                    
                    total = SPIRRID(q=cb,
                            sampling_type='MCS',
                            evars=dict(w=w_arr),
                            tvars=dict(tau=taui, E_f=E_f, V_f=V_f, r=ri,
                                       m=mi, sV0=sV0, Pf=Pf),
                            n_int=70)
                    if isinstance(ri, RV):
                        r_arr = np.linspace(ri.ppf(0.001), ri.ppf(0.999), 200)
                        Er = np.trapz(r_arr ** 2 * ri.pdf(r_arr), r_arr)
                    else:
                        Er = ri ** 2
                    result = total.mu_q_arr / Er
                    
                    sigma_c = np.max(result)
                    
                    if sigma_c == result[-1]:
                        print "w_arr too short"
                        
                    res_array[i_tau, i_r] = sigma_c
        #mayaviplot
        
        mlab.surf(x_axis, y_axis, res_array)
        #mlab.xlabel("rand tau")
        #mlab.ylabel("rand r")
        #mlab.zlabel("sigma")
    mlab.show()
Ejemplo n.º 16
0
from stats.spirrid import make_ogrid as orthogonalize
import numpy as np
from etsproxy.mayavi import mlab
import mayavi

#x,y data generation
CoV_tau_range = [1e-7, 0.5]
CoV_r_range = [1e-7, 0.5]
dp_tau = 20
dp_r = 20
CoV_tau_arr = np.linspace( CoV_tau_range[0], CoV_tau_range[1], dp_tau )
#CoV_tau_arr = CoV_tau_arr[::-1]
CoV_r_arr = np.linspace( CoV_r_range[0], CoV_r_range[1], dp_r )
e_arr = orthogonalize( [CoV_tau_arr, CoV_r_arr] )
x_axis1 = e_arr[0]
y_axis1 = e_arr[1]
list( CoV_tau_arr )
#x,y,z plot


# ------------------------------------------- 
def sigma_m( m ):
    dataname = "sigmaOPT20_with_m{}.npy".format( m )
    res = np.load( dataname )
    from mayavi.api import Engine
    engine = Engine()
    engine.start()
    if len( engine.scenes ) == 0:
        engine.new_scene()
    mlab.surf( x_axis1 , y_axis1 , res  , representation = 'wireframe' )
    surface = engine.scenes[0].children[0].children[0].children[0].children[0].children[0]
Ejemplo n.º 17
0
            l=RV("uniform", 5.0, 10.0),
            D_f=26e-3,
            E_f=72e3,
            theta=0.0,
            xi=RV("weibull_min", scale=0.017, shape=8, n_int=10),
            phi=1.0,
            Ll=50.0,
            #                              Lr = 1.0
        ),
        n_int=3,
    )

    from stats.spirrid import orthogonalize
    from time import sleep

    e_arr = orthogonalize(s.evar_list)
    n_e_arr = [e / np.max(np.fabs(e)) for e in e_arr]

    max_mu_q = np.max(np.fabs(s.mu_q_arr))
    n_mu_q_arr = s.mu_q_arr / max_mu_q
    n_std_q_arr = np.sqrt(s.var_q_arr) / max_mu_q

    import enthought.mayavi.mlab as m

    f = m.figure(1, size=(1000, 500), fgcolor=(0, 0, 0), bgcolor=(1.0, 1.0, 1.0))

    s = m.surf(n_e_arr[1], n_e_arr[2], n_mu_q_arr[0, :, :])

    m.axes(
        s,
        color=(0.7, 0.7, 0.7),
Ejemplo n.º 18
0
                        ),
         n_int = 20)

    ctt = CTT(length = length,
              nx = nx,
              matrix_strength = matrix_strength,
              cb_randomization = rand,
              cb_type = 'mean',
              )
    P = np.linspace(0.1, 400, 200)
    matrix = []
    reinf = []
    for p in P:
        ctt.applied_force = p
        matrix.append(ctt.eps_r_x)
        reinf.append(ctt.eps_m_x)
    e_arr = orthogonalize([ctt.x_arr, P])
    n_e_arr = [ e / np.max(np.fabs(e)) for e in e_arr ]

    mu_m_arr = np.array(matrix)
    mu_r_arr = np.array(reinf)

    n_mu_m_arr = mu_m_arr / np.max(np.fabs(mu_m_arr))
    n_mu_r_arr = mu_r_arr / np.max(np.fabs(mu_r_arr))

    #m.surf(n_e_arr[0], n_e_arr[1], n_mu_m_arr)
    m.surf(n_e_arr[0], n_e_arr[1], n_mu_r_arr)
    plt.plot(ctt.eps, P)
    plt.show()
    m.show()
Ejemplo n.º 19
0
##    plt.show()
#    e_arr = orthogonalize([x, P])
#    n_e_arr = [ e / np.max(np.fabs(e)) for e in e_arr ]
#
#    mu_q_arr = np.array(forces)
#
#    n_mu_q_arr = mu_q_arr / np.max(np.fabs(mu_q_arr))
#    m.surf(n_e_arr[0], n_e_arr[1], n_mu_q_arr)

    mfy = MultifilamentYarn()
    mfy.Ll = 10.
    mfy.Lr = 20.

    x = np.linspace(-30, 30, 300)
    P = np.linspace(0., 580, 200)
    forces = []
    for p in P:
        mfy.P = p
        forces.append(mfy.get_force_x_reinf(x))
#        plt.plot( x, mfy.get_force_x_reinf( x ) )
#    plt.show()
    e_arr = orthogonalize([x, P])
    n_e_arr = [ e / np.max(np.fabs(e)) for e in e_arr ]

    mu_q_arr = np.array(forces)

    n_mu_q_arr = mu_q_arr / np.max(np.fabs(mu_q_arr))
    m.surf(n_e_arr[0], n_e_arr[1], n_mu_q_arr)

    m.show()
Ejemplo n.º 20
0
def rand_tau_r( E_f, V_f, mu_tau, mu_r, m_list, CoV_tau_range, CoV_r_range, dp_tau, dp_r, sV0 ):
    #rand tau and rand r
    m = m_list[0]
    s0 = ( ( mu_tau * ( m + 1 ) * sV0 ** m ) / ( E_f * pi * mu_r ** 3 ) ) ** ( 1. / ( m + 1 ) )
    mu_xi = s0 * gamma( 1. + 1. / ( 1. + m ) )
    for i_m, mi in enumerate( m_list ):
        s0i = mu_xi / gamma( 1. + 1. / ( 1. + mi ) )
        sV0i = ( ( s0i ** ( mi + 1 ) * E_f * pi * mu_r ** 3. ) / ( mu_tau * ( mi + 1. ) ) ) ** ( 1. / mi )
        #
        #print 'Nr', i_m, 's0i', s0i, 'sV0i', sV0i, 'mu_xi', s0i * gamma(1. + 1. / (1. + mi))
        #
        #Pf = RV( 'uniform', loc = 0.0, scale = 1.0 )
        #w_arr = np.linspace(0, 1.2, 30)
        # loc scale generation for specific CoV
        #CoVtau
        CoV_tau_arr = np.linspace( CoV_tau_range[0], CoV_tau_range[1], dp_tau )
        loc_tau_arr = mu_tau - CoV_tau_arr * mu_tau * 3 ** 0.5
        scale_tau_arr = 2 * mu_tau - 2 * loc_tau_arr
        #CoVr
        CoV_r_arr = np.linspace( CoV_r_range[0], CoV_r_range[1], dp_r )
        loc_r_arr = mu_r - CoV_r_arr * mu_r * 3 ** 0.5
        scale_r_arr = 2 * mu_r - 2 * loc_r_arr
        #shaping for mayavi
        e_arr = orthogonalize( [CoV_tau_arr, CoV_r_arr] )
        x_axis = e_arr[0]
        y_axis = e_arr[1]
        #TAU gen Tuple of [loc,scale]
        stats_tau = []
        for s in range( dp_tau ):
            stats_tau.append( RV( 'uniform', loc = loc_tau_arr[s], scale = scale_tau_arr[s] ) )
        stats_tau[0] = mu_tau
        stats_r = []
        for s in range( dp_r ):
            stats_r.append( RV( 'uniform', loc = loc_r_arr[s], scale = scale_r_arr[s] ) )
        stats_r[0] = mu_r
        #r gen Tuple of [loc,scale]

        sigma_array = np.zeros( ( dp_tau, dp_r ) )
        w_array = np.zeros( ( dp_tau, dp_r ) )
        
        ##grid
        sigma_array_grid = np.zeros( ( dp_tau, dp_r ) )
        w_array_grid = np.zeros( ( dp_tau, dp_r ) )
        for i_tau, taui in enumerate( stats_tau ):
                for i_r, ri in enumerate( stats_r ):
                    total = SPIRRID( q = cb,
                        sampling_type = 'PGrid',
                        evars = dict(),
                        tvars = dict( tau = taui, E_f = E_f, V_f = V_f, r = ri,
                        m = mi, sV0 = sV0i ),
                        n_int = 70 )
                    
                    if isinstance( ri, RV ):
                        r_arr = np.linspace( ri.ppf( 0.001 ), ri.ppf( 0.999 ), 200 )
                        Er = np.trapz( r_arr ** 2 * ri.pdf( r_arr ), r_arr )
                    else:
                        Er = ri ** 2
                    #Optimization  taui, E_f, V_f, ri, mi, sV0i, Pf, Er
                    def spirrid_func( w_in, Er ):
                        w_arr = np.array( w_in )
                        #print 'w', w_arr
                        total.evars = dict( w = w_arr )
                        g = -1.*total.mu_q_arr / Er
                        #print 'res', g
                        total.evars = dict( w = w_arr )
                        return g
                    #w_test = np.linspace(0.001, 1, 1000)
                    #total.evars = dict(w=w_test)
                   # plt.plot(w_test, -1.*total.mu_q_arr / Er)
                    #plt.show()
                    print i_tau, 'von', dp_tau
                    #Optimierung
                    w_ult, sigma_ult, trash1, trash2, trash3 = fmin( spirrid_func, x0 = 0.1, args = [Er], ftol = 0.2, full_output = 1 )
                    sigma_array[i_tau, i_r] = np.float( -1.*sigma_ult )
                    w_array[i_tau, i_r] = np.float( w_ult )
                    
                    #grid
                    w_grid = np.linspace( 0.2, 0.28, 50 )
                    res_grid = -1.* spirrid_func( w_grid, Er )
                    index_max_grid = np.argmax( res_grid )
                    sigma_array_grid[i_tau, i_r] = res_grid[index_max_grid]
                    w_array_grid[i_tau, i_r] = w_grid[index_max_grid]
                    #print w_grid[index_max_grid]
                    
                   

        #print np.max( sigma_array )
        s_dataname = 'sigmaOPT20_with_m{}.npy'.format( mi )
        np.save( s_dataname, sigma_array )
        w_dataname = 'wOPT20_with_m{}.npy'.format( mi )
        np.save( w_dataname, w_array )
        
        #Grid Datasave
        s_gridname = 'sigmaGRID20_with_m{}.npy'.format( mi )
        np.save( s_gridname , sigma_array_grid )
        w_gridname = 'wGRID20_with_m{}.npy'.format( mi )
        np.save( w_gridname, w_array_grid )
        #mayaviplot
        mlab.surf( x_axis, y_axis, w_array )

    mlab.xlabel( "rand tau" )
    mlab.ylabel( "rand r" )
    mlab.zlabel( "sigma" )
    mlab.show()