def initiate_reactor(reactor): first_stage = Stage( myreactor = reactor, reactor_id = reactor.id, sn = 1, t = 1.0, power = 0, phy = 0, dens_I = 0, dens_Xe = 0, dens_Sm = 0, dens_Pm = 0) first_stage.save() #画一个平的图 thex = np.arange(0, float(first_stage.t) * 3600 + 1, 60) density1 = np.exp(thex / 360) density2 = np.exp(10-thex / 360) density3 = np.sin(thex / 360) density4 = np.cos(thex / 360) reactivity1 = np.sin(thex / 360) reactivity2 = np.sin(thex / 360+1) reactivity3 = reactivity1 + reactivity2 thepoints = { 'x': thex, 'I': density1, 'Xe': density2, 'Pm': density3, 'Sm': density4, 'I_Xe': reactivity1, 'Pm_Sm': reactivity2, 'ALL': reactivity3} drawimage(thepoints, reactor.id, 1) return first_stage
def create_next_stage(reactor, last_stage, next_power, next_time): next_stage = Stage( myreactor = reactor, reactor_id = reactor.id, sn = last_stage.sn + 1, t = next_time, power = next_power, phy = 250, dens_I = -1, dens_Xe = -1, dens_Pm = -1, dens_Sm = -1) next_stage.save() thepoints = wtf(reactor, last_stage, next_stage) next_stage.dens_I = thepoints['I'][-1] next_stage.dens_Xe = thepoints['Xe'][-1] next_stage.dens_Pm = thepoints['Pm'][-1] next_stage.dens_Sm = thepoints['Sm'][-1] next_stage.phy = thepoints['phy'] next_stage.save() drawimage(thepoints, reactor.id, next_stage.sn) return next_stage