Esempio n. 1
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()
Esempio n. 2
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()
Esempio n. 3
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()
Esempio n. 4
0
 tdir = tempfile.mkdtemp()
 n_img = n_mu_q_arr.shape[0]
 fnames = [os.path.join(tdir, 'x%02d.jpg' % i) for i in range(n_img) ]
 
 f = m.figure(1, size = (1000, 500), fgcolor = (0, 0, 0),
              bgcolor = (1., 1., 1.))
 
 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'
Esempio n. 5
0
    f = m.figure(1, size=(1000, 500), fgcolor=(0, 0, 0), bgcolor=(1., 1., 1.))

    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'
Esempio n. 6
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()
Esempio n. 7
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()