<?php
/*
Earth's Average Internal Temperature Code
© Charles Chandler
http://qdl.scs-inc.us/?top=19195
*/
// Given some temperatures at specific depths,
// we assign those temps to specific radii.
$gradientPts = array(
$solSys->earth->radius_mean_km - 6370 => 7000,
$solSys->earth->radius_mean_km - 5150 => 5000,
$solSys->earth->radius_mean_km - 2900 => 3500,
$solSys->earth->radius_mean_km - 2800 => 3000,
$solSys->earth->radius_mean_km - 200 => 1300,
$solSys->earth->radius_mean_km - 0 => 300,
);
// Now we're going to divide the Earth into 100 equal-volume
// concentric shells, and we'll assign temperatures to those
// volumes, by interpolating between the temps at known radii.
$volumeIncrement = VolumeOfSphere($solSys->earth->radius_mean_km) / 100;
$thisVolume = 0;
$temperatures = array();
for ($i = 1; $i <= 100; $i++) {
$thisVolume += $volumeIncrement;
$thisRadius = RadiusOfSphere($thisVolume);
$lastRad = 0;
$lastTmp = 7000;
foreach($gradientPts as $rad => $tmp) {
if (($thisRadius <= $rad) and ($thisRadius >= $lastRad)) {
$diffRad = $rad - $lastRad;
$diffTmp = $lastTmp - $tmp;
$diffRadPartial = $thisRadius - $lastRad;
$diffTmpPartial = $lastTmp - ($diffTmp * ($diffRadPartial / $diffRad));
break;
}
$lastRad = $rad;
$lastTmp = $tmp;
}
$temperatures[] = $diffTmpPartial;
}
// Now just average the temperature array, to get
// the average temperature inside the Earth.
echo (array_sum($temperatures) / 100).'<br >'; // 2220.7930090397
?>
|