Exemplo n.º 1
0
    def export_qwalk(self):
        ''' Export QWalk input files into current directory.
    Returns:
      bool: whether it was successful.'''
        self.recover(pkl.load(open(self.path + self.pickle, 'rb')))

        ready = False
        if len(self.qwfiles['slater']) == 0:
            self.nextstep()

            if not self.completed:
                return False

            cwd = os.getcwd()
            os.chdir(self.path)

            print(self.logname,
                  ": %s attempting to generate QWalk files." % self.name)

            # Check on the properties run
            status = resolve_status(self.prunner, self.preader, self.propoutfn)
            print(self.logname, ": properties status= %s" % (status))
            if status == 'not_started':
                ready = False
                self.prunner.add_command("cp %s INPUT" % self.propinpfn)
                self.prunner.add_task("%s &> %s" %
                                      (paths['Pproperties'], self.propoutfn))

                if self.bundle:
                    self.scriptfile = "%s.run" % self.name
                    self.bundle_ready = self.prunner.script(
                        self.scriptfile, self.driverfn)
                else:
                    qsubfile = self.runner.submit(
                        self.path.replace('/', '-') + self.name)
            elif status == 'ready_for_analysis':
                self.preader.collect(self.propoutfn)

            if self.preader.completed:
                ready = True
                print(self.logname, ": converting crystal to QWalk input now.")
                self.qwfiles = crystal2qmc.convert_crystal(
                    base=self.name, propoutfn=self.propoutfn)
            else:
                ready = False
                print(
                    self.logname,
                    ": conversion postponed because properties is not finished."
                )

            os.chdir(cwd)
        else:
            ready = True

        with open(self.path + self.pickle, 'wb') as outf:
            pkl.dump(self, outf)

        return ready
Exemplo n.º 2
0
 def status(self):
     ''' Determine the course of action based on info from reader and runner.'''
     current_status = resolve_status(self.runner, self.reader, self.outfile)
     if current_status == 'done':
         return 'ok'
     elif current_status == 'retry':
         return 'retry'
     else:
         return 'not_finished'
Exemplo n.º 3
0
    def nextstep(self):
        ''' Perform next step in calculation. trialfunc managers are updated if they aren't completed yet.'''
        # Recover old data.
        self.recover(pkl.load(open(self.path + self.pickle, 'rb')))

        print(self.logname, ": next step.")

        # Check dependency is completed first.
        if self.writer.trialfunc == '':
            print(self.logname, ": checking trial function.")
            self.writer.trialfunc = self.trialfunc.export(self.path)

        # Work on this job.
        cwd = os.getcwd()
        os.chdir(self.path)

        # Write the input file.
        if not self.writer.completed:
            self.writer.qwalk_input(self.infile)

        status = resolve_status(self.runner, self.reader, self.outfile)
        print(self.logname, ": %s status= %s" % (self.name, status))
        if status == "not_started" and self.writer.completed:
            exestr = "%s %s &> %s" % (paths['qwalk'], self.infile, self.stdout)
            self.runner.add_task(exestr)
            print(self.logname, ": %s status= submitted" % (self.name))
        elif status == "ready_for_analysis":
            #This is where we (eventually) do error correction and resubmits
            status = self.reader.collect(self.outfile)
            if status == 'ok':
                print(self.logname,
                      ": %s status= %s, task complete." % (self.name, status))
                self.completed = True
            else:
                print(
                    self.logname,
                    ": %s status= %s, attempting rerun." % (self.name, status))
                exestr = "%s %s &> %s" % (paths['qwalk'], self.infile,
                                          self.stdout)
                self.runner.add_task(exestr)
        elif status == 'done':
            self.completed = True

        # Ready for bundler or else just submit the jobs as needed.
        if self.bundle:
            self.scriptfile = "%s.run" % self.name
            self.bundle_ready = self.runner.script(self.scriptfile)
        else:
            qsubfile = self.runner.submit(
                self.path.replace('/', '-') + self.name)

        # Update the file.
        with open(self.pickle, 'wb') as outf:
            pkl.dump(self, outf)

        os.chdir(cwd)
Exemplo n.º 4
0
    def nextstep(self):
        ''' Determine and perform the next step in the calculation.'''
        # Recover old data.
        self.recover(pkl.load(open(self.path + self.pickle, 'rb')))

        print(self.logname, ": next step.")
        cwd = os.getcwd()
        os.chdir(self.path)

        if not self.writer.completed:
            self.writer.pyscf_input(self.driverfn, self.chkfile)

        status = resolve_status(self.runner, self.reader, self.outfile)
        print(self.logname, ": %s status= %s" % (self.name, status))

        if status == "not_started":
            self.runner.add_task("python3 %s > %s" %
                                 (self.driverfn, self.outfile))
        elif status == "ready_for_analysis":
            status = self.reader.collect(self.outfile, self.chkfile)
            if status == 'killed':
                print(
                    self.logname,
                    ": attempting restart (%d previous restarts)." %
                    self.restarts)
                sh.copy(self.driverfn,
                        "%d.%s" % (self.restarts, self.driverfn))
                sh.copy(self.outfile, "%d.%s" % (self.restarts, self.outfile))
                sh.copy(self.chkfile, "%d.%s" % (self.restarts, self.chkfile))
                if os.path.exists(self.chkfile):
                    self.writer.dm_generator = dm_from_chkfile(
                        "%d.%s" % (self.restarts, self.chkfile))
                self.writer.pyscf_input(self.driverfn, self.chkfile)
                self.runner.add_task("/usr/bin/python3 %s > %s" %
                                     (self.driverfn, self.outfile))
                self.restarts += 1
            elif status == 'done':
                print(self.logname,
                      ": %s status= %s, task complete." % (self.name, status))

        # Ready for bundler or else just submit the jobs as needed.
        if self.bundle:
            self.scriptfile = "%s.run" % self.name
            self.bundle_ready = self.runner.script(self.scriptfile,
                                                   self.driverfn)
        else:
            qsubfile = self.runner.submit(jobname=self.path.replace('/', '-') +
                                          self.name,
                                          ppath=[paths['pyscf']])

        self.completed = self.reader.completed
        # Update the file.
        with open(self.pickle, 'wb') as outf:
            pkl.dump(self, outf)
        os.chdir(cwd)
Exemplo n.º 5
0
    def nextstep(self):
        ''' Determine and perform the next step in the calculation.'''
        self.recover(pkl.load(open(self.path + self.pickle, 'rb')))

        print(self.logname, ": next step.")
        cwd = os.getcwd()
        os.chdir(self.path)

        # Generate input files.
        if not self.writer.completed:
            if self.writer.guess_fort is not None:
                sh.copy(self.writer.guess_fort, 'fort.20')
            with open(self.crysinpfn, 'w') as f:
                self.writer.write_crys_input(self.crysinpfn)
            with open(self.propinpfn, 'w') as f:
                self.writer.write_prop_input(self.propinpfn)

        # Check on the CRYSTAL run
        status = resolve_status(self.runner, self.creader, self.crysoutfn)
        print(self.logname, ": status= %s" % (status))

        if status == "not_started":
            self.runner.add_command("cp %s INPUT" % self.crysinpfn)
            self.runner.add_task("%s &> %s" %
                                 (paths['Pcrystal'], self.crysoutfn))

        elif status == "ready_for_analysis":
            #This is where we (eventually) do error correction and resubmits
            status = self.creader.collect(self.crysoutfn)
            print(self.logname, ": status %s" % status)
            if status == 'killed':
                if self.restarts >= self.max_restarts:
                    print(
                        self.logname,
                        ": restarts exhausted (%d previous restarts). Human intervention required."
                        % self.restarts)
                else:
                    print(
                        self.logname,
                        ": attempting restart (%d previous restarts)." %
                        self.restarts)
                    self.writer.restart = True
                    if self.trylev:
                        print(self.logname, ": trying LEVSHIFT.")
                        self.writer.levshift = [10, 1]  # No mercy.
                        self.savebroy = deepcopy(self.writer.broyden)
                        self.writer.broyden = []
                        self.lev = True
                    sh.copy(self.crysinpfn,
                            "%d.%s" % (self.restarts, self.crysinpfn))
                    sh.copy(self.crysoutfn,
                            "%d.%s" % (self.restarts, self.crysoutfn))
                    sh.copy('fort.79', "%d.fort.79" % (self.restarts))
                    self.writer.guess_fort = './fort.79'
                    sh.copy(self.writer.guess_fort, 'fort.20')
                    self.writer.write_crys_input(self.crysinpfn)
                    sh.copy(self.crysinpfn, 'INPUT')
                    self.runner.add_task("%s &> %s" %
                                         (paths['Pcrystal'], self.crysoutfn))
                    self.restarts += 1
        elif status == 'done' and self.lev:
            # We used levshift to converge. Now let's restart to be sure.
            print("Recovering from LEVSHIFTer.")
            self.writer.restart = True
            self.writer.levshift = []
            self.creader.completed = False
            self.lev = False
            sh.copy(self.crysinpfn, "%d.%s" % (self.restarts, self.crysinpfn))
            sh.copy(self.crysoutfn, "%d.%s" % (self.restarts, self.crysoutfn))
            sh.copy('fort.79', "%d.fort.79" % (self.restarts))
            self.writer.guess_fort = './fort.79'
            sh.copy(self.writer.guess_fort, 'fort.20')
            self.writer.write_crys_input(self.crysinpfn)
            sh.copy(self.crysinpfn, 'INPUT')
            self.runner.add_task("%s &> %s" %
                                 (paths['Pcrystal'], self.crysoutfn))
            self.restarts += 1

        # Ready for bundler or else just submit the jobs as needed.
        if self.bundle:
            self.scriptfile = "%s.run" % self.name
            self.bundle_ready = self.runner.script(self.scriptfile)
        else:
            qsubfile = self.runner.submit(
                self.path.replace('/', '-') + self.name)

        self.completed = self.creader.completed

        # Update the file.
        with open(self.pickle, 'wb') as outf:
            pkl.dump(self, outf)
        os.chdir(cwd)