Exemple #1
0
    def initialize(self, comm, config, args):

        rank = comm.Get_rank()
        size = comm.Get_size()

        self.config = config
        self.args = args

        filename = args.struct_file[0] 
        self.struct_filename = filename
        self.npoints,self.natoms = coord_reader.get_nframes_natoms(filename)

        if coord_reader.supports_parallel_reading(filename): 
            # read coordinates in parallel
            self.idxs_thread, self.npoints_per_thread, self.offsets_per_thread = p_index.get_idxs_thread(comm, self.npoints)
            coords_thread = coord_reader.get_coordinates(filename, idxs=self.idxs_thread)
            coords_ravel = coords_thread.ravel()
            ravel_lengths, ravel_offsets = p_index.get_ravel_offsets(self.npoints_per_thread,self.natoms)
            coordstemp = np.zeros(self.npoints*3*self.natoms, dtype='float')
            start = MPI.Wtime()
            comm.Allgatherv(coords_ravel, (coordstemp, ravel_lengths, ravel_offsets, MPI.DOUBLE))
            self.coords = coordstemp.reshape((self.npoints,3,self.natoms))
        else: 
            # serial reading
            if rank == 0:
                self.coords = coord_reader.get_coordinates(filename)
            else:
                self.coords = np.zeros((self.npoints,3,self.natoms),dtype=np.double)
            comm.Bcast(self.coords, root=0) 

        logging.info('input coordinates loaded')

        self.initialize_local_scale()
        self.initialize_weights()
        self.initialize_metric()
Exemple #2
0
    def initialize(self, comm, config, args):

        rank = comm.Get_rank()
        size = comm.Get_size()

        self.config = config
        self.args = args

        filename = args.struct_file[0]
        self.struct_filename = filename
        self.npoints, self.natoms = coord_reader.get_nframes_natoms(filename)

        if coord_reader.supports_parallel_reading(filename):
            # read coordinates in parallel
            self.idxs_thread, self.npoints_per_thread, self.offsets_per_thread = p_index.get_idxs_thread(
                comm, self.npoints)
            coords_thread = coord_reader.get_coordinates(filename,
                                                         idxs=self.idxs_thread)
            coords_ravel = coords_thread.ravel()
            ravel_lengths, ravel_offsets = p_index.get_ravel_offsets(
                self.npoints_per_thread, self.natoms)
            coordstemp = np.zeros(self.npoints * 3 * self.natoms,
                                  dtype='float')
            start = MPI.Wtime()
            comm.Allgatherv(
                coords_ravel,
                (coordstemp, ravel_lengths, ravel_offsets, MPI.DOUBLE))
            self.coords = coordstemp.reshape((self.npoints, 3, self.natoms))
        else:
            # serial reading
            if rank == 0:
                self.coords = coord_reader.get_coordinates(filename)
            else:
                self.coords = np.zeros((self.npoints, 3, self.natoms),
                                       dtype=np.double)
            comm.Bcast(self.coords, root=0)

        logging.info('input coordinates loaded')

        self.initialize_local_scale()
        self.initialize_weights()
        self.initialize_metric()
Exemple #3
0
    def initialize(self, comm, config, args):

        rank = comm.Get_rank()
        size = comm.Get_size()

        self.config = config
        self.args = args

        filename = args.struct_file[0] 
        self.struct_filename = filename
        self.npoints,self.natoms = coord_reader.get_nframes_natoms(filename)

        if coord_reader.supports_parallel_reading(filename): 
            # read coordinates in parallel
            self.idxs_thread, self.npoints_per_thread, self.offsets_per_thread = p_index.get_idxs_thread(comm, self.npoints)
            coords_thread = coord_reader.get_coordinates(filename, idxs=self.idxs_thread)
            coords_ravel = coords_thread.ravel()
            ravel_lengths, ravel_offsets = p_index.get_ravel_offsets(self.npoints_per_thread,self.natoms)
            coordstemp = np.zeros(self.npoints*3*self.natoms, dtype='float')
            start = MPI.Wtime()
            comm.Allgatherv(coords_ravel, (coordstemp, ravel_lengths, ravel_offsets, MPI.DOUBLE))
            self.coords = coordstemp.reshape((self.npoints,3,self.natoms))
        else: 
            # serial reading
            if rank == 0:
                self.coords = coord_reader.get_coordinates(filename)
            else:
                self.coords = np.zeros((self.npoints,3,self.natoms),dtype=np.double)
            comm.Bcast(self.coords, root=0) 

        logging.info('input coordinates loaded')

        # load file of values
        valfile = reader.open(args.valfile)
        self.values = valfile.readlines()

        format = os.path.splitext(args.valfile)[1]
        if format == '.ev':
            self.fitdcs = True
        else:
            self.fitdcs = False
            if len(self.values.shape) > 2:
                raise ValueError('file of values should contain a single column')

        self.initialize_metric()
        self.function = config.get(self.args.section,'function')

        self.status_sigma = config.get(self.args.section,'status')
        if self.status_sigma == 'constant':
            self.sigma = config.getfloat(self.args.section,'sigma')
            self.ksigma = None
        elif self.status_sigma == 'kneighbor':
            self.sigma = None
            self.ksigma = config.getint(self.args.section,'ksigma')

        if args.embed_file is not None:
            #embed_file = reader.open(args.embed_file)
            #self.embed_filename = embed_file.filename
            #self.npoints_embed = embed_file.nlines
            #self.idxs_thread_embed = p_index.get_idxs_thread_v(comm, self.npoints_embed)
            #if hasattr(embed_file, '_skip'): # multi-thread reading
            #    coords_thread_embed = embed_file.readlines(self.idxs_thread_embed)
            #    self.coords_embed = np.vstack(comm.allgather(coords_thread_embed))
            #else: # serial reading
            #    if rank == 0:
            #        self.coords_embed = embed_file.readlines()
            #    else:
            #        self.coords_embed = None
            #    self.coords_embed = comm.bcast(self.coords_embed, root=0)
            filename_embed = args.embed_file
            self.embed_filename = filename_embed
            self.npoints_embed,self.natoms_embed = coord_reader.get_nframes_natoms(filename_embed)
            if coord_reader.supports_parallel_reading(filename_embed): 
                # read coordinates in parallel
                self.idxs_thread_embed, self.npoints_per_thread_embed, self.offsets_per_thread_embed = p_index.get_idxs_thread(comm, self.npoints_embed)
                coords_thread_embed = coord_reader.get_coordinates(filename_embed, idxs=self.idxs_thread_embed)
                coords_ravel_embed = coords_thread_embed.ravel()
                ravel_lengths, ravel_offsets = p_index.get_ravel_offsets(self.npoints_per_thread_embed,self.natoms_embed)
                coordstemp_embed = np.zeros(self.npoints_embed*3*self.natoms_embed, dtype='float')
                comm.Allgatherv(coords_ravel, (coordstemp_embed, ravel_lengths, ravel_offsets, MPI.DOUBLE))
                self.coords_embed = coordstemp_embed.reshape((self.npoints_embed,3,self.natoms_embed))
            else: 
                # serial reading
                if rank == 0:
                    self.coords_embed = coord_reader.get_coordinates(filename_embed)
                else:
                    self.coords_embed = np.zeros((self.npoints_embed,3,self.natoms_embed),dtype=np.double)
                comm.Bcast(self.coords_embed, root=0) 
Exemple #4
0
    def initialize(self, comm, config, args):

        rank = comm.Get_rank()
        size = comm.Get_size()

        self.config = config
        self.args = args

        filename = args.struct_file[0]
        self.struct_filename = filename
        self.npoints, self.natoms = coord_reader.get_nframes_natoms(filename)

        if coord_reader.supports_parallel_reading(filename):
            # read coordinates in parallel
            self.idxs_thread, self.npoints_per_thread, self.offsets_per_thread = p_index.get_idxs_thread(
                comm, self.npoints)
            coords_thread = coord_reader.get_coordinates(filename,
                                                         idxs=self.idxs_thread)
            coords_ravel = coords_thread.ravel()
            ravel_lengths, ravel_offsets = p_index.get_ravel_offsets(
                self.npoints_per_thread, self.natoms)
            coordstemp = np.zeros(self.npoints * 3 * self.natoms,
                                  dtype='float')
            start = MPI.Wtime()
            comm.Allgatherv(
                coords_ravel,
                (coordstemp, ravel_lengths, ravel_offsets, MPI.DOUBLE))
            self.coords = coordstemp.reshape((self.npoints, 3, self.natoms))
        else:
            # serial reading
            if rank == 0:
                self.coords = coord_reader.get_coordinates(filename)
            else:
                self.coords = np.zeros((self.npoints, 3, self.natoms),
                                       dtype=np.double)
            comm.Bcast(self.coords, root=0)

        logging.info('input coordinates loaded')

        # load file of values
        valfile = reader.open(args.valfile)
        self.values = valfile.readlines()

        format = os.path.splitext(args.valfile)[1]
        if format == '.ev':
            self.fitdcs = True
        else:
            self.fitdcs = False
            if len(self.values.shape) > 2:
                raise ValueError(
                    'file of values should contain a single column')

        self.initialize_metric()
        self.function = config.get(self.args.section, 'function')

        self.status_sigma = config.get(self.args.section, 'status')
        if self.status_sigma == 'constant':
            self.sigma = config.getfloat(self.args.section, 'sigma')
            self.ksigma = None
        elif self.status_sigma == 'kneighbor':
            self.sigma = None
            self.ksigma = config.getint(self.args.section, 'ksigma')

        if args.embed_file is not None:
            #embed_file = reader.open(args.embed_file)
            #self.embed_filename = embed_file.filename
            #self.npoints_embed = embed_file.nlines
            #self.idxs_thread_embed = p_index.get_idxs_thread_v(comm, self.npoints_embed)
            #if hasattr(embed_file, '_skip'): # multi-thread reading
            #    coords_thread_embed = embed_file.readlines(self.idxs_thread_embed)
            #    self.coords_embed = np.vstack(comm.allgather(coords_thread_embed))
            #else: # serial reading
            #    if rank == 0:
            #        self.coords_embed = embed_file.readlines()
            #    else:
            #        self.coords_embed = None
            #    self.coords_embed = comm.bcast(self.coords_embed, root=0)
            filename_embed = args.embed_file
            self.embed_filename = filename_embed
            self.npoints_embed, self.natoms_embed = coord_reader.get_nframes_natoms(
                filename_embed)
            if coord_reader.supports_parallel_reading(filename_embed):
                # read coordinates in parallel
                self.idxs_thread_embed, self.npoints_per_thread_embed, self.offsets_per_thread_embed = p_index.get_idxs_thread(
                    comm, self.npoints_embed)
                coords_thread_embed = coord_reader.get_coordinates(
                    filename_embed, idxs=self.idxs_thread_embed)
                coords_ravel_embed = coords_thread_embed.ravel()
                ravel_lengths, ravel_offsets = p_index.get_ravel_offsets(
                    self.npoints_per_thread_embed, self.natoms_embed)
                coordstemp_embed = np.zeros(self.npoints_embed * 3 *
                                            self.natoms_embed,
                                            dtype='float')
                comm.Allgatherv(coords_ravel, (coordstemp_embed, ravel_lengths,
                                               ravel_offsets, MPI.DOUBLE))
                self.coords_embed = coordstemp_embed.reshape(
                    (self.npoints_embed, 3, self.natoms_embed))
            else:
                # serial reading
                if rank == 0:
                    self.coords_embed = coord_reader.get_coordinates(
                        filename_embed)
                else:
                    self.coords_embed = np.zeros(
                        (self.npoints_embed, 3, self.natoms_embed),
                        dtype=np.double)
                comm.Bcast(self.coords_embed, root=0)