#include #include using namespace std; // Some constants useful in solar system #define mmoon 7.342e25 // Moon mass in g #define mearth 5.97219e27 // Earth mass in g #define msun 1.989e33 // Sun mass in g #define au 1.495978707e13 // au in cm #define rearth 6371e5 // Earth dameter in cm #define dmoon 384400e5 // Distance moon in cm #define sec_per_year 3.1556926e7 // seconds per year #define parsec 3.085678e18 // cm per parsec #define kparsec 3.085678e21 // cm per kilo parsec #define mparsec 3.085678e24 // cm per mega parsec // unit system of the simulation (solar system) #define m_unit msun #define l_unit au #define t_unit sec_per_year // Years // unit system of the simulation (galaxies) // #define m_unit 1e10*msun // #define l_unit kparsec // #define t_unit 1e6*sec_per_year // mega Years // unit system of the simulation (clusters) // #define m_unit 1e10*msun // #define l_unit kparsec // #define t_unit 1e9*sec_per_year // giga Years // resulting velocity units #define v_unit l_unit / t_unit // Gravitational constant in internal units #define G 6.672e-8 * m_unit * t_unit * t_unit / l_unit / l_unit / l_unit int main(int argc, const char **argv) { // Define the variables we need double dist, mass, acc, acc_cgs; // Lets output at the beginning some useful information ... cout << "Hallo World" << endl; cout << "My own unit system is: " << endl; cout << "L = " << l_unit << endl; cout << "T = " << t_unit << endl; cout << "M = " << m_unit << endl; cout << "V = " << v_unit << endl; cout << "Gravitational constant in my internal units is: " << endl; cout << "G = " << G << endl; // acc from earth cout << "Acceleration by earth:" << endl; dist = rearth / l_unit; mass = mearth / m_unit; acc = G * mass / (dist * dist); acc_cgs = acc * l_unit / (t_unit * t_unit); cout << "acc = " << acc << " [internal units] = " << acc_cgs << " [cm/s^2]" << endl; // acc from moon cout << "Acceleration by moon:" << endl; dist = (dmoon - rearth) / l_unit; // here the size of earth could matter ! mass = mmoon / m_unit; acc = G * mass / (dist * dist); acc_cgs = acc * l_unit / (t_unit * t_unit); cout << "acc = " << acc << " [internal units] = " << acc_cgs << " [cm/s^2]" << endl; // acc from moon cout << "Acceleration by sun:" << endl; dist = au / l_unit; mass = msun / m_unit; acc = G * mass / (dist * dist); acc_cgs = acc * l_unit / (t_unit * t_unit); cout << "acc = " << acc << " [internal units] = " << acc_cgs << " [cm/s^2]" << endl; // acc from galaxy cout << "Acceleration by galaxy:" << endl; dist = 8 * kparsec / l_unit; mass = 1e11 * msun / m_unit; acc = G * mass / (dist * dist); acc_cgs = acc * l_unit / (t_unit * t_unit); cout << "acc = " << acc << " [internal units] = " << acc_cgs << " [cm/s^2]" << endl; // acc from virgo cluster cout << "Acceleration by virgo:" << endl; dist = 10 * mparsec / l_unit; mass = 1e15 * msun / m_unit; acc = G * mass / (dist * dist); acc_cgs = acc * l_unit / (t_unit * t_unit); cout << "acc = " << acc << " [internal units] = " << acc_cgs << " [cm/s^2]" << endl; // acc of sun on pluto cout << "Acceleration of sun on pluto:" << endl; dist = 39.5 * au / l_unit; mass = msun / m_unit; acc = G * mass / (dist * dist); acc_cgs = acc * l_unit / (t_unit * t_unit); cout << "acc = " << acc << " [internal units] = " << acc_cgs << " [cm/s^2]" << endl; // acc of sun on voyager cout << "Acceleration of sun on voyager:" << endl; dist = 138 * au / l_unit; mass = msun / m_unit; acc = G * mass / (dist * dist); acc_cgs = acc * l_unit / (t_unit * t_unit); cout << "acc = " << acc << " [internal units] = " << acc_cgs << " [cm/s^2]" << endl; // acc on galaxy at border of a cluster cout << "Acceleration at border of a cluster:" << endl; dist = 2 * mparsec / l_unit; mass = 1e15 * msun / m_unit; acc = G * mass / (dist * dist); acc_cgs = acc * l_unit / (t_unit * t_unit); cout << "acc = " << acc << " [internal units] = " << acc_cgs << " [cm/s^2]" << endl; return 0; }