-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface_InitialValues.py
More file actions
157 lines (138 loc) · 6.44 KB
/
Interface_InitialValues.py
File metadata and controls
157 lines (138 loc) · 6.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
from PyQt5.QtWidgets import QDialog, QApplication, QPushButton, QVBoxLayout, QGridLayout, QHBoxLayout, QFormLayout
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
import matplotlib.pyplot as plt2
from PyQt5 import QtCore, QtGui, QtWidgets
class Interface_InitialValues(QDialog):
def __init__(self, parent=None):
super(Interface_InitialValues, self).__init__(parent)
QDialog.setObjectName(self,"Dialog")
self.setStyleSheet("background-color: white")
QDialog.resize(self,900, 800)
self.label_4 = QtWidgets.QLabel()
#self.label_4.setGeometry(QtCore.QRect(80, 280, 55, 16))
self.figure1 = plt2.figure()
# this is the Canvas Widget that
# displays the 'figure'it takes the
# 'figure' instance as a parameter to __init__
self.canvas = FigureCanvas(self.figure1)
self.canvas1 = FigureCanvas(self.figure1)
self.canvas2 = FigureCanvas(self.figure1)
self.canvas3 = FigureCanvas(self.figure1)
self.canvas.resize(50,50)
font = QtGui.QFont()
font.setPointSize(12)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.pushButton = QtWidgets.QPushButton()
self.pushButton.setObjectName("pushButton")
self.MplWidget1 = QtWidgets.QWidget()
self.MplWidget1.setObjectName("MplWidget1")
self.lineEdit_3 = QtWidgets.QLineEdit()
self.lineEdit_3.setObjectName("lineEdit_3")
self.lineEdit_2 = QtWidgets.QLineEdit()
self.lineEdit_2.setObjectName("lineEdit_2")
self.MplWidget3 = QtWidgets.QWidget()
self.MplWidget3.setObjectName("MplWidget3")
self.label_3 = QtWidgets.QLabel()
font = QtGui.QFont()
font.setPointSize(12)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.label = QtWidgets.QLabel()
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setTextFormat(QtCore.Qt.RichText)
self.label.setIndent(0)
self.label.setObjectName("label")
self.lineEdit = QtWidgets.QLineEdit()
self.lineEdit.setObjectName("lineEdit")
self.label_2 = QtWidgets.QLabel()
font = QtGui.QFont()
font.setPointSize(12)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.MplWidget2 = QtWidgets.QWidget()
self.MplWidget2.setObjectName("MplWidget2")
self.lineEdit_4 = QtWidgets.QLineEdit()
self.lineEdit_4.setObjectName("lineEdit_4")
self.label_6 = QtWidgets.QLabel()
self.label_6.setObjectName("label_6")
self.label_5 = QtWidgets.QLabel()
self.label_5.setObjectName("label_5")
self.label_9 = QtWidgets.QLabel()
self.label_9.setObjectName("label_9")
# self.MplWidget1.layout().addWidget(self.canvas)
# adding push button to the layout
# setting layout to the main window
#self.setLayout(layout)
layout = QGridLayout()
# adding tool bar to the layout
layout.setColumnMinimumWidth(0,5)
# layout.setColumnStretch(1,-5)
#layout.setColumnStretch(2,200)
# adding canvas to the layout
layout.addWidget(self.label,1,0)
layout.addWidget(self.lineEdit,1,1)
layout.addWidget(self.label_2,2,0)
layout.addWidget(self.lineEdit_2,2,1)
layout.addWidget(self.label_3,3,0)
layout.addWidget(self.lineEdit_3,3,1)
layout.addWidget(self.label_4,4,0)
layout.addWidget(self.lineEdit_4,4,1)
layout.addWidget(self.pushButton,7,1)
layout.addWidget(self.canvas,1,3)
layout.addWidget(self.canvas1,3,3)
layout.addWidget(self.canvas2,5,3)
layout.addWidget(self.label_9,6,0)
# layout.addWidget(self.canvas3,4,3)
# adding push button to the layout
# setting layout to the main window
self.setLayout(layout)
#self.retranslateUi(QDialog)
# QtCore.QMetaObject.connectSlotsByName(Ui_Dialog)
#def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
QDialog.setWindowTitle(self, "Approximation graphics")
self.label_4.setText("N =")
self.pushButton.setText(_translate("Dialog", "Let\'s plot!"))
self.label_3.setText(_translate("Dialog", "X ="))
self.label.setText(_translate("Dialog", "x0 ="))
self.label_2.setText(_translate("Dialog", "y0 ="))
self.label_6.setText(_translate("Dialog", "d.livitin@innopolis.university"))
self.label_5.setText(_translate("Dialog", "Made by Daniil Livitin "))
self.lineEdit.setText(_translate("Dialog", "0"))
self.lineEdit_2.setText(_translate("Dialog", "0"))
self.lineEdit_3.setText(_translate("Dialog", "7"))
self.pushButton.setFixedSize(300,50)
self.pushButton.setStyleSheet("background-color: grey")
def plot(self,arrayForEuler,arrayForImproved,arrayForRungeKutta):
self.figure1.clear()
plt2.figure(1)
plt2.plot(arrayForEuler[0], arrayForEuler[1])
plt2.xlabel("x")
plt2.ylabel("y(Exact)")
plt2.title('Exact Graph')
self.canvas.draw()
self.figure1.clear()
plt2.plot(arrayForEuler[0], arrayForEuler[1], label='Exact solution')
plt2.plot(arrayForEuler[0], arrayForEuler[2], label='Euler')
plt2.xlabel("x")
plt2.ylabel("y(Approximation)")
plt2.title('Approximation Graph')
plt2.plot(arrayForEuler[0], arrayForImproved[2], label='Improved Euler')
plt2.plot(arrayForEuler[0], arrayForRungeKutta[2], label='Runge Kutta')
plt2.legend()
self.canvas1.draw()
self.figure1.clear()
plt2.xlabel("x")
plt2.ylabel("Error")
plt2.title('Errors Graph')
arrayForEuler[4] = [abs(ele) for ele in arrayForEuler[4]]
arrayForImproved[4] = [abs(ele) for ele in arrayForImproved[4]]
arrayForRungeKutta[4] = [abs(ele) for ele in arrayForRungeKutta[4]]
plt2.plot(arrayForEuler[0], arrayForEuler[4], label='Euler Error')
plt2.plot(arrayForEuler[0], arrayForImproved[4], label='Improved Euler Error')
plt2.plot(arrayForEuler[0], arrayForRungeKutta[4], label='Runge Kutta Error')
plt2.legend()
self.canvas2.draw()