import conf import copy import random _RAD_INCR = conf.get_fvalue('OLD', 'RAD_INCR') _LUM_INCR = conf.get_fvalue('OLD', 'LUM_INCR') _TEMP_INCR = conf.get_fvalue('OLD', 'TEMP_INCR') _MASS_INCR = conf.get_fvalue('OLD', 'MASS_INCR') random.seed() class Old: star = None name = 'old' def __init__(self, star): self.star = star def calc_duration(self): if self.star.mass > 2: return 10**6 else: return 10**6 def calc_aspiration_state(self): asp_state = copy.copy(self.star) asp_state.temp = random.randrange(4500, 5999) * _TEMP_INCR asp_state.rad *= _RAD_INCR asp_state.lum *= _LUM_INCR asp_state.mass *= _MASS_INCR
from stages.init_stage import Init from stages.mainseq_stage import Mainseq from stages.old_stage import Old from stages.dying_stage import Dying import conf STAGE_ITERATIONS = conf.get_fvalue('SPEED', 'STAGE_ITERATIONS') class Maturity: star = None asp_state = None stage = None cur_stage_dur = 0 step_years = 0 stage_threshold = 0 change_for_step = {'lum': 0, 'rad': 0, 'temp': 0, 'mass': 0} def __init__(self, star): self.star = star self.stage = Init(self.star) self._update_values() def __str__(self): return self.stage.name def _update_values(self): self.cur_stage_dur = self.stage.calc_duration() self.asp_state = self.stage.calc_aspiration_state() self.step_years = self.cur_stage_dur / STAGE_ITERATIONS self.stage_threshold = self.star.age + self.cur_stage_dur
import conf import copy _RAD_DECR = conf.get_fvalue('INIT', 'RAD_DECR') _LUM_DECR = conf.get_fvalue('INIT', 'LUM_DECR') _TEMP_INCR = conf.get_fvalue('INIT', 'TEMP_INCR') _MASS_INCR = conf.get_fvalue('INIT', 'MASS_INCR') class Init: star = None name = 'init' def __init__(self, star): self.star = star def calc_duration(self): if self.star.mass > 1: return (10**6) / (self.star.mass * 100) elif self.star.mass == 1: return 10**6 else: return (100 / self.star.mass) * (10**6) def calc_aspiration_state(self): asp_state = copy.copy(self.star) asp_state.mass *= _MASS_INCR asp_state.rad = (asp_state.mass ** 0.75) * _RAD_DECR asp_state.lum = (asp_state.mass ** 3.9) * _LUM_DECR asp_state.temp *= _TEMP_INCR return asp_state
import copy import conf import random _RAD_DECR = conf.get_fvalue('DYING', 'RAD_DECR') _LUM_INCR = conf.get_fvalue('DYING', 'LUM_INCR') _TEMP_INCR = conf.get_fvalue('DYING', 'TEMP_INCR') _MASS_DECR = conf.get_fvalue('DYING', 'MASS_DECR') _MASS_DECR_WHITE_DWARF = conf.get_fvalue('DYING', 'MASS_DECR_WHITE_DWARF') random.seed() class Dying: star = None name = 'dying' def __init__(self, star): self.star = star def calc_duration(self): if self.star.mass > 8: return 0.000019 else: return 1 def calc_aspiration_state(self): asp_state = copy.copy(self.star) if asp_state.mass > 8: asp_state.mass = random.randrange(138, 300) / 100 if asp_state.mass > 2.5: asp_state.rad = _RAD_DECR * 1 / (2.95 * asp_state.mass)
from graphics import * import conf _WINDOW_NAME = conf.get_str('WINDOW', 'NAME') _WINDOW_HEIGHT = conf.get_intvalue('WINDOW', 'HEIGHT') _WINDOW_WIDTH = conf.get_intvalue('WINDOW', 'WIDTH') _RAD_PIX = conf.get_fvalue('GRAPHIC', 'SOLAR_RADIUS_IN_PIXELS') LAB_X = conf.get_fvalue('WINDOW', 'LAB_X') LAB_Y = conf.get_fvalue('WINDOW', 'LAB_Y') CENTRE = Point(_WINDOW_WIDTH / 2, _WINDOW_HEIGHT / 2) COLORS = { 'Black': color_rgb(0, 0, 0), 'Dark_red': color_rgb(139, 0, 0), 'Red': color_rgb(100, 0, 0), 'Yellow': color_rgb(255, 255, 0), 'White': color_rgb(255, 255, 255), 'Bluish_white': color_rgb(166, 202, 240), 'Blue': color_rgb(0, 0, 255), } graph_window = GraphWin(_WINDOW_NAME, _WINDOW_WIDTH, _WINDOW_HEIGHT) graph_window.setBackground('Black') class GraphStar: star = None circle = None pos = CENTRE