Beispiel #1
0
 def __init__(self, input, uselogger=True):
     if input:
         parameters = inp_out.read_parameter_input(input, uselogger)
     else:
         parameters = inp_out.read_parameter_input({'atomlist':[('Xx',1,0,0)],'structure':'Cluster'}, uselogger)
     self.__dict__.update(parameters)
     if self.loggername:
         global logger
         logger = logging.getLogger(self.loggername)
     if self.restart_optimizer:
         try:
             rank = MPI.COMM_WORLD.Get_rank()
         except:
             rank = 0
         if rank==0:
             logger.info('restarting output')
             outdict = inp_out.restart_output(self)
             self.__dict__.update(outdict)
             logger.info('Loading individual files')
             poplist = []
             for indfile in self.population:
                 ind = inp_out.read_individual(indfile)
                 poplist.append(ind)
             self.population = poplist
             logger.info('Loading bests')
             bestlist = []
             for bestfile in self.BESTS:
                 ind = inp_out.read_individual(bestfile)
                 bestlist.append(ind)
             self.BESTS = bestlist
             self.restart = True
             if self.structure == 'Defect':
                 bulk = inp_out.read_xyz(self.solidfile)
                 bulk.set_pbc(True)
                 bulk.set_cell(self.solidcell)
                 self.solidbulk = bulk.copy()
             else:
                 self.solidbulk = None
     else:
         self.convergence = False
         self.generation = 0
         self.Runtimes = [time.time()]
         self.Evaluations = list()
         self.CXs = list()
         self.Muts = list()
         self.cxattempts = 0
         self.mutattempts = list()
         self.BESTS = list()
         self.genrep = 0
         self.minfit = 0
         self.convergence = False
         self.overrideconvergence = False
         self.population = list()
         self.calc = None
         self.static_calc = None
Beispiel #2
0
 def read(self,optfile):
     parameters = inp_out.read_parameter_input(optfile,True)
     self.__dict__.update(parameters)
     outdict = inp_out.restart_output(self)
     self.__dict__.update(outdict)
     poplist = []
     for indfile in self.population:
         ind = inp_out.read_individual(indfile)
         poplist.append(ind)
     self.population = poplist
     bestlist = []
     for bestfile in self.BESTS:
         ind = inp_out.read_individual(bestfile)
         bestlist.append(ind)
     self.BESTS = bestlist
     self.restart = True
     return self
Beispiel #3
0
 def __init__(self, input, uselogger=True):
     if input:
         parameters = inp_out.read_parameter_input(input, uselogger)
     else:
         parameters = inp_out.read_parameter_input({'atomlist':[('Xx',1,0,0)],'structure':'Cluster'}, uselogger)
     self.__dict__.update(parameters)
     try:
         rank = MPI.COMM_WORLD.Get_rank()
     except:
         rank = 0
     if 'stem' in parameters['fitness_scheme']:
       if rank == 0 :
         nk = self.stemcalc.parameters['Pixels']
         self.stemcalc.psf = np.empty([nk,nk],dtype=float)
         fileobj = open('PSF.txt', 'r')
         lines = fileobj.readlines()
         for x in range(0,nk):
            self.stemcalc.psf[x] = lines[x].split()
         fileobj.close()
        #self.stemcalc.psf = tools.StemCalc.get_probe_function(self.stemcalc.parameters)
       else: 
         self.stemcalc.psf = None           
       self.stemcalc.psf = MPI.COMM_WORLD.bcast(self.stemcalc.psf,root=0)
     if self.loggername:
         global logger
         logger = logging.getLogger(self.loggername)
     if self.restart_optimizer:
         try:
             rank = MPI.COMM_WORLD.Get_rank()
         except:
             rank = 0
         if rank==0:
             logger.info('restarting output')
             outdict = inp_out.restart_output(self)
             self.__dict__.update(outdict)
             logger.info('Loading individual files')
             poplist = []
             for indfile in self.population:
                 ind = inp_out.read_individual(indfile)
                 poplist.append(ind)
             self.population = poplist
             logger.info('Loading bests')
             bestlist = []
             for bestfile in self.BESTS:
                 ind = inp_out.read_individual(bestfile)
                 bestlist.append(ind)
             self.BESTS = bestlist
             self.restart = True
             if self.structure == 'Defect':
                 bulk = inp_out.read_xyz(self.solidfile)
                 bulk.set_pbc(True)
                 bulk.set_cell(self.solidcell)
                 self.solidbulk = bulk.copy()
             else:
                 self.solidbulk = None
     else:
         self.convergence = False
         self.generation = 0
         self.Runtimes = [time.time()]
         self.Evaluations = list()
         self.CXs = list()
         self.Muts = list()
         self.cxattempts = 0
         self.mutattempts = list()
         self.BESTS = list()
         self.genrep = 0
         self.minfit = 0
         self.convergence = False
         self.overrideconvergence = False
         self.population = list()
         self.calc = None
         self.static_calc = None