Beispiel #1
0
 def w_x_res(self, w_arr, ll, lr):
     self.CB_model_view.model.Ll = ll
     self.CB_model_view.model.Lr = lr
     cb_epsm_interpolators_lst = [
         MFnLineArray(xdata=np.linspace(-1e5, 1e5, 5), ydata=np.zeros(5))
     ]
     cb_epsf_interpolators_lst = [
         MFnLineArray(xdata=np.linspace(-1e5, 1e5, 5), ydata=np.zeros(5))
     ]
     sigma_c_lst = [0.0]
     w_lst = [0.0]
     for w in w_arr:
         self.CB_model_view.model.w = w
         if self.CB_model_view.sigma_c > sigma_c_lst[-1]:
             w_lst.append(w)
             sigma_c_lst.append(self.CB_model_view.sigma_c)
             x_i = np.hstack((-self.length - 1e-1, self.CB_model_view.x_arr,
                              self.length + 1e-1))
             epsm_i = np.hstack((self.CB_model_view.epsm_arr[0],
                                 self.CB_model_view.epsm_arr,
                                 self.CB_model_view.epsm_arr[-1]))
             epsf_i = np.hstack((self.CB_model_view.epsf_arr[0],
                                 self.CB_model_view.epsf_arr,
                                 self.CB_model_view.epsf_arr[-1]))
             cb_epsm_interpolators_lst.append(
                 MFnLineArray(xdata=x_i, ydata=epsm_i))
             cb_epsf_interpolators_lst.append(
                 MFnLineArray(xdata=x_i, ydata=epsf_i))
     w_interpolator = MFnLineArray(xdata=np.array(sigma_c_lst),
                                   ydata=np.array(w_lst))
     return w_interpolator, [sigma_c_lst, cb_epsm_interpolators_lst
                             ], [sigma_c_lst, cb_epsf_interpolators_lst]
Beispiel #2
0
 def get_epsf_x(self, w):
     '''
     evaluates the mean fiber strain profile at given load
     '''
     self.CB_model.w = w
     if self.CB_model.Ll > self.CB_model.Lr:
         epsf_interp = MFnLineArray(xdata=-self.CB_model._x_arr[::-1],
                                    ydata=self.CB_model._epsf_arr[::-1])
     else:
         epsf_interp = MFnLineArray(xdata=self.CB_model._x_arr,
                                    ydata=self.CB_model._epsf_arr)
     return epsf_interp.get_values(self.x)
 def w_x_results(self, w_arr, x):
     epsm = np.zeros((len(w_arr), len(x)))
     mu_epsf = np.zeros((len(w_arr), len(x)))
     sigma_c = []
     for i, w in enumerate(w_arr):
         self.model.w = w
         epsm_line = MFnLineArray(xdata=self.x_arr, ydata=self.epsm_arr)
         mu_epsf_line = MFnLineArray(xdata=self.x_arr,
                                     ydata=self.mu_epsf_arr)
         epsm[i, :] = epsm_line.get_values(x)
         mu_epsf[i, :] = mu_epsf_line.get_values(x)
         sigma_c.append(self.sigma_c)
     return epsm, mu_epsf, np.array(sigma_c)
 def montecarlo(self, N):
     ppf = MFnLineArray(xdata=self.hui_cdf, ydata=self.x)
     fragment_lengths = []
     for i in range(N):
         fragment_length = ppf.get_value(np.random.rand(1)) + ppf.get_value(
             np.random.rand(1))
         fragment_lengths.append(fragment_length / 2.)
     return np.array(fragment_lengths)
 def _get__epsm_arr(self):
     if len(self.sorted_reinf_lst[0]) != 0 and len(
             self.sorted_reinf_lst[1]) != 0:
         epsm_cont_interp = MFnLineArray(xdata=self.cont_fibers.x_arr,
                                         ydata=self.cont_fibers.epsm_arr)
         epsm_short_interp = MFnLineArray(xdata=self.short_fibers.x_arr,
                                          ydata=self.short_fibers.epsm_arr)
         added_epsm_cont = self.cont_fibers.epsm_arr + epsm_short_interp.get_values(
             self.cont_fibers.x_arr)
         added_epsm_short = self.short_fibers.epsm_arr + epsm_cont_interp.get_values(
             self.short_fibers.x_arr)
         sorted_unique_idx = np.unique(np.hstack(
             (self.cont_fibers.x_arr, self.short_fibers.x_arr)),
                                       return_index=True)[1]
         return np.hstack(
             (added_epsm_cont, added_epsm_short))[sorted_unique_idx]
     elif len(self.sorted_reinf_lst[0]) != 0:
         return self.cont_fibers.epsm_arr
     elif len(self.sorted_reinf_lst[1]) != 0:
         self.short_fibers.w = self.w
         return self.short_fibers.epsm_arr
Beispiel #6
0
 def _get_U_line(self):
     '''work done by external force - mfn_line'''
     w_arr = self.w_arr_energy
     u_lst = []
     F_lst = []
     for w in w_arr:
         self.model.w = w
         u_lst.append(self.u_evaluated)
         F_lst.append(self.sigma_c)
     u_arr = np.array(u_lst)
     F_arr = np.array(F_lst)
     U_line = MFnLineArray(xdata=w_arr, ydata=np.hstack((0, cumtrapz(F_arr, u_arr))))
     return U_line
Beispiel #7
0
 def _get_psi_line(self):
     try:
         psi = open('psi_Curtin', 'r')
         line = pickle.load(psi)
     except:
         eta_psi_vect = np.vectorize(self.intt)
         psi = np.linspace(1e-3, 4.99, 300)
         eta_psi_func = eta_psi_vect(psi)
         eta2 = np.linspace(0.7476 - e**(-2. * 0.577216) / 5, 0.74759, 500)
         psi2 = e**(-2. * 0.577216) / (0.7476 - eta2)
         line = MFnLineArray(xdata=np.hstack((eta_psi_func, eta2)),
                             ydata=np.hstack((psi, psi2)))
     return line
Beispiel #8
0
    def p_x(self, x_arr, P=0.2, order=1, **kw):
        '''
        returns p for a range of x
        '''
        kw['x'] = 0.0
        kw['w'] = 0.0

        w = newton(self.force_residuum, 1e-3, args=(order, P, kw))
        kw['w'] = w
        #x_arr = linspace( -kw['Ll'], kw['Lr'], np )
        p_arr = []
        for i, x in enumerate(x_arr):
            kw['x'] = x
            p_arr.append(self.mean_e_P(order=order, **kw).flatten())
        return MFnLineArray(xdata=x_arr, ydata=array(p_arr).flatten())
Beispiel #9
0
    def _friction_fets_default(self):
        width = self.specimen_width
        G = self.g * width
        T_max = self.t_max * width

        ifopen_law = MFnLineArray(ydata=[-1.0e+1, 0., 1.0e+10],
                                  xdata=[-1., 0., 1.])
        mats_ifopen = MATS1DElastic(stress_strain_curve=ifopen_law)

        mats = MATS1D5Bond(mats_phase1=MATS1DElastic(E=0),
                           mats_phase2=MATS1DElastic(E=0),
                           mats_ifslip=MATS1DPlastic(E=G,
                                                     sigma_y=T_max,
                                                     K_bar=0.,
                                                     H_bar=0.),
                           mats_ifopen=mats_ifopen)

        fets = FETS1D52L6ULRH(mats_eval=mats)  #quadratic
        fets.vtk_r *= self.vtk_r
        return fets
Beispiel #10
0
    def get_df_average(self, n_points):
        '''derive the average phi-function based on all entries
        in damage_function_list
        '''

        def get_y_average(self, x_average):
            '''get the y-values from the mfn-functions in df_list for
            'x_average' and return the average.
            Note that the shape of 'mfn.xdata' does not necessarily needs to be equal in all
            'DamageFunctionEntries' as the number of steps used for calibration or the adaptive
            refinement in 'tloop' might have been different for each case.
            '''
            y_list = [ self.damage_function_list[i].damage_function.get_value(x_average) \
                       for i in range(len(self.damage_function_list)) ]
            return sum(y_list) / len(y_list)

        get_y_average_vectorized = frompyfunc(get_y_average, 2, 1)

        mfn = MFnLineArray()

        # take the smallest value of the strains for the average function. Beyond this value
        # the average does not make sense anymore because it depends on the arbitrary number
        # of entries in the df_list
        #
        xdata_min = min(self.damage_function_list[i].damage_function.xdata[-1] \
                         for i in range(len(self.damage_function_list)))

        # number of sampling point used for the average phi function
        #
        mfn.xdata = linspace(0., xdata_min, num=n_points)

        # get the corresponding average ydata values
        #
        mfn.ydata = self.get_y_average_vectorized(mfn.xdata)

        return mfn
Beispiel #11
0
 def _get_matrix_strength(self):
     # evaluates a random field
     # realization and creates a spline reprezentation
     rf = self.random_field.random_field
     rf_spline = MFnLineArray(xdata=self.random_field.xgrid, ydata=rf)
     return rf_spline.get_values(self.x_arr)
Beispiel #12
0
        for w in w_arr:
            cdfs.append(self.Pw(w))
        return cdfs


if __name__ == '__main__':
    ac = AnalyticalCracks(l0=1.,
                          d=0.007,
                          tau=0.1,
                          sigma0=2200.,
                          s=2.0,
                          rho=5.0,
                          c=1.0,
                          x=np.linspace(0.0, 5.0, 500))
    for s in [1., 3., 5.0]:
        ac.s = s
        pdf_x = ac.p_x(s, ac.x)
        pdf_x = pdf_x / np.trapz(pdf_x, ac.x)
        cdf_x = np.hstack((0., cumtrapz(pdf_x, ac.x)))
        sf = MFnLineArray(xdata=cdf_x + 1e-12 * ac.x, ydata=ac.x)
        rand_vals1 = sf.get_values(np.random.rand(10000))
        rand_vals2 = sf.get_values(np.random.rand(10000))
        cracks = ac.w_func(rand_vals1, rand_vals2)
        plt.hist(cracks, bins=40, normed=True, label=str(s), cumulative=True)
        w_arr = np.linspace(0.0, 7.0, 100)
        cdf_w = ac.CDF_w(w_arr)
        plt.plot(w_arr, cdf_w, color='black', lw=2)
    plt.ylim(0, 1.2)
    plt.legend()
    plt.show()
Beispiel #13
0
 def _get_ctrl_indices(self):
     interp_indices_list = []
     for i, value in enumerate(self.ctrl_list):
         interp_array = MFnLineArray(xdata=value, ydata=arange(len(value)))
         interp_indices_list.append(interp_array)
     return interp_indices_list
Beispiel #14
0
 def _damage_law_default(self):
     return MFnLineArray(xdata=[0.0, 1.0],
                         ydata=[0.0, 0.0],
                         plot_diff=False)
Beispiel #15
0
 def _get_mean_curve( self ):
     '''Mean response curve.
     '''
     return MFnLineArray( xdata = self.eps_arr, ydata = self.mu_q_arr )
Beispiel #16
0
 def get_sigma_m_x_input(self, sigma):
     self.apply_load(sigma)
     line = MFnLineArray(xdata=self.x_arr,
                         ydata=self.epsm_arr)
     return line.get_values(self.x_input)
Beispiel #17
0
 def reset_stress_strain_curve(self):
     self._stress_strain_curve = MFnLineArray(ydata=[0., self.E],
                                              xdata=[0., 1.])
Beispiel #18
0
 def __stress_strain_curve_default(self):
     return MFnLineArray(ydata=[0., self.E], xdata=[0., 1.])
Beispiel #19
0
 def pdf(self, e, depsf, r, al, ar):
     cdf_line = MFnLineArray(xdata=e, ydata=self.cdf(e, depsf, r, al, ar))
     return cdf_line.get_diffs(e)
Beispiel #20
0
 def pdf(self, e, r, L):
     cdf_line = MFnLineArray(xdata=e, ydata=self.cdf(e, r, L))
     return cdf_line.get_diffs(e)
Beispiel #21
0
 def eta(self, psi):
     psi_line = MFnLineArray(xdata=self.psi_line.ydata,
                             ydata=self.psi_line.xdata)
     return psi_line.get_values(psi, k=1)
Beispiel #22
0
 def _mfn_default( self ):
     return MFnLineArray()
Beispiel #23
0
 def get_L(self, Ll, Lr):
     self.result_values
     BC_line = MFnLineArray(xdata=self.BC_range,
                            ydata=self.BC_range,
                            extrapolate='constant')
     return BC_line.get_values([Ll, Lr])
Beispiel #24
0
 def _get_var_curve( self ):
     '''variance of q at eps'''
     return MFnLineArray( xdata = self.eps_arr, ydata = self.var_q_arr )
    def _get_tloop(self):

        #fets_eval.mats_eval.nu = self.nu
        specmn = self.specmn_fe_grid

        if False:
            elstmr = self.elstmr_fe_grid
            supprt = self.supprt_fe_grid

        self.fe_domain.n_dofs

        self.center_top_dofs = specmn[0, 0, -1, 0, 0, -1].dofs
        center_bottom_dofs = specmn[0, 0, 0, 0, 0, 0].dofs

        support_elem = self.shape_y - 4

        #--------------------------------------------------------------
        # boundary conditions for the symmetry and the single support
        #--------------------------------------------------------------
        bc_symplane_yz = BCSlice(var='u',
                                 value=0.,
                                 dims=[0],
                                 slice=specmn[0, :, :, 0, :, :])
        bc_symplane_xz = BCSlice(var='u',
                                 value=0.,
                                 dims=[1],
                                 slice=specmn[:, 0, :, :, 0, :])

        #--------------------------------------------------------------
        # boundary conditions for the symmetry and the single support
        #--------------------------------------------------------------
        support_slice = specmn[-1, support_elem, :, -1, 0, :]
        support_000 = BCSlice(var='u',
                              value=0.,
                              dims=[0, 2],
                              slice=support_slice)

        #--------------------------------------------------------------
        # loading
        #--------------------------------------------------------------
        # w_max = center displacement:
        w_max = -0.07  # [m]

        time_function = MFnLineArray(xdata=[0.0, 0.2, 0.4, 1.0],
                                     ydata=[0.0, 0.2, 0.75, 1.0])

        bc_el_w = BCSlice(
            var='u',
            value=w_max,
            dims=[2],  #time_function = time_function.get_value,
            slice=specmn[0, 0, 0, 0, 0, 0])

        p_max = -0.0042 / (0.2 * 0.2)
        p_slice = specmn[:, 0, -1, :, :, -1]
        bc_el_w = BCSlice(
            var='f',
            value=p_max,
            dims=[2],
            integ_domain='local',  #time_function = time_function.get_value,
            slice=p_slice)

        #--------------------------------------------------------------
        # ts
        #--------------------------------------------------------------
        center_dof = center_bottom_dofs[0, 0, 2]
        # center_top_line_dofs
        #
        #ctl_dofs = elstmr[:, :, -1, :, :, -1].dofs[:, :, 2].flatten()

        # force-displacement-diagram
        #
        self.f_w_diagram_center = RTraceGraph(
            name='displacement (center) - reaction 2',
            var_x='U_k',
            idx_x=center_dof,
            # elastomer load
            var_y='F_int',
            idx_y_arr=support_slice.dofs[:, :, 2].flatten(),
            record_on='update',
            transform_x='-x * 1000',  # %g * x' % ( fabs( w_max ),),
            # due to symmetry the total force sums up from four parts of the beam (2 symmetry axis):
            #
            transform_y='-2 * 1000. * y')

        bcond_list = [
            bc_symplane_yz,
            bc_symplane_xz,
            support_000,
            # var 1:
            bc_el_w,
            #                               bc_center_w,
            #                               # var 2:
            #                               bc_center_w_elem,
            #                               # var 3:
            #                               bc_center_w_xline, bc_center_w_yline
        ]
        rtrace_list = [
            self.f_w_diagram_center,
            RTraceDomainListField(name='Displacement',
                                  var='u',
                                  idx=0,
                                  warp=True),

            #                             RTraceDomainListField(name = 'Stress' ,
            #                                            var = 'sig_app', idx = 0, warp = True,
            #                                            record_on = 'update'),
            #                             RTraceDomainListField(name = 'Strain' ,
            #                                        var = 'eps_app', idx = 0, warp = True,
            #                                        record_on = 'update'),
            RTraceDomainListField(name='Damage',
                                  var='omega_mtx',
                                  idx=0,
                                  warp=True,
                                  record_on='update'),
            RTraceDomainListField(
                name='max principle stress',
                idx=0,
                var='max_principle_sig',
                warp=True,
                #                                      position = 'int_pnts',
                record_on='update',
            )
            #                             RTraceDomainListField(name = 'IStress' ,
            #                                            position = 'int_pnts',
            #                                            var = 'sig_app', idx = 0,
            #                                            record_on = 'update'),
            #                             RTraceDomainListField(name = 'IStrain' ,
            #                                            position = 'int_pnts',
            #                                            var = 'eps_app', idx = 0,
            #                                            record_on = 'update'),
        ]

        ts = TS(sdomain=self.fe_domain,
                bcond_list=bcond_list,
                rtrace_list=rtrace_list)

        print 'tstep', self.tstep
        # Add the time-loop control
        tloop = TLoop(
            tstepper=ts,

            #                       # allow only a low tolerance
            #                       #
            #                       KMAX = 50,
            #                       tolerance = 5e-4,

            # allow a high tolerance
            #
            KMAX=100,
            tolerance=0.001,

            #                       # allow a very high tolerance
            #                       #
            #                       KMAX = 50,
            #                       tolerance = 0.01,
            RESETMAX=0,
            debug=False,
            tline=TLine(min=0.0, step=self.tstep, max=1))

        return tloop