// Events that occur during entity geneation void Planet::events() { // These events only apply to planets with atmospheres if (pressure > 0.0) { if (j <= 0.3 && surfWater < 1.0) surfWater += 0.05; if (j <= 1.0) { // Reduce pressure if no magnetic field present during a young star (extreme UV) if (!magField) pressure -= 1e5 / gravity; // Early impactors cause some pressure decrease but volcanic events cause pressure increase. Random +/- pressure change //pressure -= 100 * gravity; } // NO LONG TERM ATMO LOSS: Rather minimal and ionosphere protects planet from solar winds. Temperture exiting atoms bigger reason for atm loss. // Generate a number, chance of life increases over time and with more surface water if (surfWater > 0.0 && temp < boilTemp && temp > freezeTemp - 50) hasLife++;//rand() % (int)(100 * surfWater / age + 1); else if ((temp >= boilTemp || temp <= freezeTemp - 50) && hasLife > 0) hasLife--; // Life results in increase in oxygen and decreses in GHG if (hasLife >= 36 && magField) { if (ageLife == 0.0) ageLife = j; if (pressure > 1e3) pressure -= 0.152 * pressure * exp(j - ageLife); // Increase surface water and decrease GHG. Increase in oxygen (from life/plants) allows bonding of hydrogen to form water greenhouseEff -= 0.032; surfWater += 0.024; if (debugLvl) printf("DEBUG: Planet is earth-like!\n"); } // Basic life slightly reduces GHG and stabilizes environment else if (hasLife >= 5) { greenhouseEff -= 0.005; if (debugLvl) printf("DEBUG: Basic life evolved!\n"); } } valueCheck(); }
// Returns a "human readable" string representation of the MSG and the // information it points to QString decodeMSG(const MSG& msg) { const WPARAM wParam = msg.wParam; const LPARAM lParam = msg.lParam; QString wmmsg = QString::fromLatin1(findWMstr(msg.message)); // Unknown WM_, so use number if (wmmsg.isEmpty()) wmmsg = QString::fromLatin1("WM_(%1)").arg(msg.message); QString rawParameters; rawParameters.sprintf("hwnd(0x%p) ", (void *)msg.hwnd); // Custom WM_'s if (msg.message > WM_APP) wmmsg = QString::fromLatin1("WM_APP + %1").arg(msg.message - WM_APP); else if (msg.message > WM_USER) wmmsg = QString::fromLatin1("WM_USER + %1").arg(msg.message - WM_USER); QString parameters; switch (msg.message) { #ifdef WM_ACTIVATE case WM_ACTIVATE: { QString activation = valueCheck(wParam, FLAG_STRING(WA_ACTIVE, "Activate"), FLAG_STRING(WA_INACTIVE, "Deactivate"), FLAG_STRING(WA_CLICKACTIVE, "Activate by mouseclick"), FLAG_STRING()); parameters.sprintf("%s Hwnd (0x%p)", activation.toLatin1().data(), (void *)msg.hwnd); } break; #endif #ifdef WM_CAPTURECHANGED case WM_CAPTURECHANGED: parameters.sprintf("Hwnd gaining capture (0x%p)", (void *)lParam); break; #endif #ifdef WM_CREATE case WM_CREATE: { LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; QString styles = flagCheck(lpcs->style, FLGSTR(WS_BORDER), FLGSTR(WS_CAPTION), FLGSTR(WS_CHILD), FLGSTR(WS_CLIPCHILDREN), FLGSTR(WS_CLIPSIBLINGS), FLGSTR(WS_DISABLED), FLGSTR(WS_DLGFRAME), FLGSTR(WS_GROUP), FLGSTR(WS_HSCROLL), FLGSTR(WS_OVERLAPPED), #if defined(WS_OVERLAPPEDWINDOW) && (WS_OVERLAPPEDWINDOW != 0) FLGSTR(WS_OVERLAPPEDWINDOW), #endif #ifdef WS_ICONIC FLGSTR(WS_ICONIC), #endif FLGSTR(WS_MAXIMIZE), FLGSTR(WS_MAXIMIZEBOX), FLGSTR(WS_MINIMIZE), FLGSTR(WS_MINIMIZEBOX), FLGSTR(WS_OVERLAPPEDWINDOW), FLGSTR(WS_POPUP), #ifdef WS_POPUPWINDOW FLGSTR(WS_POPUPWINDOW), #endif FLGSTR(WS_SIZEBOX), FLGSTR(WS_SYSMENU), FLGSTR(WS_TABSTOP), FLGSTR(WS_THICKFRAME), #ifdef WS_TILED FLGSTR(WS_TILED), #endif #ifdef WS_TILEDWINDOW FLGSTR(WS_TILEDWINDOW), #endif FLGSTR(WS_VISIBLE), FLGSTR(WS_VSCROLL), FLAG_STRING()); QString exStyles = flagCheck(lpcs->dwExStyle, #ifdef WS_EX_ACCEPTFILES FLGSTR(WS_EX_ACCEPTFILES), #endif #ifdef WS_EX_APPWINDOW FLGSTR(WS_EX_APPWINDOW), #endif FLGSTR(WS_EX_CLIENTEDGE), FLGSTR(WS_EX_DLGMODALFRAME), #ifdef WS_EX_LEFT FLGSTR(WS_EX_LEFT), #endif FLGSTR(WS_EX_LEFTSCROLLBAR), #ifdef WS_EX_LTRREADING FLGSTR(WS_EX_LTRREADING), #endif #ifdef WS_EX_MDICHILD FLGSTR(WS_EX_MDICHILD), #endif #ifdef WS_EX_NOACTIVATE FLGSTR(WS_EX_NOACTIVATE), #endif #ifdef WS_EX_NOANIMATION FLGSTR(WS_EX_NOANIMATION), #endif FLGSTR(WS_EX_NOPARENTNOTIFY), FLGSTR(WS_EX_OVERLAPPEDWINDOW), #ifdef WS_EX_PALETTEWINDOW FLGSTR(WS_EX_PALETTEWINDOW), #endif #ifdef WS_EX_RIGHT FLGSTR(WS_EX_RIGHT), #endif #ifdef WS_EX_RIGHTSCROLLBAR FLGSTR(WS_EX_RIGHTSCROLLBAR), #endif #ifdef WS_EX_RTLREADING FLGSTR(WS_EX_RTLREADING), #endif FLGSTR(WS_EX_STATICEDGE), FLGSTR(WS_EX_TOOLWINDOW), FLGSTR(WS_EX_TOPMOST), #ifdef WS_EX_TRANSPARENT FLGSTR(WS_EX_TRANSPARENT), #endif FLGSTR(WS_EX_WINDOWEDGE), #ifdef WS_EX_CAPTIONOKBTN FLGSTR(WS_EX_CAPTIONOKBTN), #endif FLAG_STRING()); QString className; if (lpcs->lpszClass != 0) { if (HIWORD(lpcs->lpszClass) == 0) // Atom className = QString::number(LOWORD(lpcs->lpszClass), 16); else // String className = QString((QChar*)lpcs->lpszClass, (int)wcslen(reinterpret_cast<const wchar_t *>(lpcs->lpszClass))); } QString windowName; if (lpcs->lpszName != 0) windowName = QString((QChar*)lpcs->lpszName, (int)wcslen(reinterpret_cast<const wchar_t *>(lpcs->lpszName))); parameters.sprintf("x,y(%4d,%4d) w,h(%4d,%4d) className(%s) windowName(%s) parent(0x%p) style(%s) exStyle(%s)", lpcs->x, lpcs->y, lpcs->cx, lpcs->cy, className.toLatin1().data(), windowName.toLatin1().data(), (void *)lpcs->hwndParent, styles.toLatin1().data(), exStyles.toLatin1().data()); } break; #endif #ifdef WM_DESTROY case WM_DESTROY: parameters.sprintf("Destroy hwnd (0x%p)", (void *)msg.hwnd); break; #endif #ifdef WM_IME_NOTIFY case WM_IME_NOTIFY: { QString imnCommand = valueCheck(wParam, FLGSTR(IMN_CHANGECANDIDATE), FLGSTR(IMN_CLOSECANDIDATE), FLGSTR(IMN_CLOSESTATUSWINDOW), FLGSTR(IMN_GUIDELINE), FLGSTR(IMN_OPENCANDIDATE), FLGSTR(IMN_OPENSTATUSWINDOW), FLGSTR(IMN_SETCANDIDATEPOS), FLGSTR(IMN_SETCOMPOSITIONFONT), FLGSTR(IMN_SETCOMPOSITIONWINDOW), FLGSTR(IMN_SETCONVERSIONMODE), FLGSTR(IMN_SETOPENSTATUS), FLGSTR(IMN_SETSENTENCEMODE), FLGSTR(IMN_SETSTATUSWINDOWPOS), FLAG_STRING()); parameters.sprintf("Command(%s : 0x%p)", imnCommand.toLatin1().data(), (void *)lParam); } break; #endif #ifdef WM_IME_SETCONTEXT case WM_IME_SETCONTEXT: { bool fSet = (BOOL)wParam; DWORD fShow = (DWORD)lParam; QString showFlgs = flagCheck(fShow, #ifdef ISC_SHOWUICOMPOSITIONWINDOW FLGSTR(ISC_SHOWUICOMPOSITIONWINDOW), #endif #ifdef ISC_SHOWUIGUIDWINDOW FLGSTR(ISC_SHOWUIGUIDWINDOW), #endif #ifdef ISC_SHOWUISOFTKBD FLGSTR(ISC_SHOWUISOFTKBD), #endif FLGSTR(ISC_SHOWUICANDIDATEWINDOW), FLGSTR(ISC_SHOWUICANDIDATEWINDOW << 1), FLGSTR(ISC_SHOWUICANDIDATEWINDOW << 2), FLGSTR(ISC_SHOWUICANDIDATEWINDOW << 3), FLAG_STRING()); parameters.sprintf("Input context(%s) Show flags(%s)", (fSet? "Active" : "Inactive"), showFlgs.toLatin1().data()); } break; #endif #ifdef WM_KILLFOCUS case WM_KILLFOCUS: parameters.sprintf("Hwnd gaining keyboard focus (0x%p)", (void *)wParam); break; #endif #ifdef WM_CHAR case WM_CHAR: #endif #ifdef WM_IME_CHAR case WM_IME_CHAR: #endif #ifdef WM_KEYDOWN case WM_KEYDOWN: #endif #ifdef WM_KEYUP case WM_KEYUP: { int nVirtKey = (int)wParam; long lKeyData = (long)lParam; int repCount = (lKeyData & 0xffff); // Bit 0-15 int scanCode = (lKeyData & 0xf0000) >> 16; // Bit 16-23 bool contextCode = (lKeyData && 0x20000000); // Bit 29 bool prevState = (lKeyData && 0x40000000); // Bit 30 bool transState = (lKeyData && 0x80000000); // Bit 31 parameters.sprintf("Virual-key(0x%x) Scancode(%d) Rep(%d) Contextcode(%d), Prev state(%d), Trans state(%d)", nVirtKey, scanCode, repCount, contextCode, prevState, transState); } break; #endif #ifdef WM_INPUTLANGCHANGE case WM_INPUTLANGCHANGE: parameters = QLatin1String("Keyboard layout changed"); break; #endif // WM_INPUTLANGCHANGE #ifdef WM_NCACTIVATE case WM_NCACTIVATE: { parameters = (msg.wParam? QLatin1String("Active Titlebar") : QLatin1String("Inactive Titlebar")); } break; #endif #ifdef WM_MOUSEACTIVATE case WM_MOUSEACTIVATE: { QString mouseMsg = QString::fromLatin1(findWMstr(HIWORD(lParam))); parameters.sprintf("TLW(0x%p) HittestCode(0x%x) MouseMsg(%s)", (void *)wParam, LOWORD(lParam), mouseMsg.toLatin1().data()); } break; #endif #ifdef WM_MOUSELEAVE case WM_MOUSELEAVE: break; // wParam & lParam not used #endif #ifdef WM_MOUSEHOVER case WM_MOUSEHOVER: #endif #ifdef WM_MOUSEWHEEL case WM_MOUSEWHEEL: #endif #ifdef WM_MOUSEHWHEEL case WM_MOUSEHWHEEL: #endif #ifdef WM_LBUTTONDBLCLK case WM_LBUTTONDBLCLK: #endif #ifdef WM_LBUTTONDOWN case WM_LBUTTONDOWN: #endif #ifdef WM_LBUTTONUP case WM_LBUTTONUP: #endif #ifdef WM_MBUTTONDBLCLK case WM_MBUTTONDBLCLK: #endif #ifdef WM_MBUTTONDOWN case WM_MBUTTONDOWN: #endif #ifdef WM_MBUTTONUP case WM_MBUTTONUP: #endif #ifdef WM_RBUTTONDBLCLK case WM_RBUTTONDBLCLK: #endif #ifdef WM_RBUTTONDOWN case WM_RBUTTONDOWN: #endif #ifdef WM_RBUTTONUP case WM_RBUTTONUP: #endif #ifdef WM_MOUSEMOVE case WM_MOUSEMOVE: { QString vrtKeys = flagCheck(wParam, FLGSTR(MK_CONTROL), FLGSTR(MK_LBUTTON), FLGSTR(MK_MBUTTON), FLGSTR(MK_RBUTTON), FLGSTR(MK_SHIFT), #ifdef MK_XBUTTON1 FLGSTR(MK_XBUTTON1), #endif #ifdef MK_XBUTTON2 FLGSTR(MK_XBUTTON2), #endif FLAG_STRING()); parameters.sprintf("x,y(%4d,%4d) Virtual Keys(%s)", GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), vrtKeys.toLatin1().data()); } break; #endif #ifdef WM_MOVE case WM_MOVE: parameters.sprintf("x,y(%4d,%4d)", LOWORD(lParam), HIWORD(lParam)); break; #endif #if defined(WM_PAINT) && defined(WM_ERASEBKGND) case WM_ERASEBKGND: case WM_PAINT: parameters.sprintf("hdc(0x%p)", (void *)wParam); break; #endif #ifdef WM_QUERYNEWPALETTE case WM_QUERYNEWPALETTE: break; // lParam & wParam are unused #endif #ifdef WM_SETCURSOR case WM_SETCURSOR: { QString mouseMsg = QString::fromLatin1(findWMstr(HIWORD(lParam))); parameters.sprintf("HitTestCode(0x%x) MouseMsg(%s)", LOWORD(lParam), mouseMsg.toLatin1().data()); } break; #endif #ifdef WM_SETFOCUS case WM_SETFOCUS: parameters.sprintf("Lost Focus (0x%p)", (void *)wParam); break; #endif #ifdef WM_SETTEXT case WM_SETTEXT: parameters.sprintf("Set Text (%s)", QString((QChar*)lParam, (int)wcslen(reinterpret_cast<const wchar_t *>(lParam))).toLatin1().data()); //Unicode string break; #endif #ifdef WM_SIZE case WM_SIZE: { QString showMode = valueCheck(wParam, FLGSTR(SIZE_MAXHIDE), FLGSTR(SIZE_MAXIMIZED), FLGSTR(SIZE_MAXSHOW), FLGSTR(SIZE_MINIMIZED), FLGSTR(SIZE_RESTORED), FLAG_STRING()); parameters.sprintf("w,h(%4d,%4d) showmode(%s)", LOWORD(lParam), HIWORD(lParam), showMode.toLatin1().data()); } break; #endif #ifdef WM_WINDOWPOSCHANGED case WM_WINDOWPOSCHANGED: { LPWINDOWPOS winPos = (LPWINDOWPOS)lParam; if (!winPos) break; QString hwndAfter = valueCheck(quint64(winPos->hwndInsertAfter), FLAG_STRING((qptrdiff)HWND_BOTTOM, "HWND_BOTTOM"), FLAG_STRING((qptrdiff)HWND_NOTOPMOST, "HWND_NOTOPMOST"), FLAG_STRING((qptrdiff)HWND_TOP, "HWND_TOP"), FLAG_STRING((qptrdiff)HWND_TOPMOST, "HWND_TOPMOST"), FLAG_STRING()); if (hwndAfter.isEmpty()) hwndAfter = QString::number((quintptr)winPos->hwndInsertAfter, 16); QString flags = flagCheck(winPos->flags, FLGSTR(SWP_DRAWFRAME), FLGSTR(SWP_FRAMECHANGED), FLGSTR(SWP_HIDEWINDOW), FLGSTR(SWP_NOACTIVATE), #ifdef SWP_NOCOPYBITS FLGSTR(SWP_NOCOPYBITS), #endif FLGSTR(SWP_NOMOVE), FLGSTR(SWP_NOOWNERZORDER), FLGSTR(SWP_NOREDRAW), FLGSTR(SWP_NOREPOSITION), #ifdef SWP_NOSENDCHANGING FLGSTR(SWP_NOSENDCHANGING), #endif FLGSTR(SWP_NOSIZE), FLGSTR(SWP_NOZORDER), FLGSTR(SWP_SHOWWINDOW), FLAG_STRING()); parameters.sprintf("x,y(%4d,%4d) w,h(%4d,%4d) flags(%s) hwndAfter(%s)", winPos->x, winPos->y, winPos->cx, winPos->cy, flags.toLatin1().data(), hwndAfter.toLatin1().data()); } break; #endif default: parameters.sprintf("wParam(0x%p) lParam(0x%p)", (void *)wParam, (void *)lParam); break; } // Yes, we want to give the WM_ names 20 chars of space before showing the // decoded message, since some of the common messages are quite long, and // we don't want the decoded information to vary in output position QString message = QString::fromLatin1("%1: ").arg(wmmsg, 20); message += rawParameters; message += parameters; return message; }
// Generate properties for a new type 2 - Planet entity void Planet::create (size_t subtype, Star* parent) { double lumTmp, radTmp = 0, radiusInit; /* PHYSICAL PARAMETERS */ gravity = G * mass / (radius * radius); // Surface gravity escVel = sqrt(2 * gravity * radius); // Escape velocity // Assuming early rocky planet in all cases. Initial atmosphere parameters albedo = 0.068; // Bond albedo: Mercury 0.068 , Venus 0.90, Earth 0.306, Mars 0.25 [5] albedoCloud = 0.315; // Albedo for water vapour clouds emissivity = 0.96; /* ORBITAL PARAMETERS */ period = 2 * PI * sqrt(pow(dist, 3) / (G * parent->mass)) / 86400; /* OTHER PARAMTERS */ radiusInit = parent->radius / (round((0.042 * parent->age + 1) * 100) / 100); lumTmp = 4 * PI * radiusInit * radiusInit * SIGMA * pow(parent->temp, 4); solarConst = lumTmp / (4 * PI * dist * dist); if (solarConst <= 0) printf("ERROR: Something probably went wrong. Solar const zero or negative!\n"); surfWater = 0.0; // earth 0.71 surfIce = 0.0; freezeTemp = 273.0; age = parent->age - 0.05; // Planet age ageLife = 0.0; // Age of first life on planet hasLife = 0; // Planet has no life to begin /* Planet aging and atmosphere + climate development */ // Planet too small and too close to star for atmo // printf("Min: %.2f Max: %.2f Grav: %.3f \n\n", parent->habitable_min / AU, parent->habitable_max / AU, gravity); if (dist < parent->habitable_min && gravity < 5) { pressure = 0.0; atmDens = atmType[1].c_str(); // Tenuous } // Planet can support an atmosphere else { pressure = gravity * gravity * 1e5; // Pressure dependent on surface gravity + ADD random factor boilTemp = 135.84 * pow(pressure, 0.0879); // Calculate boiling point of water at the pressure using: y = 135.84*x^0.0879 [8] surfWater = 0.75; // All planets with atmo start with some oceans [9] // Update the initial cloud emissivity parameters. Assuming water vapour clouds form initially. greenhouseEff = 0.806; // Lots of CO2 and GHG in atmo cloudCover = 0.15; // Earth 0.68 cloudFactor = 0.33; albedo = cloudCover * albedoCloud + surfIce; // Total emissivity = groundCover * ground emiss + cloudCover * avg cloud emiss - GHG emissSurf = 0.96 * (1 - cloudCover); emissCloud = cloudCover * cloudFactor; emissivity = emissSurf + emissCloud - greenhouseEff; } // Calculate initial temperature temp = pow(solarConst * (1 - albedo) / (4 * SIGMA * emissivity), 0.25); // 70% effective early star. Recalculate temperature cloudFactor = 0.65; // Increase the significance of clouds in cooling // Loop cycle generates history of planet. Starts 0.1 billion years after star formation. Age of sun 4.567 bya, age of earth 4.54 bya (wikipedia) for (j = 0.0; j <= age; j += 0.1) { // Print Debug info! if (debugLvl > 1) { printf("Emiss: %.3f = %.3f + %.3f - %.3f Albedo: %.3f\n", emissivity, emissSurf, emissCloud, greenhouseEff, albedo); printf("Pressure: %.4f bar\n", pressure / 1e5); printf("Temp: %.2f K (%.2f C) Boiling: %.2f K (%.2f C) \n", temp, temp - 273, boilTemp, boilTemp - 273); printf("CloudCover: %.3f Factor: %.3f\n", cloudCover, cloudFactor); printf("Age: %.2f SurfWater: %.2f%% SurfIce: %.2f%%\n\n", j, surfWater * 100, surfIce * 100); } // Star aging with planet for simulation if (parent->age > 0 && parent->age <= 8) { // Radius increases over time according to age and stellar class radTmp = (round((0.042 * j + 1) * 100) / 100) * radiusInit; // u = 0.042 * j + 1, rounded to nearest hundredth } // Entering red giant phase for main sequence? else if (parent->age > 8) { radTmp = (0.1835 * j * j - 3.431 * j + 17.52) * radiusInit; //y = 0.1835*j^2 - 3.431*j + 17.52 } // Introduce random events Planet::events(); // First check if atmosphere exerts any pressure if (pressure > 0.0) { // Reduce the pressure due to CO2 absorption by ocean up to half initial pressure pressure -= 0.03 * surfWater * pressure / (j + 0.1); // Check if water boiling. Increase greenhouse effect and pressure, decrease surface water if water present. if (temp >= boilTemp) { // If planet still has some surface water, decrease it if (surfWater > 0.0) { // Increase cloud cover as surface water turns into water vapour if (surfWater - 0.25 > 0.0) { cloudCover += 0.25; surfWater -= 0.25; } else { cloudCover += surfWater; surfWater -= surfWater; } cloudFactor += exp (-4 * cloudFactor); // More GHG over time as H2O/CO2 is released greenhouseEff += 0.005; // Increase pressure due to evaporating liquids, volcanoes and other effects pressure += surfWater * 1.8e6; if (debugLvl) printf("DEBUG: Too hot, water boiling!\n"); } else { // If there is no mag field, atmospheric H2O seperates and reacts with sulfur to form sulfur dioxide if (!magField) { // SO2 clouds pressure += pressure / 1.4e2; greenhouseEff += (greenhouseEff * (1 - greenhouseEff / 0.996)) / 5; cloudFactor += (cloudFactor * (1 - cloudFactor)) / 5; albedoCloud += (albedoCloud * (1 - albedoCloud / 0.90)) / 5; // Albedo factor for SO2 clouds should approach 0.90 } if (debugLvl) printf("DEBUG: Water boiled away, no surface water!\n"); } } // Check if water is frozen. Ice increases surface albedo and freezes water out of the atmosphere reducing clouds and pressure. else if (temp <= freezeTemp) { // If planet still has some surface water, decrease it if (surfWater > 0.0) { if (debugLvl) printf("DEBUG: Too cold, water freezing!\n"); surfWater -= 0.15; surfIce += 0.005; // Decrease cloud cover as H2O freezes out cloudCover -= 0.045 / cloudCover; cloudFactor -= 0.02; } else { // Reduce pressure and GHG becasue reasons pressure -= pressure / 1.7; greenhouseEff -= greenhouseEff / 3; // Reduced pressure on cold planets reduces density of GHG if (debugLvl) printf("DEBUG: Water frozen, no surface water!\n"); } } // Conditions suitable for life (Not boiling or freezing) else { // Decrease water over time as more water evaporates into the hydrosphere to form clouds if (surfWater >= 0.0) { cloudCover += 0.0047 / cloudCover; // Increase cloud cover as oceans turn to water vapour surfWater -= 0.007 / surfWater; // pressure+? greenhouseEff -= 0.0034; // Less GHG over time as CO2 is absorbed by water, and oxygen populates air } } // Change amount of surface ice on planet based on temperature and cloud cover if (pressure < 1e4) surfIce -= surfIce / 7; // Decrease if pressure is too low to sustain frozen ice (ice in atmosphere instead) else if (temp <= 320 && surfWater > 0.0) surfIce += 0.0233; // Increase ice if below arbitrary temperture and surface still has water to freeze. valueCheck(); // Update albedo as it scales with cloud cover and surface ice albedo = cloudCover * albedoCloud + surfIce; // Earth ice ~9.2%, mars 15-18% // Update the emissivity parameters emissSurf = 0.96 * (1 - cloudCover); emissCloud = cloudCover * cloudFactor; //OLD VAL: 0.68 * cloudCoverL + 0.55 * cloudCoverM + 0.33 * cloudCoverH; emissivity = emissSurf + emissCloud - greenhouseEff; // groundCover * ground emiss + cloudCover * avg cloud emiss - greenhouse EARTH 0.615 apparent // Calculate boiling point of water at the pressure using: y = 135.84*x^0.0879 [8] boilTemp = 135.84 * pow(pressure, 0.0879); if (boilTemp <= freezeTemp) boilTemp = freezeTemp; } // Update luminosity and solar constant as star radius increases lumTmp = 4 * PI * radTmp * radTmp * SIGMA * pow(parent->temp, 4); solarConst = lumTmp / (4 * PI * dist * dist); // Recalculate the planet's current temperature temp = pow(solarConst * (1 - albedo) / (4 * SIGMA * emissivity), 0.25); // Recalculate the planet temperature. Using 1/4 ratio for A_abs/A_rad } // Print Debug info if (debugLvl > 1) { printf("Emiss: %.3f = %.3f + %.3f - %.3f Albedo: %.3f\n", emissivity, emissSurf, emissCloud, greenhouseEff, albedo); printf("Pressure: %.4f bar\n", pressure / 1e5); printf("Temp: %.2f K (%.2f C) Boiling: %.2f K (%.2f C) \n", temp, temp - 273, boilTemp, boilTemp - 273); printf("CloudCover: %.3f Factor: %.3f\n", cloudCover, cloudFactor); printf("Age: %.2f SurfWater: %.2f%% SurfIce: %.2f%%\n\n", j, surfWater * 100, surfIce * 100); } // Determine atmosphere density category depending on pressure atmComp = atmCompType[rng(2, 5)]; // Nitrogen, Oxygen, Carbon Dioxide, Methane if (pressure > 2e6) atmDens = atmType[4]; // Dense else if (pressure > 2e4) atmDens = atmType[3]; // Substantial else if (pressure > 100) atmDens = atmType[2]; // Minimal else { atmDens = atmType[1]; // Tenuous atmComp = atmCompType[0]; // None } /* OLD: Keep as an example of strcmp and normal_dist if (strcmp(atmDens, "Substantial") == 0) { std::normal_distribution<double> distribution(0.01, 0.25); pressure = abs(distribution(generator) * 1e6); } // Keep because these gave nice numbers when seed = 10, range of ~0.02 - 4.0 AU printf("Semi-Major Axis: %.2f AU\n", distribution(generator)); printf("Semi-Major Axis: %.2f AU\n", distribution(generator)); printf("Semi-Major Axis: %.2f AU\n", distribution(generator)); printf("Semi-Major Axis: %.2f AU\n", distribution(generator)); printf("Semi-Major Axis: %.2f AU\n", distribution(generator)); */ }
void PortOutput::setVal(bool value) { digitalWrite(this->id, valueCheck(value)); };
void PortOutput::setDefault() { digitalWrite(this->id, valueCheck(this->defaultValue)); };
bool PortInput :: getVal() { return valueCheck(digitalRead(this->id)); };