Пример #1
0
    def run(self, *args):
        "User has pressed [Run]: run the minimization."
        if not self.setup_atoms():
            return
        fmax = self.fmax.value
        steps = self.steps.value
        mininame = self.minimizers[self.algo.get_active()]
        self.begin(mode="min", algo=mininame, fmax=fmax, steps=steps)
        algo = getattr(ase.optimize, mininame)
        try:
            logger_func = self.gui.simulation['progress'].get_logger_stream
        except (KeyError, AttributeError):
            logger = None
        else:
            logger = logger_func()  # Don't catch errors in the function.

        # Display status message
        self.status_label.set_text(_("Running ..."))
        self.status_label.modify_fg(ui.STATE_NORMAL, '#AA0000')
        while ui.events_pending():
            ui.main_iteration()

        self.prepare_store_atoms()
        if mininame == "MDMin":
            minimizer = algo(self.atoms,
                             logfile=logger,
                             dt=self.mdmin_dt.value)
        else:
            minimizer = algo(self.atoms, logfile=logger)
        minimizer.attach(self.store_atoms)
        try:
            minimizer.run(fmax=fmax, steps=steps)
        except AseGuiCancelException:
            # Update display to reflect cancellation of simulation.
            self.status_label.set_text(
                _("Minimization CANCELLED after "
                  "%i steps.") % (self.count_steps, ))
            self.status_label.modify_fg(ui.STATE_NORMAL, '#AA4000')
        except MemoryError:
            self.status_label.set_text(
                _("Out of memory, consider using "
                  "LBFGS instead"))
            self.status_label.modify_fg(ui.STATE_NORMAL, '#AA4000')

        else:
            # Update display to reflect successful end of simulation.
            self.status_label.set_text(
                _("Minimization completed in %i steps.") %
                (self.count_steps, ))
            self.status_label.modify_fg(ui.STATE_NORMAL, '#007700')

        self.end()
        if self.count_steps:
            # Notify other windows that atoms have changed.
            # This also notifies this window!
            self.gui.notify_vulnerable()
Пример #2
0
 def begin(self, **kwargs):
     DefaultProgressIndicator.begin(self, **kwargs)
     # Set GPAW specific stuff.
     self.active = True
     self.oldenergy = None
     self.poscount = None
     self.reset_gpaw_bars()
     # With GPAW, all calculations are slow: Show progress window
     # immediately.
     self.show()
     while ui.events_pending():
         ui.main_iteration()
Пример #3
0
 def begin(self, **kwargs):
     DefaultProgressIndicator.begin(self, **kwargs)
     # Set GPAW specific stuff.
     self.active = True
     self.oldenergy = None
     self.poscount = None
     self.reset_gpaw_bars()
     # With GPAW, all calculations are slow: Show progress window
     # immediately.
     self.show()
     while ui.events_pending():
         ui.main_iteration()
Пример #4
0
 def activity(self):
     "Register that activity occurred."
     if self.active is None and time.time(
     ) > self.starttime + self.waittime:
         # This has taken so long that a progress bar is needed.
         self.show()
         self.active = True
     # Allow GTK to update display
     if self.active:
         while ui.events_pending():
             ui.main_iteration()
     if self.raisecancelexception:
         self.cancelbut.set_sensitive(True)
         raise AseGuiCancelException
Пример #5
0
 def activity(self):
     "Register that activity occurred."
     if self.active is None and time.time(
     ) > self.starttime + self.waittime:
         # This has taken so long that a progress bar is needed.
         self.show()
         self.active = True
     # Allow GTK to update display
     if self.active:
         while ui.events_pending():
             ui.main_iteration()
     if self.raisecancelexception:
         self.cancelbut.set_sensitive(True)
         raise AseGuiCancelException
Пример #6
0
    def run(self, *args):
        "User has pressed [Run]: run the minimization."
        if not self.setup_atoms():
            return
        fmax = self.fmax.value
        steps = self.steps.value
        mininame = self.minimizers[self.algo.get_active()]
        self.begin(mode="min", algo=mininame, fmax=fmax, steps=steps)
        algo = getattr(ase.optimize, mininame)
        try:
            logger_func = self.gui.simulation['progress'].get_logger_stream
        except (KeyError, AttributeError):
            logger = None
        else:
            logger = logger_func()  # Don't catch errors in the function.

        # Display status message
        self.status_label.set_text(_("Running ..."))
        self.status_label.modify_fg(ui.STATE_NORMAL,
                                    '#AA0000')
        while ui.events_pending():
            ui.main_iteration()

        self.prepare_store_atoms()
        if mininame == "MDMin":
            minimizer = algo(self.atoms, logfile=logger,
                             dt=self.mdmin_dt.value)
        else:
            minimizer = algo(self.atoms, logfile=logger)
        minimizer.attach(self.store_atoms)
        try:
            minimizer.run(fmax=fmax, steps=steps)
        except AseGuiCancelException:
            # Update display to reflect cancellation of simulation.
            self.status_label.set_text(_("Minimization CANCELLED after "
                                         "%i steps.")
                                       % (self.count_steps,))
            self.status_label.modify_fg(ui.STATE_NORMAL,
                                        '#AA4000')
        except MemoryError:
            self.status_label.set_text(_("Out of memory, consider using "
                                         "LBFGS instead"))
            self.status_label.modify_fg(ui.STATE_NORMAL,
                                        '#AA4000')

        else:
            # Update display to reflect successful end of simulation.
            self.status_label.set_text(_("Minimization completed in %i steps.")
                                       % (self.count_steps,))
            self.status_label.modify_fg(ui.STATE_NORMAL,
                                        '#007700')

        self.end()
        if self.count_steps:
            # Notify other windows that atoms have changed.
            # This also notifies this window!
            self.gui.notify_vulnerable()

        # Open movie window and energy graph
        if self.gui.images.nimages > 1:
            self.gui.movie()
            assert not np.isnan(self.gui.images.E[0])
            if not self.gui.plot_graphs_newatoms():
                expr = 'i, e - E[-1]'
                self.gui.plot_graphs(expr=expr)