コード例 #1
0
def sims3D():
    circrad = 0.01  #millimeters
    eps = 0.003
    zh = 2 * circrad
    halfzpts = 40
    X, Ves, Vrb, Vzline, zline = constructSolns(circrad, eps, zh, halfzpts,
                                                regSolnChainofSpheresNegExp)
    mydict = {
        'X': X,
        'Ves': Ves,
        'Vrb': Vrb,
        'circrad': circrad,
        'eps': eps,
        'zh': zh,
        'halfzpts': halfzpts
    }
    basedir = os.path.expanduser('~/CricketProject/CompReg2Exact/')
    basename = 'negexpspheres_BCsonaxis_zhdiameter_largereps40x2pts'
    F = open(os.path.join(basedir, basename + '.pickle'), 'w')
    cPickle.Pickler(F).dump(mydict)
    F.close()
    mydict = fo.loadPickle(basedir=basedir, basename=basename)
    graphSolns(mydict['X'], mydict['Ves'], mydict['Vrb'], mydict['circrad'],
               basedir, basename)
    vRS.plainPlots(zline, np.abs(Vzline[:, 0]), "|u|", "z", "velocity", None,
                   basedir + basename + '/zline_umag.pdf')
    vRS.plainPlots(zline, np.abs(Vzline[:, 1]), "|v|", "z", "velocity", None,
                   basedir + basename + '/zline_vmag.pdf')
    vRS.plainPlots(zline, np.abs(Vzline[:, 2]), "|w|", "z", "velocity", None,
                   basedir + basename + '/zline_wmag.pdf')
コード例 #2
0
def adderrs_Linf(fname,mydict=None):
    if mydict == None:
        basedir,basename = os.path.split(fname)
        mydict = fo.loadPickle(basename=basename,basedir=basedir,newfolder=False)
    d = fo.ExtractDict(mydict)
    umag_Linf_err_negex = np.zeros((len(d.freqlist),len(d.epslist),3))
    uang_Linf_err_negex = np.zeros((len(d.freqlist),len(d.epslist),3))
    umag_Linf_err_gauss = np.zeros((len(d.freqlist),len(d.epslist),3))
    uang_Linf_err_gauss = np.zeros((len(d.freqlist),len(d.epslist),3))
    umag_Linf_axiserr_negex = np.zeros((len(d.freqlist),len(d.epslist),3))
    uang_Linf_axiserr_negex = np.zeros((len(d.freqlist),len(d.epslist),3))
    umag_Linf_axiserr_gauss = np.zeros((len(d.freqlist),len(d.epslist),3))
    uang_Linf_axiserr_gauss = np.zeros((len(d.freqlist),len(d.epslist),3))
    umag_Linf_relerr_negex = np.zeros((len(d.freqlist),len(d.epslist),3))
    uang_Linf_relerr_negex = np.zeros((len(d.freqlist),len(d.epslist),3))
    umag_Linf_relerr_gauss = np.zeros((len(d.freqlist),len(d.epslist),3))
    uang_Linf_relerr_gauss = np.zeros((len(d.freqlist),len(d.epslist),3))
    umag_Linf_axisrelerr_negex = np.zeros((len(d.freqlist),len(d.epslist),3))
    uang_Linf_axisrelerr_negex = np.zeros((len(d.freqlist),len(d.epslist),3))
    umag_Linf_axisrelerr_gauss = np.zeros((len(d.freqlist),len(d.epslist),3))
    uang_Linf_axisrelerr_gauss = np.zeros((len(d.freqlist),len(d.epslist),3))
    ind = np.nonzero(d.pdict['obspts'][:,0]**2 + d.pdict['obspts'][:,1]**2 > 4*d.pdict['circrad']**2)
    zh = d.pdict['obsptszline'][1,2] - d.pdict['obsptszline'][0,2]
    print(zh) 
    print("Calculating error....")
    for j in range(len(d.freqlist)):
#        umlevs = vRS.contourCircle(d.pdict['obspts'][:,0],d.pdict['obspts'][:,1],d.pdict['circrad'],np.abs(u_exact[j]),os.path.expanduser('~/CricketProject/ChooseEpsilon/zradius_umag_exact_freq%03d.pdf' % freq))
#        ualevs = vRS.contourCircle(d.pdict['obspts'][:,0],d.pdict['obspts'][:,1],d.pdict['circrad'],np.angle(u_exact[j]),os.path.expanduser('~/CricketProject/ChooseEpsilon/zradius_uang_exact_freq%03d.pdf' % freq))
#        vmlevs = vRS.contourCircle(d.pdict['obspts'][:,0],d.pdict['obspts'][:,1],d.pdict['circrad'],np.abs(v_exact[j]),os.path.expanduser('~/CricketProject/ChooseEpsilon/zradius_vmag_exact_freq%03d.pdf' % freq))
#        valevs = vRS.contourCircle(d.pdict['obspts'][:,0],d.pdict['obspts'][:,1],d.pdict['circrad'],np.angle(v_exact[j]),os.path.expanduser('~/CricketProject/ChooseEpsilon/zradius_vang_exact_freq%03d.pdf' % freq))
        for k in range(len(d.epslist)):
            umag_Linf_err_negex, uang_Linf_err_negex = calcErrLinf(umag_Linf_err_negex, uang_Linf_err_negex,d.u_exact[j][ind],d.v_exact[j][ind],0.0,d.u_negex[j][k][ind],d.v_negex[j][k][ind],d.w_negex[j][k][ind],j,k)
            umag_Linf_err_gauss, uang_Linf_err_gauss = calcErrLinf(umag_Linf_err_gauss, uang_Linf_err_gauss,d.u_exact[j][ind],d.v_exact[j][ind],0.0,d.u_gauss[j][k][ind],d.v_gauss[j][k][ind],d.w_gauss[j][k][ind],j,k)
            umag_Linf_axiserr_negex, uang_Linf_axiserr_negex = calcErrLinf(umag_Linf_axiserr_negex, uang_Linf_axiserr_negex,np.median(d.uz_negex[j][k]),np.median(d.vz_negex[j][k]),np.median(d.wz_negex[j][k]),d.uz_negex[j][k],d.vz_negex[j][k],d.wz_negex[j][k],j,k)
            umag_Linf_axiserr_gauss, uang_Linf_axiserr_gauss = calcErrLinf(umag_Linf_axiserr_gauss, uang_Linf_axiserr_gauss,np.median(d.uz_gauss[j][k]),np.median(d.vz_gauss[j][k]),np.median(d.wz_gauss[j][k]),d.uz_gauss[j][k],d.vz_gauss[j][k],d.wz_gauss[j][k],j,k)
            umag_Linf_relerr_negex, uang_Linf_relerr_negex = calcRelErrLinf(umag_Linf_relerr_negex, uang_Linf_relerr_negex,d.u_exact[j][ind],d.v_exact[j][ind],0.0,d.u_negex[j][k][ind],d.v_negex[j][k][ind],d.w_negex[j][k][ind],j,k)
            umag_Linf_relerr_gauss, uang_Linf_relerr_gauss = calcRelErrLinf(umag_Linf_relerr_gauss, uang_Linf_relerr_gauss,d.u_exact[j][ind],d.v_exact[j][ind],0.0,d.u_gauss[j][k][ind],d.v_gauss[j][k][ind],d.w_gauss[j][k][ind],j,k)
            umag_Linf_axisrelerr_negex, uang_Linf_axisrelerr_negex = calcRelErrLinf(umag_Linf_axisrelerr_negex, uang_Linf_axisrelerr_negex,np.median(d.uz_negex[j][k]),np.median(d.vz_negex[j][k]),np.median(d.wz_negex[j][k]),d.uz_negex[j][k],d.vz_negex[j][k],d.wz_negex[j][k],j,k)
            umag_Linf_axisrelerr_gauss, uang_Linf_axisrelerr_gauss = calcRelErrLinf(umag_Linf_axisrelerr_gauss, uang_Linf_axisrelerr_gauss,np.median(d.uz_gauss[j][k]),np.median(d.vz_gauss[j][k]),np.median(d.wz_gauss[j][k]),d.uz_gauss[j][k],d.vz_gauss[j][k],d.wz_gauss[j][k],j,k)
    #add entries to dict and save
    mydict['umag_Linf_err_negex'] = umag_Linf_err_negex
    mydict['umag_Linf_err_gauss'] = umag_Linf_err_gauss
    mydict['uang_Linf_err_negex'] = uang_Linf_err_negex
    mydict['uang_Linf_err_gauss'] = uang_Linf_err_gauss
    mydict['umag_Linf_axiserr_negex'] = umag_Linf_axiserr_negex
    mydict['umag_Linf_axiserr_gauss'] = umag_Linf_axiserr_gauss
    mydict['uang_Linf_axiserr_negex'] = uang_Linf_axiserr_negex
    mydict['uang_Linf_axiserr_gauss'] = uang_Linf_axiserr_gauss
    mydict['umag_Linf_relerr_negex'] = umag_Linf_relerr_negex
    mydict['umag_Linf_relerr_gauss'] = umag_Linf_relerr_gauss
    mydict['uang_Linf_relerr_negex'] = uang_Linf_relerr_negex
    mydict['uang_Linf_relerr_gauss'] = uang_Linf_relerr_gauss
    mydict['umag_Linf_axisrelerr_negex'] = umag_Linf_axisrelerr_negex
    mydict['umag_Linf_axisrelerr_gauss'] = umag_Linf_axisrelerr_gauss
    mydict['uang_Linf_axisrelerr_negex'] = uang_Linf_axisrelerr_negex
    mydict['uang_Linf_axisrelerr_gauss'] = uang_Linf_axisrelerr_gauss
    F = open( fname+'.pickle', 'w' )
    Pickler(F).dump(mydict)
    F.close()
コード例 #3
0
def sims3D():
    circrad = 0.01 #millimeters
    eps = 0.003
    zh = 2*circrad
    halfzpts = 40
    X, Ves, Vrb, Vzline,zline = constructSolns(circrad,eps,zh,halfzpts,regSolnChainofSpheresNegExp)
    mydict = {'X':X,'Ves':Ves,'Vrb':Vrb,'circrad':circrad,'eps':eps,'zh':zh,'halfzpts':halfzpts}
    basedir = os.path.expanduser('~/CricketProject/CompReg2Exact/')
    basename = 'negexpspheres_BCsonaxis_zhdiameter_largereps40x2pts'
    F = open( os.path.join(basedir,basename+'.pickle'), 'w' )
    cPickle.Pickler(F).dump(mydict)
    F.close()
    mydict = fo.loadPickle(basedir=basedir,basename=basename)    
    graphSolns(mydict['X'],mydict['Ves'],mydict['Vrb'],mydict['circrad'],basedir,basename)
    vRS.plainPlots(zline,np.abs(Vzline[:,0]),"|u|","z","velocity",None,basedir+basename+'/zline_umag.pdf')
    vRS.plainPlots(zline,np.abs(Vzline[:,1]),"|v|","z","velocity",None,basedir+basename+'/zline_vmag.pdf')
    vRS.plainPlots(zline,np.abs(Vzline[:,2]),"|w|","z","velocity",None,basedir+basename+'/zline_wmag.pdf')
コード例 #4
0
def adderrs_Linf(fname, mydict=None):
    if mydict == None:
        basedir, basename = os.path.split(fname)
        mydict = fo.loadPickle(basename=basename,
                               basedir=basedir,
                               newfolder=False)
    d = fo.ExtractDict(mydict)
    umag_Linf_err_negex = np.zeros((len(d.freqlist), len(d.epslist), 3))
    uang_Linf_err_negex = np.zeros((len(d.freqlist), len(d.epslist), 3))
    umag_Linf_err_gauss = np.zeros((len(d.freqlist), len(d.epslist), 3))
    uang_Linf_err_gauss = np.zeros((len(d.freqlist), len(d.epslist), 3))
    umag_Linf_axiserr_negex = np.zeros((len(d.freqlist), len(d.epslist), 3))
    uang_Linf_axiserr_negex = np.zeros((len(d.freqlist), len(d.epslist), 3))
    umag_Linf_axiserr_gauss = np.zeros((len(d.freqlist), len(d.epslist), 3))
    uang_Linf_axiserr_gauss = np.zeros((len(d.freqlist), len(d.epslist), 3))
    umag_Linf_relerr_negex = np.zeros((len(d.freqlist), len(d.epslist), 3))
    uang_Linf_relerr_negex = np.zeros((len(d.freqlist), len(d.epslist), 3))
    umag_Linf_relerr_gauss = np.zeros((len(d.freqlist), len(d.epslist), 3))
    uang_Linf_relerr_gauss = np.zeros((len(d.freqlist), len(d.epslist), 3))
    umag_Linf_axisrelerr_negex = np.zeros((len(d.freqlist), len(d.epslist), 3))
    uang_Linf_axisrelerr_negex = np.zeros((len(d.freqlist), len(d.epslist), 3))
    umag_Linf_axisrelerr_gauss = np.zeros((len(d.freqlist), len(d.epslist), 3))
    uang_Linf_axisrelerr_gauss = np.zeros((len(d.freqlist), len(d.epslist), 3))
    ind = np.nonzero(d.pdict['obspts'][:, 0]**2 +
                     d.pdict['obspts'][:, 1]**2 > 4 * d.pdict['circrad']**2)
    zh = d.pdict['obsptszline'][1, 2] - d.pdict['obsptszline'][0, 2]
    print(zh)
    print("Calculating error....")
    for j in range(len(d.freqlist)):
        #        umlevs = vRS.contourCircle(d.pdict['obspts'][:,0],d.pdict['obspts'][:,1],d.pdict['circrad'],np.abs(u_exact[j]),os.path.expanduser('~/CricketProject/ChooseEpsilon/zradius_umag_exact_freq%03d.pdf' % freq))
        #        ualevs = vRS.contourCircle(d.pdict['obspts'][:,0],d.pdict['obspts'][:,1],d.pdict['circrad'],np.angle(u_exact[j]),os.path.expanduser('~/CricketProject/ChooseEpsilon/zradius_uang_exact_freq%03d.pdf' % freq))
        #        vmlevs = vRS.contourCircle(d.pdict['obspts'][:,0],d.pdict['obspts'][:,1],d.pdict['circrad'],np.abs(v_exact[j]),os.path.expanduser('~/CricketProject/ChooseEpsilon/zradius_vmag_exact_freq%03d.pdf' % freq))
        #        valevs = vRS.contourCircle(d.pdict['obspts'][:,0],d.pdict['obspts'][:,1],d.pdict['circrad'],np.angle(v_exact[j]),os.path.expanduser('~/CricketProject/ChooseEpsilon/zradius_vang_exact_freq%03d.pdf' % freq))
        for k in range(len(d.epslist)):
            umag_Linf_err_negex, uang_Linf_err_negex = calcErrLinf(
                umag_Linf_err_negex, uang_Linf_err_negex, d.u_exact[j][ind],
                d.v_exact[j][ind], 0.0, d.u_negex[j][k][ind],
                d.v_negex[j][k][ind], d.w_negex[j][k][ind], j, k)
            umag_Linf_err_gauss, uang_Linf_err_gauss = calcErrLinf(
                umag_Linf_err_gauss, uang_Linf_err_gauss, d.u_exact[j][ind],
                d.v_exact[j][ind], 0.0, d.u_gauss[j][k][ind],
                d.v_gauss[j][k][ind], d.w_gauss[j][k][ind], j, k)
            umag_Linf_axiserr_negex, uang_Linf_axiserr_negex = calcErrLinf(
                umag_Linf_axiserr_negex, uang_Linf_axiserr_negex,
                np.median(d.uz_negex[j][k]), np.median(d.vz_negex[j][k]),
                np.median(d.wz_negex[j][k]), d.uz_negex[j][k],
                d.vz_negex[j][k], d.wz_negex[j][k], j, k)
            umag_Linf_axiserr_gauss, uang_Linf_axiserr_gauss = calcErrLinf(
                umag_Linf_axiserr_gauss, uang_Linf_axiserr_gauss,
                np.median(d.uz_gauss[j][k]), np.median(d.vz_gauss[j][k]),
                np.median(d.wz_gauss[j][k]), d.uz_gauss[j][k],
                d.vz_gauss[j][k], d.wz_gauss[j][k], j, k)
            umag_Linf_relerr_negex, uang_Linf_relerr_negex = calcRelErrLinf(
                umag_Linf_relerr_negex, uang_Linf_relerr_negex,
                d.u_exact[j][ind], d.v_exact[j][ind], 0.0,
                d.u_negex[j][k][ind], d.v_negex[j][k][ind],
                d.w_negex[j][k][ind], j, k)
            umag_Linf_relerr_gauss, uang_Linf_relerr_gauss = calcRelErrLinf(
                umag_Linf_relerr_gauss, uang_Linf_relerr_gauss,
                d.u_exact[j][ind], d.v_exact[j][ind], 0.0,
                d.u_gauss[j][k][ind], d.v_gauss[j][k][ind],
                d.w_gauss[j][k][ind], j, k)
            umag_Linf_axisrelerr_negex, uang_Linf_axisrelerr_negex = calcRelErrLinf(
                umag_Linf_axisrelerr_negex, uang_Linf_axisrelerr_negex,
                np.median(d.uz_negex[j][k]), np.median(d.vz_negex[j][k]),
                np.median(d.wz_negex[j][k]), d.uz_negex[j][k],
                d.vz_negex[j][k], d.wz_negex[j][k], j, k)
            umag_Linf_axisrelerr_gauss, uang_Linf_axisrelerr_gauss = calcRelErrLinf(
                umag_Linf_axisrelerr_gauss, uang_Linf_axisrelerr_gauss,
                np.median(d.uz_gauss[j][k]), np.median(d.vz_gauss[j][k]),
                np.median(d.wz_gauss[j][k]), d.uz_gauss[j][k],
                d.vz_gauss[j][k], d.wz_gauss[j][k], j, k)
    #add entries to dict and save
    mydict['umag_Linf_err_negex'] = umag_Linf_err_negex
    mydict['umag_Linf_err_gauss'] = umag_Linf_err_gauss
    mydict['uang_Linf_err_negex'] = uang_Linf_err_negex
    mydict['uang_Linf_err_gauss'] = uang_Linf_err_gauss
    mydict['umag_Linf_axiserr_negex'] = umag_Linf_axiserr_negex
    mydict['umag_Linf_axiserr_gauss'] = umag_Linf_axiserr_gauss
    mydict['uang_Linf_axiserr_negex'] = uang_Linf_axiserr_negex
    mydict['uang_Linf_axiserr_gauss'] = uang_Linf_axiserr_gauss
    mydict['umag_Linf_relerr_negex'] = umag_Linf_relerr_negex
    mydict['umag_Linf_relerr_gauss'] = umag_Linf_relerr_gauss
    mydict['uang_Linf_relerr_negex'] = uang_Linf_relerr_negex
    mydict['uang_Linf_relerr_gauss'] = uang_Linf_relerr_gauss
    mydict['umag_Linf_axisrelerr_negex'] = umag_Linf_axisrelerr_negex
    mydict['umag_Linf_axisrelerr_gauss'] = umag_Linf_axisrelerr_gauss
    mydict['uang_Linf_axisrelerr_negex'] = uang_Linf_axisrelerr_negex
    mydict['uang_Linf_axisrelerr_gauss'] = uang_Linf_axisrelerr_gauss
    F = open(fname + '.pickle', 'w')
    Pickler(F).dump(mydict)
    F.close()
コード例 #5
0
        negex.append(lRS.Brinkman3DNegExpBlob(r,eps))
        gauss.append(lRS.Brinkman3DGaussianBlob(r,eps))
    leg = ['$\epsilon$ = ' + str(s) for s in epslist]
    plainPlots(r,np.asarray(negex).transpose(),'Negative Exponential Blob','distance (mm) from blob location','blob strength',leg,basedir+basename+'/negexpblob%05d.pdf' % int(np.round(epslist[0]*100000)))
    plainPlots(r,np.asarray(gauss).transpose(),'Gaussian Exponential Blob','distance (mm) from blob location','blob strength',leg,basedir+basename+'/gaussblob%05d.pdf' % int(np.round(epslist[0]*100000)))

if __name__ == '__main__':
    basedir = os.path.expanduser('~/CricketProject/QuasiSteadyVSFourier/')
    if not os.path.exists(basedir):
        basedir = '/Volumes/PATRIOT32G/CricketProject/QuasiSteadyVSFourier/'   
        if not os.path.exists(basedir):        
            print('Choose a different directory for saving files')
            raise(SystemExit)
    basename = 'multfreqs_050_095'
    print('loading file...')
    mydict = fo.loadPickle(basename=basename,basedir=basedir)
    N = mydict['u_fourier'].shape[1]
    tvec = mydict['dt']*np.arange(0,N)
    for ptind in [0,len(mydict['x'])/2,len(mydict['x'])-1]:
        myPlots(tvec,np.real(mydict['u_fourier'][ptind,:]),'location = %0.2f' % mydict['x'][ptind],'time','velocity',fname=os.path.join(os.path.join(basedir,basename),'u_fourier_point%02d.pdf' % ptind),stylestr='k-')
        myPlots(tvec,np.real(mydict['u_quasi'][ptind,:]),'location = %0.2f' % mydict['x'][ptind],'time','velocity',fname=os.path.join(os.path.join(basedir,basename),'u_quasi_point%02d.pdf' % ptind),stylestr='k-')
    maxvec_fouri = np.zeros(mydict['x'].shape)
    maxvec_quasi = np.zeros(mydict['x'].shape)
    for ptind in range(len(mydict['x'])):
        maxvec_fouri[ptind] = np.max(np.real(mydict['u_fourier'][ptind,int(N/2):]))
        maxvec_quasi[ptind] = np.max(np.real(mydict['u_quasi'][ptind,int(N/2):]))
    #print(maxvec_quasi)
    #print(maxvec_fouri)
    #plot fourier results
    myPlots(mydict['x'],maxvec_fouri,None,'initial location','max velocity','fourier simulation',plt.loglog,os.path.join(os.path.join(basedir,basename),'u_fourier_xdecay.pdf'),stylestr='k-')
    #plot slope of -3
コード例 #6
0
        r,
        np.asarray(gauss).transpose(), 'Gaussian Exponential Blob',
        'distance (mm) from blob location', 'blob strength', leg, basedir +
        basename + '/gaussblob%05d.pdf' % int(np.round(epslist[0] * 100000)))


if __name__ == '__main__':
    basedir = os.path.expanduser('~/CricketProject/QuasiSteadyVSFourier/')
    if not os.path.exists(basedir):
        basedir = '/Volumes/PATRIOT32G/CricketProject/QuasiSteadyVSFourier/'
        if not os.path.exists(basedir):
            print('Choose a different directory for saving files')
            raise (SystemExit)
    basename = 'multfreqs_050_095'
    print('loading file...')
    mydict = fo.loadPickle(basename=basename, basedir=basedir)
    N = mydict['u_fourier'].shape[1]
    tvec = mydict['dt'] * np.arange(0, N)
    for ptind in [0, len(mydict['x']) / 2, len(mydict['x']) - 1]:
        myPlots(tvec,
                np.real(mydict['u_fourier'][ptind, :]),
                'location = %0.2f' % mydict['x'][ptind],
                'time',
                'velocity',
                fname=os.path.join(os.path.join(basedir, basename),
                                   'u_fourier_point%02d.pdf' % ptind),
                stylestr='k-')
        myPlots(tvec,
                np.real(mydict['u_quasi'][ptind, :]),
                'location = %0.2f' % mydict['x'][ptind],
                'time',