<?php
/*
Code
© Charles Chandler
http://qdl.scs-inc.us/?top=7981
*/
$joules = 0;
$masses = 0;
$massPg = GetPageByID(7941);
$elemPg = GetPageByID(7083);
$rsltPg = GetPageByID(7959);
$massArr = TableToArray($massPg->contents);
$elemArr = TableToArray($elemPg->contents);
define('solVol_m3', 1.412 * pow(10, 27));
define('solTemp_K', LU(12057, 'sun_temperature'));
$scaleFactor3 = 20;
$scaleFactor4 = 20;
$scaleFactor6 = 35;
$rsltArr = array(
array(
0 => '#',
1 => 'ab.',
2 => 'kg/m<sup>3</sup>',
3 => '× 10<sup>'.$scaleFactor3.'</sup> m<sup>3</sup>',
4 => '× 10<sup>'.$scaleFactor4.'</sup> kg',
5 => 'J·kg·K',
6 => '× 10<sup>'.$scaleFactor6.'</sup> Joules',
)
);
for ($i = 1; $i < sizeof($elemArr); $i++) {
for ($j = 1; $j < sizeof($massArr); $j++) {
if ($elemArr[$i][1] == $massArr[$j][0]) {
$tmp = array();
$tmp[0] = $elemArr[$i][0]; // #
$tmp[1] = $elemArr[$i][1]; // ab.
$tmp[2] = $elemArr[$i][7]; // kg/m3
$tmp[3] = $massArr[$j][2] * solVol_m3; // decimal of total volume * solar volume m3 = m3
$tmp[4] = $tmp[2] * $tmp[3]; // kg
$tmp[5] = $elemArr[$i][9]; // J/kg·K
$tmp[6] = $tmp[4] * $tmp[5] * solTemp_K; // Joules
$masses += $tmp[4];
$joules += $tmp[6];
$tmp[3] = sprintf("%01.3f", round($tmp[3] / pow(10, $scaleFactor3), 3));
$tmp[4] = sprintf("%01.3f", round($tmp[4] / pow(10, $scaleFactor4), 3));
$tmp[6] = sprintf("%01.3f", round($tmp[6] / pow(10, $scaleFactor6), 3));
$rsltArr[] = $tmp;
}
}
}
$tmp = array();
$tmp[0] = '';
$tmp[1] = '';
$tmp[2] = '';
$tmp[3] = 'totals: ';
$tmp[4] = round($masses / pow(10, $scaleFactor4), 3);
$tmp[5] = '';
$tmp[6] = round($joules / pow(10, $scaleFactor6), 3);
$rsltArr[] = $tmp;
$rsltPg->contents = ArrayToTable($rsltArr, 'standard');
$rsltPg->CommitToDb('scripting');
/* $massArr
0 =>
array (
0 => 'ab.',
1 => 'kg/m3',
2 => 'decimal of total volume',
3 => 'mass',
),
1 =>
array (
0 => 'Os',
1 => '20000',
2 => '0.007514766286155780',
3 => '1.08040924347184e+29',
),
*/
/* $elemArr
0 =>
array (
0 => '#',
1 => 'ab.',
2 => 'name',
3 => 'per',
4 => 'grp',
5 => 'b.p. K',
6 => 'a.mass',
7 => 'kg/m3',
8 => 'at24/m3',
9 => 'J/kg·K',
),
1 =>
array (
0 => '1',
1 => 'H',
2 => 'hydrogen',
3 => '1',
4 => '1',
5 => '20',
6 => '1.0079',
7 => '76',
8 => '40626',
9 => '14304',
),
*/
?>
|