Ejemplo n.º 1
0
    def returnDiff(params):
        """
        Tune using the given in-plane locus

        Arguments
        =========
        params [0]  :          rb
        params [1:4]:  y45,y90,yb
        """
        ## Find 4 parameters...
        paramR = np.ones(4)
        paramY = np.ones(4)

        paramR[0:4] = rv[0], rv[1], rv[2], params[0]
        paramY[1:4] = params[1:4]
        k = 2
        m = 8  ## the exponent is fixed?

        yldFunc = wrapYLD(r=paramR, y=paramY, m=m, k=k)
        if type(yldFunc).__name__ == 'int':
            if yldFunc == -1:
                return 1

        yldLocus = locus(yldFunc, 1000)  ##
        ## convert yldLocus in to (th,r) coordinates
        r, th = xy2rt(np.array(yldLocus[0]), np.array(yldLocus[1]))

        th0, r0 = YS  ## reference
        radIntp = rad_xy2(r, th, th0)
        radIntp = np.array(radIntp)

        return np.sqrt(((radIntp - r0)**2).sum()) / (len(r) - 1)
Ejemplo n.º 2
0
    def returnDiff(params):
        """
        Tune using the given in-plane locus

        Arguments
        =========
        params [0]  :          rb
        params [1:4]:  y45,y90,yb
        """
        ## Find 4 parameters...
        paramR = np.ones(4)
        paramY = np.ones(4)

        paramR[0:4]  = rv[0],rv[1],rv[2],params[0]
        paramY[1:4] = params[1:4]
        k=2; m=8 ## the exponent is fixed?

        yldFunc = wrapYLD(r=paramR,y=paramY,m=m,k=k)
        if type(yldFunc).__name__=='int':
            if yldFunc==-1:
                return 1

        yldLocus = locus(yldFunc,1000) ##
        ## convert yldLocus in to (th,r) coordinates
        r,th=xy2rt(np.array(yldLocus[0]),np.array(yldLocus[1]))

        th0,r0 = YS## reference
        radIntp = rad_xy2(r,th,th0)
        radIntp = np.array(radIntp)

        return np.sqrt(((radIntp-r0)**2).sum())/ (len(r)-1)
Ejemplo n.º 3
0
def main(ax=None):
    if type(ax).__name__ == 'NoneType':
        fig = plt.figure()
        ax = fig.add_subplot(111)
    import time
    t0 = time.time()

    ## two parameters from Jeong et al. Acta Mat 112, 2016
    ## for the interstitial-free steel
    r0 = 2.20
    r45 = 2.0
    r90 = 2.9

    ## the rest of parameters are assumed as 1.
    rb = 1.
    y0 = 1
    y45 = 1
    y90 = 1
    yb = 1.

    h48g = wrapHill48R([r0, r45, r90])
    yld2000 = wrapYLD(r=[r0, r45, r90, rb], y=[y0, y45, y90, yb], m=6, k=2)

    funcs = vm, h48g, yld2000
    labs = ['von Mises', 'Hill48R', 'yld2000']
    ls = ['-', '--', '-.', ':']
    xs = []
    ys = []
    t_indv = []
    for i in xrange(len(funcs)):
        t_indv0 = time.time()
        x, y = locus(funcs[i])
        t_indv.append(time.time() - t_indv0)
        xs.append(x)
        ys.append(y)

    for i in xrange(len(funcs)):
        print 'time %s :' % labs[i], t_indv[i]
    print 'total time:', time.time() - t0
    for i in xrange(len(funcs)):
        ax.plot(xs[i], ys[i], label=labs[i], ls=ls[i])

    ax.legend(loc='best')
    fn = 'vm_check.pdf'
    print '%s has been saved' % fn
    ax.set_xlim(-0.25, 1.75)
    ax.set_ylim(-0.25, 1.75)
    ax.set_aspect('equal')

    try:
        fig.savefig(fn)
    except:
        pass
Ejemplo n.º 4
0
def main(ax=None):
    if type(ax).__name__=='NoneType':
        fig = plt.figure()
        ax  = fig.add_subplot(111)
    import time
    t0=time.time()

    ## two parameters from Jeong et al. Acta Mat 112, 2016
    ## for the interstitial-free steel
    r0   = 2.20
    r45  = 2.0
    r90  = 2.9

    ## the rest of parameters are assumed as 1.
    rb   =1.
    y0   =1
    y45  =1
    y90  =1
    yb   =1.

    h48g = wrapHill48R([r0,r45,r90])
    yld2000 = wrapYLD(r=[r0,r45,r90,rb],y=[y0,y45,y90,yb],m=6,k=2)

    funcs =    vm,    h48g,        yld2000
    labs  = ['von Mises', 'Hill48R','yld2000']
    ls    = ['-','--','-.',':']
    xs=[];ys=[]
    t_indv=[]
    for i in xrange(len(funcs)):
        t_indv0= time.time()
        x,y = locus(funcs[i])
        t_indv.append(time.time()-t_indv0)
        xs.append(x)
        ys.append(y)

    for i in xrange(len(funcs)):
        print 'time %s :'%labs[i], t_indv[i]
    print 'total time:',time.time()-t0
    for i in xrange(len(funcs)):
        ax.plot(xs[i],ys[i],label=labs[i],ls=ls[i])

    ax.legend(loc='best')
    fn='vm_check.pdf'
    print '%s has been saved'%fn
    ax.set_xlim(-0.25,1.75)
    ax.set_ylim(-0.25,1.75)
    ax.set_aspect('equal')

    try:
        fig.savefig(fn)
    except:
        pass
Ejemplo n.º 5
0
def ex1():
    """
    Excercise - Tune H48 using three r-values and calculate YS.
    Using the three given r-values used in H48
    find rb, y0, y45, y90, and yb by fitting YS of H48 with
    that of yld2000-2d
    """
    import tuneH48
    import mk.yieldFunction.yf2 as yf2
    rv = [2.2, 2.0, 2.9]
    f, g, h, n = tuneH48.tuneGenR(r=rv)
    yfunc_H48 = yf2.wrapHill48Gen(f, g, h, n)
    YS_H48X, YS_H48Y = locus(yfunc_H48, 1000)
    r, th = xy2rt(np.array(YS_H48X), np.array(YS_H48Y))

    ## popt = [rv, y45, y90, yb]
    popt = case2([r, th], rv=rv)
    rv.append(popt[0])
    ys = np.ones(4)
    ys[1:] = popt[1:]

    ##
    print 'rv:', rv
    print 'ys:', ys
    yfunc_yld2000 = wrapYLD(r=rv, y=ys, m=8)

    import matplotlib.pyplot as plt
    fig = plt.figure()
    ax = fig.add_subplot(111)

    YS_YLDX, YS_YLDY = locus(yfunc_yld2000, 1000)
    ax.plot(YS_H48X, YS_H48Y, '-', label='Hill48')
    ax.plot(YS_YLDX, YS_YLDY, '-', label='YLD2000')
    ax.set_xlim(0., )
    ax.set_ylim(0., )
    ax.set_aspect('equal')
    ax.legend(loc='best')
    # print YS_YLDX
    # print YS_YLDY
    fig.savefig('Yld2000-Hill48.pdf')
Ejemplo n.º 6
0
def ex1():
    """
    Excercise - Tune H48 using three r-values and calculate YS.
    Using the three given r-values used in H48
    find rb, y0, y45, y90, and yb by fitting YS of H48 with
    that of yld2000-2d
    """
    import tuneH48
    import mk.yieldFunction.yf2 as yf2
    rv=[2.2,2.0,2.9]
    f,g,h,n = tuneH48.tuneGenR(r=rv)
    yfunc_H48 = yf2.wrapHill48Gen(f,g,h,n)
    YS_H48X, YS_H48Y = locus(yfunc_H48,1000)
    r, th = xy2rt(np.array(YS_H48X), np.array(YS_H48Y))

    ## popt = [rv, y45, y90, yb]
    popt = case2([r,th], rv=rv)
    rv.append(popt[0])
    ys = np.ones(4)
    ys[1:] = popt[1:]

    ##
    print 'rv:', rv
    print 'ys:', ys
    yfunc_yld2000 = wrapYLD(r=rv,y=ys,m=8)

    import matplotlib.pyplot as plt
    fig = plt.figure(); ax=fig.add_subplot(111)

    YS_YLDX, YS_YLDY = locus(yfunc_yld2000,1000)
    ax.plot(YS_H48X,YS_H48Y,'-',label='Hill48')
    ax.plot(YS_YLDX,YS_YLDY,'-',label='YLD2000')
    ax.set_xlim(0.,)
    ax.set_ylim(0.,)
    ax.set_aspect('equal')
    ax.legend(loc='best')
    # print YS_YLDX
    # print YS_YLDY
    fig.savefig('Yld2000-Hill48.pdf')