Ejemplo n.º 1
0
def test():
    """
    Test reactor in rod control and power control modes.
    """
    i = 0
    t0 = time.time()
    legoReactor = LegoReactor()
    legoReactor.setRodPosition(50.)  # set rod position to 50% withdrawn
    while i < 10000:
        legoReactor.timeStep()
        print("===================================")
        print("Time [s] = %f" % legoReactor.t[-1])
        print("Rod percent Withdrawn = %f" % legoReactor.S[4])
        print("Reactor Power [MW] = %f " %
              float(qFuel(legoReactor.S[0]) / 1.e6))
        print("Tfuel [K] = %f ,  Tcoolant [K] = %f" %
              (legoReactor.S[2], legoReactor.S[3]))
        i += 1
    i = 0
    legoReactor.togglePwrCtrl(200.)  # set reactor power to 200 MW
    while i < 10000:
        legoReactor.timeStep()
        print("===================================")
        print("Time [s] = %f" % legoReactor.t[-1])
        print("Rod percent Withdrawn = %f" % legoReactor.S[4])
        print("Reactor Power [MW] = %f " %
              float(qFuel(legoReactor.S[0]) / 1.e6))
        print("Tfuel [K] = %f ,  Tcoolant [K] = %f" %
              (legoReactor.S[2], legoReactor.S[3]))
        i += 1
    t1 = time.time()
    print(t1 - t0)
Ejemplo n.º 2
0
 def __controlPID(self):
     maxRate = 0.60  # maxumum rod movement rate in %/s
     Kp = 0.0100000  # Proportional tunable const
     Ki = 0.0001000  # Intergral tunable const
     Kd = 0.0001000  # Derivitive tunable const
     currentpwr = qFuel(self.S[0]) / 1.e6
     errorFn = self.pwrSet - qFuel(self.storVals[0, :]) / 1.e6
     errorIntegral = np.sum(
         errorFn[-100:])  # base integral error on past 100 values
     errorDerivative = (errorFn[-1] - errorFn[-2]) / (self.tstep)
     if hasattr(self, 'pwrSet'):
         pidOut = self.pidBias + Kp * (
             self.pwrSet -
             currentpwr) + Ki * errorIntegral + Kd * errorDerivative
         self.hrate = pidOut
         if abs(self.hrate) > maxRate:
             self.hrate = maxRate * (self.hrate / abs(self.hrate))
     else:
         self.togglePwrCtrl(qFuel(self.S[0]) / 1.e6)
Ejemplo n.º 3
0
    def writeToArduino(self):
        """ write rod and power out to arduino if connected """
        if self.ser:
            # rod % withdrawn ranges stored in S[4] from 0 to 100
            rodWriteOut = abs((self.legoReactor.S[4] / 100.) * 160.)
            if rodWriteOut < 5.0:
                rodWriteOut = 5.0
            elif rodWriteOut > 140.0:
                rodWriteOut = 140.
            self.ser.write("r" + str(rodWriteOut))
            time.sleep(0.1)  # arduino needs time to adjust motor position

            # compute output voltage to blue LED
            maxPwr = 500.  # if pwr in [MW] greater than this value, set max bulb brightness
            normPwr = abs(qFuel(self.legoReactor.S[0]) / 1.e6 / maxPwr)
            # normPwr ranges from 0 to 255
            normPwr = 250. * normPwr
            if normPwr >= 250:
                normPwr = 250
            self.ser.write("p" + str(int(normPwr)))
Ejemplo n.º 4
0
    def draw_plot(self):
        # Determine plot data length depending on zoom lvl
        zoomPercentage = self.zoom / 100.
        if zoomPercentage < 0.02:
            zoomPercentage = 0.02
        plotMask = int(zoomPercentage * len(self.data[0]))

        # Plot the data
        xdata = np.array(
            np.array(range(plotMask)) /
            float(plotMask)) * self.legoReactor.maxTime * zoomPercentage
        pwrdata = qFuel(self.data[1][0, :][-plotMask:]) / 1.e6
        fuelTdata = self.data[1][2, :][-plotMask:]
        coolTdata = self.data[1][3, :][-plotMask:]
        self.axes1.clear()
        self.axes2.clear()
        self.axes3.clear()
        self.axes1.set_ylim(0, 550.)
        self.axes2.set_ylim(400, 1700.)
        self.axes3.set_ylim(400, 700.)
        self.axes1.set_title('Reactor Power [MW] Trace', size=12)
        self.axes1.set_ylabel('Power [MW]')
        self.axes1.set_xlabel(str(round(max(xdata), 0)) + ' time [s]')
        self.axes1.plot(xdata, pwrdata, linewidth=2)
        self.axes2.set_ylabel('Fuel Temperature [K]')
        self.axes3.set_ylabel('Coolant Temperature [K]')
        fuelPlot, = self.axes2.plot(xdata,
                                    fuelTdata,
                                    color='r',
                                    linewidth=2,
                                    label='Fuel T')
        coolPlot, = self.axes3.plot(xdata,
                                    coolTdata,
                                    color='b',
                                    linewidth=2,
                                    label='Coolant T')
        handles, labels = self.axes2.get_legend_handles_labels()
        self.axes2.legend(handles, labels, loc=2)
        handles, labels = self.axes3.get_legend_handles_labels()
        self.axes3.legend(handles, labels, bbox_to_anchor=(0.402, 0.85))
        self.canvas.draw()
Ejemplo n.º 5
0
 def updateMonitors(self):
     self.rodPosOut.SetValue(str(round(self.legoReactor.S[4], 1)))
     self.cooltOut.SetValue(str(self.legoReactor.S[3]))
     self.fueltOut.SetValue(str(self.legoReactor.S[2]))
     self.powOut.SetValue(str(float(qFuel(self.legoReactor.S[0]) / 1.e6)))
     self.rodGauge.SetValue(self.legoReactor.S[4])