%% DYKE COOLING WITH LATENT HEAT % Calculates the cooling time for a dyke of uniform initial temperature. % Uses MATLAB's ODE solver to solve the heat equation. % Accounts for latent heat and finds position of solidification front. %% DEFINE MODEL PARAMETERS: Hd=0.5; % Dyke half-width (m) H=Hd*10; % Location of boundary condition, total width of model (m) TI=1200+273.15; % Initial temperature (K) T0=0+273.15; % Boundary temperature (K) Tc=1000+273.15; % Solidification temperature (K) cpS=1200; % Specific heat capacity for solid basalt (J kg-1 K-1) cpL=1200; % Specific heat capacity for liquid basalt (J kg-1 K-1) kS=1.3; % Thermal conductivity for solid basalt (W m-1 K-1) kL=1.3; % Thermal conductivity for liquid basalt (W m-1 K-1) rho=2700; % Density of basalt (kg m-3) (assume constant) L=400000; % Latent heat of fusion (J kg-1) tMAX=3*Hd^2 / (10^-6); % Simulation duration (s) %% SET UP MODEL % Define spatial grid: N=2000; % Number of cells n=500; % Number of time intervals evaluated xB=linspace(0,H,N+1)'; % Cell boundaries x=(xB(1:N,1)+xB(2:N+1,1))/2; % Mid-points of cells % Define initial temperature vector: TIvec=zeros(size(x))+T0; % Set all cells to T0. TIvec(xTc)); if isempty(xc) % If no phase change is found: xc=NaN; end end