Exemplo n.º 1
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()
Exemplo n.º 2
0
    def _plot3d_points_flat_fired(self):
        '''Plot array of variable using colormap
        '''
        aramis_cdt = self.aramis_cdt

        m.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1) , size=(1600, 900))
        engine = m.get_engine()
        scene = engine.scenes[0]
        scene.scene.disable_render = True

        plot3d_var = getattr(aramis_cdt, self.plot3d_var_)

        mask = np.logical_or(np.isnan(aramis_cdt.x_arr),
                             aramis_cdt.data_array_undeformed_mask[0, :, :])
        mask = None
        m.points3d(aramis_cdt.x_arr[mask],
                   aramis_cdt.y_arr[mask],
                   aramis_cdt.z_arr[mask],
                   plot3d_var[mask],
                   mode='cube',
                   scale_mode='none', scale_factor=1)
        m.view(0, 0)
        scene.scene.parallel_projection = True
        scene.scene.disable_render = False

        if self.plot_title:
            m.title('step no. %d' % aramis_cdt.evaluated_step_idx, size=0.3)

        m.scalarbar(orientation='horizontal', title=self.plot3d_var_)

        # plot axes
        m.axes()

        m.show()
Exemplo n.º 3
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()
Exemplo n.º 4
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()
Exemplo 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()
Exemplo n.º 6
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()
Exemplo n.º 7
0
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]
    surface.actor.mapper.scalar_range = np.array( [ 6.97602671, 8.8533387 ] )
    surface.actor.mapper.scalar_visibility = False
    scene = engine.scenes[0]
    scene.scene.background = ( 1.0, 1.0, 1.0 )
    surface.actor.property.specular_color = ( 0.0, 0.0, 0.0 )
    surface.actor.property.diffuse_color = ( 0.0, 0.0, 0.0 )
    surface.actor.property.ambient_color = ( 0.0, 0.0, 0.0 )
    surface.actor.property.color = ( 0.0, 0.0, 0.0 )
    surface.actor.property.line_width = 1.
    warp_scalar = engine.scenes[0].children[0].children[0]
    module_manager = engine.scenes[0].children[0].children[0].children[0].children[0]
    warp_scalar.filter.normal = np.array( [ 0. , 0. , 0.2] )
    module_manager.scalar_lut_manager.scalar_bar.global_warning_display = 1
    module_manager.scalar_lut_manager.scalar_bar.position2 = np.array( [ 0.8 , 0.17] )
    module_manager.scalar_lut_manager.scalar_bar.position = np.array( [ 0.1 , 0.01] )
    module_manager.scalar_lut_manager.data_range = np.array( [ 6.97602671, 8.8533387 ] )
    module_manager.scalar_lut_manager.default_data_range = np.array( [ 6.97602671, 8.8533387 ] )
    module_manager.vector_lut_manager.scalar_bar.global_warning_display = 1
    module_manager.vector_lut_manager.scalar_bar.position2 = np.array( [ 0.8 , 0.17] )
    module_manager.vector_lut_manager.scalar_bar.position = np.array( [ 0.1 , 0.01] )
    module_manager.vector_lut_manager.data_range = np.array( [ 0., 1.] )
    module_manager.vector_lut_manager.default_data_range = np.array( [ 0., 1.] )
    scene.scene.isometric_view()

    scene.scene.camera.position = [1.2836424071875543, 1.4371492101974028, 4.0390558511994534]
    scene.scene.camera.focal_point = [0.17361105930834225, 0.21417386120592863, 3.4874067491767562]
    scene.scene.camera.view_angle = 30.0
    scene.scene.camera.view_up = [-0.21371002618964222, -0.23386371429877953, 0.94849132196367569]
    scene.scene.camera.clipping_range = [0.79163912587841923, 2.7365159886347699]
    scene.scene.camera.compute_view_plane_normal()

    #mlab.surf( x_axis2, y_axis2, res2 )
    #mlab.xlabel( "rand tau" )
    #mlab.ylabel( "rand r" )
    #mlab.zlabel( "z" )
    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()
Exemplo n.º 9
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()
Exemplo n.º 10
0
def mlab_plot():
    w = np.linspace(0, 1.8, 30)
    x = np.linspace(-50., 20., 30)
    P = CBEMClampedFiberSP()
    spirrid = SPIRRID(q = P,
                      sampling_type = 'LHS',
                      evars = dict(w = w,
                                    x = x),
                      tvars = dict(Ll = 50.,
                                   Lr = 20.,
                                   tau = RV('uniform', 0.05, .15),
                                   l = RV('uniform', 2.0, 15.0),
                                   A_f = Af,
                                   E_f = Ef,
                                   theta = 0.01, #RV('uniform', 0.0, .02),
                                   xi = RV('weibull_min', scale = 0.0179, shape = 5, n_int = 10),
                                   phi = phi,
                                   E_m = Em,
                                   A_m = Am,
                                   Nf = 1.
                                    ),
                    n_int = 20)

    e_arr = make_ogrid([x, w])
    n_e_arr = [ e / np.max(np.fabs(e)) for e in e_arr ]
    mu_q_arr = spirrid.mu_q_arr
    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)
    from numpy import array

# ------------------------------------------- 
    scene = engine.scenes[0]
    scene.scene.background = (1.0, 1.0, 1.0)
    scene.scene.camera.position = [1.5028781189276834, 3.5681173520859848, 1.9543753549631095]
    scene.scene.camera.focal_point = [-0.29999999701976776, 0.5, 0.5]
    scene.scene.camera.view_angle = 30.0
    scene.scene.camera.view_up = [-0.14835983161589669, -0.35107055575000001, 0.92452086252733578]
    scene.scene.camera.clipping_range = [1.9820957553309271, 6.1977861427731007]
    scene.scene.camera.compute_view_plane_normal()
    module_manager = engine.scenes[0].children[0].children[0].children[0].children[0]
    module_manager.scalar_lut_manager.lut_mode = 'Greys'
    m.show()
Exemplo n.º 11
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()
Exemplo n.º 12
0
        pts = pts + offset_arr

        return pts


if __name__ == '__main__':

    from numpy import mgrid, c_, hstack, vstack, shape
    from etsproxy.mayavi import mlab

    geo_supprt = GeoSUPPRT()

    shape_xy = 2
    shape_z = 1

    grid = mgrid[0:1:complex(0, shape_xy + 1),
                 0:1:complex(0, shape_xy + 1 ),
                 0:1:complex(0, shape_z + 1)]

    X, Y, Z = grid

    gpoints = c_[ X.flatten(), Y.flatten(), Z.flatten() ]
    
    mlab.figure(bgcolor=(1.,1.,1.,))
    fp1 = geo_supprt(gpoints)
    mlab.points3d(fp1[:, 0], fp1[:, 1], fp1[:, 2],
                   scale_factor = 0.003 ,
                   resolution = 8)
    mlab.axes()
    mlab.show()
Exemplo n.º 13
0
    
    s = m.surf(n_e_arr[1], n_e_arr[2], n_mu_q_arr[0, :, :])
    ms = s.mlab_source
    
    m.axes(s, color = (.7, .7, .7),
           extent = (-1, 1, 0, 1, 0, 1),
           ranges = (-0.21, 0.21, 0.1, 20, 0, max_mu_q),
           xlabel = 'x[mm]', ylabel = 'Lr[mm]',
           zlabel = 'f[N]',)
    m.view(-60.0, 70.0, focalpoint = [0., 0.45, 0.45])
    
    m.savefig(fnames[0])
    
    for i, fname in enumerate(fnames[1:]):
        ms.scalars = n_mu_q_arr[i, :, :]
        m.savefig(fname)
    
    images = string.join(fnames, ' ')
    destination = os.path.join('fig', 'fiber_cb_8p_anim.gif')
    
    import platform
    if platform.system() == 'Linux':
        os.system('convert ' + images + ' ' + destination)
    else:
        raise NotImplementedError, 'film production available only on linux'
    
    m.show()

def create_demo_object():
    pass
Exemplo n.º 14
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()
Exemplo n.º 15
0
    def _plot3d_points_fired(self):
        '''Plot arrays of variables in 3d relief
        '''
        aramis_cdt = self.aramis_cdt
        m.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1), size=(900, 600))

        engine = m.get_engine()
        scene = engine.scenes[0]
        scene.scene.disable_render = True

        #-----------------------------------
        # plot crack width ('crack_field_w')
        #-----------------------------------

        z_arr = np.zeros_like(aramis_cdt.z_arr)

        plot3d_var = getattr(aramis_cdt, self.plot3d_var_)
        m.points3d(z_arr, aramis_cdt.x_arr, aramis_cdt.y_arr, plot3d_var,
                   mode='cube', colormap="blue-red", scale_mode='scalar', vmax=.2)

        # scale glyphs
        #
        glyph = engine.scenes[0].children[0].children[0].children[0]
        glyph.glyph.glyph_source.glyph_position = 'tail'
        glyph.glyph.glyph_source.glyph_source.x_length = self.glyph_x_length_cr
        glyph.glyph.glyph_source.glyph_source.y_length = self.glyph_y_length_cr
        glyph.glyph.glyph_source.glyph_source.z_length = self.glyph_z_length_cr

        #-----------------------------------
        # plot displacement jumps ('d_ux_w')
        #-----------------------------------

        plot3d_var = getattr(aramis_cdt, self.plot3d_var_)
        m.points3d(z_arr, aramis_cdt.x_arr, aramis_cdt.y_arr, plot3d_var, mode='cube',
                   colormap="blue-red", scale_mode='none')

        glyph1 = engine.scenes[0].children[1].children[0].children[0]
#       # switch order of the scale_factor corresponding to the order of the
        glyph1.glyph.glyph_source.glyph_source.x_length = self.glyph_z_length
        glyph1.glyph.glyph_source.glyph_source.y_length = self.glyph_x_length
        glyph1.glyph.glyph_source.glyph_source.z_length = self.glyph_y_length

        # rotate scene
        #
        scene = engine.scenes[0]
        scene.scene.parallel_projection = True
        m.view(0, 90)

        glyph.glyph.glyph_source.glyph_position = 'head'
        glyph.glyph.glyph_source.glyph_position = 'tail'

        module_manager = engine.scenes[0].children[0].children[0]
        module_manager.scalar_lut_manager.scalar_bar_representation.minimum_size = np.array([1, 1])
        module_manager.scalar_lut_manager.scalar_bar_representation.position2 = np.array([ 0.20603604, 0.16827586])
        module_manager.scalar_lut_manager.scalar_bar_representation.moving = 0
        module_manager.scalar_lut_manager.scalar_bar_representation.position = np.array([ 0.53971972, 0.19931035])
        module_manager.scalar_lut_manager.scalar_bar_representation.maximum_size = np.array([100000, 100000])
        scene.scene.disable_render = False

        if self.plot_title:
            m.title('step no. %d' % aramis_cdt.evaluated_step_idx, size=0.3)

        m.scalarbar(orientation='horizontal', title=self.plot3d_var_)

        # plot axes
        #
        m.axes()

        m.show()
Exemplo n.º 16
0
        pts = pts + offset_arr

        return pts


if __name__ == '__main__':

    from numpy import mgrid, c_, hstack, vstack, shape
    from etsproxy.mayavi import mlab

    geo_supprt = GeoSUPPRT()

    shape_xy = 2
    shape_z = 1

    grid = mgrid[0:1:complex(0, shape_xy + 1),
                 0:1:complex(0, shape_xy + 1 ),
                 0:1:complex(0, shape_z + 1)]

    X, Y, Z = grid

    gpoints = c_[ X.flatten(), Y.flatten(), Z.flatten() ]
    
    mlab.figure(bgcolor=(1.,1.,1.,))
    fp1 = geo_supprt(gpoints)
    mlab.points3d(fp1[:, 0], fp1[:, 1], fp1[:, 2],
                   scale_factor = 0.003 ,
                   resolution = 8)
    mlab.axes()
    mlab.show()
Exemplo n.º 17
0
def w_m(m):
    dataname = "wOPT20_with_m{}.npy".format(m)
    res = np.load(dataname)
    #res2 = np.load( "sigmaAN_with_m7.0.npy" )

    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]
    surface.actor.mapper.scalar_range = np.array([6.97602671, 8.8533387])
    surface.actor.mapper.scalar_visibility = False
    scene = engine.scenes[0]
    scene.scene.background = (1.0, 1.0, 1.0)
    surface.actor.property.specular_color = (0.0, 0.0, 0.0)
    surface.actor.property.diffuse_color = (0.0, 0.0, 0.0)
    surface.actor.property.ambient_color = (0.0, 0.0, 0.0)
    surface.actor.property.color = (0.0, 0.0, 0.0)
    surface.actor.property.line_width = 1.
    warp_scalar = engine.scenes[0].children[0].children[0]
    module_manager = engine.scenes[0].children[0].children[0].children[
        0].children[0]
    warp_scalar.filter.normal = np.array([0., 0., 15])
    module_manager.scalar_lut_manager.scalar_bar.global_warning_display = 1
    module_manager.scalar_lut_manager.scalar_bar.position2 = np.array(
        [0.8, 0.17])
    module_manager.scalar_lut_manager.scalar_bar.position = np.array(
        [0.1, 0.01])
    module_manager.scalar_lut_manager.data_range = np.array(
        [6.97602671, 8.8533387])
    module_manager.scalar_lut_manager.default_data_range = np.array(
        [6.97602671, 8.8533387])
    module_manager.vector_lut_manager.scalar_bar.global_warning_display = 1
    module_manager.vector_lut_manager.scalar_bar.position2 = np.array(
        [0.8, 0.17])
    module_manager.vector_lut_manager.scalar_bar.position = np.array(
        [0.1, 0.01])
    module_manager.vector_lut_manager.data_range = np.array([0., 1.])
    module_manager.vector_lut_manager.default_data_range = np.array([0., 1.])
    scene.scene.isometric_view()

    scene.scene.camera.position = [
        1.2836424071875543, 1.4371492101974028, 4.0390558511994534
    ]
    scene.scene.camera.focal_point = [
        0.17361105930834225, 0.21417386120592863, 3.4874067491767562
    ]
    scene.scene.camera.view_angle = 30.0
    scene.scene.camera.view_up = [
        -0.21371002618964222, -0.23386371429877953, 0.94849132196367569
    ]
    scene.scene.camera.clipping_range = [
        0.79163912587841923, 2.7365159886347699
    ]
    scene.scene.camera.compute_view_plane_normal()

    mlab.show()
Exemplo n.º 18
0
    s = m.surf(n_e_arr[1], n_e_arr[2], n_mu_q_arr[0, :, :])
    ms = s.mlab_source

    m.axes(
        s,
        color=(.7, .7, .7),
        extent=(-1, 1, 0, 1, 0, 1),
        ranges=(-0.21, 0.21, 0.1, 20, 0, max_mu_q),
        xlabel='x[mm]',
        ylabel='Lr[mm]',
        zlabel='f[N]',
    )
    m.view(-60.0, 70.0, focalpoint=[0., 0.45, 0.45])

    m.savefig(fnames[0])

    for i, fname in enumerate(fnames[1:]):
        ms.scalars = n_mu_q_arr[i, :, :]
        m.savefig(fname)

    images = string.join(fnames, ' ')
    destination = os.path.join('fig', 'fiber_cb_8p_anim.gif')

    import platform
    if platform.system() == 'Linux':
        os.system('convert ' + images + ' ' + destination)
    else:
        raise NotImplementedError, 'film production available only on linux'

    m.show()
Exemplo n.º 19
0
    def param_plot( self ):
        fig = plt.figure()
        ax = fig.gca( projection = '3d' )
        values = self.results
        p1 = self.values1
        p2 = self.values2
        n1 = self.name1
        n2 = self.name2
        n3 = self.name3

        x = np.linspace( p1[0], p1[-1], 20 )
        y = np.linspace( p2[0], p2[-1], 20 )

        X = np.meshgrid( x, x )[0]
        Y = np.meshgrid( y, y )[1]

        val = np.array( values[0:9] ).reshape( 3, 3 )
        spl = spline( p1, p2, val, kx = 2, ky = 2 )
        Z = spl( x, y ) / 0.89

        val2 = np.array( values[9:] ).reshape( 3, 3 )
        spl2 = spline( p1, p2, val2, kx = 2, ky = 2 )
        ZZ = spl2( x, y ) / 0.89
#
#        ax.plot_wireframe( X, Y, Z, rstride = 5, cstride = 5, alpha = 1.,
#                         color = 'black', lw = 2 )
#
#        i = 0
#        for V in p2:
#            for vorsp in p1:
#                print vorsp, V, values[i]
#                ax.plot( [vorsp, vorsp], [V, V], values[i] / 0.89, 'ko', lw = 5 )
#                i += 1
        # glas 1200tex 5cN: ax.plot( [100, 100], [30, 30], np.array( [588.32, 588.32] ) / 0.89, 'ro', label = '%.1f MPa' % ( 588.32 / 0.89 ) )
        # carbon 1600tex 5cN: ax.plot( [70, 70], [60, 60], np.array( [1768., 1768.] ) / 0.89, 'ro', label = '%.1f MPa' % ( 1768. / 0.89 ) )

#        ax.plot( [0, 0], [-1e15, -1e15], color = 'black', label = self.label1, lw = 2 )


        ax.plot_wireframe( X, Y, ZZ, rstride = 5, cstride = 5, alpha = 1.,
                         color = 'black', lw = 2 )

        i = 0
        for V in p2:
            for vorsp in p1:
                print vorsp, V, values[9 + i]
                ax.plot( [vorsp, vorsp], [V, V], values[9 + i] / 0.89, 'ko' )
                m.points3d( vorsp, V, values[i] / 0.89 )
                i += 1
        # glas 1200ax.plot( [50, 50], [30, 30], np.array( [594.15, 594.15] ) / 0.89, 'ro', label = '%.1f MPa' % ( 594.15 / 0.89 ) )
        ax.plot( [70, 70], [40, 40], np.array( [1773., 1773.] ) / 0.89, 'ro', label = '%.1f MPa' % ( 1773. / 0.89 ) )
        m.points3d( 100, 30, 588.32 / 0.89, color = ( 0.5, 0.7, 0.2 ) )
        ax.plot( [0, 0], [-1e15, -1e15], color = 'black', label = self.label2, lw = 2 )


        ax.legend( loc = 'upper left' )
        ax.set_title( self.title )
        ax.set_xlabel( n1 )
        ax.set_xlim3d( self.xlim[0], self.xlim[1] )
        ax.set_ylabel( n2 )
        ax.set_ylim3d( self.ylim[0], self.ylim[1] )
        ax.set_zlabel( n3 )
        ax.set_zlim3d( self.zlim[0], self.zlim[1] )

        #plt.show()


        e_arr = orthogonalize( [x, y] )
        #n_e_arr = [ e / np.max(np.fabs(e)) for e in e_arr ]

        strength = Z

        #strength_n = strength / np.max(np.fabs(strength))
        m.surf( e_arr[0], e_arr[1], strength )

        m.show()
Exemplo 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()
Exemplo n.º 21
0
    def plot3d_points(self):

        # set background color to white and forground color to black
        #
        m.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1), size=(900, 600))

        # NOTE: the missing facettes have all the coordinate position (0,0,0);
        # the missing facettes therefore are displayed in points3d as missing elements (gaps)

        plot3d_var = getattr(self, self.plot3d_var_[0])
        vmax = self.plot3d_var_[1]

#        m.points3d(self.x_arr, self.y_arr, self.z_arr, plot3d_var, mode = 'cube', colormap = "blue-red", scale_mode ='none', vmax = vmax)
#        m.points3d(self.x_arr_avg, self.y_arr_avg, self.z_arr, plot3d_var, mode = 'cube', colormap = "blue-red", scale_mode ='none', vmax = vmax)
        m.points3d(self.x_arr, self.y_arr, self.z_arr, plot3d_var, mode='cube', colormap="blue-red", scale_mode='none', vmax=vmax)

        # switch coordinate order to display glyphs at their head/tail insted of their center
#        m.points3d(self.z_arr, self.x_arr, self.y_arr, plot3d_var, mode = 'cube', colormap = "blue-red", scale_mode ='none', vmax = vmax)

        # plot scalarbar
        #
        m.scalarbar(orientation='horizontal', title=self.plot3d_var)
        # @todo: predefine scalarbar position
#        m.scalarbar().position = [0., 0.]

        # plot axes
        #
        m.axes()

        # figure title
        # uses directory path by default
        #
        if plot_title == 'true':
            m.title(os.path.join(self.data_dir, self.basename))

        # get mayavi engine
        #
        engine = m.get_engine()

        # scale glyphs
        #
        glyph = engine.scenes[0].children[0].children[0].children[0]
        glyph.glyph.glyph_source.glyph_source.x_length = self.glyph_x_length
        glyph.glyph.glyph_source.glyph_source.y_length = self.glyph_y_length
        glyph.glyph.glyph_source.glyph_source.z_length = self.glyph_z_length
        glyph.glyph.glyph_source.glyph_position = 'tail'

        # rotate scene
        #
        scene = engine.scenes[0]
        scene.scene.parallel_projection = True
        scene.scene.z_plus_view()

        # preset position of scalarbar
        #
        module_manager = engine.scenes[0].children[0].children[0]
        module_manager.scalar_lut_manager.scalar_bar_representation.maximum_size = np.array([100000, 100000])
        module_manager.scalar_lut_manager.scalar_bar_representation.minimum_size = np.array([1, 1])
        module_manager.scalar_lut_manager.scalar_bar_representation.position2 = np.array([ 0.20603604, 0.16827586])
        module_manager.scalar_lut_manager.scalar_bar_representation.moving = 0
        module_manager.scalar_lut_manager.scalar_bar_representation.position = np.array([ 0.40858859, 0.09310345])
        module_manager.scalar_lut_manager.scalar_bar_representation.maximum_size = np.array([100000, 100000])

#        # @todo: use mlab-functionality instead
#        view = mlab.view()
#        roll = mlab.roll()
#        # Reposition the camera
#        mlab.view(*view)
#        mlab.roll(roll)
#
#        f = mlab.gcf()
#        camera = f.scene.camera
#        cam.parallel_scale = 9

        m.show()
Exemplo n.º 22
0
    def plot3d_cracks(self):
        # set background color to white and forground color to black
        #
        m.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1), size=(900, 600))

        # get mayavi engine
        #
        engine = m.get_engine()
        scene = engine.scenes[0]
        scene.scene.disable_render = True

        #-----------------------------------
        # plot crack width ('crack_field_w')
        #-----------------------------------

        # flatten z_arr
        # @todo: use instead: extent = [xmin, xmax, ymin, ymax, zmin, zmax],
        #
        z_arr = np.zeros_like(self.z_arr)
        # NOTE: coordinate order is switched in order to display glyphs at their tail instead of their center
        # (only possible in mayavis's x-direction)
        #
        plot3d_var = getattr(self, self.plot3d_var_[0])
#        plot3d_var = getattr(self, 'crack_field_w')
        vmax = self.plot3d_var_[1]
        m.points3d(z_arr, self.x_arr, self.y_arr, plot3d_var, mode='cube', colormap="blue-red", scale_mode='scalar', vmax=vmax)

        # plot scalarbar
        #
        m.scalarbar(orientation='horizontal', title=self.plot3d_var)

        # figure title
        # uses directory path by default
        #
        if plot_title == 'true':
            m.title(os.path.join(self.data_dir, self.basename))

        # scale glyphs
        #
        glyph = engine.scenes[0].children[0].children[0].children[0]
        glyph.glyph.glyph_source.glyph_position = 'tail'
        glyph.glyph.glyph_source.glyph_source.x_length = self.glyph_x_length_cr
        glyph.glyph.glyph_source.glyph_source.y_length = self.glyph_y_length_cr
        glyph.glyph.glyph_source.glyph_source.z_length = self.glyph_z_length_cr

        #-----------------------------------
        # plot displacement jumps ('d_ux_w')
        #-----------------------------------

#        plot3d_var = getattr(self, 'd_ux_w')
        plot3d_var = getattr(self, 'crack_field_w')
        m.points3d(z_arr, self.x_arr, self.y_arr, plot3d_var, mode='cube', colormap="blue-red", scale_mode='none', vmax=vmax)
        # m.surf(z_arr, self.x_arr, self.y_arr, colormap="blue-red")
        glyph1 = engine.scenes[0].children[1].children[0].children[0]
#         # switch order of the scale_factor corresponding to the order of the
        glyph1.glyph.glyph_source.glyph_source.x_length = self.glyph_z_length
        glyph1.glyph.glyph_source.glyph_source.y_length = self.glyph_x_length
        glyph1.glyph.glyph_source.glyph_source.z_length = self.glyph_y_length

        # rotate scene
        #
        scene = engine.scenes[0]
        scene.scene.parallel_projection = True
        m.view(0, 90)
#         scene.scene.camera.position = [616.49832063929375, 638.29074243238438, 514.06081220962164]
#         scene.scene.camera.focal_point = [11.259753942489624, 11.990119934082031, 9.7502956390380859]
#         scene.scene.camera.view_angle = 30.0
#         scene.scene.camera.view_up = [0.79246046934594205, -0.54446721176015089, -0.27488517574095594]
#         scene.scene.camera.clipping_range = [595.49259262137014, 1526.1362976999562]
#         scene.scene.camera.compute_view_plane_normal()

        glyph.glyph.glyph_source.glyph_position = 'head'
        glyph.glyph.glyph_source.glyph_position = 'tail'

        module_manager = engine.scenes[0].children[0].children[0]
        module_manager.scalar_lut_manager.scalar_bar_representation.minimum_size = np.array([1, 1])
        module_manager.scalar_lut_manager.scalar_bar_representation.position2 = np.array([ 0.20603604, 0.16827586])
        module_manager.scalar_lut_manager.scalar_bar_representation.moving = 0
        module_manager.scalar_lut_manager.scalar_bar_representation.position = np.array([ 0.53971972, 0.19931035])
        module_manager.scalar_lut_manager.scalar_bar_representation.maximum_size = np.array([100000, 100000])
        scene.scene.disable_render = False
        # plot axes
        #
        m.axes()

        m.show()
Exemplo n.º 23
0
    def plot3d_surf(self):

        # set background color to white and forground color to black
        #
        m.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1), size=(1600, 900))

        #----------------------------------------------------
        # plot 'plot_var' as 3d-surface plot
        #----------------------------------------------------
        # @todo: is this comment still relavant? "why is moved in the y direction?"

        if self.use_mask == 'true':
            mask_arr = self.grid_mask_w
        else:
            mask_arr = None

        plot3d_var = getattr(self, self.plot3d_var_[0])
        vmax = self.plot3d_var_[1]

#        m.surf(self.x_arr, self.y_arr, plot3d_var, vmax = vmax, mask = mask_arr, warp_scale = warp_scale)
        m.surf(self.x_arr_avg, self.y_arr_avg, plot3d_var, vmax=vmax, mask=mask_arr, warp_scale=warp_scale)

        # use average coordinate values (1D-arrays)
        #
#        m.surf(self.x_arr_avg, self.y_arr_avg, plot3d_var, vmax = vmax, mask = mask_arr, warp_scale = warp_scale)


        # plot scalarbar
        #
        m.scalarbar(orientation='horizontal', title=self.plot3d_var)

        # plot axes
        #
#        m.axes()

        # figure title
        # uses directory path by default
        #
        if plot_title == 'true':
            m.title(os.path.join(self.data_dir, self.basename))

        # get mayavi engine
        #
        engine = m.get_engine()

        # rotate scene
        #
        scene = engine.scenes[0]
        scene.scene.parallel_projection = True
        if self.warp_scale == 1:
            scene.scene.z_plus_view()
        else:
            scene.scene.isometric_view()
            scene.scene.camera.position = [-319.07443227647047, -469.29101319337502, 434.40818470843612]
            scene.scene.camera.focal_point = [-66.983721840860625, -79.447548413824947, 1.1328650920308507]
            scene.scene.camera.view_angle = 30.0
            scene.scene.camera.view_up = [0.49290441759866288, 0.48449293877207339, 0.72271144130401255]
            scene.scene.camera.clipping_range = [325.28180250321782, 995.97136098229157]
            scene.scene.camera.compute_view_plane_normal()
            scene.scene.render()

        # predefine the position of the scalarbar
        #
        module_manager = engine.scenes[0].children[0].children[0].children[0].children[0]
        module_manager.scalar_lut_manager.scalar_bar_representation.minimum_size = np.array([1, 1])
        module_manager.scalar_lut_manager.scalar_bar_representation.position2 = np.array([ 0.27780226, 0.11638842])
        module_manager.scalar_lut_manager.scalar_bar_representation.position = np.array([ 0.59707606, 0.16105125])
        module_manager.scalar_lut_manager.scalar_bar_representation.maximum_size = np.array([100000, 100000])
        m.show()
Exemplo n.º 24
0
    def plot_n_tex(self, title = None):
        '''plot number of textile reinforcement 'n_tex' for all loading case combinations
        '''
        #----------------------------------------
        # script to get the maximum number of reinforcement ('n_tex')
        # at all given coordinate points for all possible loading
        # case combinations:
        #----------------------------------------
        # set option to "True" for surrounding 
        # evaluation of necessary layers "n_tex"
        # needed for all loading cases

        # get the list of all loading case combinations:
        #
        lcc_list = self.lcc_list

        #----------------------------------------------
        # run trough all loading case combinations:
        #----------------------------------------------

        n_tex_list = []
        for lcc in lcc_list:

            # get the ls_table object and retrieve its 'ls_class'
            # (= LSTable_ULS-object)
            #
            ls_class = lcc.ls_table.ls_class

            # get 'n_tex'-column array 
            #
            n_tex = ls_class.n_tex
#            n_tex = ls_class.n_tex_up
#            n_tex = ls_class.n_tex_lo
            n_tex_list.append(n_tex)

        # stack the list to an array in order to use ndmax-function
        #
        n_tex_arr = hstack(n_tex_list)

        #----------------------------------------------
        # get the overall maximum values:
        #----------------------------------------------

        n_tex_max = ndmax(n_tex_arr, axis = 1)[:, None]

        #----------------------------------------------
        # plot
        #----------------------------------------------
        #
        X = lcc_list[0].ls_table.X[:, 0]
        Y = lcc_list[0].ls_table.Y[:, 0]
        Z = lcc_list[0].ls_table.Z[:, 0]
        plot_col = n_tex_max[:, 0]

        # if n_tex is negative plot 0 instead:
        #
        plot_col = where(plot_col < 0, 0, plot_col)

        mlab.figure(figure = title,
                     bgcolor = (1.0, 1.0, 1.0),
                     fgcolor = (0.0, 0.0, 0.0))

        mlab.points3d(X, Y, (-1.0) * Z, plot_col,
                       colormap = "YlOrBr",
                       mode = "cube",
                       scale_mode = 'none',
                       scale_factor = 0.10)

        mlab.scalarbar(title = 'n_tex (all LCs)', orientation = 'vertical')

        mlab.show()
Exemplo n.º 25
0
    def plot_assess_value(self, title = None, add_assess_values_from_file = None, save_assess_values_to_file = None):
        '''plot the assess value for all loading case combinations
        '''
        #----------------------------------------
        # script to get the maximum values of 'assess_value' 
        # at all given coordinate points for all possible loading
        # case combinations:
        #----------------------------------------

        # get the list of all loading case combinations:
        #
        lcc_list = self.lcc_list

        #----------------------------------------------
        # run trough all loading case combinations:
        #----------------------------------------------

        assess_value_list = []
        for lcc in lcc_list:

            # get the ls_table object and retrieve its 'ls_class'
            # (= LSTable_ULS-object)
            #
            ls_class = lcc.ls_table.ls_class
 
            # get 'assess_name'-column array 
            #
            assess_name = ls_class.assess_name
            if assess_name == 'max_eta_nm_tot':
                assess_value = getattr(ls_class, 'eta_nm_tot')
            if assess_name == 'max_n_tex':
                assess_value = getattr(ls_class, 'n_tex')
            if assess_name == 'max_eta_tot':
                assess_value = getattr(ls_class, 'eta_tot')
            
#            n_tex = ls_class.n_tex_up
#            n_tex = ls_class.n_tex_lo
            assess_value_list.append(assess_value)

        # stack the list to an array in order to use ndmax-function
        #
        assess_value_arr = hstack(assess_value_list)
        print 'assess_value_arr.shape', assess_value_arr.shape

        #----------------------------------------------
        # get the overall maximum values:
        #----------------------------------------------

        assess_value_max = ndmax(assess_value_arr, axis = 1)[:, None]

        #----------------------------------------------
        # plot
        #----------------------------------------------
        #
        X = lcc_list[0].ls_table.X[:, 0]
        Y = lcc_list[0].ls_table.Y[:, 0]
        Z = lcc_list[0].ls_table.Z[:, 0]
        if self.reader_type == 'RFEM':
            Z *= -1.0 
        plot_col = assess_value_max[:, 0]
        
        # save assess values to file in order to superpose them later
        #
        if save_assess_values_to_file != None:
            print 'assess_values saved to file %s' %( save_assess_values_to_file )
            assess_value_arr = plot_col
            np.savetxt( save_assess_values_to_file, assess_value_arr )

        # add read in saved assess values to be superposed with currently read in assess values
        #
        if add_assess_values_from_file != None:
            print 'superpose assess_value_arr with values read in from file %s' %( add_assess_values_from_file )
            assess_value_arr = np.loadtxt( add_assess_values_from_file )
            plot_col += assess_value_arr

#        # if n_tex is negative plot 0 instead:
#        #
#        plot_col = where(plot_col < 0, 0, plot_col)

        mlab.figure(figure = title,
                     bgcolor = (1.0, 1.0, 1.0),
                     fgcolor = (0.0, 0.0, 0.0))

        mlab.points3d(X, Y, Z, plot_col,
                       colormap = "YlOrBr",
                       mode = "cube",
                       scale_mode = 'none',
                       scale_factor = 0.10)

        mlab.scalarbar(title = assess_name + ' (all LCs)', orientation = 'vertical')

        mlab.show()