%Welcome to MEFISTO, the Mineralization, Earthquake, and Fluid-flow %Integrated SimulaTOr. For more information, visit www.mefisto.org. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %1. DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %1a. Basic geometry variables. % block_height: Cell height (m). Normal to interface. % dip: Interface dip (radians). % dt: time (s) per model increment. % L: Dip-parallel length of interface (km). % nx: Number of cells in the x (strike) direction. % ny: Number of cells in the y (dip) direction. % plate_rate: Plate convergence rate (m/yr). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %1b. Model execution variables. % aftershocks: Number of ruptures that are mapped after a large event (see %'rupture_snap') occurs % burn_in: Number of increments to ignore at the beginning. Intended for %model to reach steady-state conditions before generating output. % frame_int: Number of increments between movie frames. % init_conditions: ['file', 'rand', or 'flat'] Controls the initial distributions of cell locations and asperitized cells. % init_loc_max: If init_conditions is 'rand', this is the maximum initial loc value. % mapruptures: [1 or 0] Option of whether to save a map of aftershock %ruptures. % n_incs = Number of time increments to run through. % rupture_snap: Earthquake magnitude above which subsequent ruptures [n = %aftershocks] are mapped. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %1c. Model physical variables. %1c1. Elasticity % D_phi_asp: Change in ratio of static to dynamic friction for asperities. % kc = 3; %Spring constant of coupling springs, which connect neighboring cells. % kl = 1; Spring constant of leading springs, which connect each cell to the subducting slab. % max_dstrength: Max shear strength added to asperities (MPa). % non_asp_str: Failure shear stress of non-asperity cells (MPa). % phi [>1]: Ratio of static to dynamic friction. % tensile_strength_factor: ratio of max_dstrength to tensile strength. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %1c2. Plasticity % flowlaw [1 or 0]: Option to incorporate temperature-dependent crystal-plastic flow. % F: Pre-exponential term for flow law. % Fe: Exponential term for flow law. % Fx: Power-law exponent for flow law. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %1c3. Hydraulics % defperm: Default hydraulic conductivity of cells (m/s). % minKfactor [0 1): factor by which a sealed cell's permeability is reduced (1 means reduced to zero). % defpore: default porosity for unhealed cells (unitless). % minporefactor [0 1): factor by which a sealed cell's porosity is reduced (1 means reduced to zero). % water_comp: Water compressibility (roughly 4.6e-4 per megapascal, for water). % sea_floor [0 or 1]: option for sea-floor constant pressure boundary % condition at top; otherwise top is no-flow boundary. % sea_floor_pressure: sea floor pressure, MPa, for sea floor constant-pressure boundary condition. % fluidmean: Depth of max fluid production (units of cell rows). % fluidsd: Standard deviation of fluid production zone. Controls height of fluid production zone, which is normally distributed parallel to dip and constant parallel to strike. % fluid_prod_mag = 1e-10; %Controls amount of fluid production. units are kg/s/mwidthx)/m(height); scales with block volume but not porosity. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %1c4. Temperature and mineral controls. % A: Strengthening pre-exponential factor. % C: Asperity nucleation factor. % Ea: Activation energy for asperity nucleation. % G: Activation energy for strengthening. % R: Gas constant. % Tmin: Temperature at the top of the slab (celsius). % Tmax [>Tmin]: Temperature at the bottom of the slab (celsius). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all cc = clock; tic %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Use this section if you wan to run MEFISTO multiple times and make a %matrix of outcomes %Enter parameters to vary. Be sure to comment them out below if you want %them to vary; otherwise they will be overwritten below. %If you don't want anything to vary, then just enter loop sizes = 1 here for O = 1:1 for P = 1:1 fluid_prod_mag = 10^-(O-1); defperm = 10^(P-11); fluid_prod_mag_stats(O,P) = fluid_prod_mag; defperm_stats(O,P) = defperm; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Model parameters. Change variables followed by '%%%User%%%' as desired. nx = 50; %%%User%%% ny = 50; %%%User%%% n_incs = 2000000;%%%User%%% burn_in = 100000; %%%User%%% init_conditions = 'flat'; %%%User%%% init_loc_max = 1; %%%User%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Simulation options mapruptures = 1;%%%User%%% frame_int = 1000;%%%User%%% rupture_snap =9; %%%User%%% aftershocks = 50;%%%User%%% aftershock_count = aftershocks;%%%User%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Spring material properties phi = 1.5; %%%User%%% D_phi_asp = 0; %%%User%%% kc = 3; %%%User%%% kl = 1; %%%User%%% alpha = kc/kl; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Temperature and mineral parameters non_asp_str = 1; %%%User%%% max_dstrength = 40; %%%User%%% tensile_strength_factor = 0.1; %%%User%%% Ea = 54; %%%User%%% C = 1e-3; %%%User%%% A = 1e7; %%%User%%% G = 54; %%%User%%% Tmin = 25; %%%User%%% Tmax = 250; %%%User%%% R = 8.314e-3; T = repmat((Tmin:(Tmax-Tmin)/(ny-1):Tmax)',1,nx); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Model geometry parameters L = 130; %%%User%%% dip = 10 * pi/180; %%%User%%% block_height = 1; %%%User%%% plate_rate = 0.05; %%%User%%% dt = 5000; %%%User%%% plate_rate_persec = plate_rate/365/24/3600; rupture_snap = 10^((rupture_snap-2/3*log10(32e16)+10.7)*1.5); block_area = (L/ny)^2*1e6; time_increment = dt; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Fluid parameters defperm = 1e-8; %%%User%%% defK = defperm/9.8; %%%User%%% K = ones(ny,nx).*defK; minKfactor = 0.99; %%%User%%% defpore = 0.01; %%%User%%% porosity = defpore.*ones(ny,nx); minporefactor = 0; %%%User%%% water_comp = 4.6e-4; sea_floor = 1; %%%User%%% sea_floor_pressure = 0; %%%User%%% overburden = ones(ny,nx)*9.8*(2400-1100)/1000000*sin(dip)*L*1000/ny.*(1:ny)'; fluidmean = ny*0.7; %%%User%%% fluidsd = 3; %%%User%%% fluid_prod_mag = 1e-10; %%%User%%% defmass = defpore*block_area*block_height*1100; fluid_mass = porosity.*block_area.*block_height.*1100;%mass filling porosity initially, density 1.1 g/cc fluid_pressure = (defpore./porosity.*fluid_mass./defmass-1)./water_comp;% + overburden*(1.1/2.4);%nonhydrostatic component; hydrostatic component omitted and added to failure crit fluid_prod = repmat(1/(sqrt(2*pi*fluidsd^2)).*exp(-((1:ny)-fluidmean).^2./(2*fluidsd^2))',1,nx)*sqrt(block_area)*block_height*fluid_prod_mag;%gaussian fluid production distribution with depth. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Flow law parameters F = 1e1; %%%User%%% Fe = 90; %%%User%%% Fx = 1; flowlaw = 1; %%%User%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% switch init_conditions case 'file' loc = load('loc_init.csv'); %Location of each slider block relative to rigid block. asp = logical(load('asp_init.csv')); %Logical array of whether or not a cell is an asperity. case 'rand' loc = init_loc_max*rand(ny,nx); asp = logical(round(rand(ny,nx))); case 'flat' loc = zeros(ny,nx); asp = false(ny,nx); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %placeholder variables rupture_slip = zeros(1,n_incs); %Total slip in each rupture. slip_surplus = zeros(1,n_incs); %Tracks the slip surplus (+) or deficit (-) at the start of each rupture. nloops = 0; %Number of times through the while loop involved in each rupture. rupture_area = zeros(1,n_incs); %Number of cells that slip in each rupture, not counting cells that slip more than once as extra cells. rupture_map = zeros(ny,nx); %map of cells that slip during any single rupture. fail_cells = false(ny,nx); %Initially no cells are failing; even if they are, the first run through the while loop will determine that and go from there. cum_slip = zeros(ny,nx); %Tracks the cumulative slip on each cell. dstrength = zeros(ny,nx); %added strength of each cell, will be based on thermal exposure since last rupture. aspage = zeros(ny,nx);%age of each asperity loc_frame = zeros(ny,nx,n_incs/frame_int+1-burn_in); %Stores a frame of the cumulative slip every frame_int ruptures. dstrength_frame = zeros(ny,nx,n_incs/frame_int+1-burn_in); %Make a movie of cell strength fluid_mass_frame = zeros(ny,nx,n_incs/frame_int+1-burn_in); fluid_pressure_frame = zeros(ny,nx,n_incs/frame_int+1-burn_in); rupturemap_frame = zeros(ny,nx,1); aftershock_frame = zeros(ny,nx,1); fluid_loss_frame = zeros(ny,nx,1); fail = zeros(ny,nx); rupture_init_X = zeros(1,n_incs); rupture_init_Y = zeros(1,n_incs); rupture_time = zeros(1,n_incs); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Begin simulation for n = 1:n_incs %Run through the total number of increments. time_increment = dt*(10^(-log10(defperm)-6))^(n<(burn_in*0.9));% This step forces the model to increase time-steps during the burn-in, so that equilibrium fluid conditions are reached. if min(min(fluid_mass)) == 0 disp('Error: A cell has run out of fluid.'); break end slip_surplus(n) = sum(sum(loc)); %Slip surplus (+) or deficit (-) at the beginning of the next rupture. if min(min(fail)) <= 0 [a,b] = min(min(fail)); [c,d] = min(min(fail,[],2)); rupture_init_X(n) = b; rupture_init_Y(n) = d; rupture_time(n) = time_increment/365/24/3600*(n-1);%yr units end while min(min(fail)) <= 0 %1e-15) %Keep running through the rupture until no cells are displaced past their point of failure. nloops = nloops+1; stress = loc+alpha*([loc(:,1:nx-1)-loc(:,2:nx),zeros(ny,1)]... +[loc(1:ny-1,:)-loc(2:ny,:);zeros(1,nx)]... +[zeros(1,nx);loc(2:ny,:)-loc(1:ny-1,:)]... +[zeros(ny,1),loc(:,2:nx)-loc(:,1:nx-1)]);%Shear stress on each slider block fail = dstrength+non_asp_str+0.1*(overburden-fluid_pressure+stress/sin(2*dip)*(cos(2*dip)-1))-stress;%updated V35%(0.6*(minstress-fluid_pressure)+dstrength+non_asp_str)/(1-0.6/sin(2*dip)-0.6*-cos(2*dip)/sin(2*dip))-stress;%updated failure criterion treating stress as shear stress, july 6 2019, V25; V27 changes overburden to minstress fail_cells = fail<=1e-15; %Logical array telling which cells fail. Changed to 1e-15 to deal with rounding errors. slip = -2*(stress-1./(phi+D_phi_asp.*asp))/(1+4*alpha); %Distance each block would slip if it were to fail. rupture_map = or(rupture_map>0,fail_cells>0); % rupture map is a logical of each cell that has slipped in this rupture. loc(fail_cells) = loc(fail_cells)+slip(fail_cells); %Move failing cells by their (negative) displacement to bring them to failure. asp(fail_cells) = false; %Reset the cells that failed so they are no longer asperities. dstrength(fail_cells) = 0; %Reset the added strength to failed cells back to zero. porosity(fail_cells) = defpore; %Set the porosity of failed cells to the default, unhealed value. fluid_pressure(fail_cells) = min(overburden(fail_cells)+dstrength(fail_cells)*tensile_strength_factor,(defpore./porosity(fail_cells).*fluid_mass(fail_cells)./defmass-1)./water_comp); % drop pressure in failed cells according to porosity; no flow during propagation if sea_floor == 1 fluid_pressure(1,:) = sea_floor_pressure;%keep top row at constant pressure fluid_mass(1,:) = porosity(1,:).*block_area.*block_height.*1100; end aspage(fail_cells) = 0;%reset the time since asperitization of each failed cell to zero. rupture_slip(n) = rupture_slip(n)+sum(slip(fail_cells)); %Add to the total amount of displacement during this rupture. cum_slip = cum_slip+fail_cells; rupture_area(n) = sum(sum(rupture_map)); %Rupture area is the total of all cells that slipped in that rupture. if nloops>2*nx*ny disp('Error: Rupture not stopping') break end end if mapruptures == 1 if n > burn_in %max_slip(n) = min(min(cum_slip)); %Used to track max slipping cell per rupture; uncomment with cum_slip as desired if rupture_area(n) > 0 if aftershock_count < aftershocks aftershock_frame(:,:,size(rupturemap_frame,3)*aftershocks+aftershock_count) = rupture_map.*aftershock_count; aftershock_count = aftershock_count + 1; end end if -rupture_slip(n)*block_area>=rupture_snap rupturemap_frame(:,:,size(rupturemap_frame,3)+1) = -cum_slip; init_Xf(size(rupturemap_frame,3)) = b; init_Yf(size(rupturemap_frame,3)) = d; aftershock_count = 1; end end end rupture_map = zeros(ny,nx); %Clear the rupture map. cum_slip = zeros(ny,nx); nloops = 0; rn = rand(size(asp)); % asp(~asp & rn=overburden+dstrength*tensile_strength_factor; fluid_loss = zeros(ny,nx); fluid_loss(crack_cells) = fluid_mass(crack_cells) - (1+fluid_pressure(crack_cells).*water_comp).*defmass.*porosity(crack_cells)./defpore; if n > burn_in if mod(n,frame_int) == 0 loc_frame(:,:,n/frame_int+1-burn_in/frame_int) = loc(:,:); %Add to the cumulative slip on each cell that failed. fluid_mass_frame(:,:,n/frame_int+1-burn_in/frame_int) = fluid_mass(:,:); fluid_pressure_frame(:,:,n/frame_int+1-burn_in/frame_int) = fluid_pressure(:,:); dstrength_frame(:,:,n/frame_int+1-burn_in/frame_int) = dstrength(:,:); fluid_loss_frame(:,:,n/frame_int+1-burn_in/frame_int) = fluid_loss(:,:); end end fluid_mass(crack_cells) = fluid_mass(crack_cells) - fluid_loss(crack_cells);%leak excess fluid mass out the roof to limit pressure loc = loc+time_increment*plate_rate_persec; %Move the driving plate to the point of the next rupture. Should always be +ive outside rupture loop. if flowlaw == 1 loc = loc-stress.^Fx.*F.*exp(-Fe./(R.*(T+273.15))).*time_increment; end stress = loc+alpha*([loc(:,1:nx-1)-loc(:,2:nx),zeros(ny,1)]... +[loc(1:ny-1,:)-loc(2:ny,:);zeros(1,nx)]... +[zeros(1,nx);loc(2:ny,:)-loc(1:ny-1,:)]... +[zeros(ny,1),loc(:,2:nx)-loc(:,1:nx-1)]);%Stress on each slider block fail = dstrength+non_asp_str+0.1*(overburden-fluid_pressure+stress/sin(2*dip)*(cos(2*dip)-1))-stress; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Wrap up t = toc; disp(['Finished calculations in ',num2str(t),' seconds']) %If there is a burn-in period to remove, take out those results from the %result vectors. if burn_in>0 rupture_time = rupture_time(burn_in+1:end); rupture_slip = rupture_slip(burn_in+1:end); rupture_slip = rupture_slip(rupture_time>0); slip_surplus = slip_surplus(burn_in+1:end); slip_surplus = slip_surplus(rupture_time>0); rupture_area = rupture_area(burn_in+1:end); rupture_area = rupture_area(rupture_time>0); rupture_init_X = rupture_init_X(burn_in-1:find(rupture_init_X,1,'last')); %did burn_in -1 to synch up with movie rupture_init_Y = rupture_init_Y(burn_in-1:find(rupture_init_Y,1,'last')); rupture_init_X = rupture_init_X(rupture_init_X>0); rupture_init_Y = rupture_init_Y(rupture_init_Y>0); rupture_time = rupture_time(rupture_time>0); rupture_time = rupture_time-rupture_time(1)+1; end Mw = 2/3*log10(-rupture_slip*block_area) + 2/3*log10(32 * 1e16) - 10.7; Mw_finite = Mw(isfinite(Mw)); stress_drop = 32000 * rupture_slip./rupture_area./sqrt(rupture_area*block_area);%megapascales slip_surplus = slip_surplus./(nx*ny); Mw_stats(O,P,1:size(Mw_finite,2)) = Mw_finite; rupture_time_stats(O,P,1:size(rupture_time,2)) = rupture_time; rupture_slip_stats(O,P,1:size(rupture_slip,2)) = rupture_slip; slip_surplus_stats(O,P,1:size(slip_surplus,2)) = slip_surplus; fluid_prod_stats(O,P) = sum(sum(fluid_prod)); fluid_loss_stats(O,P,:) = permute((sum(sum(fluid_loss_frame./time_increment))),[3 2 1]); totmass_stats(O,P,:) = permute(sum(sum(fluid_mass_frame(2:end,:,:))),[3 2 1]); pgrad_stats(O,P,:) = permute(sum(fluid_pressure_frame(fluidmean,:,:)-fluid_pressure_frame(2,:,:))*1000000/nx/(L*1000*fluidmean/ny),[3 2 1]); porosity_frame = defpore - defpore*minporefactor*(dstrength_frame./max_dstrength); porosity_hist_stats(O,P,:) = permute(mean(mean(porosity_frame)),[3 2 1]); save('results.mat') end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Make plots. if O*P == 1 %Plot the asperity area and rupture sizes over time. figure(1) subplot(2,1,1) errorbar(rupture_time(rupture_time>0),Mw_finite,Mw_finite,zeros(size(Mw_finite)),'.k','CapSize',0) ylim([min(Mw_finite)-0.5 max(Mw_finite)+0.5]) ylabel('Magnitude') subplot(2,1,2) plot(rupture_time,slip_surplus) xlabel('Time (yr)') ylabel('Average slip deficit (m)') figure(2) X = min(Mw_finite):0.1:max(Mw_finite); for i = 1:size(X,2) Y(i) = sum(Mw_finite>X(1,i)); end plot(X,log10(Y),'Marker','o','MarkerEdgeColor',[1 0 0],'LineStyle','none') xlabel('Magnitude') ylabel('log_{10} Cumulative number') axis equal end save(num2str(cc(1:5)),'defperm','defpore','dip','Ea','A','G','C','fluid_prod_mag','minKfactor','minporefactor','alpha','phi','sea_floor')