Exemplo n.º 1
0
 def make_sens_multiplication(self):
     '''takes all multiplicators  (A) from the form and selected materials
     from list (B). Computes A x B results and creates new tasks
     '''
     
     self.window().create_master_task() 
        
     selection, poc = self.get_selected_items()
     
     if not selection:
         msg = "Select some material first"        
         self.messenger(msg)
         return
     
     count = self.initial_count
     
     for material_id in selection:
         for row_nr in range(self.number_of_multipliers): 
             key = str(row_nr)
             
             values_row, sorption_values = self.__get_values_for_current_material(key, self.editor_values)
             
             if values_row or sorption_values:
                 workcopy = copy.deepcopy(self.material)
                 count += 1
                 fdir = '{num:0{width}}'.format(num=count, width=poc+1)
                 #operation with material
                 mtr_file = self.window().output_dir + fdir +\
                 SEPARATOR + self.window().flow_ini.dict_files['Material']
                 if values_row:
                     changed_values = workcopy.compute_new_material_values(material_id, values_row)
                 if sorption_values:
                     workcopy.compute_new_sorption_val(material_id, sorption_values)
                     
                 workcopy.save_changes(mtr_file)
                 self.create_common_task_files(fdir)
                 
                 if values_row:
                     message = '{} computed values {} (None = no change)\n'.format(material_id, changed_values)
                     self.log_message(message, fdir)
                 
                 workcopy = {}    
     
     if self.window().centralWidget.tab_settings.launcher_check_hydra.isChecked():
         batch.create_cluster_batch(self.window().output_dir)
     
     self.message_after_computation(count)
Exemplo n.º 2
0
 def make_sens_multiplication_group(self):
     '''
     takes all multiplicators  (A) from the form and selected materials
     from list (B). Computes A results for Group B of materials and creates new tasks
     '''
     self.window().create_master_task() 
        
     selection, pocet = self.get_selected_items()
     
     
     if not selection:
         msg = "Select some material first"        
         self.messenger(msg)
         return
     
     #field_values = self.get_editor_values()
     count = self.initial_count
     
     for row_nr in range(self.number_of_multipliers): 
         key = str(row_nr)
         values_row, sorption_values = self.__get_values_for_current_material(key, self.editor_values)
         if values_row or sorption_values:
             workcopy = copy.deepcopy(self.material)
             count += 1
             message = 'Log for sensitivity changes (conductvity, prorosity, storativity, geometry). (None = no change)\n'
             for material_id in selection:
                 if values_row:
                     changed_values = workcopy.compute_new_material_values(material_id, values_row)
                     message += '{} new values {} \n'.format(material_id, changed_values)
                 if sorption_values:
                     workcopy.compute_new_sorption_val(material_id, sorption_values)
                 
             fdir = '{num:0{width}}'.format(num=count, width=pocet+1)
             fname = self.window().output_dir + fdir + SEPARATOR + self.window().flow_ini.dict_files['Material'] 
             
             workcopy.save_changes(fname)
             
             self.create_common_task_files(fdir)
             
             self.log_message(message, fdir)
                 
             workcopy = {}    
     
     if self.window().centralWidget.tab_settings.launcher_check_hydra.isChecked():
         batch.create_cluster_batch(self.window().output_dir)
     
     self.message_after_computation(count)
Exemplo n.º 3
0
 def save_monte_carlo_results(self):    
     '''
     save results from dict computed_conductivity_values if there are any
     '''
     
     if len(self.computed_conductivity_values) == 0:
         msg = "ERROR - nothing to save"           
         self.messenger(msg)
         return
     
     pocet = int(self.edit_monte_tasks.text())
     poc = len(str(pocet+1))
     
     local_launcher, cluster_launcher = self.window().get_launchers()
        
     for loop_nr in range(pocet):
         workcopy = copy.deepcopy(self.material)
         
         for mat in self.computed_conductivity_values.keys():
         
             workcopy[mat]['type_spec'] = []
             for direction_value in self.computed_conductivity_values[mat]:
                 
                 self.monte_logger.log_message(\
                       loop_nr, mat, workcopy[mat]['type_spec'], direction_value[loop_nr])
                 workcopy[mat]['type_spec'].append(direction_value[loop_nr])   
             
         
         for mat in self.computed_storativity_values.iterkeys():
             self.monte_logger.log_message(\
                   loop_nr, mat, workcopy[mat]['storativity'], self.computed_storativity_values[mat][loop_nr])
             workcopy[mat]['storativity'] = self.computed_storativity_values[mat][loop_nr]  
             
         for mat in self.computed_geometry_values.iterkeys():
             self.monte_logger.log_message(\
                   loop_nr, mat, workcopy[mat]['geometry_spec'], self.computed_geometry_values[mat][loop_nr])
             workcopy[mat]['geometry_spec'] = self.computed_geometry_values[mat][loop_nr]      
         
         for mat in self.computed_porosity_values.iterkeys():
             self.monte_logger.log_message(\
                   loop_nr, mat, workcopy[mat]['dualporosity'], self.computed_porosity_values[mat][loop_nr])
             workcopy[mat]['dualporosity'] = self.computed_porosity_values[mat][loop_nr]
             
         for mat in self.computed_sorption_values.iterkeys():
             for subst_nr in workcopy[mat]['sorption'].iterkeys():
                 workcopy[mat]['sorption'][subst_nr] = self.computed_sorption_values[mat][subst_nr][loop_nr]
         
         fdir = '{num:0{width}}'.format(num=loop_nr, width=poc+1)
         fname = self.window().output_dir + fdir + SEPARATOR +  self.window().flow_ini.dict_files['Material']
         
         workcopy.save_changes(fname)
         ffname = self.window().output_dir + fdir + SEPARATOR + fdir + '_ini.ini'
         self.window().flow_ini.create_changed_copy(ffname, Material = self.window().flow_ini.dict_files['Material'])
         
         batch.create_launcher_scripts(ffname, local_launcher, cluster_launcher)
         
         solver_utils.create_task_identifier('basic', self.window().output_dir + fdir)
         workcopy = {}  
     
     if self.window().centralWidget.tab_settings.launcher_check_hydra.isChecked():
         batch.create_cluster_batch(self.window().output_dir)
     
     #self.monte_logger.close()
     msg = "{} new tasks has been created".format(pocet)           
     self.messenger(msg)