示例#1
0
    def __init__(self, parent):
        self.mySystem = parent
        QtWidgets.QWidget.__init__(self)
        self.setupUi(self)

        self.latex_installed = self.mySystem.myPyplane.latex_installed
        self.Layout = QtWidgets.QVBoxLayout(self.frame)
        self.Canvas = Canvas(self, self.latex_installed)
        self.Layout.addWidget(self.Canvas)

        # Axis labels
        self.xlabel_str = "x"
        self.ylabel_str = "y"

        # set forward and backward integration true
        if myConfig.get_boolean("Trajectories", "traj_checkForwardByDefault"):
            self.forwardCheckbox.setChecked(True)
        if myConfig.get_boolean("Trajectories", "traj_checkBackwardByDefault"):
            self.backwardCheckbox.setChecked(True)

        self.xminLineEdit.setText(str(myConfig.read("Phaseplane", "pp_xmin")))
        self.xmaxLineEdit.setText(str(myConfig.read("Phaseplane", "pp_xmax")))
        self.yminLineEdit.setText(str(myConfig.read("Phaseplane", "pp_ymin")))
        self.ymaxLineEdit.setText(str(myConfig.read("Phaseplane", "pp_ymax")))

        self.Plot = PhasePlot(self, self.Canvas)
        self.Plot.set_window_range()

        self.VF = Vectorfield(self)
        self.SL = StreamlineHandler(self)
        self.Nullclines = NullclineHandler(self)
        self.Equilibria = EquilibriumHandler(self)

        # menu checkers
        self.mySystem.myPyplane.toggle_vectorfield_action.setChecked(
            self.VF.tgl)

        # connect buttons
        self.SetButton.clicked.connect(self.Plot.set_window_range)
        self.ZoomButton.clicked.connect(self.Canvas.toggle_zoom_mode)
        self.ZoomButton.setCheckable(True)
        self.RefreshButton.clicked.connect(self.Plot.refresh)
        self.CreateTrajectoryButton.clicked.connect(
            self.mySystem.Trajectories.create_trajectory)
        # linearize button and combo box
        # TODO: Fix next line!
        # self.connect(self.linBox, QtCore.SIGNAL('activated(QString)'), self.eq_chosen)
        self.linButton.clicked.connect(self.linearize_system)

        self.hide_linearization_objects()
示例#2
0
    def __init__(self, parent):
        self.mySystem = parent
        QtWidgets.QWidget.__init__(self)
        self.setupUi(self)
        
        self.latex_installed = self.mySystem.myPyplane.latex_installed
        self.Layout = QtWidgets.QVBoxLayout(self.frame)
        self.Canvas = Canvas(self, self.latex_installed)
        self.Layout.addWidget(self.Canvas)

        # Axis labels
        self.xlabel_str = "x"
        self.ylabel_str = "y"

        # set forward and backward integration true
        if myConfig.get_boolean("Trajectories", "traj_checkForwardByDefault"):
            self.forwardCheckbox.setChecked(True)
        if myConfig.get_boolean("Trajectories", "traj_checkBackwardByDefault"):
            self.backwardCheckbox.setChecked(True)

        self.xminLineEdit.setText(str(myConfig.read("Phaseplane", "pp_xmin")))
        self.xmaxLineEdit.setText(str(myConfig.read("Phaseplane", "pp_xmax")))
        self.yminLineEdit.setText(str(myConfig.read("Phaseplane", "pp_ymin")))
        self.ymaxLineEdit.setText(str(myConfig.read("Phaseplane", "pp_ymax")))
        
        self.Plot = PhasePlot(self, self.Canvas)
        self.Plot.set_window_range()

        self.VF = Vectorfield(self)
        self.SL = StreamlineHandler(self)
        self.Nullclines = NullclineHandler(self)
        self.Equilibria = EquilibriumHandler(self)

        # menu checkers
        self.mySystem.myPyplane.toggle_vectorfield_action.setChecked(self.VF.tgl)

        # connect buttons
        self.SetButton.clicked.connect(self.Plot.set_window_range)
        self.ZoomButton.clicked.connect(self.Canvas.toggle_zoom_mode)
        self.ZoomButton.setCheckable(True)
        self.RefreshButton.clicked.connect(self.Plot.refresh)
        self.CreateTrajectoryButton.clicked.connect(self.mySystem.Trajectories.create_trajectory)
        # linearize button and combo box
        # TODO: Fix next line!
        # self.connect(self.linBox, QtCore.SIGNAL('activated(QString)'), self.eq_chosen)
        self.linButton.clicked.connect(self.linearize_system)

        self.hide_linearization_objects()
示例#3
0
文件: Widgets.py 项目: klim-/pyplane
class PhaseplaneWidget(QtGui.QWidget, Ui_ZoomWidget):
    def __init__(self, parent):
        self.mySystem = parent
        QtGui.QWidget.__init__(self)
        self.setupUi(self)
        
        self.latex_installed = self.mySystem.myPyplane.latex_installed
        self.Layout = QtGui.QVBoxLayout(self.frame)
        self.Canvas = Canvas(self, self.latex_installed)
        self.Layout.addWidget(self.Canvas)


        # set forward and backward integration true
        if myConfig.get_boolean("Trajectories", "traj_checkForwardByDefault"):
            self.forwardCheckbox.setChecked(True)
        if myConfig.get_boolean("Trajectories", "traj_checkBackwardByDefault"):
            self.backwardCheckbox.setChecked(True)

        self.xminLineEdit.setText(str(myConfig.read("Phaseplane", "pp_xmin")))
        self.xmaxLineEdit.setText(str(myConfig.read("Phaseplane", "pp_xmax")))
        self.yminLineEdit.setText(str(myConfig.read("Phaseplane", "pp_ymin")))
        self.ymaxLineEdit.setText(str(myConfig.read("Phaseplane", "pp_ymax")))
        
        self.Plot = PhasePlot(self, self.Canvas)
        self.Plot.set_window_range()

        self.VF = Vectorfield(self)
        self.SL = StreamlineHandler(self)
        self.Nullclines = NullclineHandler(self)
        self.Equilibria = EquilibriumHandler(self)

        # menu checkers
        self.mySystem.myPyplane.toggle_vectorfield_action.setChecked(self.VF.tgl)

        # connect buttons
        self.SetButton.clicked.connect(self.Plot.set_window_range)
        self.ZoomButton.clicked.connect(self.Canvas.toggle_zoom_mode)
        self.ZoomButton.setCheckable(True)
        self.RefreshButton.clicked.connect(self.Plot.refresh)
        self.CreateTrajectoryButton.clicked.connect(self.mySystem.Trajectories.create_trajectory)
        # linearize button and combo box
        self.connect(self.linBox, QtCore.SIGNAL('activated(QString)'), self.eq_chosen)
        self.linButton.clicked.connect(self.linearize_system)

        self.hide_linearization_objects()

    def hide_linearization_objects(self):
        self.linLabel.hide()
        self.linBox.hide()
        self.linButton.hide()

    def show_linearization_objects(self):
        self.linLabel.show()
        self.linButton.show()
        # clear combo box
        self.linBox.clear()
        # put equilibria in combo box
        eq_list = self.Equilibria.list_characterized_equilibria()
        self.linBox.addItems(eq_list)
        self.linBox.show()

    def eq_chosen(self, text):
        # TODO: highlight selected point
        pass

    def linearize_system(self):
        eq_identifier = str(self.linBox.currentText())
        equilibrium = self.Equilibria.get_equilibrium_by_character_identifier(eq_identifier)
        jac = self.Equilibria.approx_ep_jacobian(equilibrium.coordinates)
        
        # set system properties
        accuracy = int(myConfig.read("Linearization","lin_round_decimals"))
        xe = round(equilibrium.coordinates[0], accuracy)
        ye = round(equilibrium.coordinates[1], accuracy)
        equilibrium = (xe, ye)
        A00 = str(round(jac[0,0], accuracy))
        A01 = str(round(jac[0,1], accuracy))
        A11 = str(round(jac[1,1], accuracy))
        A10 = str(round(jac[1,0], accuracy))
        x_dot_string = A00 + "*(x-(" + str(xe) + ")) + (" + A01 + ")*(y-(" + str(ye) + "))"
        y_dot_string = A10 + "*(x-(" + str(xe) + ")) + (" + A11 + ")*(y-(" + str(ye) + "))"
        equation_string = (x_dot_string, y_dot_string)

        self.mySystem.myPyplane.new_linearized_system(equation_string, eq_identifier, equilibrium)

    def trajectory_direction(self):
        forward = self.forwardCheckbox.isChecked()
        backward = self.backwardCheckbox.isChecked()
        return [forward, backward]

    def read_init(self):
        """ read initial condition from line edits """
        x_init = float(self.xinitLineEdit.text())
        y_init = float(self.yinitLineEdit.text())
        return [x_init, y_init]
示例#4
0
class PhaseplaneWidget(QtGui.QWidget, Ui_ZoomWidget):
    def __init__(self, parent):
        self.mySystem = parent
        QtGui.QWidget.__init__(self)
        self.setupUi(self)

        self.latex_installed = self.mySystem.myPyplane.latex_installed
        self.Layout = QtGui.QVBoxLayout(self.frame)
        self.Canvas = Canvas(self, self.latex_installed)
        self.Layout.addWidget(self.Canvas)

        # set forward and backward integration true
        if myConfig.get_boolean("Trajectories", "traj_checkForwardByDefault"):
            self.forwardCheckbox.setChecked(True)
        if myConfig.get_boolean("Trajectories", "traj_checkBackwardByDefault"):
            self.backwardCheckbox.setChecked(True)

        self.xminLineEdit.setText(str(myConfig.read("Phaseplane", "pp_xmin")))
        self.xmaxLineEdit.setText(str(myConfig.read("Phaseplane", "pp_xmax")))
        self.yminLineEdit.setText(str(myConfig.read("Phaseplane", "pp_ymin")))
        self.ymaxLineEdit.setText(str(myConfig.read("Phaseplane", "pp_ymax")))

        self.Plot = PhasePlot(self, self.Canvas)
        self.Plot.set_window_range()

        self.VF = Vectorfield(self)
        self.SL = StreamlineHandler(self)
        self.Nullclines = NullclineHandler(self)
        self.Equilibria = EquilibriumHandler(self)

        # menu checkers
        self.mySystem.myPyplane.toggle_vectorfield_action.setChecked(
            self.VF.tgl)

        # connect buttons
        self.SetButton.clicked.connect(self.Plot.set_window_range)
        self.ZoomButton.clicked.connect(self.Canvas.toggle_zoom_mode)
        self.ZoomButton.setCheckable(True)
        self.RefreshButton.clicked.connect(self.Plot.refresh)
        self.CreateTrajectoryButton.clicked.connect(
            self.mySystem.Trajectories.create_trajectory)
        # linearize button and combo box
        self.connect(self.linBox, QtCore.SIGNAL('activated(QString)'),
                     self.eq_chosen)
        self.linButton.clicked.connect(self.linearize_system)

        self.hide_linearization_objects()

    def hide_linearization_objects(self):
        self.linLabel.hide()
        self.linBox.hide()
        self.linButton.hide()

    def show_linearization_objects(self):
        self.linLabel.show()
        self.linButton.show()
        # clear combo box
        self.linBox.clear()
        # put equilibria in combo box
        eq_list = self.Equilibria.list_characterized_equilibria()
        self.linBox.addItems(eq_list)
        self.linBox.show()

    def eq_chosen(self, text):
        # TODO: highlight selected point
        pass

    def linearize_system(self):
        eq_identifier = str(self.linBox.currentText())
        equilibrium = self.Equilibria.get_equilibrium_by_character_identifier(
            eq_identifier)
        jac = self.Equilibria.approx_ep_jacobian(equilibrium.coordinates)

        # set system properties
        accuracy = int(myConfig.read("Linearization", "lin_round_decimals"))
        xe = round(equilibrium.coordinates[0], accuracy)
        ye = round(equilibrium.coordinates[1], accuracy)
        equilibrium = (xe, ye)
        A00 = str(round(jac[0, 0], accuracy))
        A01 = str(round(jac[0, 1], accuracy))
        A11 = str(round(jac[1, 1], accuracy))
        A10 = str(round(jac[1, 0], accuracy))
        x_dot_string = A00 + "*(x-(" + str(
            xe) + ")) + (" + A01 + ")*(y-(" + str(ye) + "))"
        y_dot_string = A10 + "*(x-(" + str(
            xe) + ")) + (" + A11 + ")*(y-(" + str(ye) + "))"
        equation_string = (x_dot_string, y_dot_string)

        self.mySystem.myPyplane.new_linearized_system(equation_string,
                                                      eq_identifier,
                                                      equilibrium)

    def trajectory_direction(self):
        forward = self.forwardCheckbox.isChecked()
        backward = self.backwardCheckbox.isChecked()
        return [forward, backward]

    def read_init(self):
        """ read initial condition from line edits """
        x_init = float(self.xinitLineEdit.text())
        y_init = float(self.yinitLineEdit.text())
        return [x_init, y_init]