-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
114 lines (102 loc) · 3.49 KB
/
mainwindow.cpp
File metadata and controls
114 lines (102 loc) · 3.49 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <visual/gnuplot.h>
#include <models/spring.h>
#include <integrators/expliciteuler.h>
#include <iostream>
#include <math.h>
#include <QMessageBox>
#include <integrators/impliciteuler.h>
#include <algorithms/eigenvalues.h>
#include <models/stiff.h>
#include <models/stiff2.h>
#include <models/s4a.h>
#include <models/s8b.h>
#include <models/s19c.h>
#include <models/s27d.h>
#include <models/s28e.h>
#include <integrators/shichman.h>
#include <integrators/maulton.h>
#include <models/c1.h>
#include <models/c2.h>
#include <models/c3.h>
using namespace std;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_2_clicked()
{
try
{
/*
double **tt = new double*[2];
tt[0] = new double[2];
tt[1] = new double[2];
tt[0][0] = 1.0;
tt[0][1] = 0.0;
tt[1][0] = 0.0;
tt[1][1] = -1.0;
double **ttt = new double*[3];
ttt[0] = new double[3];
ttt[1] = new double[3];
ttt[2] = new double[3];
ttt[0][0] = 1.0;
ttt[0][1] = 2.0;
ttt[0][2] = 3.0;
ttt[1][0] = 4.0;
ttt[1][1] = 5.0;
ttt[1][2] = 6.0;
ttt[2][0] = 7.0;
ttt[2][1] = 8.0;
ttt[2][2] = 9.0;
ExactMethodBase *e = new PowerMethod(ttt, 3);
cout << "Min = " << e->getMin() << endl;
cout << "Iterations = " << e->getIterationsCount() << endl;
cout << "Max = " << e->getMax() << endl;
cout << "Iterations = " << e->getIterationsCount() << endl;
return;
*/
int nGraphic = 800;
ModelBase* model = new C3();
IntegratorBase *intergator = new ImplicitEuler();
intergator->setModel(model);
intergator->setNGraphic(nGraphic);
intergator->setEps(0.001);
intergator->setParam("hInt", (model->getTStop() - model->getTStart()) / (double)nGraphic);
intergator->setParam("dMax", 0.01);
intergator->setParam("kMax", 11);
double** results = intergator->integrate();
double* time = intergator->getTime();
//double* stiffnessPM = euler->stiffnessPM;
//double* stiffnessPMIterations = euler->stiffnessPMIterations;
//double* stiffnessSPM = euler->stiffnessSPM;
//double* stiffnessSPMIterations = euler->stiffnessSPMIterations;
//double* stiffnessIPM = euler->stiffnessIPM;
//double* stiffnessIPMIterations = euler->stiffnessIPMIterations;
Gnuplot *plot = new Gnuplot();
plot->plotGraphic(time, results[0], nGraphic, "X1");
plot->plotGraphic(time, results[1], nGraphic, "X2");
plot->plotGraphic(time, results[2], nGraphic, "X3");
//plot->plotGraphic(time, stiffnessPM, nGraphic, "Stiffness PM");
//plot->plotGraphic(time, stiffnessPMIterations, nGraphic, "StiffnessPMIterations");
//plot->plotGraphic(time, stiffnessSPM, nGraphic, "Stiffness SPM");
//plot->plotGraphic(time, stiffnessSPMIterations, nGraphic, "StiffnessSPMIterations");
//plot->plotGraphic(time, stiffnessIPM, nGraphic, "Stiffness IPM");
//plot->plotGraphic(time, stiffnessIPMIterations, nGraphic, "StiffnessIPMIterations");
}
catch (const char* e)
{
QMessageBox::information(NULL, "Error", e, QMessageBox::Ok);
}
catch (string e)
{
QMessageBox::information(NULL, "Error", e.c_str(), QMessageBox::Ok);
}
}