Beispiel #1
0
    def __init__(self,
                 system,
                 database,
                 min1=None,
                 min2=None,
                 parent=None,
                 app=None):
        QtGui.QMainWindow.__init__(self, parent=parent)
        self.ui = UI()
        self.ui.setupUi(self)
        self.ui.centralwidget.hide()
        self.setWindowTitle("Double ended connect")

        self.app = app
        self.system = system
        self.database = database

        self.ogl = self.ui.ogl
        self.ogl.setSystem(system)

        self.textEdit = self.ui.textEdit
        self.textEdit.setReadOnly(True)
        self.textEdit_writer = OutLog(self.textEdit)
        self.view_log = self.ui.view_Log
        self.ui.actionLog.setChecked(True)

        if min1 is not None and min2 is not None:
            self.decrunner = DECRunner(system,
                                       database,
                                       min1,
                                       min2,
                                       outstream=self.textEdit_writer)
            self.decrunner.on_finished.connect(self.on_finished)

        self.view_3D = self.ui.view_ogl
        self.ui.action3D.setChecked(True)

        self.wgt_energies = ConnectEnergyWidget(parent=self)
        self.view_energies = self.new_view("Energies", self.wgt_energies,
                                           QtCore.Qt.TopDockWidgetArea)
        self.ui.actionEnergy.setChecked(True)

        self.wgt_graphview = GraphViewWidget(database=self.database,
                                             parent=self,
                                             app=app)
        self.view_graphview = self.new_view("Graph View", self.wgt_graphview,
                                            QtCore.Qt.TopDockWidgetArea)
        self.view_graphview.hide()
        self.ui.actionGraph.setChecked(False)

        self.ui.actionPause.setVisible(False)
        self.ui.actionD_Graph.setVisible(False)
        self.ui.actionSummary.setVisible(False)
        self.ui.actionSummary.setChecked(False)

        self.smoothed_path = None
Beispiel #2
0
    def __init__(self, system, database, min1=None, min2=None, parent=None, app=None):
        QtGui.QMainWindow.__init__(self, parent=parent)
        self.ui = UI()
        self.ui.setupUi(self)
        self.ui.centralwidget.hide()
        self.setWindowTitle("Double ended connect")

        self.app = app
        self.system = system
        self.database = database

        self.ogl = self.ui.ogl
        self.ogl.setSystem(system)

        self.textEdit = self.ui.textEdit
        self.textEdit.setReadOnly(True)
        self.textEdit_writer = OutLog(self.textEdit)
        self.view_log = self.ui.view_Log
        self.ui.actionLog.setChecked(True)

        if min1 is not None and min2 is not None:
            self.decrunner = DECRunner(system, database, min1, min2, outstream=self.textEdit_writer)
            self.decrunner.on_finished.connect(self.on_finished)

        self.view_3D = self.ui.view_ogl
        self.ui.action3D.setChecked(True)

        self.wgt_energies = ConnectEnergyWidget(parent=self)
        self.view_energies = self.new_view("Energies", self.wgt_energies, QtCore.Qt.TopDockWidgetArea)
        self.ui.actionEnergy.setChecked(True)

        self.wgt_graphview = GraphViewWidget(database=self.database, parent=self, app=app)
        self.view_graphview = self.new_view("Graph View", self.wgt_graphview, QtCore.Qt.TopDockWidgetArea)
        self.view_graphview.hide()
        self.ui.actionGraph.setChecked(False)

        self.ui.actionPause.setVisible(False)
        self.ui.actionD_Graph.setVisible(False)
        self.ui.actionSummary.setVisible(False)
        self.ui.actionSummary.setChecked(False)
        #        self.ui.actionRandom_connect.setChecked(False)
        #        self.ui.actionRandom_connect.setVisible(False)

        self.smoothed_path = None
Beispiel #3
0
class ConnectViewer(QtGui.QMainWindow):
    """
    external viewer for connect runs
    
    This viewer will use DECRunner to run a connect job in parallel.
    The log messages from that run will be redirected into a GUI text viewer.
    When the run is finished, the completed path will be shown in an OGL viewer
    
    Parameters
    ----------
    system : 
    database :
    min1, min2 : Minimum objects
        the minima to try to connect
    parent : 
        the parent window
    app : 
        the application
    
    See Also
    --------
    DECRunner
    
    """
    def __init__(self, system, database, min1=None, min2=None, parent=None, app=None):
        QtGui.QMainWindow.__init__(self, parent=parent)
        self.ui = UI()
        self.ui.setupUi(self)
        self.ui.centralwidget.hide()
        self.setWindowTitle("Double ended connect")
        
        self.app = app
        self.system = system
        self.database = database
        
        self.ogl = self.ui.ogl
        self.ogl.setSystem(system)

        
        self.textEdit = self.ui.textEdit      
        self.textEdit.setReadOnly(True)
        self.textEdit_writer = OutLog(self.textEdit)
        self.view_log = self.ui.view_Log
        self.ui.actionLog.setChecked(True)
        
        if min1 is not None and min2 is not None:
            self.decrunner = DECRunner(system, database, min1, min2, outstream=self.textEdit_writer)
            self.decrunner.on_finished.connect(self.on_finished)

        self.view_3D = self.ui.view_ogl
        self.ui.action3D.setChecked(True)
        
        self.wgt_energies = ConnectEnergyWidget(parent=self)
        self.view_energies = self.new_view("Energies", self.wgt_energies, QtCore.Qt.TopDockWidgetArea)
        self.ui.actionEnergy.setChecked(True)

        self.wgt_graphview = GraphViewWidget(database=self.database, parent=self, app=app)
        self.view_graphview = self.new_view("Graph View", self.wgt_graphview, QtCore.Qt.TopDockWidgetArea)
        self.view_graphview.hide()
        self.ui.actionGraph.setChecked(False)
        
        self.ui.actionPause.setVisible(False)
        self.ui.actionD_Graph.setVisible(False)
        self.ui.actionSummary.setVisible(False)
        self.ui.actionSummary.setChecked(False)
        
        self.smoothed_path = None


    def start(self):
        self.decrunner.start()

    def on_finished(self):
        print("success", self.decrunner.success)
        if self.decrunner.success:
            # get the path data
            self.smoothed_path = np.array(self.decrunner.smoothed_path)
            self.S = np.array(self.decrunner.S)
            self.energies = np.array(self.decrunner.energies)

            # show the smoothed path in the ogl viewer
            self.show_path()
            
            # plot the energies
            self.make_energy_plot()

            # plot the graph of minima
            self.make_graph()

    def make_energy_plot(self):
        if self.wgt_energies.isVisible() and self.decrunner.success:
            self.wgt_energies.update_gui(self.S, self.energies)

    def show_path(self):
        if self.ogl.isVisible() and self.smoothed_path is not None:
            self.ogl.setCoordsPath(self.smoothed_path)


    def make_graph(self):
        if self.wgt_graphview.isVisible() and self.decrunner.success:
            self.wgt_graphview.make_graph(database=self.decrunner.database, minima=self.decrunner.newminima)
            self.wgt_graphview.show_graph()
        

    def new_view(self, title, widget, pos=QtCore.Qt.RightDockWidgetArea):
        child = QtGui.QDockWidget(title, self)
        child.setWidget(widget)
        self.addDockWidget(pos, child)
        return child

    def toggle_view(self, view, show):
        if show:
            view.show()
        else:
            view.hide()

    def on_actionEnergy_toggled(self, checked):
        self.toggle_view(self.view_energies, checked)
        self.make_energy_plot()
    def on_actionGraph_toggled(self, checked):
        self.toggle_view(self.view_graphview, checked)
        self.make_graph()
    def on_action3D_toggled(self, checked):
        self.toggle_view(self.view_3D, checked)
        self.show_path()
    def on_actionLog_toggled(self, checked):
        self.toggle_view(self.view_log, checked)

    def on_actionKill_triggered(self, checked=None):
        sys.stderr.write( "kill toggled, terminating early\n")
        if checked is None: return
        self.decrunner.terminate_early()
    
    def closeEvent(self, event):
        self.on_actionKill_triggered(True)
        super(ConnectViewer, self).closeEvent(event)