def __init__(self, facility):

        self.heel = batch_class(0, "heel")  # heel initialization.
        self.batch = batch_class(0, "batch")  # batch initialization.

        self.process_time_delay = np.loadtxt(
            facility.process_states_dir + '/process.operation.time.inp',
            usecols=[1])[1]  # 8 hours = 0.3333 days
        # self.batch = batch_class(self.batch_size, "batch")
        self.failure_rate = np.loadtxt(
            facility.failure_equipment_dir + '/melter.failure.data.inp',
            usecols=[1])  # 0.0333 days-1 = 1/30 days
        self.maintenance_time_delay = np.loadtxt(
            facility.failure_equipment_dir + '/melter.failure.data.inp',
            usecols=[2])  # 0.1667 days = 4 hours
        self.cleaning_time_delay = np.loadtxt(
            facility.failure_equipment_dir + '/melter.failure.data.inp',
            usecols=[3])  # 0.0833 days = 2 hours

        self.time_of_last_failure = 0  # The melter hasn't failed yet.
        self.true_batch_loss = 0
        self.failure_count = 0

        self.failure_data_output = data_output_class(
            "melter_failure_data", facility.equipment_failure_odir)
        facility_component_class.__init__(self, "melter", "processor",
                                          facility.material_flow_odir)

        self.sum = 0.0
 def __init__(self, facility, kmp_identifier):
     
     self.batch = batch_class(0, "batch")
     
     self.identifier = kmp_identifier 
     self.measured_weight = 0 # measurement
     self.muf = 0
     
     
     
     self.uncertainty = np.loadtxt(facility.kmps_dir + '/key.measurement.points.inp', usecols=[2])[kmp_identifier] # std = 0.01; uncertainty only associated with measurement
     self.time_delay = np.loadtxt(facility.kmps_dir + '/key.measurement.points.inp', usecols=[1])[kmp_identifier] # kmp measurement time = 30 mins = 0.0208 days.
     #print self.uncertainty
     
     #self.kmp_alarm_threshold = self.alarm_threshold() #expected values: (0.02, 0.101980390272)
     # print self.kmp_alarm_threshold[1]
     # only one standard deviation can be used as a threshold. However, the false alarm probability will be low in this case compared to 0.95.
     # Or, you can use a false alarm probability of 95%. 
     
     self.kmp_alarm_threshold1 = 0.0 
     self.kmp_alarm_threshold2 = 0.0
     self.kmp_alarm_threshold_0_3 = 0.0
     self.kmp_alarm_threshold_3_3 = 0.0
     
     facility_component_class.__init__(self, "key_measurement_point_%i"%(kmp_identifier), "kmp", facility.kmps_odir)
     
     self.muf_data_output1 = open(facility.muf_odir+ '/muf1.out', 'w+') # muf info
     self.muf_data_output2 = open(facility.muf_odir+ '/muf2.out', 'w+')
     self.muf_data_output3 = open(facility.muf_odir+ '/muf3.out', 'w+')        
Exemplo n.º 3
0
    def __init__(self, facility):

        self.batch = batch_class(0, "batch")
        self.time_delay = np.loadtxt(facility.process_states_dir +
                                     '/process.operation.time.inp',
                                     usecols=[1])[2]  # 0.125 days = 3 hours

        facility_component_class.__init__(self, "trimmer", "processor", None)
 def __init__(self,facility):
     self.expected_loss = np.loadtxt(facility.process_states_dir+ \
             '/melter.loss.fraction.inp',usecols=[1])[0] 
     self.batch_loss_bounds = np.loadtxt(facility.process_states_dir+'/melter.loss.fraction.inp',
             usecols=[1])[1:3] 
     self.process_time_delay = np.loadtxt(facility.process_states_dir+ \
             '/process.operation.time.inp',usecols=[1])[1] 
     self.heel = batch_class(0,"heel")
     self.failure_rate = np.loadtxt(facility.failure_equipment_dir+'/melter.failure.data.inp',usecols=[1]) 
     self.maintenance_time_delay = np.loadtxt(facility.failure_equipment_dir+ \
             '/melter.failure.data.inp',usecols=[2]) 
     self.cleaning_time_delay = np.loadtxt(facility.failure_equipment_dir+ \
             '/melter.failure.data.inp',usecols=[2]) 
     self.time_of_last_failure = 0
     self.true_batch_loss = 0
     self.failure_count = 0
     self.failure_data_output = data_output_class("melter_failure_data", facility.equipment_failure_odir)
     facility_component_class.__init__(self, 0, 0, 0, "melter", "processor", facility.material_flow_odir)
    def batch_preparation(self,facility):
        """
        The storage buffer takes some SNM from its inventory, creates it into a batch, then passes such on
        to the next part.
        """
        self.write_to_log(facility,'Prepare batch in Storage Buffer for transfer: %.1f kg \n\n\n'%(self.batch_size))
        self.increment_operation_time(facility,self.time_delay)
        self.inventory = self.inventory - self.batch_size
        #######
        # This variable must be set in order for the edge transition to function properly 
        # since it is the first facility component to create the batch
        #######
        self.expected_weight.batch_weight = self.batch_size
        self.expected_weight.storage_batch_loss()

        self.data_output.storage_output(facility, self)

        return batch_class(self.batch_size,"batch")
    def __init__(self, facility):

        self.batch = batch_class(0, "batch")
        self.inventory_muf = 0
        self.inventory_2_melter = 0
        self.measured_inventory = 0
        #self.inventory = 0

        self.time_delay = np.loadtxt(
            facility.process_states_dir + '/process.operation.time.inp',
            usecols=[1])[3]  # 0.0833 days = 2 hours (recycle storage time)
        facility_component_class.__init__(self, "recycle_storage", "storage",
                                          facility.inventory_odir)

        self.inventory_muf_output = open(
            facility.inventory_odir + '/inventory_muf.out', 'w+')
        self.inventory_2_melter_output = open(
            facility.inventory_odir + '/inventory_2_melter.out', 'w+')
    def __init__(self, facility):

        #self.batch_size = np.loadtxt(facility.process_states_dir + '/batch.inp') # 20 KG
        self.batch = batch_class(0, "batch")

        self.inventory = 0
        self.end_time_inspection = 0.166667  # 4 hours

        self.time_delay = np.loadtxt(facility.process_states_dir +
                                     '/process.operation.time.inp',
                                     usecols=[1])[3]  # 0.0833 days; 2 hours

        #if (facility.total_campaign == 1):
        self.measured_inventory = 0

        #self.measured_inventory_calculation(facility)
        #print "Round (storage buffer inventory) " + str(facility.total_campaign) +" : " + str(self.measured_inventory)

        facility_component_class.__init__(self, "product_storage", "storage",
                                          facility.inventory_odir)
    def inspect(self):
        """
        Method that gets called whenever an alarm is set off.  The melter is cleaned, the heel moved to
        recycle storage, the storage units are remeasured manually,
        a mass balance is executed, and then the heel is moved back into the storage buffer.

        The false_alarm_count gets incremented here.
        """
        self.write_to_log('\n\n--Conducting Facility Inspection--\n\n\n')
        self.operation_time = self.operation_time + self.facility_inspection_time
        self.fuel_fabricator.inspect(self)
        self.storage_unit.inspect(self)
        self.final_storage_unit.inspect(self)
        self.account()
        batch = batch_class(0, "temprorary class for heel transfer")
        self.fuel_fabricator.recycle_storage.process_batch(self, batch)
        self.edge.edge_transition(self, batch, self.fuel_fabricator.recycle_storage, self.storage_unit.kmp)
        self.storage_unit.store_batch(self, batch)
        self.did_conduct_inspection = True
        self.false_alarm_count = self.false_alarm_count + 1
Exemplo n.º 9
0
    def __init__(self, facility, initial_inventory):
        self.batch_size = np.loadtxt(facility.process_states_dir +
                                     '/batch.inp')  # 20 KG
        self.inventory = initial_inventory  # 10,000 KG

        self.batch = batch_class(self.batch_size, "batch")

        self.measured_inventory = self.measured_inventory_calculation(facility)
        print "Round (measured storage buffer inventory) " + str(
            facility.total_campaign) + " : " + str(self.measured_inventory)

        self.time_delay = np.loadtxt(
            facility.process_states_dir + '/process.operation.time.inp',
            usecols=[
                1
            ])[0]  #Storage buffer batch preparation time: 1 hour = 0.0417
        self.time_inspection = 0.333333  # 8 hours of inspection; an input file for it is needed (two different inventories)

        facility_component_class.__init__(self, "storage_buffer", "storage",
                                          facility.inventory_odir)
    def clean_heel(self,facility):
        """
        The accumulated SNM leftover from all previous campaigns (the heel) is cleaed out and returned.
        """
        self.write_to_log(facility,'Cleaning the heel\n\n')
        self.increment_operation_time(facility,self.cleaning_time_delay)
        #######
        # Create new batch instance, because the assignment variable only copies the pointer, not the 
        # object itself.
        #######
        cleaned_out_heel = batch_class(self.heel.weight,"heel")
        #######
        # A little bit of variable shuffle to make sure that the edge transition with the heel occurs as expected
        #######
        self.expected_weight.batch_weight = self.expected_weight.residual_weight
        self.heel.weight = 0
        self.expected_weight.residual_weight = 0
        self.expected_weight.update_total_weight

        self.data_output.processor_output(facility, self, cleaned_out_heel)

        return cleaned_out_heel 
Exemplo n.º 11
0
    def __init__(self, root_dir, subsystem):
        """
        Although large, all this part does is to read in the number of input files required to start up the
        facility. 
        
        """
        # variable initiation
        self.operation_time = 0
        self.total_campaign = 1

        self.measured_muf = 0
        self.false_alarm_count = 0
        self.melter_did_fail = False
        self.did_conduct_inspection = False

        self.log_file = open(root_dir + '/log.txt', 'w')
        self.root_dir = root_dir
        self.subsystem = subsystem

        self.sequential_muf = 0.0
        self.failure_check = False
        self.total_muf_cal = 0
        self.muf_cal_1 = 0
        self.muf_cal_2 = 0
        self.muf_cal_3 = 0

        self.false_alarm_count_1 = 0
        self.false_alarm_count_2 = 0
        self.false_alarm_count_3 = 0
        self.melter_failure_count = 0
        # Begin Preprocessing
        self.log_file.write('Fuel fabrication \n\nPREPROCESSING\n')

        # Get a home directory path.
        home_dir = open(self.root_dir +
                        '/simulation/meta.data/home.dir.inp').read()

        # Get directory paths.
        directory_path_file = open(
            self.root_dir +
            '/simulation/meta.data/fuel.fabrication_simulation.dir.inp'
        ).readlines()

        directory_paths = directory_path_file[0].split(
            ',')  #split path data and set directories.

        # Get directory paths for input & output files.
        self.input_dir = directory_paths[0]
        self.output_dir = directory_paths[1]

        # Get paths for subdirectories in 'input' directory.
        self.edge_transition_dir = directory_paths[2]
        self.failure_distribution_dir = directory_paths[3]
        self.failure_equipment_dir = directory_paths[4]
        self.kmps_dir = directory_paths[5]
        self.process_states_dir = directory_paths[6]
        self.system_false_alarm_dir = directory_paths[7]

        # Get paths for directories in 'output' directory.
        self.data_dir = directory_paths[8]
        self.figures_dir = directory_paths[9]

        # Get paths for directories in 'data' directory.
        self.system_odir = directory_paths[10]
        self.material_flow_odir = directory_paths[11]
        self.inventory_odir = directory_paths[12]
        self.false_alarm_odir = directory_paths[13]
        self.kmps_odir = directory_paths[14]
        self.muf_odir = directory_paths[15]
        self.equipment_failure_odir = directory_paths[16]

        # Get paths for directories in 'figures' directory.
        self.system_gdir = directory_paths[17]
        self.material_flow_gdir = directory_paths[18]
        self.inventory_gdir = directory_paths[19]
        self.false_alarm_gdir = directory_paths[20]
        self.kmps_gdir = directory_paths[21]
        self.muf_gdir = directory_paths[22]
        self.equipment_failure_gdir = directory_paths[23]

        # Read input data
        self.total_operation_time = np.loadtxt(
            self.process_states_dir + '/facility.operation.inp'
        )  #250 days, np.loadtxt loads data from a text file.
        self.end_of_campaign_time_delay = np.loadtxt(
            self.system_false_alarm_dir + '/system.inspection.time.inp',
            usecols=[1]
        )  # End of campaign inspection time: 4 hours = 0.1667 days. 'usecols' defines which columns to read.
        self.end_of_campaign_alarm_threshold = np.loadtxt(
            self.system_false_alarm_dir +
            '/eoc.alarm.threshold.inp')  # Threshold = 2.4kg.
        self.facility_inspection_time = np.loadtxt(
            self.system_false_alarm_dir +
            '/facility.inspection.time.inp')  # 4 hours = 0.1667 days
        self.initial_inventory = np.loadtxt(
            self.process_states_dir +
            '/unprocessed.storage.inventory.inp')  # 10,000 KG

        # Open output files
        self.system_time_output = open(
            self.system_odir + '/facility.operation.time.out',
            'w+')  # facility operation time output file
        self.system_info_output = open(
            self.system_odir + '/system_info.out',
            'w+')  # facility operation time, # of campaign, # of false alarms
        self.muf_check_output = open(self.kmps_odir + '/muf_check.out',
                                     'w+')  # muf info

        # Write data to output files
        self.system_time_output.write('%.4f\n' % (self.operation_time))
        self.system_info_output.write(
            '%.4f\t%i\t%i\n' %
            (self.operation_time, self.total_campaign, self.false_alarm_count))

        # Initialize facility components
        self.storage_buffer = storage_buffer_class(self,
                                                   self.initial_inventory)
        self.melter = melter_class(self)
        self.trimmer = trimmer_class(self)
        self.product_storage = product_storage_class(self)
        self.recycle_storage = recycle_storage_class(self)

        # Initialize the edge transition.
        self.edge = edge_transition_class(self, 0)

        # Initialize key measurement points.
        self.kmp = []
        for n in range(4):  # 0,1,2,3
            self.kmp.append(kmp_class(self, n))

        # total amount of heel + batch initilization

        self.total = batch_class(0, "total")

        # Log end of Preprocess
        self.log_file.write('\n\nEND PREPROCESSING \n\n\n')