Exemplo n.º 1
0
    def __init__(self,
                 paw,
                 dmat,
                 filename=None,
                 frequencies=None,
                 restart_filename=None,
                 interval=1):
        TDDFTObserver.__init__(self, paw, interval)
        self.has_initialized = False
        self.dmat = dmat
        self.filename = filename
        self.restart_filename = restart_filename
        self.world = paw.world
        self.wfs = paw.wfs
        self.log = paw.log
        self.using_blacs = self.wfs.ksl.using_blacs
        if self.using_blacs:
            ksl_comm = self.wfs.ksl.block_comm
            kd_comm = self.wfs.kd.comm
            assert self.world.size == ksl_comm.size * kd_comm.size

        assert self.world.rank == self.wfs.world.rank

        if filename is not None:
            self.read(filename)
            return

        self.time = paw.time
        if isinstance(frequencies, FoldedFrequencies):
            frequencies = [frequencies]
        self.foldedfreqs_f = frequencies
        self.__generate_freq_w()
        self.Nw = np.sum([len(ff.frequencies) for ff in self.foldedfreqs_f])
Exemplo n.º 2
0
    def __init__(self, paw, filename, split=False, interval=1):
        TDDFTObserver.__init__(self, paw, interval)
        self.split = split
        if paw.niter == 0:
            self.writer = Writer(filename,
                                 paw.world,
                                 mode='w',
                                 tag=self.__class__.ulmtag)
            self.writer.write(version=self.__class__.version)
            self.writer.write(split=self.split)
            self.writer.sync()
            self.index = 1
        else:
            # Check the earlier file
            reader = WaveFunctionReader(filename)
            assert reader.version == self.__class__.version
            self.split = reader.split  # Use the earlier split value
            self.index = len(reader)
            reader.close()

            # Append to earlier file
            self.writer = Writer(filename,
                                 paw.world,
                                 mode='a',
                                 tag=self.__class__.ulmtag)

        if self.split:
            name, ext = tuple(filename.rsplit('.', 1))
            self.split_filename_fmt = name + '-%06d.' + ext
Exemplo n.º 3
0
 def __init__(self,
              paw,
              filename,
              center=False,
              density='comp',
              interval=1):
     TDDFTObserver.__init__(self, paw, interval)
     self.master = paw.world.rank == 0
     if paw.niter == 0:
         # Initialize
         self.do_center = center
         self.density_type = density
         if self.master:
             self.fd = open(filename, 'w')
     else:
         # Read and continue
         self.read_header(filename)
         if self.master:
             self.fd = open(filename, 'a')
Exemplo n.º 4
0
 def __init__(self, paw, restart_filename, interval=100):
     TDDFTObserver.__init__(self, paw, interval)
     self.restart_filename = restart_filename
Exemplo n.º 5
0
 def __del__(self):
     if self.master:
         self.fd.close()
     TDDFTObserver.__del__(self)
Exemplo n.º 6
0
 def __init__(self, paw, flush_interval=10, interval=1):
     TDDFTObserver.__init__(self, paw, interval)
     assert flush_interval > 0
     self.flush_interval = flush_interval
     self.flush_next = paw.niter + self.flush_interval - 1
Exemplo n.º 7
0
 def __del__(self):
     self.writer.close()
     TDDFTObserver.__del__(self)