Ejemplo n.º 1
0
vel = -0.00025; surcharge=-20.e3; # surcharge equals to the initial vertical stress of the RVE packing
dim = 2; B = 0.05; L = 0.6; H = 0.4;
mydomain = ReadGmsh('footing.msh',numDim=dim,integrationOrder=2)  # read Gmsh mesh with 6-node triangle element (2500 tri6); each element has 3 Gauss points
k = kronecker(mydomain)
numg = 3*2500; # number of Gauss points
nump = 16; # number of processes in multiprocessing
packNo=list(range(0,numg,50))

prob = MultiScale(domain=mydomain,ng=numg,np=nump,random=False,rtol=1e-2,usePert=False,pert=-2.e-5,verbose=False)

disp = Vector(0.,Solution(mydomain))

t=0
stress = prob.getCurrentStress()
proj = Projector(mydomain)
sig = proj(stress)
sig_bounda = interpolate(sig,FunctionOnBoundary(mydomain))
traction = matrix_mult(sig_bounda,mydomain.getNormal())
x = mydomain.getX()
bx = FunctionOnBoundary(mydomain).getX()
footingBase = whereZero(bx[1]-sup(bx[1]))*whereNonPositive(bx[0]-B)
tractFoot = traction*footingBase
forceFoot = integrate(tractFoot,where=FunctionOnBoundary(mydomain))
lengthFoot = integrate(footingBase,where=FunctionOnBoundary(mydomain))
fout=file('./result/bearing.dat','w')
fout.write('0 '+str(forceFoot[0])+' '+str(forceFoot[1])+' '+str(lengthFoot)+'\n')

# Dirichlet BC, rollers at left and right, fixties at bottom, rigid and rough footing
Dbc = whereZero(x[0])*[1,0]+whereZero(x[0]-sup(x[0]))*[1,0]+whereZero(x[1]-inf(x[1]))*[1,1]+whereZero(x[1]-sup(x[1]))*whereNonPositive(x[0]-B)*[1,1]
Vbc = whereZero(x[0])*[0,0]+whereZero(x[0]-sup(x[0]))*[0,0]+whereZero(x[1]-inf(x[1]))*[0,0]+whereZero(x[1]-sup(x[1]))*whereNonPositive(x[0]-B)*[0,vel]
Ejemplo n.º 2
0
def wavesolver2d(domain,
                 h,
                 tend,
                 lam,
                 mu,
                 rho,
                 U0,
                 xc,
                 savepath,
                 output="vtk"):
    from esys.escript.linearPDEs import LinearPDE
    x = domain.getX()
    # ... open new PDE ...
    mypde = LinearPDE(domain)
    #mypde.setSolverMethod(LinearPDE.LUMPING)
    mypde.setSymmetryOn()
    kmat = kronecker(domain)
    mypde.setValue(D=kmat * rho)

    # define small radius around point xc
    # Lsup(x) returns the maximum value of the argument x
    src_radius = 50  #2*Lsup(domain.getSize())
    print("src_radius = ", src_radius)

    dunit = numpy.array([0., 1.])  # defines direction of point source

    # ... set initial values ....
    n = 0
    # initial value of displacement at point source is constant (U0=0.01)
    # for first two time steps
    u = U0 * (cos(length(x - xc) * 3.1415 / src_radius) +
              1) * whereNegative(length(x - xc) - src_radius) * dunit
    u_m1 = u
    t = 0

    u_pot = cbphones(domain, u, [[0, 500], [250, 500], [400, 500]], 2)
    u_pc_x1 = u_pot[0, 0]
    u_pc_y1 = u_pot[0, 1]
    u_pc_x2 = u_pot[1, 0]
    u_pc_y2 = u_pot[1, 1]
    u_pc_x3 = u_pot[2, 0]
    u_pc_y3 = u_pot[2, 1]

    # open file to save displacement at point source
    u_pc_data = open(os.path.join(savepath, 'U_pc.out'), 'w')
    u_pc_data.write("%f %f %f %f %f %f %f\n" %
                    (t, u_pc_x1, u_pc_y1, u_pc_x2, u_pc_y2, u_pc_x3, u_pc_y3))

    #   while t<tend:
    while t < 1.:

        # ... get current stress ....
        t = 1.
        ##OLD WAY
        break
        g = grad(u)
        stress = lam * trace(g) * kmat + mu * (g + transpose(g))
        ### ... get new acceleration ....
        #mypde.setValue(X=-stress)
        #a=mypde.getSolution()
        ### ... get new displacement ...
        #u_p1=2*u-u_m1+h*h*a
        ###NEW WAY
        mypde.setValue(X=-stress * (h * h), Y=(rho * 2 * u - rho * u_m1))
        u_p1 = mypde.getSolution()
        # ... shift displacements ....
        u_m1 = u
        u = u_p1
        #stress =
        t += h
        n += 1
        print(n, "-th time step t ", t)
        u_pot = cbphones(domain, u, [[300., 200.], [500., 200.], [750., 200.]],
                         2)

        #     print "u at point charge=",u_pc
        u_pc_x1 = u_pot[0, 0]
        u_pc_y1 = u_pot[0, 1]
        u_pc_x2 = u_pot[1, 0]
        u_pc_y2 = u_pot[1, 1]
        u_pc_x3 = u_pot[2, 0]
        u_pc_y3 = u_pot[2, 1]

        # save displacements at point source to file for t > 0
        u_pc_data.write(
            "%f %f %f %f %f %f %f\n" %
            (t, u_pc_x1, u_pc_y1, u_pc_x2, u_pc_y2, u_pc_x3, u_pc_y3))

        # ... save current acceleration in units of gravity and displacements
        #saveVTK(os.path.join(savepath,"usoln.%i.vtu"%n),acceleration=length(a)/9.81,
        #displacement = length(u), tensor = stress, Ux = u[0] )
        if output == "vtk":
            saveVTK(os.path.join(savepath, "tonysol.%i.vtu" % n),
                    output1=length(u),
                    tensor=stress)
        else:
            quT = qu.toListOfTuples()
            #Projector is used to smooth the data.
            proj = Projector(mymesh)
            smthT = proj(T)

            #move data to a regular grid for plotting
            xi, yi, zi = toRegGrid(smthT, mymesh, 200, 200, width, depth)

            # contour the gridded data,
            # select colour
            pl.matplotlib.pyplot.autumn()
            pl.clf()
            # contour temperature
            CS = pl.contour(xi, yi, zi, 5, linewidths=0.5, colors='k')
            # labels and formatting
            pl.clabel(CS, inline=1, fontsize=8)
            pl.title("Heat Refraction across a clinal structure.")
            pl.xlabel("Horizontal Displacement (m)")
            pl.ylabel("Depth (m)")
            pl.legend()
            if getMPIRankWorld() == 0:  #check for MPI processing
                pl.savefig(
                    os.path.join(saved_path, "heatrefraction001_cont.png"))

    u_pc_data.close()
Ejemplo n.º 3
0
h = Lsup(mesh.getSize())
numDim = mesh.getDim()
smooth = h * 2.0  # SMOOTHING PARAMETER FOR THE TRANSITION ACROSS THE INTERFACE

### DEFINITION OF THE PDE ###
velocityPDE = LinearPDE(mesh, numEquations=numDim)

advectPDE = LinearPDE(mesh)
advectPDE.setReducedOrderOn()
advectPDE.setValue(D=1.0)
advectPDE.setSolverMethod(solver=LinearPDE.DIRECT)

reinitPDE = LinearPDE(mesh, numEquations=1)
reinitPDE.setReducedOrderOn()
reinitPDE.setSolverMethod(solver=LinearPDE.LUMPING)
my_proj = Projector(mesh)

### BOUNDARY CONDITIONS ###
xx = mesh.getX()[0]
yy = mesh.getX()[1]
zz = mesh.getX()[2]
top = whereZero(zz - l1)
bottom = whereZero(zz)
left = whereZero(xx)
right = whereZero(xx - l0)
front = whereZero(yy)
back = whereZero(yy - l0)
b_c = (bottom + top) * [1.0, 1.0, 1.0] + (left + right) * [1.0, 0.0, 0.0] + (
    front + back) * [0.0, 1.0, 0.0]
velocityPDE.setValue(q=b_c)
Ejemplo n.º 4
0
   u, u_t = prob.solve(damp=damp)
   # update maximum kinetic energy
   Ek =  integrate(length(u_t)**2*rho)/2.
   # write data at selected timesteps
   if t%tWrite == 0:

      # check quasi-static state
      while Ek > rtol or Ek <0:
         u, u_t = prob.solve(damp=0.99,dynRelax=True)
         Ek =  integrate(length(u_t)**2*rho)/2.
         print t, Ek

      # get stress at (n) timesteps
      stress = prob.getCurrentStress()
      dom = prob.getDomain()
      proj = Projector(dom)
      # project Gauss point value to nodal value
      sig = proj(stress)
      # interpolate to stress at the boundary
      sig_bounda = interpolate(sig,FunctionOnBoundary(dom)) 
      # compute boundary traction by s_ij*n_j
      traction = matrix_mult(sig_bounda,dom.getNormal())
      # get mask for boundary nodes on the bottom
      botSurf = whereZero(bx[1])
      # traction at the bottom
      tractBot = traction*botSurf
      # resultant force at the bottom
      forceBot = integrate(tractBot,where=FunctionOnBoundary(dom))
      # length of the bottom surface
      lengthBot = integrate(botSurf,where=FunctionOnBoundary(dom))
      # write stress at the bottom surface
Ejemplo n.º 5
0
        x[0]) + whereZero(x[0] - mx)
    ###############################################ESCRIPT PDE CONSTRUCTION
    mypde = LinearPDE(domain)
    mypde.setValue(A=kro, Y=4. * 3.1415 * G * rhoe, q=q, r=0.)
    mypde.setSymmetryOn()
    sol = mypde.getSolution()

    g_field = grad(sol)  #The gravitational acceleration g.
    g_fieldz = g_field * [0, 1]  #The vertical component of the g field.
    gz = length(g_fieldz)  #The magnitude of the vertical component.
    # Save the output to file.
    saveVTK(os.path.join(save_path,"ex10d.vtu"),\
            grav_pot=sol,g_field=g_field,g_fieldz=g_fieldz,gz=gz,rho=rhoe)

    ################################################MODEL SIZE SAMPLING
    smoother = Projector(domain)  #Function smoother.
    z = 1000.  #Distance of profile from source.
    sol_angz = []  #Array for analytic gz
    sol_anx = []  #Array for x
    #calculate analytic gz and x location.
    for x in range(int(-mx / 2.), int(mx / 2.), 10):
        sol_angz.append(analytic_gz(x, z, R, rho))
        sol_anx.append(x + mx / 2)
    #save analytic solution
    pl.savetxt(os.path.join(save_path, "ex10d_as.asc"), sol_angz)

    sol_escgz = []  #Array for escript solution for gz
    #calculate the location of the profile in the domain
    for i in range(0, len(sol_anx)):
        sol_escgz.append([sol_anx[i], my / 2. - z])
Ejemplo n.º 6
0
    ###########################################################GET SOLUTION
    T=mypde.getSolution()
    print("PDE has been solved  ...")

    ##################################################REGRIDDING & PLOTTING
    xi, yi, zi = toRegGrid(T, nx=50, ny=50)
    pl.matplotlib.pyplot.autumn()
    pl.contourf(xi,yi,zi,10)
    pl.xlabel("Horizontal Displacement (m)")
    pl.ylabel("Depth (m)")
    pl.savefig(os.path.join(save_path,"Tcontour.png"))
    print("Solution has been plotted  ...")
    ##########################################################VISUALISATION
    # calculate gradient of solution for quiver plot
    #Projector is used to smooth the data.
    proj=Projector(domain)
    #move data to a regular grid for plotting
    xi,yi,zi = toRegGrid(T,200,200)
    cut=int(len(xi)//2)
    pl.clf()
    pl.plot(zi[:,cut],yi)
    pl.title("Temperature Depth Profile")
    pl.xlabel("Temperature (K)")
    pl.ylabel("Depth (m)")
    pl.savefig(os.path.join(save_path,"tdp.png"))
    pl.clf()
        
    # Heat flow depth profile.
    # grid the data.
    qu=proj(-kappa*grad(T))
    xiq,yiq,ziq = toRegGrid(qu[1],50,50)