%% Mars Crustal Thickness & Volcanic Residual Pressure - Robinson Projection % Function: Read Khan2022 Mars crustal thickness dat files, calculate volcanic residual pressure % Generate 2 figures (crustal thickness + residual pressure), each with 2×2 Robinson maps % Unified fixed color scale across all subplots, bottom-center colorbar per figure % Output: 4 residual pressure .dat files + 2 high-resolution PNG figures clear; clc; close all; %% ===================== Configuration ===================== % Input files (4 crustal density models) input_files = { 'Mars-thick-Khan2022-39-2800-2800.dat', 'Mars-thick-Khan2022-39-2850-2850.dat', 'Mars-thick-Khan2022-39-2900-2900.dat', 'Mars-thick-Khan2022-39-2950-2950.dat' }; rho_crust_list = [2800, 2850, 2900, 2950]; % Crustal density, kg/m³ output_dat_files = { 'residual_pressure_2800.dat', 'residual_pressure_2850.dat', 'residual_pressure_2900.dat', 'residual_pressure_2950.dat' }; % Output figure names fig_pr_name = 'Mars_GlobalResidualPressure_Khan2022.png'; fig_thick_name = 'Mars_GlobalCrustalThickness_Khan2022.png'; % Volcanic physical model constants (unchanged) E_star = 23.7; % Apparent modulus E*, GPa g = 3.72; % Mars gravitational acceleration, m/s² gEarth = 9.8; % Earth gravitational acceleration, m/s² rhoEarth = 2830; % Average Earth crust density, kg/m³ mu0 = 151.4; % Pure magma viscosity μ₀, Pa·s phi = 0.55; % Crystal volume fraction φ phi0 = 0.64; % Viscosity constant φ₀ C = 3; % Crystal viscosity constant C kappa = 3e-7; % Magma thermal diffusivity κ, m²/s c = 1600; % Magma heat capacity c, J/(kg·K) dT_dx = 13e-3; % Host rock temperature gradient, K/m L = 414e3; % Magma latent heat L, J/kg H = 11.65 * 1000; % Vertical extent of deep magma chamber H, m rho_M = 3462; % Mantle density ρ_M, kg/m³ sigma_d = 0.11 * 1e6; % Differential stress σ_d, Pa rho_m = 3000; % Magma-crystal mixture density ρ_m, kg/m³ mars_radius = 3389.5; % Mars mean radius, km (for map projection) % ========== Unified fixed color scale ranges ========== pr_caxis = [-60, 20]; % Residual pressure: fixed -60 ~ 20 MPa for all subplots thick_caxis = [0, 120]; % Crustal thickness: fixed 0 ~ 120 km for all subplots % ========== Subplot layout parameters (adjust spacing here) ========== left_margin = 0.07; % Left margin of the whole figure right_margin = 0.07; % Right margin top_margin = 0.12; % Top margin (for main title) bottom_margin = 0.14; % Bottom margin (space for colorbar) h_spacing = 0.01; % Horizontal gap between subplots (smaller = tighter) v_spacing = 0.04; % Vertical gap between subplots (smaller = tighter) %% ===================== Precompute Constant Terms ===================== exponent_mu = C * phi0 / (1 - phi0); mu_m = mu0 * ((1 - phi) / (1 - phi/phi0))^exponent_mu; P_e = (rho_M - rho_m) * g * H; term1 = sqrt(kappa * mu_m / pi); term2 = c * dT_dx / L; %% ===================== Lat/Lon Grid Preprocessing ===================== lat = 90:-1:-90; % Latitude: 90°N to 90°S (matches data order) lon_0_360 = 0:1:360; % Original longitude: 0° to 360° lon_0_360 = lon_0_360(1:end-1); % Remove duplicate 360° column to avoid seam artifact lon = lon_0_360; lon(lon > 180) = lon(lon > 180) - 360; % Convert to -180°~180° [lon_sorted, sort_idx] = sort(lon); [Lon_grid, Lat_grid] = meshgrid(lon_sorted, lat); %% ===================== Calculate Grids for All 4 Density Cases ===================== Pr_all = cell(1,4); % Store residual pressure grids for 4 cases thick_all = cell(1,4); % Store crustal thickness grids for 4 cases for idx = 1:4 rho_crust = rho_crust_list(idx); input_file = input_files{idx}; output_file = output_dat_files{idx}; fprintf('Processing case %d/4: rho_crust = %d kg/m³\n', idx, rho_crust); fprintf(' Reading file: %s\n', input_file); % Read crustal thickness data try crust_thick_km = load(input_file); catch ME error('Failed to read file: %s\n%s', input_file, ME.message); end [n_lat, n_lon] = size(crust_thick_km); fprintf(' Data dimension: %d lat × %d lon\n', n_lat, n_lon); if n_lat ~= 181 || n_lon ~= 361 warning('Input data is not 181×361. Please verify 1° resolution grid.'); end % --- Residual pressure calculation (formula unchanged) --- E_GPa = E_star + (g/gEarth) * (rho_crust / rhoEarth) * crust_thick_km.^0.4; E_Pa = E_GPa * 1e9; crust_thick_m = crust_thick_km * 1000; P_o = P_e + (rho_crust - rho_m) * g * crust_thick_m + sigma_d; inside = term1 * term2 * E_Pa.^2; deltaP_crit = 3.5 * inside.^(2/5); Pr_MPa = (P_o - deltaP_crit) / 1e6; % Prepare plotting grids (remove 360° column + reorder longitude) Pr_plot = Pr_MPa(:, 1:end-1); Pr_plot = Pr_plot(:, sort_idx); Pr_all{idx} = Pr_plot; thick_plot = crust_thick_km(:, 1:end-1); thick_plot = thick_plot(:, sort_idx); thick_all{idx} = thick_plot; % Write residual pressure output .dat file fprintf(' Writing output: %s\n', output_file); fid = fopen(output_file, 'w'); if fid == -1 error('Cannot create output file: %s. Check write permission.', output_file); end for i = 1:n_lat fprintf(fid, '%.6f ', Pr_MPa(i, :)); fprintf(fid, '\n'); end fclose(fid); end %% ===================== Precompute Exact Subplot Positions ===================== plot_width = (1 - left_margin - right_margin - h_spacing) / 2; plot_height = (1 - top_margin - bottom_margin - v_spacing) / 2; % 4 subplot coordinates: [left, bottom, width, height] (normalized figure units) sub_pos = [ left_margin, bottom_margin + plot_height + v_spacing, plot_width, plot_height; % Top-left left_margin + plot_width + h_spacing, bottom_margin + plot_height + v_spacing, plot_width, plot_height; % Top-right left_margin, bottom_margin, plot_width, plot_height; % Bottom-left left_margin + plot_width + h_spacing, bottom_margin, plot_width, plot_height % Bottom-right ]; %% ===================== Colormap Definitions ===================== % Residual pressure: blue-white-brown (consistent with original model) n_col = 1024; c_blue = [0, 0.4, 0.6]; c_white = [1.00, 1.00, 1.00]; c_brown = [0.8, 0.4, 0.2]; cmap_pr = [ interp1([0 0.75 1],[c_blue(1) c_white(1) c_brown(1)],linspace(0,1,n_col))', ... interp1([0 0.75 1],[c_blue(2) c_white(2) c_brown(2)],linspace(0,1,n_col))', ... interp1([0 0.75 1],[c_blue(3) c_white(3) c_brown(3)],linspace(0,1,n_col))' ]; % Crustal thickness: blue-yellow-brown (consistent with original style) n_col_thick = 256; c_low = [0, 0.4, 0.6]; % Deep blue (low thickness) c_mid = [1, 1, 0.6]; % Light yellow (mid thickness) c_high = [0.6, 0, 0]; % Dark brown (high thickness) cmap_thick = [ interp1([0 0.5 1],[c_low(1) c_mid(1) c_high(1)],linspace(0,1,n_col_thick))', ... interp1([0 0.5 1],[c_low(2) c_mid(2) c_high(2)],linspace(0,1,n_col_thick))', ... interp1([0 0.5 1],[c_low(3) c_mid(3) c_high(3)],linspace(0,1,n_col_thick))' ]; %% ===================== Figure 1: Residual Pressure 2×2 Robinson Maps ===================== fprintf('\nGenerating residual pressure figure...\n'); figure('Color','w','Position',[100 100 1400 1200]); for idx = 1:4 % Create axes with manually calculated compact position ax = axes('Position', sub_pos(idx,:)); axesm('mollweid', ... 'Geoid', [mars_radius 0], 'Frame', 'on', ... 'Grid', 'on', ... 'MeridianLabel', 'off', ... 'ParallelLabel', 'off'); box off; set(gca, 'XColor', 'none', 'YColor', 'none', 'XTick', [], 'YTick', []); hold on; pcolorm(Lat_grid, Lon_grid, Pr_all{idx}); shading flat; contourm(Lat_grid, Lon_grid, Pr_all{idx}, [0 0], 'k--', 'LineWidth', 0.5); colormap(cmap_pr); caxis(pr_caxis); % Lock color scale to unified fixed range title(['\rho_{crust} = ', num2str(rho_crust_list(idx)), ' kg m^{-3}'], ... 'FontSize',14,'FontName','Arial','FontWeight','bold'); setm(ax, 'MLabelParallel', -85); setm(ax, 'PLabelMeridian', -170); tightmap; end % Unified horizontal colorbar centered at the bottom cb_pr = colorbar('Orientation', 'horizontal'); set(cb_pr, 'Position', [0.22, 0.07, 0.56, 0.03]); cb_pr.Label.String = 'Residual pressure (MPa)'; cb_pr.Label.FontSize = 13; cb_pr.Label.FontName = 'Arial'; cb_pr.FontSize = 14; cb_pr.FontName = 'Arial'; % Overall figure title sgtitle('Mars Volcanic Residual Pressure (Khan2022 Crustal Thickness Model)', ... 'FontSize',15,'FontName','Arial','FontWeight','bold'); exportgraphics(gcf, fig_pr_name, 'Resolution', 1200); %% ===================== Figure 2: Crustal Thickness 2×2 Robinson Maps ===================== fprintf('Generating crustal thickness figure...\n'); figure('Color','w','Position',[100 100 1400 1000]); for idx = 1:4 ax = axes('Position', sub_pos(idx,:), 'Box', 'off'); axesm('mollweid', ... 'Geoid', [mars_radius 0], ... 'Frame', 'on', ... 'Grid', 'on', ... 'MeridianLabel', 'off', ... 'ParallelLabel', 'off'); box off; set(gca, 'XColor', 'none', 'YColor', 'none', 'XTick', [], 'YTick', []); hold on; pcolorm(Lat_grid, Lon_grid, thick_all{idx}); shading flat; colormap(cmap_thick); caxis(thick_caxis); % Lock color scale to unified fixed range title(['\rho_{crust} = ', num2str(rho_crust_list(idx)), ' kg m^{-3}'], ... 'FontSize',14,'FontName','Arial','FontWeight','bold'); setm(ax, 'MLabelParallel', -85); setm(ax, 'PLabelMeridian', -170); tightmap; end % Unified horizontal colorbar centered at the bottom cb_thick = colorbar('Orientation', 'horizontal'); set(cb_thick, 'Position', [0.22, 0.07, 0.56, 0.03]); cb_thick.Label.String = 'Crustal Thickness (km)'; cb_thick.Label.FontSize = 13; cb_thick.Label.FontName = 'Arial'; cb_thick.FontSize = 14; cb_thick.FontName = 'Arial'; % Overall figure title sgtitle('Mars Global Crustal Thickness (Khan2022 Model, 1° Resolution)', ... 'FontSize',15,'FontName','Arial','FontWeight','bold'); exportgraphics(gcf, fig_thick_name, 'Resolution', 1200); %% ===================== Completion Summary ===================== fprintf('\n========== All Calculations and Plotting Completed ==========\n'); for idx = 1:4 fprintf('Case %d (rho = %d kg/m³):\n', idx, rho_crust_list(idx)); fprintf(' Crustal thickness: %.2f ~ %.2f km (display scale: 0 ~ 120 km)\n', ... min(thick_all{idx}(:)), max(thick_all{idx}(:))); fprintf(' Residual pressure: %.3f ~ %.3f MPa (display scale: -60 ~ 20 MPa)\n', ... min(Pr_all{idx}(:)), max(Pr_all{idx}(:))); end fprintf('\nOutput files:\n'); fprintf(' 4 residual pressure .dat files\n'); fprintf(' Figure 1: %s\n', fig_pr_name); fprintf(' Figure 2: %s\n', fig_thick_name);