Introduction
Assuming that the earth was a hot ball at a homogeneous temperature upon its formation, we can model the cooling of the earth using heat transfer modeling. The model allows to compute the geotherm of the earth, and make predictions about the earth’s crust thickness and the geothermal gradient for the first km of the earth, 4.5 Ga after earth’s formation. For this purpose, we apply the Fourier heat diffusion equation to the earth for the initial and boundary value problem defined by the initial temperature of the earth and the earth’s surface temperature.
The Fourier heat diffusion model expressed in spherical coordinates is as follows:

where T is the temperature, r the radius, t the time, and D the thermal diffusivity.
Consider a hot ball of radius a.
At time zero, our hot ball has a uniform temperature:

The earth's surface temperature is a constant:

The explicit discretization yields Ti+1,j = A*Ti,j+1 + B*Ti,j + C*Ti,j-1 + D, where A, B, C, and D are given in the table below.

To account for the latent heat fusion of magma, or the energy converted into heat during the crystallization of magma, we introduce the enthalpy which is expressed as follows:


where ρs and ρl the density of the solid and liquid phases, cs and cl are the specific heat of solid and liquid phases, h the latent heat of fusion of magma, and Tf the melting point of magma.
As the cooling of the earth starts at a fully liquid phase, we introduce the energy of the latent heat fusion of magma Qi,j at each node of the lattice, which is initially set to ρ*h. For each incremental calculation, we then check whether Ti+1,j < Tf and Qi,j > 0. If this is the case, we first decrease Qi,j by ρ*c*(Tf -Ti+i,j), and if Qi+1,j is still positive, we set Ti+1,j = Tf; otherwise, Ti+1,j = Tf + Qi+1,j / (ρ*c).
Using the Code
The class ExplicitScheme.cs does the job. Each cell of the lattice is represented by the class Node.cs.
The method next()
of the ExplicitScheme.cs does the traversal of the cells from the surface to the center of the earth to compute the new temperatures for each time increment. The class Node.cs does the calculation for the latent heat fusion of magma which is converted to heat during crystallization of magma.
The radiogenic heating at each time increment considering the radioactive decay of uranium, thorium and potassium isotopes is calculated as follows:
q = 3.95e-12 * Math.Exp(-0.158 * time / Ga) + 2.7e-12 * Math.Exp(-0.05 * time / Ga) +
5.7e-12 * Math.Exp(-0.577 * time / Ga);
The thermal diffusivity as a function of temperature and earth’s layers is calculated as follows:
if (TVector[i].Temperature < 363)
{
D = Math.Max((19.64 - 0.0222 * TVector[i].Temperature) * 1e-7, 7.3e-7);
}
else if (TVector[i].Temperature < 1050)
{
D = (7.85 - 0.00284 * TVector[i].Temperature) * 1e-7;
}
else
D = 3e-7;
Mathematical details for the algorithm and model parameters are described in the article "A Finite-Difference Model for the Thermal History of the Earth".
Reference