def initial_stress_conditions(models): LSfault = fdfault.output(models[0], 'sfault') LSnfault = fdfault.output(models[0], 'snfault') SSnfault = fdfault.output(models[1], 'snfault') Sfault = fdfault.output(models[1], 'sfault') LSfault.load() Sfault.load() LSnfault.load() SSnfault.load() plt.figure(figsize=(5, 4)) plt.subplot(121) plt.plot(LSnfault.Sn[0, :], LSnfault.y - maxy, 'b-', label="TM1") # plt.plot(SSnfault.Sn[0,:], SSnfault.y-maxy, 'b-', label ="TM2") plt.xlabel("Normal stress (MPa)") plt.ylabel("Depth (km)") # plt.legend(loc='upper left', frameon=False) plt.title('(a)', loc='left') plt.xticks([0, -100, -200, -300]) plt.subplot(122) plt.plot(LSfault.S[0, :], LSfault.y - maxy, 'b-') # plt.plot(Sfault.S[0,:], Sfault.y-maxy, 'b-') plt.xlabel("Shear stress (MPa)") plt.title('(b)', loc='left') plt.xticks([0, 25, 50, 75, 100]) plt.tight_layout() plt.show()
def plot_slip_rate(models): steps = [0, 2, 4, 6, 8, 10] c = ['b', 'g', 'r', 'c', 'm', 'k', 'y'] LVfault = fdfault.output(models[0], 'vfault') SVfault = fdfault.output(models[1], 'vfault') LVfault_coh = fdfault.output(models[2], 'vfault') SVfault_coh = fdfault.output(models[3], 'vfault') LVfault.load() SVfault.load() LVfault_coh.load() SVfault_coh.load() plt.figure() plt.subplot(1, 2, 1) for i in range(len(steps)): c1 = str(c[i] + '-') c2 = str(c[i] + '--') plt.plot(LVfault.V[steps[i], :], LVfault.y - maxy, c1, label=str(round(LVfault.t[steps[i]], 0)) + ' s') plt.plot(SVfault.V[steps[i], :], SVfault.y - maxy, c2) plt.title('(a)', loc='left') plt.ylabel("Distance along fault (km)") plt.xlabel("Slip rate (m/s)") plt.legend(loc="upper right", frameon=False) plt.grid(True) plt.subplot(1, 2, 2) for i in range(len(steps)): c1 = str(c[i] + '-') c2 = str(c[i] + '--') plt.plot(LVfault_coh.V[steps[i], :], LVfault_coh.y - maxy, c1, label=str(round(LVfault_coh.t[steps[i]], 0)) + ' s') plt.plot(SVfault_coh.V[steps[i], :], SVfault_coh.y - maxy, c2) plt.title('(b)', loc='left') # plt.ylabel("Depth") plt.xlabel("Slip rate (m/s)") plt.legend(loc="upper right", frameon=False) plt.grid(True) plt.show()
def initial_slip_rate(models, models_litho): # On fault slip rate + normal and shear stress LVfault = fdfault.output(models[0], 'vfault') LCVfault = fdfault.output(models[1], 'vfault') LVfault_litho = fdfault.output(models_litho[0], 'vfault') LCVfault_litho = fdfault.output(models_litho[1], 'vfault') LVfault.load() LCVfault.load() LVfault_litho.load() LCVfault_litho.load() # plt.figure(figsize=(6, 4)) plt.subplot(141) plt.plot(LVfault.V[0, :], LVfault.y - maxy, 'b-', label="RSN") plt.xlabel("Slip rate(m/s)") plt.ylabel("Depth (km)") plt.title('(a) RSN', loc='left') plt.xticks([0, 0.20, 0.40, 0.60]) plt.subplot(142) plt.plot(LVfault_litho.V[0, :], LVfault.y - maxy, 'b-', label="RSNL") plt.xlabel("Slip rate(m/s)") plt.title('(c) RSNL', loc='left') plt.xticks([0, 0.20, 0.40, 0.60]) # plt.yticks([]) plt.subplot(143) plt.plot(LCVfault.V[0, :], LVfault.y - maxy, 'b-', label="RSC") plt.xlabel("Slip rate(m/s)") plt.title('(b) RSC', loc='left') plt.xticks([0, 0.25, 0.50, 0.75]) # plt.yticks([]) plt.subplot(144) plt.plot(LCVfault_litho.V[0, :], LVfault.y - maxy, 'b-', label="RSCL") plt.xlabel("Slip rate(m/s)") plt.title('(d) RSCL', loc='left') plt.xticks([0, 0.25, 0.50, 0.75]) # plt.yticks([]) # plt.tight_layout() plt.show()
def peak_slip(models, models_litho): Lfault_shallow = fdfault.output(models[0], 'ufault') Lfault_deep = fdfault.output(models[1], 'ufault') litho_shallow = fdfault.output(models_litho[0], 'ufault') litho_deep = fdfault.output(models_litho[1], 'ufault') normal_stress = fdfault.output(models[0], 'snfault') shear_stress = fdfault.output(models[0], 'sfault') Lfault_shallow.load() Lfault_deep.load() litho_shallow.load() litho_deep.load() normal_stress.load() shear_stress.load() Lfault_shallow_slip = Lfault_shallow.U.max(axis=0) Lfault_deep_slip = Lfault_deep.U.max(axis=0) litho_shallow_slip = litho_shallow.U.max(axis=0) litho_deep_slip = litho_deep.U.max(axis=0) depths = Lfault_shallow.y # plt.figure(figsize=(6.20, 4)) plt.subplot(131) plt.plot(Lfault_shallow_slip, depths - maxy, 'b-', label="RSN") plt.plot(litho_shallow_slip, depths - maxy, 'r-', label="RSNL") plt.xlabel('Peak Slip (m)') plt.ylabel('Depth (km)') plt.legend(loc='lower right', frameon=False) plt.title('(a)', loc='left') plt.subplot(132) plt.plot(Lfault_deep_slip, depths - maxy, 'b-', label="RSC") plt.plot(litho_deep_slip, depths - maxy, 'r-', label="RSCL") plt.xlabel('Peak Slip (m)') plt.legend(loc='lower right', frameon=False) plt.title('(b)', loc='left') plt.subplot(133) plt.plot(np.absolute(shear_stress.S[0, :]) / np.absolute(normal_stress.Sn[0, :]), depths - maxy, 'b-', label="T1C") plt.xlabel('Shear stress/Normal stress') # plt.xticks([0, 100, 200]) plt.title('(c)', loc='left') plt.tight_layout() plt.show()
def write_off_fault_2d(problem, station, depthsign = 1., author = "", version = "", grid_spacing = ""): """ Converts code output units for off-fault station into a formatted text file for SCEC website This function converts off fault data from binary (written by the C++ code) to ASCII text for a 3D benchmark simulation. Required inputs are the problem name (string) and station (tuple of strings in the format ``(strike, across, depth)``). Optional inputs include depthsign (1. by default, changes sign on depth coordinate if -1.), and author, verision, and grid spacing strings which will be inserted into the header of the output file. The text file is written to ``{problem}_body{across}st{strike}dp{depth}.txt`` in the current directory. :param problem: Problem name to write to file :type problem: str :param station: Coordinates in 2D of output station (tuple of 3 strings, but ``strike`` should be ``'0'``) :type station: tuple :param depthsign: Sign of depth output, must be ``1.`` or ``-1.`` (optional, default is ``1.``) :type depthsign: float :param author: Person who ran the simulation (optional, default is ``""``) :type author: str :param version: Code version used in simulation (optional, default is ``""``) :type version: str :param grid_spacing: Grid spacing used in simulation (optional, default is ``""``) :type grid_spacing: str :returns: None """ stationstr = 'body'+station[1]+'st'+station[0]+'dp'+station[2] n_vel = fdfault.output(problem,stationstr+'-n-vel') n_vel.load() v_vel = fdfault.output(problem,stationstr+'-v-vel') v_vel.load() assert(n_vel.nt == v_vel.nt) assert(depthsign == 1. or depthsign == -1.) n_disp = cumtrapz(n_vel.vx, n_vel.t, initial=0.) v_disp = cumtrapz(v_vel.vy, v_vel.t, initial=0.) f = open(problem+'_'+stationstr+'.txt','w') f.write('# problem='+problem+'\n') f.write('# author='+author+'\n') f.write('# date='+datetime.date.today().strftime("%y/%m/%d")+"\n") f.write('# code=fdfault\n') f.write('# version='+version+'\n') f.write('# element_size='+grid_spacing+'\n') f.write('# time_step='+str(v_vel.t[1]-v_vel.t[0])+' s\n') f.write('# num_time_steps='+str(v_vel.nt)+'\n') f.write('# location= 0 km strike, '+str(v_vel.x)+' km across, '+ str(depthsign*v_vel.y)+' km depth\n') f.write('# Column #1 = Time (s)\n') f.write('# Column #2 = horizontal displacement (m)\n') f.write('# Column #3 = horizontal velocity (m/s)\n') f.write('# Column #4 = vertical displacement (m)\n') f.write('# Column #5 = vertical velocity (m/s)\n') f.write('# Column #6 = normal displacement (m)\n') f.write('# Column #7 = normal velocity (m/s)\n') f.write('#\n') f.write('t h-disp h-vel v-disp v-vel n-disp n-vel\n') f.write('#\n') for i in range(v_vel.nt): f.write("{:.12E} {:E} {:E} {:E} {:E} {:E} {:E}\n".format(v_vel.t[i], 0., 0., depthsign*v_disp[i], depthsign*v_vel.vy[i], n_disp[i], n_vel.vx[i])) f.close()
def write_on_fault_2d(problem, station, depthsign = 1., normal = True, author = "", version = "", grid_spacing = ""): """ Converts code output units for on-fault station into a formatted text file for SCEC website This function converts on fault data from binary (written by the C++ code) to ASCII text for a 2D benchmark simulation. Required inputs are the problem name (string) and station (tuple of strings in the format ``(strike, depth)``, with values chosen appropriately for a 2D simulation). Optional inputs include depthsign (1. by default, changes sign on depth coordinate if -1.), and author, verision, and grid spacing strings which will be inserted into the header of the output file. The text file is written to ``{problem}_faultst{strike}dp{depth}.txt`` in the current directory. :param problem: Problem name to write to file :type problem: str :param station: Coordinates of output station (tuple of 2 strings for strike and depth coordinates) :type station: tuple :param depthsign: Sign of depth output, must be ``1.`` or ``-1.`` (optional, default is ``1.``) :type depthsign: float :param author: Person who ran the simulation (optional, default is ``""``) :type author: str :param version: Code version used in simulation (optional, default is ``""``) :type version: str :param grid_spacing: Grid spacing used in simulation (optional, default is ``""``) :type grid_spacing: str :returns: None """ stationstr = 'faultst'+station[0]+'dp'+station[1] v_slip = fdfault.output(problem,stationstr+'-v-slip') v_slip.load() v_slip_rate = fdfault.output(problem,stationstr+'-v-slip-rate') v_slip_rate.load() v_shear_stress = fdfault.output(problem,stationstr+'-v-shear-stress') v_shear_stress.load() assert(v_slip.nt == v_slip_rate.nt) assert(v_slip.nt == v_shear_stress.nt) assert(depthsign == 1. or depthsign == -1.) if normal: n_stress = fdfault.output(problem,stationstr+'-n-stress') n_stress.load() f = open(problem+'_'+stationstr+'.txt','w') f.write('# problem='+problem+'\n') f.write('# author='+author+'\n') f.write('# date='+datetime.date.today().strftime("%y/%m/%d")+"\n") f.write('# code=fdfault\n') f.write('# version='+version+'\n') f.write('# element_size='+grid_spacing+'\n') f.write('# time_step='+str(v_slip.t[1]-v_slip.t[0])+' s\n') f.write('# num_time_steps='+str(v_slip.nt)+'\n') f.write('# location= 0 km strike, '+str(v_slip.x)+' km across, '+ str(depthsign*v_slip.y)+' km depth\n') f.write('# Column #1 = Time (s)\n') f.write('# Column #2 = horizontal slip (m)\n') f.write('# Column #3 = horizontal slip rate (m/s)\n') f.write('# Column #4 = horizontal shear stress (MPa)\n') f.write('# Column #5 = vertical slip (m)\n') f.write('# Column #6 = vertical slip rate (m/s)\n') f.write('# Column #7 = vertical shear stress (MPa)\n') if normal: f.write('# Column #8 = normal stress (MPa)\n') f.write('#\n') if normal: f.write('t h-slip h-slip-rate h-shear-stress v-slip v-slip-rate v-shear-stress n-stress\n') else: f.write('t h-slip h-slip-rate h-shear-stress v-slip v-slip-rate v-shear-stress\n') f.write('#\n') for i in range(v_slip.nt): if normal: f.write("{:.12E} {:E} {:E} {:E} {:E} {:E} {:E} {:E}\n".format(v_slip.t[i], 0., 0., 0., depthsign*v_slip.Uy[i], depthsign*v_slip_rate.Vy[i], depthsign*v_shear_stress.Sy[i], n_stress.Sn[i])) else: f.write("{:.12E} {:E} {:E} {:E} {:E} {:E} {:E}\n".format(v_slip.t[i], 0., 0., 0., depthsign*v_slip.Uy[i], depthsign*v_slip_rate.Vy[i], depthsign*v_shear_stress.Sy[i])) f.close()
# icohesion = c1 + (depth - y1) * (c2-c1)/(y2-y1) # return icohesion # for i in range(nby1): # if y_fault[i] >= 65.0: # cohesion[i,0] = get_cohesion(y_fault[i]) # p.set_paramfile(1,fdfault.swparamfile(nby1,1,zer,zer,zer,cohesion,zer,zer)) # plt.plot(cohesion[:,0], y_fault) # plt.show() # sys.exit() # Full domain properties p.add_output( fdfault.output('vxbody', 'vx', 0, nt - 1, 50 * refine, 0, nx - 1, 2 * refine, 0, ny - 1, 2 * refine, 0, 0, 1)) p.add_output( fdfault.output('vybody', 'vy', 0, nt - 1, 50 * refine, 0, nx - 1, 2 * refine, 0, ny - 1, 2 * refine, 0, 0, 1)) p.add_output( fdfault.output('sxbody', 'sxx', 0, nt - 1, 50 * refine, 0, nx - 1, 2 * refine, 0, ny - 1, 1 * refine, 0, 0, 1)) p.add_output( fdfault.output('sxybody', 'sxy', 0, nt - 1, 50 * refine, 0, nx - 1, 2 * refine, 0, ny - 1, 2 * refine, 0, 0, 1)) p.add_output( fdfault.output('sybody', 'syy', 0, nt - 1, 50 * refine, 0, nx - 1, 2 * refine, 0, ny - 1, 2 * refine, 0, 0, 1)) # Only fault properties p.add_output(
def create_problem(arg, name="rough_example", outname="ufault", refine=1): """ Create demo problem Inputs: Required: arg = 1d array of length 3 holding simulation inputs (shear/normal stress, normal stress, ratio of out of plane to in plane normal component) Optional: name = problem name (string) outname = name of output file (string) refine = simulation refinement (default is 1, which should be fine for this) Outputs: None Note: function will fail if the stress on any point of the fault exceeds the strength. Should (probably) not occur for the parameter range specified in the demo, but in here for safety purposes. """ assert len(arg) == 3 syy, ston, sxtosy = arg p = fdfault.problem(name) # set rk and fd order p.set_rkorder(4) p.set_sbporder(4) # set problem info nt = 800*refine + 1 nx = 400*refine + 1 ny = 150*refine + 1 lx = 32. ly = 12. p.set_nt(nt) p.set_cfl(0.3) p.set_ninfo((nt-1)//4) # set number of blocks and coordinate information p.set_nblocks((1,2,1)) p.set_nx_block(([nx], [ny, ny], [1])) # set block dimensions p.set_block_lx((0,0,0),(lx, ly)) p.set_block_lx((0,1,0),(lx, ly)) # set block boundary conditions p.set_bounds((0,0,0),['absorbing', 'absorbing', 'absorbing', 'none']) p.set_bounds((0,1,0),['absorbing', 'absorbing', 'none', 'absorbing']) # set block surface sxx = sxtosy*syy sxy = -syy*ston x = np.linspace(0., lx, nx) y = ly*np.ones(nx)+generate_profile(nx, lx, 1.e-2, 20, 1., 18749) surf = fdfault.curve(nx, 'y', x, y) # set initial fields norm_x, norm_y = generate_normals_2d(x, y, 'y') sn = np.zeros(nx) st = np.zeros(nx) for i in range(nx): sn[i], st[i] = rotate_xy2nt_2d(sxx, sxy, syy, (norm_x[i], norm_y[i]), 'y') assert np.all(st+0.7*sn < 0.), "shear stress is too high" p.set_block_surf((0,0,0), 3, surf) p.set_block_surf((0,1,0), 2, surf) p.set_stress((sxx, sxy, 0., syy, 0., 0.)) # set interface type p.set_iftype(0,'slipweak') # set slip weakening parameters p.add_pert(fdfault.swparam('constant', dc = 0.8, mus = 0.7, mud = 0.2),0) p.add_pert(fdfault.swparam('boxcar', x0 = 2., dx = 2., mus = 10000.),0) p.add_pert(fdfault.swparam('boxcar', x0 = 30., dx = 2., mus = 10000.),0) # add load perturbation nuc_pert = np.zeros((nx, 1)) idx = (np.abs(x - lx/2.) < 2.) nuc_pert[idx, 0] = (-0.7*sn[idx]-st[idx])+0.1 p.set_loadfile(0, fdfault.loadfile(nx, 1, np.zeros((nx, 1)), nuc_pert, np.zeros((nx, 1)))) # add output unit outname = "ufault" p.add_output(fdfault.output(outname,'U', nt, nt, 1, 0, nx - 1, 1, ny, ny, 1, 0, 0, 1)) p.write_input(directory=join(fdfault_path,"problems"))
('045', '075'), ('075', '075'), ('120', '075'), ('000', '120')] fields = [ 'h-slip', 'h-slip-rate', 'h-shear-stress', 'v-slip', 'v-slip-rate', 'v-shear-stress' ] fname = ['Ux', 'Vx', 'Sx', 'Uz', 'Vz', 'Sz'] for station in onfault: xcoord = float(station[0]) / 10. zcoord = -float(station[1]) / 10. xpt, ypt, zpt = p.find_nearest_point((xcoord, 0., zcoord), known='y', knownloc=ny) for fld, fn in zip(fields, fname): p.add_output( fdfault.output( 'faultst' + station[0] + 'dp' + station[1] + '-' + fld, fn, 0, nt, 1, xpt, xpt, 1, ypt, ypt, 1, zpt, zpt, 1)) # off fault stations offfault = [('030', '-120', '000'), ('030', '120', '000'), ('030', '-120', '075'), ('030', '120', '075')] fields = ['h-vel', 'v-vel', 'n-vel'] fname = ['vx', 'vz', 'vy'] for station in offfault: xcoord = float(station[1]) / 10. ycoord = float(station[0]) / 10. zcoord = -float(station[2]) / 10. xpt, ypt, zpt = p.find_nearest_point((xcoord, ycoord, zcoord)) for fld, fn in zip(fields, fname):
print('dynamic friction ' + str(MUD)) print('sxx ' + str(sxx)) print('syy ' + str(syy)) print('shear stress ' + str(sxy)) print('fault roughness ' + str(rms_ratio)) print('seed iterations ' + str(seed_iterations)) print('seed ' + str(seed)) print('extent in km ' + str(extent_km)) print(min_range, max_range) # ------------------------------------------- # add output unit #p.add_output(fdfault.output('vfault','V',0, end_time-1, interval_time, 0, nx-1, 1, ny, ny, 1, 0, 0, 1)) #p.add_output(fdfault.output('sfault','S',0, end_time-1, interval_time, 0, nx-1, 1, ny, ny, 1, 0, 0, 1)) #p.add_output(fdfault.output('snfault','Sn',0, end_time-1, interval_time, 0, nx-1, 1, ny, ny, 1, 0, 0, 1)) #p.add_output(fdfault.output('sxfault','Sx',0, end_time-1, interval_time, 0, nx-1, 1, ny, ny, 1, 0, 0, 1)) #p.add_output(fdfault.output('syfault','Sy',0, end_time-1, interval_time, 0, nx-1, 1, ny, ny, 1, 0, 0, 1)) #p.add_output(fdfault.output('sxxbody','sxx',0, end_time-1, interval_time, 0, 3200, 2, 0, 1601, 2, 0, 0, 1)) #p.add_output(fdfault.output('sxybody','sxy',0, end_time-1, interval_time, 0, 3200, 2, 0, 1601, 2, 0, 0, 1)) #p.add_output(fdfault.output('syybody','syy',0, end_time-1, interval_time, 0, 3200, 2, 0, 1601, 2, 0, 0, 1)) p.add_output( fdfault.output('slip', 'U', 0, end_time - 1, interval_time, 0, nx - 1, 1, ny, ny, 1, 0, 0, 1)) p.write_input() seed = seed + 1 #pore_pressure = pore_pressure + 0.01 seed_iterations = seed_iterations + 1
for i in range(nby0): if y_fault[i] > 7.6: cohes[i,0] += cmax p.set_paramfile(0,fdfault.swparamfile(nby0,1,zer,zer,zer,cohes,zer,zer)) p.set_stress plt.plot(cohes[:,0], y_fault) plt.show() fdfault.loadfile() # add output unit p.add_output(fdfault.output('vxbody','vx',0, nt-1, 50*refine, 0, nx-1, 2*refine, 0, nby0-1, 2*refine, 0, 0, 1)) p.add_output(fdfault.output('vybody','vy',0, nt-1, 50*refine, 0, nx-1, 2*refine, 0, nby0-1, 2*refine, 0, 0, 1)) p.add_output(fdfault.output('vfault','V', 0, nt-1, 50*refine, nx1, nx1, refine, 0, nby0-1, 2*refine, 0, 0, 1)) p.add_output(fdfault.output('sxbody','sxx',0, nt-1, 50*refine, 0, nx-1, 2*refine, 0, nby0-1, 1*refine, 0, 0, 1)) p.add_output(fdfault.output('sxybody','sxy',0, nt-1, 50*refine, 0, nx-1, 2*refine, 0, nby0-1, 2*refine, 0, 0, 1)) p.add_output(fdfault.output('sybody','syy',0, nt-1, 50*refine, 0, nx-1, 2*refine, 0, nby0-1, 2*refine, 0, 0, 1)) p.add_output(fdfault.output('sfault','S', 0, nt-1, 50*refine, nx1, nx1, refine, 0, nby0-1, 2*refine, 0, 0, 1)) p.add_output(fdfault.output('snfault','Sn', 0, nt-1, 50*refine, nx1, nx1, refine, 0, nby0-1, 2*refine, 0, 0, 1)) # -- add output for seismogram # off fault stations offfault = [('000', '000', '000'), ('100', '000', '000'), ('200', '000', '000'), ('300', '000', '000'), ('400', '000', '000'),('500', '000', '000'),('600', '000', '000'), ('700', '000', '000'), ('800', '000', '000')] fields = ['h-vel','n-vel'] fname = ['vx','vy']
def print_vertical_velocity(models, steps, color_map): # steps = [50, 100, 150, 200] row = len(steps) col = 2 mx = 0.5 mn = mx * (-1) Lbody_vy = fdfault.output(models[0], 'vybody') Sbody_vy = fdfault.output(models[1], 'vybody') Lbody_vy.load() Sbody_vy.load() fig1 = plt.figure() indx = 1 label = 'Vertical' for i in range(row): print(indx) # long term model ax1 = fig1.add_subplot(row, col, indx) a = ax1.pcolor(Lbody_vy.x, Lbody_vy.y, Lbody_vy.vy[steps[i], :, :], cmap=color_map, vmax=mx, vmin=mn) ax1.set_yticklabels([-10, '', '', '', '', 0]) ax1.tick_params( axis='x', # changes apply to the x-axis which='both', # both major and minor ticks are affected bottom='off', # ticks along the bottom edge are off top='off', # ticks along the top edge are off right='off') ax1.set_title('Time: ' + str(round(Lbody_vy.t[steps[i]], 0)) + ' s', loc='left') ax1.set_ylabel('Depth (km)') if indx == 7: set_color_bar(a, label, fig1) ax1.set_xlabel('Distance (km)') elif indx == 1: ax1.set_title('(a) \n Time: ' + str(round(Lbody_vy.t[steps[i]], 0)) + ' s', loc='left') else: ax1.set_xticklabels([]) # short term model ax1 = fig1.add_subplot(row, col, indx + 1) a = ax1.pcolor(Sbody_vy.x, Sbody_vy.y, Sbody_vy.vy[steps[i], :, :], cmap=color_map, vmax=mx, vmin=mn) ax1.set_yticklabels([]) ax1.tick_params( axis='x', # changes apply to the x-axis which='both', # both major and minor ticks are affected bottom='off', # ticks along the bottom edge are off top='off', # ticks along the top edge are off right='off') if indx == 7: set_color_bar(a, label, fig1) ax1.set_xlabel('Distance (km)') elif indx == 1: ax1.set_title('(b) \n', loc='left') else: ax1.set_xticklabels([]) indx += 2 # fig1.savefig('rupture_vy_without_coh.png') # save the figure to file # plt.close(fig1) plt.show()
def print_horizontal_velocity(models, steps): row = len(steps) col = 2 mx = 0.5 mn = mx * (-1) Lbody_vx = fdfault.output(models[0], 'vxbody') Sbody_vx = fdfault.output(models[1], 'vxbody') Lbody_vx.load() Sbody_vx.load() # maxy = max(Lbody_vx.y) fig1 = plt.figure(figsize=(9, 5)) indx = 0 label = 'Horizontal' for i in range(row): # long term model indx = indx + 1 ax1 = fig1.add_subplot(row, col, indx) a = ax1.pcolor(Lbody_vx.x, Lbody_vx.y, Lbody_vx.vx[steps[i], :, :], cmap=color_map, vmax=mx, vmin=mn) ax1.set_yticklabels([-10, 0]) # ax1.tick_params(axis='x', which='both', bottom='off', top='off',right='off') # ax1.set_title('Time: '+ str(round(Lbody_vx.t[steps[i]],0))+' s', loc='left') if indx == 1: ax1.set_title('(a) \t\t\t' + 't = ' + str(round(Lbody_vx.t[steps[i]], 2)) + ' s', loc='left') ax1.set_xticklabels([]) ax1.set_ylabel('Depth (km)') if indx == (row * 2 - 1): ax1.set_xlabel('Distance (km)') ax1.set_ylabel('Depth (km)') ax1.set_title('t = ' + str(round(Lbody_vx.t[steps[i]], 2)) + ' s', loc='left') elif indx > 1 and indx < (row * 2 - 1): ax1.set_xticklabels([]) ax1.set_title('t = ' + str(round(Lbody_vx.t[steps[i]], 2)) + ' s', loc='left') # short term model indx = indx + 1 ax1 = fig1.add_subplot(row, col, indx) a = ax1.pcolor(Sbody_vx.x, Sbody_vx.y, Sbody_vx.vx[steps[i], :, :], cmap=color_map, vmax=mx, vmin=mn) ax1.set_yticklabels([]) # ax1.tick_params(axis='x', which='both', bottom='off', top='off', right='off') if indx == row * 2: ax1.set_xlabel('Distance (km)') elif indx == 2: ax1.set_title('(b)', loc='left') else: ax1.set_xticklabels([]) # fig1.savefig('rupture_vx_without_coh.png') # save the figure to file # plt.close(fig1) set_color_bar(a, label, fig1) plt.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.05, hspace=None) plt.show()
def spatio_temporal_slip_rate(models, models_litho): Lfault_shallow = fdfault.output(models[0], 'vfault') Lfault_deep = fdfault.output(models[1], 'vfault') litho_shallow = fdfault.output(models_litho[0], 'vfault') litho_deep = fdfault.output(models_litho[1], 'vfault') Lfault_shallow.load() Lfault_deep.load() litho_shallow.load() litho_deep.load() times = Lfault_shallow.t depths = Lfault_shallow.y time_len = int(len(times)) meshX, meshY = np.meshgrid(times[:time_len], depths) fig = plt.figure(figsize=(5.5, 4)) plt.subplot(141) plt.pcolor(meshX, meshY - maxy, (Lfault_shallow.V).T, vmax=10, vmin=0, cmap=color_map) plt.xlabel('Time (s)') plt.xticks([0, 1, 2, 3, 4]) plt.title('(a) RSN', loc='left') plt.ylabel('Depth (km)') # cb = plt.colorbar() plt.subplot(142) plt.pcolor(meshX, meshY - maxy, (litho_shallow.V).T, vmax=10, vmin=0, cmap=color_map) plt.xlabel('Time (s)') plt.yticks([]) plt.xticks([0, 1, 2, 3, 4]) plt.title('(b) RSNL', loc='left') plt.subplot(143) ax1 = plt.pcolor(meshX, meshY - maxy, (Lfault_deep.V).T, vmax=10, vmin=0, cmap=color_map) plt.xlabel('Time (s)') plt.yticks([]) plt.xticks([0, 1, 2, 3, 4]) plt.title('(c) RSC', loc='left') # cb = plt.colorbar() plt.subplot(144) ax1 = plt.pcolor(meshX, meshY - maxy, (litho_deep.V).T, vmax=10, vmin=0, cmap=color_map) plt.xlabel('Time (s)') plt.yticks([]) plt.xticks([0, 1, 2, 3, 4]) plt.title('(d) RSCL', loc='left') cb = fig.colorbar(ax1, ticks=[0, 5, 10]) cb.set_label('Slip veolocity (m/s)') plt.tight_layout() plt.show()
def calculate_pgv(models, models_litho): Lbody_vx_shallow = fdfault.output(models[0], 'vxbody') Lbody_vy_shallow = fdfault.output(models[0], 'vybody') Lbody_vx_deep = fdfault.output(models[1], 'vxbody') Lbody_vy_deep = fdfault.output(models[1], 'vybody') litho_vx_shallow = fdfault.output(models_litho[0], 'vxbody') litho_vy_shallow = fdfault.output(models_litho[0], 'vybody') litho_vx_deep = fdfault.output(models_litho[1], 'vxbody') litho_vy_deep = fdfault.output(models_litho[1], 'vybody') Lbody_vx_shallow.load() Lbody_vy_shallow.load() Lbody_vx_deep.load() Lbody_vy_deep.load() litho_vx_shallow.load() litho_vy_shallow.load() litho_vx_deep.load() litho_vy_deep.load() shallow = np.sqrt(Lbody_vx_shallow.vx[:, :, 401]**2 + Lbody_vy_shallow.vy[:, :, 401]**2) LV_shallow = shallow.max(axis=0) deep = np.sqrt(Lbody_vx_deep.vx[:, :, 401]**2 + Lbody_vy_deep.vy[:, :, 401]**2) LV_deep = deep.max(axis=0) litho_shallow = np.sqrt(litho_vx_shallow.vx[:, :, 401]**2 + litho_vy_shallow.vy[:, :, 401]**2) LV_litho_shallow = litho_shallow.max(axis=0) litho_deep = np.sqrt(litho_vx_deep.vx[:, :, 401]**2 + litho_vy_deep.vy[:, :, 401]**2) LV_litho_deep = litho_deep.max(axis=0) # load surface data filename = open('surface.pkl', 'rb') surface = pickle.load(filename) filename.close() plt.subplot(511) plt.plot(surface['x1'], surface['y1'], 'b-') plt.plot(surface['x2'], surface['y2'], 'b-') plt.plot(surface['xfault'], surface['yfault'] - 70, color='red', linestyle='--', linewidth=3) plt.xticks([]) plt.ylabel('Depth (km)') plt.yticks([0, -5, -10]) plt.text(55, -5, 'Footwall') plt.text(5, -5, 'Hanging wall') plt.text(0, -3, '(a)') plt.annotate('Fault', xy=(35, -6.5), xytext=(45, -8), arrowprops=dict(facecolor='black', shrink=0.005), color='red') plt.subplot(512) plt.plot(Lbody_vx_shallow.x[:, 401], LV_shallow, 'b-') plt.yticks([0, 1, 2]) plt.xticks([]) plt.text(0, 1.5, '(b) RSN') # plt.legend(loc='upper right', frameon=False) plt.subplot(513) plt.plot(Lbody_vx_shallow.x[:, 401], LV_litho_shallow, 'r-') plt.yticks([0, 10, 20]) plt.xticks([]) plt.text(0, 15, '(c) RSNL') # plt.legend(loc='upper right', frameon=False) plt.subplot(514) plt.plot(Lbody_vx_shallow.x[:, 401], LV_deep, 'b-') plt.yticks([0, 1, 2]) plt.text(0, 1.1, '(d) RSC') plt.xticks([]) # plt.legend(loc='upper right', frameon=False) plt.subplot(515) plt.plot(Lbody_vx_shallow.x[:, 401], LV_litho_deep, 'r-') plt.yticks([0, 5, 10]) plt.xlabel('Distance across fault (km)') plt.text(0, 7, '(e) RSCL') # plt.legend(loc='upper right', frameon=False) plt.text(-14, 40, 'Peak ground velocity (m/s)', rotation=90) plt.show()
p.set_stress((-120., 70., 0., -100., 0., 0.)) # set interface type p.set_iftype(0, 'slipweak') # set slip weakening parameters p.add_pert(fdfault.swparam('constant', dc=0.4, mus=0.676, mud=0.525), 0) p.add_pert(fdfault.swparam('boxcar', x0=2., dx=2., mus=10000.), 0) p.add_pert(fdfault.swparam('boxcar', x0=30., dx=2., mus=10000.), 0) # add load perturbations p.add_load(fdfault.load('boxcar', 0., 16., 1.5, 0., 0., 0., 11.6, 0.)) # add output unit p.add_output( fdfault.output('vxbody', 'vx', 0, 1600, 50, 0, 1200, 2, 0, 1600, 2, 0, 0, 1)) p.add_output( fdfault.output('vybody', 'vy', 0, 1600, 50, 0, 1200, 2, 0, 1600, 2, 0, 0, 1)) p.add_output( fdfault.output('vfault', 'V', 0, 1600, 10, 601, 601, 1, 0, 1600, 2, 0, 0, 1)) p.write_input()