Ghost/Create_epsmap.py
def cube_scan(self):
        """Calculate the score for all cubes"""
        #
        # Define the epsmap
        #
        cubes=self.epsmap.get_cubes(sidelength=self.options.sidelength,eps=80.0,clearmaps=False)
        print 'Creating map with %d cubes' %(len(cubes))
        self.cube_eps={}
        self.cube_grad={}
        for cube in cubes:
            self.cube_eps[cube]=80.0
            self.cube_grad[cube]=0.0
            self.epsmap.set_cubeeps(cube,80.0)
        #
        # If starteps is defined, then load the starting epsmap
        #
        if options.starteps=='':
            print 'Using epsmap with 80 everywhere as starting point for iteration'
        else:
            if options.starteps=='PBE':
                print 'Using normal 8/80 PBE dielectric map as starting EPSMAP'
                count=0
                diels=[]
                for cube in cubes:
                    centre=self.epsmap.cubes[cube]['coord']
                    diel=self.epsmap.maps['x'].get_coord_value(centre[0],centre[1],centre[2])

                    if int(diel)!=80:
                        count=count+1
                        diels.append(diel)
                    self.cube_eps[cube]=diel
                if len(diels)==0:
                    diels.append(0.0)
                print '%4d (%5.2f%%) cubes have a diel different from 80. Their avg eps is %5.1f' %(count,float(count)/float(len(cubes))*100.0,sum(diels)/len(diels))
                print diels
            else:
                print 'Loading starting epsmap from: %s' %options.starteps
                fd=open(options.starteps)
                import pickle
                self.epsmap=pickle.load(fd)
                fd.close()
                if len(self.epsmap.keys())!=len(cubes):
                    print 'Loaded starting epsmap has wrong size'
                    print len(self.epsmap.keys()),len(cubes)
                    raise Excepion('invalid starting epsmap')
        #
        # ---
        #
        self.cubes=sorted(self.cube_eps.keys())
        self.cube_grad=self.get_cube_scores()
        os.chdir(topdir)
        fd=open('cube_scan_sidelength_%5.1f_eps%5.1f.pickle' %(options.sidelength,options.eps),'w')
        import pickle
        pickle.dump([self.epsmap.cubes,self.cube_grad],fd)
        fd.close()
        #
        # Tell all children to die
        #
        if self.options.cluster:
            import pypar
            print 'Master is killing all children'
            for proc in range(1,self.procs):
                pypar.send([{},-1],proc)
        return
Calculate the score for all cubes
Calculate the score for all cubes
Calculate the score for all cubes
def cube_scan(self):
         Define the epsmap
        cubes=self.epsmap.get_cubes(sidelength=self.options.sidelength,eps=80.0,clearmaps=False)
        print 'Creating map with %d cubes' %(len(cubes))
        self.cube_eps={}
        self.cube_grad={}
        for cube in cubes:
            self.cube_eps[cube]=80.0
            self.cube_grad[cube]=0.0
            self.epsmap.set_cubeeps(cube,80.0)
         If starteps is defined, then load the starting epsmap
        if options.starteps=='':
            print 'Using epsmap with 80 everywhere as starting point for iteration'
        else:
            if options.starteps=='PBE':
                print 'Using normal 8/80 PBE dielectric map as starting EPSMAP'
                count=0
                diels=[]
                for cube in cubes:
                    centre=self.epsmap.cubes[cube]['coord']
                    diel=self.epsmap.maps['x'].get_coord_value(centre[0],centre[1],centre[2])
                    if int(diel)!=80:
                        count=count+1
                        diels.append(diel)
                    self.cube_eps[cube]=diel
                if len(diels)==0:
                    diels.append(0.0)
                print '%4d (%5.2f%%) cubes have a diel different from 80. Their avg eps is %5.1f' %(count,float(count)/float(len(cubes))*100.0,sum(diels)/len(diels))
                print diels
            else:
                print 'Loading starting epsmap from: %s' %options.starteps
                fd=open(options.starteps)
                import pickle
                self.epsmap=pickle.load(fd)
                fd.close()
                if len(self.epsmap.keys())!=len(cubes):
                    print 'Loaded starting epsmap has wrong size'
                    print len(self.epsmap.keys()),len(cubes)
                    raise Excepion('invalid starting epsmap')
         ---
        self.cubes=sorted(self.cube_eps.keys())
        self.cube_grad=self.get_cube_scores()
        os.chdir(topdir)
        fd=open('cube_scan_sidelength_%5.1f_eps%5.1f.pickle' %(options.sidelength,options.eps),'w')
        import pickle
        pickle.dump([self.epsmap.cubes,self.cube_grad],fd)
        fd.close()
         Tell all children to die
        if self.options.cluster:
            import pypar
            print 'Master is killing all children'
            for proc in range(1,self.procs):
                pypar.send([{},-1],proc)
        return
def cube_scan ( self ) : cubes = self . epsmap . get_cubes ( sidelength = self . options . sidelength , eps = 80.0 , clearmaps = False ) print 'Creating map with %d cubes' % ( len ( cubes ) ) self . cube_eps = { } self . cube_grad = { } for cube in cubes : self . cube_eps [ cube ] = 80.0 self . cube_grad [ cube ] = 0.0 self . epsmap . set_cubeeps ( cube , 80.0 ) if options . starteps == '' : print 'Using epsmap with 80 everywhere as starting point for iteration' else : if options . starteps == 'PBE' : print 'Using normal 8/80 PBE dielectric map as starting EPSMAP' count = 0 diels = [ ] for cube in cubes : centre = self . epsmap . cubes [ cube ] [ 'coord' ] diel = self . epsmap . maps [ 'x' ] . get_coord_value ( centre [ 0 ] , centre [ 1 ] , centre [ 2 ] ) if int ( diel ) != 80 : count = count + 1 diels . append ( diel ) self . cube_eps [ cube ] = diel if len ( diels ) == 0 : diels . append ( 0.0 ) print '%4d (%5.2f%%) cubes have a diel different from 80. Their avg eps is %5.1f' % ( count , float ( count ) / float ( len ( cubes ) ) * 100.0 , sum ( diels ) / len ( diels ) ) print diels else : print 'Loading starting epsmap from: %s' % options . starteps fd = open ( options . starteps ) import pickle self . epsmap = pickle . load ( fd ) fd . close ( ) if len ( self . epsmap . keys ( ) ) != len ( cubes ) : print 'Loaded starting epsmap has wrong size' print len ( self . epsmap . keys ( ) ) , len ( cubes ) raise Excepion ( 'invalid starting epsmap' ) self . cubes = sorted ( self . cube_eps . keys ( ) ) self . cube_grad = self . get_cube_scores ( ) os . chdir ( topdir ) fd = open ( 'cube_scan_sidelength_%5.1f_eps%5.1f.pickle' % ( options . sidelength , options . eps ) , 'w' ) import pickle pickle . dump ( [ self . epsmap . cubes , self . cube_grad ] , fd ) fd . close ( ) if self . options . cluster : import pypar print 'Master is killing all children' for proc in range ( 1 , self . procs ) : pypar . send ( [ { } , - 1 ] , proc ) return
Calculate the score for all cubes
Calculate the score for all cubes
"""Calculate the score for all cubes""" # # Define the epsmap # # # If starteps is defined, then load the starting epsmap # # # --- # # # Tell all children to die #
self