def init_expt(self, data_len): ''' self.mu: (aug_dim, data_len) self.cov: (aug_dim, aug_dim) self.prec: (aug_dim, aug_dim) self.expt2: (aug_dim, aug_dim, data_len) ''' self.mu = tile(self.prior.mu, (1, data_len)) self.cov = ncopy(self.prior.cov[:, :, 0]) self.prec = ncopy(self.prior.prec[:, :, 0]) self.expt2 = self.calc_expt2()
def make_data( x, y, z ): """Creates some simple array data of the given dimensions to test with.""" x = x.astype( 'f' ) y = y.astype( 'f' ) z = z.astype( 'f' ) arr_list = [x, y, z] n_arr = len( arr_list ) ogrid = [] for i, arr in enumerate( arr_list ): shape = ones( ( n_arr, ), dtype='int' ) shape[i] = len( arr ) arr_i = ncopy( arr ).reshape( tuple( shape ) ) ogrid.append( arr_i ) x, y, z = ogrid scalars = x * z * y #(numpy.sin(x*y*z)/(x*y*z)) # The copy makes the data contiguous and the transpose makes it # suitable for display via tvtk. Please note that we assume here # that the ArraySource is configured to not transpose the data. s = transpose( scalars ).copy() # Reshaping the array is needed since the transpose messes up the # dimensions of the data. The scalars themselves are ravel'd and # used internally by VTK so the dimension does not matter for the # scalars. s.shape = s.shape[::-1] return s
def shuffle(self, array): """Suffle a list""" self.logger.log("Shuffling array") try: new_array = ncopy(array) nshuffle(new_array) return new_array except Exception as excpt: self.logger.log(excpt)
def orthogonalize( arr_list ): '''Orthogonalize a list of one-dimensional arrays. ''' n_arr = len( arr_list ) ogrid = [] for i, arr in enumerate( arr_list ): shape = ones( ( n_arr, ), dtype = 'int' ) shape[i] = len( arr ) arr_i = ncopy( arr ).reshape( tuple( shape ) ) ogrid.append( arr_i ) return ogrid
def orthogonalize( arr_list ): '''Orthogonalize a list of one-dimensional arrays. ''' n_arr = len( arr_list ) ogrid = [] for i, arr in enumerate( arr_list ): shape = ones( ( n_arr, ), dtype='int' ) shape[i] = len( arr ) arr_i = ncopy( arr ).reshape( tuple( shape ) ) ogrid.append( arr_i ) return ogrid
def layer_response_eps_t_eps_c( self, u, thickness_unreinf ): '''Unknown constitutive law of the layer ''' eps_t, eps_c = u E_yarn = self.E_yarn self.eps_c = eps_c # print 'eps_c XXX', eps_c thickness = self.thickness_reinf + thickness_unreinf mask_arr_reinf = hstack( [ ones( self.n_layers / 2 ), zeros( self.n_layers / 2 )] ) z_t_i_arr = self.z_t_i_arr + mask_arr_reinf * thickness_unreinf # ------------------------------------ # derived params depending on value for 'eps_t' # ------------------------------------ # heights of the compressive zone: # x = abs( eps_c ) / ( abs( eps_c ) + abs( eps_t ) ) * thickness # print 'x', x # strain at the height of each reinforcement layer [-]: # eps_t_i_arr = eps_t / ( thickness - x ) * ( z_t_i_arr - x ) # use a ramp function to consider only positive strains eps_t_i_arr = ( fabs( eps_t_i_arr ) + eps_t_i_arr ) / 2.0 # print 'eps_t_i_arr', eps_t_i_arr self.eps_t_i_arr = ncopy( eps_t_i_arr ) # construct the constitutive law of the crack bridge - linear elastic # with the search effective modulus of elasticity # eps_fail = eps_t sig_fail = E_yarn * eps_fail # linear law of the crack bridge # conservative for iteration of response due to imposed loads # 'Einwirkungsseite' # # xdata = array( [0., eps_fail ] ) # ydata = array( [0., sig_fail ] ) # plastic law of the crack bridge # conservative for iteration of resistance stress # 'Widerstandsseite' # xdata = array( [0, 0.01 * eps_fail, eps_fail ] ) ydata = array( [0, 0.99 * sig_fail, sig_fail ] ) mfn_line_array = MFnLineArray( xdata = xdata, ydata = ydata ) return x, eps_t_i_arr, mfn_line_array
def layer_response_eps_t_E_yarn( self, u, thickness_unreinf ): '''Unknown constitutive law of the layer ''' eps_t, E_yarn = u # ------------------------------------ # derived params depending on value for 'eps_t' # ------------------------------------ thickness = self.thickness_reinf + thickness_unreinf mask_arr_reinf = hstack( [ ones( self.n_layers / 2 ), zeros( self.n_layers / 2 )] ) z_t_i_arr = self.z_t_i_arr + mask_arr_reinf * thickness_unreinf # heights of the compressive zone: # x = abs( self.eps_c ) / ( abs( self.eps_c ) + abs( eps_t ) ) * thickness # print 'x', x # strain at the height of each reinforcement layer [-]: # eps_t_i_arr = eps_t / ( thickness - x ) * ( z_t_i_arr - x ) # use a ramp function to consider only positive strains eps_t_i_arr = ( fabs( eps_t_i_arr ) + eps_t_i_arr ) / 2.0 # print 'eps_t_i_arr', eps_t_i_arr self.eps_t_i_arr = ncopy( eps_t_i_arr ) # construct the constitutive law of the crack bridge - linear elastic # with the search effective modulus of elasticity # eps_fail = eps_t sig_fail = E_yarn * eps_fail xdata = array( [0., eps_fail ] ) ydata = array( [0., sig_fail ] ) mfn_line_array = MFnLineArray( xdata = xdata, ydata = ydata ) return x, eps_t_i_arr, mfn_line_array