Esempio n. 1
0
def create_demo_object():

    #===========================================================================
    # Control variable
    #===========================================================================
    e_arr = np.linspace(0, 0.012, 80)

    powers = np.linspace(1, math.log(20, 10), 6)
    n_int_range = np.array(np.power(10, powers), dtype=int)

    #===========================================================================
    # Randomization
    #===========================================================================
    tvars = dict(
        fu=RV('weibull_min', 1200.0e6, 200.),
        qf=1500.0,
        # qf = RV('uniform', 1500., 100.),
        L=0.02,  # 
        # L = RV('uniform', 0.02, 0.02 / 2.),
        A=RV('norm', 5.30929158457e-10, .03 * 5.30929158457e-10),
        E_mod=RV('uniform', 70.e9, 250.e9),
        z=RV('uniform', 0.0, 0.03),
        phi=0.0,  # 
        # phi = RV('cos_distr', 0.0, 1.0),
        # phi = RV('uniform', 0.0, 1.0),
        f=RV('uniform', 0.0, 0.03))

    #===========================================================================
    # Integrator object
    #===========================================================================
    s = SPIRRID(
        q=ConstantFrictionFiniteFiber(),
        e_arr=e_arr,
        n_int=10,
        tvars=tvars,
    )

    #===========================================================================
    # Lab
    #===========================================================================
    slab = SPIRRIDLAB(s=s,
                      save_output=False,
                      show_output=True,
                      dpi=300,
                      qname='fiber_po_8p',
                      plot_mode='subplots',
                      n_int_range=n_int_range,
                      extra_compiler_args=True,
                      le_sampling_lst=['LHS', 'PGrid'],
                      le_n_int_lst=[10, 10],
                      plot_sampling_idx=[
                          0,
                          3,
                      ])

    return slab
Esempio n. 2
0
def create_demo_object():

    m_la, std_la = 10., 1.0
    m_xi, std_xi = 1.0, 0.1

    # discretize the control variable (x-axis)
    e_arr = np.linspace(0, 2.0, 80)

    # n_int range for sampling efficiency test
    powers = np.linspace(1, math.log(500, 10), 50)
    n_int_range = np.array(np.power(10, powers), dtype=int)

    #===========================================================================
    # Randomization
    #===========================================================================
    s = SPIRRID(
        q=fiber_tt_2p(),
        e_arr=e_arr,
        n_int=10,
        tvars=dict(la=RV('norm', m_la, std_la), xi=RV('norm', m_xi, std_xi)),
    )

    #===========================================================================
    # Exact solution
    #===========================================================================
    def mu_q_ex(e, m_xi, std_xi, m_la):
        return e * (0.5 - 0.5 * erf(0.5 * math.sqrt(2) *
                                    (e - m_xi) / std_xi)) * m_la

    #===========================================================================
    # Lab
    #===========================================================================
    slab = SPIRRIDLAB(s=s,
                      save_output=False,
                      show_output=True,
                      dpi=300,
                      exact_arr=mu_q_ex(e_arr, m_xi, std_xi, m_la),
                      plot_mode='subplots',
                      n_int_range=n_int_range,
                      extra_compiler_args=True,
                      le_sampling_lst=['LHS', 'PGrid'],
                      le_n_int_lst=[440, 5000])

    return slab
Esempio n. 3
0
    def setup_class(cls):

        np.random.seed(2356)

        #===========================================================================
        # Control variable
        #===========================================================================
        e_arr = np.linspace(0, 0.012, 80)

        cls.m_la, cls.std_la = 10., 1.0
        cls.m_xi, cls.std_xi = 1.0, 0.1

        #===========================================================================
        # Randomization
        #===========================================================================

        cls.s = SPIRRID(
            q=fiber_tt_2p(),
            evars={'e': e_arr},
            codegen_type='numpy',
            n_int=10,
            tvars=dict(la=RV('norm', cls.m_la, cls.std_la),
                       xi=RV('norm', cls.m_xi, cls.std_xi)),
        )
Esempio n. 4
0
                q - T * (abs(x) - l / 2.)) * Heaviside(abs(x) - l / 2.)
            q_x = q_x * Heaviside(x + Ll) * Heaviside(Lr - x)
            q_x = q_x * Heaviside(q_x)

            return q_x

    q = CBClampedFiberSP()

    s = SPIRRID(
        q=q,
        sampling_type='LHS',
        evars=dict(w=np.linspace(0.0, 0.4, 50),
                   x=np.linspace(-20.1, 20.5, 100),
                   Lr=np.linspace(0.1, 20.0, 50)),
        tvars=dict(
            tau=RV('uniform', 0.7, 1.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=5)

    e_arr = make_ogrid(s.evar_lst)
    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))
Esempio n. 5
0
def create_demo_object():

    D = 26 * 1.0e-6  # m
    A = (D / 2.0)**2 * math.pi

    # set the mean and standard deviation of the two random variables
    la_mean, la_stdev = 0.0, 0.2
    xi_mean, xi_stdev = 0.019027, 0.0022891
    E_mean, E_stdev = 70.0e+9, 15.0e+9
    th_mean, th_stdev = 0.0, 0.01
    A_mean, A_stdev = A * 0.3, 0.7 * A

    do = 'norm'

    if do == 'general':

        # set the mean and standard deviation of the two random variables
        la_mean, la_stdev = 0.0, 0.2
        xi_mean, xi_stdev = 0.019027, 0.0022891
        E_mean, E_stdev = 70.0e+9, 15.0e+9
        th_mean, th_stdev = 0.0, 0.01
        A_mean, A_stdev = A * 0.3, 0.7 * A

        # construct the normal distributions and get the methods
        # for the evaluation of the probability density functions
        g_la = RV('uniform', la_mean, la_stdev)
        g_xi = RV('norm', xi_mean, xi_stdev)
        g_E = RV('uniform', E_mean, E_stdev)
        g_th = RV('uniform', th_mean, th_stdev)
        g_A = RV('uniform', A_mean, A_stdev)

        mu_ex_file = 'fiber_tt_5p_30.txt'
        delimiter = ','

    elif do == 'uniform':

        # set the mean and standard deviation of the two random variables
        la_mean, la_stdev = 0.0, 0.2
        xi_mean, xi_stdev = 0.01, 0.02
        E_mean, E_stdev = 70.0e+9, 15.0e+9
        th_mean, th_stdev = 0.0, 0.01
        A_mean, A_stdev = A * 0.3, 0.7 * A

        # construct the uniform distributions and get the methods
        # for the evaluation of the probability density functions
        g_la = RV('uniform', la_mean, la_stdev)
        g_xi = RV('uniform', xi_mean, xi_stdev)
        g_E = RV('uniform', E_mean, E_stdev)
        g_th = RV('uniform', th_mean, th_stdev)
        g_A = RV('uniform', A_mean, A_stdev)

        mu_ex_file = 'fiber_tt_5p_40_unif.txt'
        delimiter = ' '

    elif do == 'norm':

        # set the mean and standard deviation of the two random variables
        la_mean, la_stdev = 0.1, 0.02
        xi_mean, xi_stdev = 0.019027, 0.0022891
        E_mean, E_stdev = 70.0e+9, 15.0e+9
        th_mean, th_stdev = 0.005, 0.001
        A_mean, A_stdev = 5.3e-10, 1.0e-11

        # construct the normal distributions and get the methods
        # for the evaluation of the probability density functions
        g_la = RV('norm', la_mean, la_stdev)
        g_xi = RV('norm', xi_mean, xi_stdev)
        g_E = RV('norm', E_mean, E_stdev)
        g_th = RV('norm', th_mean, th_stdev)
        g_A = RV('norm', A_mean, A_stdev)

        mu_ex_file = os.path.join(file_dir,
                                  'fiber_tt_5p_n_int_40_norm_exact.txt')
        delimiter = ' '

    # discretize the control variable (x-axis)
    e_arr = np.linspace(0, 0.04, 40)

    # n_int range for sampling efficiency test
    powers = np.linspace(1, math.log(20, 10), 15)
    n_int_range = np.array(np.power(10, powers), dtype=int)

    #===========================================================================
    # Randomization
    #===========================================================================
    s = SPIRRID(
        q=fiber_tt_5p(),
        e_arr=e_arr,
        n_int=10,
        tvars=dict(lambd=g_la, xi=g_xi, E_mod=g_E, theta=g_th, A=g_A),
    )

    # Exact solution
    def mu_q_ex(e):
        data = np.loadtxt(mu_ex_file, delimiter=delimiter)
        x, y = data[:, 0], data[:, 1]
        f = interp1d(x, y, kind='linear')
        return f(e)

    #===========================================================================
    # Lab
    #===========================================================================
    slab = SPIRRIDLAB(s=s,
                      save_output=False,
                      show_output=True,
                      dpi=300,
                      exact_arr=mu_q_ex(e_arr),
                      plot_mode='subplots',
                      n_int_range=n_int_range,
                      extra_compiler_args=True,
                      le_sampling_lst=['LHS', 'PGrid'],
                      le_n_int_lst=[25, 30])

    return slab
Esempio n. 6
0
 def _random_changed(self):
     # get the default distribution
     if self.random:
         self.spirrid.rv_dict[ self.varname ] = RV(pd = self.pd, name = self.varname, n_int = self.n_int)
     else:
         del self.spirrid.rv_dict[ self.varname ]