run `mv retainingSmooth.yade.gz 0.yade.gz` to generate initial RVE packing """ from esys.escript import * from esys.finley import Rectangle from esys.weipa import saveVTK from esys.escript.pdetools import Projector from msFEM2D import MultiScale from saveGauss import saveGauss2D import time vel = -0.00017; surcharge=-2.e4; # surcharge equals to the initial vertical stress of the RVE packing; vel<0 passive failure; vel>0 active failure B = 0.4; H = 0.2; wallH = 0.17; baseH = H-wallH; # setup dimensions nx = 40; ny = 20 # discretization with 40x20 quads mydomain = Rectangle(l0=B,l1=H,n0=nx,n1=ny,order=2,integrationOrder=2) dim = mydomain.getDim() k = kronecker(mydomain) numg = 4*nx*ny; nump = 16; packNo=range(0,numg,16) disp = Vector(0.,Solution(mydomain)) prob = MultiScale(domain=mydomain,ng=numg,np=nump,random=False,rtol=1e-2,usePert=False,pert=-2.e-5,verbose=True) t=0 time_start = time.time() x = mydomain.getX() bx = FunctionOnBoundary(mydomain).getX() left = whereZero(x[0]) right = whereZero(x[0]-B)
dt = DT # current time step size t_vis = 0 n_vis = 0 counter_vis = 0 mkDir(VIS_DIR) # ========================= # # set up domain # if DIM == 2: dom = Rectangle(NE_L, NE_H, l0=L, l1=H, order=1, optimize=True) else: dom = Brick(NE_L, NE_L, NE_H, l0=L, l1=L, l2=H, order=1, optimize=True) BBOX = boundingBox(dom) DIM = dom.getDim() x = dom.getX() # # initial values: # sigma = Tensor(0.0, Function(dom)) eps_e = Tensor(0.0, Function(dom)) if CASE == 2 or CASE == 3: alpha = ALPHA_0 * exp(-length(Function(dom).getX() - xc) ** 2 / WWW ** 2) else: alpha = Scalar(ALPHA_0, Function(dom)) pde = LinearPDESystem(dom) pde.setSymmetryOn() pde.getSolverOptions().setSolverMethod(pde.getSolverOptions().DIRECT)
fs=FaultSystem(dim=2) fs.addFault(V0=[0.5,0.25], strikes=90*DEG, ls=0.5, tag=1) # ... create a slip distribution on the fault: p, m=fs.getParametrization(mydomain.getX(),tag=1) p0,p1= fs.getW0Range(tag=1) s=m*(p-p0)*(p1-p)/((p1-p0)/2)**2*slip_max*[0.,1.] # ... calculate stress according to slip: D=symmetric(grad(s)) chi, d=fs.getSideAndDistance(D.getFunctionSpace().getX(),tag=1) sigma_s=(mu*D+lam*trace(D)*kronecker(mydomain))*chi #... open symmetric PDE ... mypde=LinearPDE(mydomain) mypde.setSymmetryOn() #... set coefficients ... C=Tensor4(0.,Function(mydomain)) for i in range(mydomain.getDim()): for j in range(mydomain.getDim()): C[i,i,j,j]+=lam C[j,i,j,i]+=mu C[j,i,i,j]+=mu # ... fix displacement in normal direction x=mydomain.getX() msk=whereZero(x[0])*[1.,0.] + whereZero(x[0]-1.)*[1.,0.] \ +whereZero(x[1])*[0.,1.] + whereZero(x[1]-1.)*[0.,1.] mypde.setValue(A=C,X=-0.5*sigma_s,q=msk) #... solve pde ... mypde.getSolverOptions().setVerbosityOn() v=mypde.getSolution() # .. write the displacement to file: D=symmetric(grad(v)) sigma=(mu*D+lam*trace(D)*kronecker(mydomain))+0.5*sigma_s
fs = FaultSystem(dim=2) fs.addFault(V0=[0.5, 0.25], strikes=90 * DEG, ls=0.5, tag=1) # ... create a slip distribution on the fault: p, m = fs.getParametrization(mydomain.getX(), tag=1) p0, p1 = fs.getW0Range(tag=1) s = m * (p - p0) * (p1 - p) / ((p1 - p0) / 2)**2 * slip_max * [0., 1.] # ... calculate stress according to slip: D = symmetric(grad(s)) chi, d = fs.getSideAndDistance(D.getFunctionSpace().getX(), tag=1) sigma_s = (mu * D + lam * trace(D) * kronecker(mydomain)) * chi #... open symmetric PDE ... mypde = LinearPDE(mydomain) mypde.setSymmetryOn() #... set coefficients ... C = Tensor4(0., Function(mydomain)) for i in range(mydomain.getDim()): for j in range(mydomain.getDim()): C[i, i, j, j] += lam C[j, i, j, i] += mu C[j, i, i, j] += mu # ... fix displacement in normal direction x = mydomain.getX() msk=whereZero(x[0])*[1.,0.] + whereZero(x[0]-1.)*[1.,0.] \ +whereZero(x[1])*[0.,1.] + whereZero(x[1]-1.)*[0.,1.] mypde.setValue(A=C, X=-0.5 * sigma_s, q=msk) #... solve pde ... mypde.getSolverOptions().setVerbosityOn() v = mypde.getSolution() # .. write the displacement to file: D = symmetric(grad(v)) sigma = (mu * D + lam * trace(D) * kronecker(mydomain)) + 0.5 * sigma_s
t_step = 0 t_step_end = 2000 TOL = 1.0e-5 max_iter=400 verbose=True useUzawa=True #define mesh l0=0.9142 l1=1.0 n0=200 n1=200 mesh=Rectangle(l0=l0, l1=l1, order=2, n0=n0, n1=n1) #get mesh dimensions numDim = mesh.getDim() #get element size h = Lsup(mesh.getSize()) #level set parameters tolerance = 1.0e-6 reinit_max = 30 reinit_each = 3 alpha = 1 smooth = alpha*h #boundary conditions x = mesh.getX() #left + bottom + right + top b_c = whereZero(x[0])*[1.0,0.0] + whereZero(x[1])*[1.0,1.0] + whereZero(x[0]-l0)*[1.0,0.0] + whereZero(x[1]-l1)*[1.0,1.0]
if exc.errno != errno.EEXIST: raise pass vel = -0.00017 surcharge = -2.e4 # surcharge equals to the initial vertical stress of the RVE packing; vel<0 passive failure; vel>0 active failure B = 0.4 H = 0.2 wallH = 0.17 baseH = H - wallH # setup dimensions nx = 40 ny = 20 # discretization with 40x20 quads mydomain = Rectangle(l0=B, l1=H, n0=nx, n1=ny, order=2, integrationOrder=2) dim = mydomain.getDim() k = kronecker(mydomain) numg = 4 * nx * ny nump = 16 packNo = list(range(0, numg, 16)) disp = Vector(0., Solution(mydomain)) prob = MultiScale(domain=mydomain, ng=numg, np=nump, random=False, rtol=1e-2, usePert=False, pert=-2.e-5, verbose=True)
# dom=Rectangle(24,16,l0=1.5) dom=Rectangle(48,32,l0=1.5) saveDataCSV("t.csv",x=dom.getX(), rho=length(dom.getX())) 1/0 # dom=Rectangle(8*48,8*32,l0=1.5) # dom=Rectangle(120,80,l0=1.5) V=Scalar(1.,Function(dom))*[-1.,0] THETA=0. fc=TransportPDE(dom,num_equations=1,theta=THETA) fc.setTolerance(1.e-12) fc.setValue(M=Scalar(1.,Function(dom)),C=V) x=dom.getX() x_0=[0.5,0.5] sigma=0.075 u0=1. for i in range(dom.getDim()): u0=u0*exp(-(x[i]-x_0[i])**2/sigma**2) u0=whereNonPositive(abs(x[0]-0.4)-0.2)*whereNonPositive(abs(x[1]-0.5)-0.2) # f1=0.5 # f2=2. # u0=f2*clip(x[0]-0.5,0.)-clip(0.5-x[0],0.)*f1+f1*0.5 # u0=exp(-3*(x[0]-2.)**2) # u0=x[0] u0/=Lsup(u0) c=0 saveVTK("u.%s.vtu"%c,u=u0) fc.setInitialSolution(u0) t_end=0.6 dt=2.49999e-2*0+6.2499999e-02/4
# generate domain: stationPositions = [(StationOffset + s * StationSpacing, Depth) for s in range(NStations)] stationTags = ["P%4.4d" % s for s in range(NStations)] domain = Rectangle(NEx, NEz, l0=Width, l1=Depth, diracPoints=stationPositions, diracTags=stationTags, order=Order, fullOrder=True) print("Domain has been generated.") Dim = domain.getDim() # setup velocity field: vp = Scalar(Vbase, Function(domain)) X = vp.getX() Top = sup(domain.getX()[Dim - 1]) for l in range(len(Vs) - 1, -1, -1): mask = wherePositive(X[Dim - 1] - (Top - Layers[l])) vp = vp * (1 - mask) + mask * Vs[l] print("Velocity field generated:", vp) # check spacing vs, wavelength: wavelength = inf(vp / (2 * np.pi * Frequency)) print("minimum wavelength = %g" % wavelength) assert wavelength > max(dx, dz) / Order # locator to grap amplitudes at geophones:
# dom=Rectangle(24,16,l0=1.5) dom = Rectangle(48, 32, l0=1.5) saveDataCSV("t.csv", x=dom.getX(), rho=length(dom.getX())) 1 / 0 # dom=Rectangle(8*48,8*32,l0=1.5) # dom=Rectangle(120,80,l0=1.5) V = Scalar(1., Function(dom)) * [-1., 0] THETA = 0. fc = TransportPDE(dom, num_equations=1, theta=THETA) fc.setTolerance(1.e-12) fc.setValue(M=Scalar(1., Function(dom)), C=V) x = dom.getX() x_0 = [0.5, 0.5] sigma = 0.075 u0 = 1. for i in range(dom.getDim()): u0 = u0 * exp(-(x[i] - x_0[i])**2 / sigma**2) u0 = whereNonPositive(abs(x[0] - 0.4) - 0.2) * whereNonPositive(abs(x[1] - 0.5) - 0.2) # f1=0.5 # f2=2. # u0=f2*clip(x[0]-0.5,0.)-clip(0.5-x[0],0.)*f1+f1*0.5 # u0=exp(-3*(x[0]-2.)**2) # u0=x[0] u0 /= Lsup(u0) c = 0 saveVTK("u.%s.vtu" % c, u=u0) fc.setInitialSolution(u0) t_end = 0.6
dt = DT # current time step size t_vis = 0 n_vis = 0 counter_vis = 0 mkDir(VIS_DIR) #========================= # # set up domain # if DIM == 2: dom = Rectangle(NE_L, NE_H, l0=L, l1=H, order=1, optimize=True) else: dom = Brick(NE_L, NE_L, NE_H, l0=L, l1=L, l2=H, order=1, optimize=True) BBOX = boundingBox(dom) DIM = dom.getDim() x = dom.getX() # # initial values: # sigma = Tensor(0., Function(dom)) eps_e = Tensor(0., Function(dom)) if CASE == 2 or CASE == 3: alpha = ALPHA_0 * exp(-length(Function(dom).getX() - xc)**2 / WWW**2) else: alpha = Scalar(ALPHA_0, Function(dom)) pde = LinearPDESystem(dom) pde.setSymmetryOn() pde.getSolverOptions().setSolverMethod(pde.getSolverOptions().DIRECT)