Python Boundary Conditions Algorithm

Asked

Viewed 79 times

1

I can’t run it in my python, someone who can help me? The problem is in the border conditions.

for it in range(2,nt):
    uu=u*u;
    uv=u*v;
    vv=v*v;
    hbu=(h-b)*u;
    hbv=(h-b)*v;
    gh=g*h;
    # Avançar o sinal em todo o domínio excepto nas fronteiras
    for ix in range(2,Nx-1):
        for iy in range(2,Ny-1):
            uP[ix,iy] = (1/4. * (u[ix-1,iy] + u[ix+1,iy] + u[ix,iy-1] + u[ix,iy+1])) - dt2dx * (uu[ix+1,iy] - uu[ix-1,iy]) - dt2dy * (uv[ix,iy+1] - uv[ix,iy-1]) + dt2dx * (g*h[ix+1,iy] - g*h[ix-1,iy])
            vP[ix,iy] = (1/4. * (v[ix-1,iy] + v[ix+1,iy] + v[ix,iy-1] + v[ix,iy+1])) - dt2dx * (uv[ix+1,iy] - uv[ix-1,iy]) - dt2dy * (vv[ix,iy+1] - vv[ix,iy-1]) + dt2dy * (gh[ix,iy+1] - gh[ix,iy-1])
            hP[ix,iy] = (1/4. * (h[ix-1,iy] + h[ix+1,iy] + h[ix,iy-1] + h[ix,iy+1])) - dt2dx * (hbu[ix+1,iy] - hbu[ix-1,iy]) - dt2dy * (hbv[ix,iy+1] - hbv[ix,iy-1]) 

  #condições fronteira
    hP[1,:]=hP[2,:];
    hP[Nx,:]=hP[Nx-1,:];
    hP[:,1]=hP[:,2];
    hP[:,Ny]=hP[:,Ny-1];

    uP[1,:]=0;
    uP[Nx,:]=0;
    uP[:,1]=uP[:,2];
    uP[:,Ny]=uP[:,Ny-1];

    vP[1,:]=vP[2,:];
    vP[Nx,:]=vP[Nx-1,:];
    vP[:,1]=0;
    vP[:,Ny]=0;

     # actualizar o sinal
    h[:]=hP[:]; u[:]=uP[:]; v[:]=vP[:];

    hStation[it] = h[ixStation, iyStation]
  • What is the expected result and what is the result? You can edit your question by placing the test conditions for the algorithm?

    1. Technical specifications Boundary conditions are closed (no exchanges with the outside): x=0, x=Lx: u=0; v/ x=0; h/ x=0 y=0, x=Ly: v=0; u/ y=0; h/ y=0 So I first discretized these 3 equations: u/ t= / x (U2) / y (uv) g*( h/ x) v t= x(uv) y(v2) g h y h t= x[(h b)u] y[(h b)v]
  • Better contextualize your problem by explaining what your program proposes to solve. If possible, give an example of input data and the expected correct result.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.