示例#1
0
def euler(nx, ny, dx, dy, dt, re, w, s, ii, jj, input_data, bc, bc3):

    if input_data['isolver'] == 3:
        w = bc3(nx, ny, w, s)
    else:
        w = bc(nx, ny, w, s)

    r = rhs(nx, ny, dx, dy, re, w, s, input_data)
    w[ii, jj] = w[ii, jj] + dt * r[ii, jj]

    s = poisson(nx, ny, dx, dy, w, input_data)

    return w, s
示例#2
0
def rk3(nx,ny,dx,dy,dt,re,w,s,ii,jj,input_data,bc,bc3):
    ip = input_data['ip']
    isolver = input_data['isolver']
    t = np.zeros((nx+1,ny+1))
    r = np.zeros((nx+1,ny+1))

    # time integration using third-order Runge Kutta method
    aa = 1.0/3.0
    bb = 2.0/3.0
    
    #stage-1
    r[:,:] = rhs(nx,ny,dx,dy,re,w[:,:],s[:,:],input_data)
    t[ii,jj] = w[ii,jj] + dt*r[ii,jj]
    if isolver == 3:
        t = bc3(nx,ny,t,s)
    else:
        t = bc(nx,ny,t,s) 
    s = poisson(nx,ny,dx,dy,t,input_data)

    #stage-2
    r[:,:] = rhs(nx,ny,dx,dy,re,t[:,:],s[:,:],input_data)
    t[ii,jj] = 0.75*w[ii,jj] + 0.25*t[ii,jj] + 0.25*dt*r[ii,jj]
    if isolver == 3:
        t = bc3(nx,ny,t,s)
    else:
        t = bc(nx,ny,t,s)    
    s[:,:] = poisson(nx,ny,dx,dy,t,input_data)

    #stage-3
    r[:,:] = rhs(nx,ny,dx,dy,re,t[:,:],s[:,:],input_data)
    w[ii,jj] = aa*w[ii,jj] + bb*t[ii,jj] + bb*dt*r[ii,jj]
    if isolver == 3:
        w = bc3(nx,ny,w,s)
    else:
        w = bc(nx,ny,w,s) 
    s[:,:] = poisson(nx,ny,dx,dy,w,input_data)
    
    return w, s
示例#3
0
def euler(nx, ny, dx, dy, dt, re, pr, w, s, th, input_data, bc, bc3):

    i = np.arange(0, nx + 1)
    j = np.arange(1, ny)
    ii, jj = np.meshgrid(i, j, indexing='ij')

    if input_data['isolver'] == 3:
        w = bc3(nx, ny, w, s)
    else:
        w = bc(nx, ny, w, s)

    rw, rth = rhs(nx, ny, dx, dy, re, pr, w, s, th, input_data)

    w[ii, jj] = w[ii, jj] + dt * rw[ii, jj]
    th[ii, jj] = th[ii, jj] + dt * rth[ii, jj]

    w[nx, :] = w[0, :]
    th[nx, :] = th[0, :]

    s = poisson(nx, ny, dx, dy, w, input_data)

    return w, s, th
示例#4
0
        exp.plotHist()
    else:
        messagebox.showerror(
            "Erro", "Valores inválidos ou Campo em Branco. Digite novamente")
        deleteText(entrySampleSpace, entryLambda)


def bt_ladder():
    test = entryArchivePoisson.get()
    pos.importPoisson(test)
    pos.plotGraphic()


GUI = Tk()
pos = poisson()
exp = expovariate()

labelLambda = Label(GUI, text="Digite o valor de Lambda")
labelLambda.place(x=50, y=20)

entryLambda = Entry(GUI)
entryLambda.place(x=60, y=50)

labelSampleSpace = Label(GUI, text="Digite o tamanho amostral")
labelSampleSpace.place(x=50, y=80)

entrySampleSpace = Entry(GUI)
entrySampleSpace.place(x=60, y=120)

buttonCalc = Button(GUI, width="25", command=bt_onClick,
示例#5
0
from poisson import *
from grid import *
from time import time
import pol

debug = True
error_cal = True

t = time()

grid = poisson(lambda x, y: 2 * pi * pi * sin(pi * x) * sin(pi * y), 32)
for i in range(100):
    grid.Gauss()

grid = Lifting_operator(grid)
for i in range(100):
    grid.Gauss()

grid = Lifting_operator(grid)
for i in range(50):
    grid.Gauss()

grid = Restriction_operator(grid)
for i in range(100):
    grid.Gauss()

grid = Lifting_operator(grid)
for i in range(50):
    grid.Gauss()

error_rlt = lambda x, y: 1 - (grid.get_value(x, y) /
示例#6
0
def rk3(nx, ny, dx, dy, dt, re, pr, w, s, th, input_data, bc, bc3):
    ip = input_data['ip']
    isolver = input_data['isolver']

    tw = np.copy(w)  #np.zeros((nx+1,ny+1))
    tth = np.copy(th)  #np.zeros((nx+1,ny+1))

    i = np.arange(0, nx + 1)
    j = np.arange(1, ny)
    ii, jj = np.meshgrid(i, j, indexing='ij')

    #stage-1
    if isolver == 3:
        w = bc3(nx, ny, w, s)
    else:
        w = bc(nx, ny, w, s)

    rw, rth = rhs(nx, ny, dx, dy, re, pr, w, s, th, input_data)

    tw[ii, jj] = w[ii, jj] + dt * rw[ii, jj]
    tth[ii, jj] = th[ii, jj] + dt * rth[ii, jj]

    tw[nx, :] = tw[0, :]
    tth[nx, :] = tth[0, :]

    s = poisson(nx, ny, dx, dy, tw, input_data)

    #stage-2
    if isolver == 3:
        tw = bc3(nx, ny, tw, s)
    else:
        tw = bc(nx, ny, tw, s)

    rw, rth = rhs(nx, ny, dx, dy, re, pr, tw, s, tth, input_data)
    tw[ii, jj] = (3.0 / 4.0) * w[ii, jj] + (1.0 / 4.0) * tw[ii, jj] + (
        1.0 / 4.0) * dt * rw[ii, jj]
    tth[ii, jj] = (3.0 / 4.0) * th[ii, jj] + (1.0 / 4.0) * tth[ii, jj] + (
        1.0 / 4.0) * dt * rth[ii, jj]

    tw[nx, :] = tw[0, :]
    tth[nx, :] = tth[0, :]

    s = poisson(nx, ny, dx, dy, tw, input_data)

    #stage-3
    if isolver == 3:
        tw = bc3(nx, ny, tw, s)
    else:
        tw = bc(nx, ny, tw, s)

    rw, rth = rhs(nx, ny, dx, dy, re, pr, tw, s, tth, input_data)
    w[ii, jj] = (1.0 / 3.0) * w[ii, jj] + (2.0 / 3.0) * tw[ii, jj] + (
        2.0 / 3.0) * dt * rw[ii, jj]
    th[ii, jj] = (1.0 / 3.0) * th[ii, jj] + (2.0 / 3.0) * tth[ii, jj] + (
        2.0 / 3.0) * dt * rth[ii, jj]

    w[nx, :] = w[0, :]
    th[nx, :] = th[0, :]

    s = poisson(nx, ny, dx, dy, w, input_data)

    return w, s, th
import numpy as np

from poisson import *
from double_grid import *
import pol

debug = False
error_cal = True

times1 = 8
times2 = 8

t = time.time()

small_grids = True
grid = poisson(lambda x, y: 2 * pi * pi * sin(pi * x) * sin(pi * y),
               64 if small_grids else 128)
'''
#64
for i in range(times1):
    grid.Gauss()
    if debug:
        print("complete")

#128
grid = Lifting_operator(grid)
for i in range(times1):
    grid.Gauss()
    if debug:
        print("complete")
'''
#256
示例#8
0
    def __init__(self,d1,r1,d2,r2):
        self.rm = np.array([[[0.0]*21 for y in range(441)] for x in range(441)])
        self.pm = np.array([[[0.0]*21 for y in range(441)] for x in range(441)])


        #now need to intiate the things
        #just create poisson object
        poisd1 = poisson(d1,10)
        poisr1 = poisson(r1, 10)
        poisd2 = poisson(d2, 10)
        poisr2 = poisson(r2,10)

        '''
        now just need to initate the pobability matrix
        now for fixed i,j m,n and action a
        if n + a-> m - a the flow of cars
        now as we have to see
        if n+a < 0 or if n + a > 21 or if m-a < 0 or if m - a > 21
        make that probability 0

        the don't make any change else make changes
        '''
        for i in range(0,21):
            for j in range(0,21):
                for m in range(0,21):
                    for n in range(0,21):
                        for a in range (0,11):
                            ac = a - 2
                            ans = 0
                            tp = 0
                            er = 0
                            if (n+ac < 0 or  n + ac > 21 or  m-ac < 0 or m - ac > 21 or abs(i-m+ac) > 10 or abs(j-n-ac) > 10):
                                self.pm[i  + j*21][m  + n*21][a] = 0
                            else:
                                if (i - m + ac >= 0 and j - n - ac >= 0):
                                    #all things are return dependent
                                    for it in range(0, 4):
                                         for jt in range(0, 4):
                                             if (it <= 10 and i - m + ac + it <= 10 and jt <= 10 and j - n - ac + jt <= 10 and it <= i and jt <= j):
                                                      tp = poisd1.get_pro(it)*poisr1.get_pro(i-m+ac + it)*poisd2.get_pro(jt)*poisr2.get_pro(j-n-ac + jt)
                                                      ans = ans + tp
                                                      er = er + 10*tp*(it+jt)


                                elif (i - m + ac <= 0 and j - n - ac >= 0):
                                    #all things are return dependent
                                    for it in range(0,4):
                                         for jt in range(0, 4):
                                             if ( it <= 10 and -i + m - ac + it <= 10 and jt <= 10 and j - n - ac + jt <= 10 and it <= i and jt <= j):
                                                      tp = poisd1.get_pro(it)*poisr1.get_pro(-i+m-ac + it)*poisd2.get_pro(jt)*poisr2.get_pro(j-n-ac + jt)
                                                      ans = ans + tp
                                                      er = er + 10 * tp*(it+jt)


                                elif (i - m + ac >= 0 and j - n - ac <= 0):
                                    #all things are return dependent
                                    for it in range(0,4):
                                         for jt in range(0, 4):
                                             if (it <= 10 and i - m + ac + it <= 10 and jt <= 10 and -j + n + ac + jt <= 10 and it <= i and jt <= j):
                                                      tp = poisd1.get_pro(it)*poisr1.get_pro(i-m+ac + it)*poisd2.get_pro(jt)*poisr2.get_pro(-j+n+ac + jt)
                                                      ans = ans + tp
                                                      er = er + 10 * tp*(it+ jt)

                                elif (i - m + ac <= 0 and j - n - ac <= 0):
                                    #all things are return dependent
                                    for it in range(0,4):
                                         for jt in range(0, 4):
                                                if (it <= 10 and -i+m-ac + it <= 10 and jt <= 10 and -j+n+ac + jt <= 10 and it <= i and jt <= j):
                                                      tp = poisd1.get_pro(it)*poisr1.get_pro(-i+m-ac + it)*poisd2.get_pro(jt)*poisr2.get_pro(-j+n+ac + jt)
                                                      ans = ans + tp
                                                      er = er + 10 * tp*( it+jt)
                            self.pm[i + j*21 ][m + n*21][a] = ans
                            if (ans != 0):
                                self.rm[i + j*21][m  + n*21][a] = er/ans - 2*abs(ac)

        for i in range(0, 21):
            for j in range(0, 21):
                for a in range(0, 11):
                    ans = 0
                    for m in range(0, 21):
                        for n in range(0, 21):
                            ans = self.pm[i + j * 21][m + n * 21][a] + ans
                    for m in range(0, 21):
                        for n in range(0, 21):
                            if (ans != 0):
                                self.pm[i + j * 21][m + n * 21][a] = (self.pm[i + j * 21][m + n * 21][a]) / ans