Ryan111
4th May 2017, 18:17
Hi guys
I'm an aerospace enginer and today wrote a program to use it as a calculator for determining some parameter of boundary layer (https://en.wikipedia.org/wiki/Boundary_layer). it's simple and no need to make it complex. ok, enough.:) now about the program, this is my program:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtMath>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
// Sample input data
quint32 Mmax = 100, Mest=21;
quint32 Uinf = 10;
double_t Cnu = 0.0002 , Xi = 1 , Xf = 2, Fm1, Yod, st, ta, A, B, C, H1, H, F1, F2, Y[100] , U[100], U0[100], V[100], V0[100], Re, DX, DY=0.00112, Ue=1, DUeDX=-0.05, X, Delt=0.0224, Delst=0.00771, Thetha=0.00297, Cf=0.00297;
Re = Uinf/Cnu;
X=Xi;
quint32 i=0;
QString text = " Program ILBLE\n 2-D Boundary layer, incompressible laminar\n 1ST order\n Explicit Method\n Input: MMAX, Re, Dy\n";
text.append(" ");
QString str = QVariant(Mmax).toString();
text.append(str);
text.append(" ");
str = QVariant(Re).toString();
text.append(str);
text.append(" ");
str = QVariant(DY).toString();
text.append(str);
text.append(" \n Flat plate plus ramp flow\n");
for(i=1 ; i <= Mmax ; i++){
U[i]= Ue;
U0[i]=Ue;
V[i]=0;
V0[i]=0;
}
U[1]=0;
U0[1]=0;
Fm1= Mest-1;
for(i=2; i<=Mest; i++){
Yod=(i-1)/Fm1;
U0[i]=Ue*((1.5*Yod)-(0.5*qPow(Yod, 3)));
}
text.append(" X , Delt , Delst , Thetha , Cf , Ue , DUeDX");
str = QVariant(X).toString();
text.append(str);
text.append(" ");
str = QVariant(Delt).toString();
text.append(str);
text.append(" ");
str = QVariant(Delst).toString();
text.append(str);
text.append(" ");
str = QVariant(Thetha).toString();
text.append(str);
text.append(" ");
str = QVariant(Cf).toString();
text.append(str);
text.append(" ");
str = QVariant(Ue).toString();
text.append(str);
text.append(" ");
str = QVariant(DUeDX).toString();
text.append(str);
text.append(" \n");
Hezar:
DX=0.4*U0[2]*DY*DY*Re;
if(X <= Xf){goto navadnoh;}
if(X+DX > Xf){
DX=Xf-Xf;
}
X=X+DX;
Ue=1.05-(X/20);
DUeDX=-0.05;
U0[Mmax]=Ue;
//Explicit
st=0.5;
ta=0;
for(i=2; i <= Mmax-1 ; i++){
A=(1/Re)-(V0[i]*(DY/2));
B=(1/Re)+(V0[i]*(DY/2));
C=(Ue*DUeDX*(qPow(DY,2)))-2*U0[i]/Re;
H1=0.5*DY/DX;
H=DX/(U0[i]*DY*DY);
U[i]=U0[i]+H*((A*U0[i+1])+(B*U0[i-1])+C);
V[i]=V[i-1]-H1*(U[i]-U0[i]+U[i-1]-U0[i-1]);
F1=1-(U[i]/Ue);
F2=F1*U[i]/Ue;
st=st+F1;
ta=ta+F2;
}
//end
Delst=Delst*DY;
Thetha=Thetha*DY;
for(i=0;i<=Mmax ; i++){
if(U[i] > 0.99*Ue){
Mest=i;
break;
}
}
Delt=(Mest-1)*DY;
Cf= (4*U[2]-U[3])/(qPow(Ue,2)*DY*Re);
if(Cf <= 0.0001){
text.append(" Near seperation at X= ");
str = QVariant(X).toString();
text.append(str);
text.append(" \n");
goto navadnoh;
}
str = QVariant(X).toString();
text.append(str);
text.append(" ");
str = QVariant(Delt).toString();
text.append(str);
text.append(" ");
str = QVariant(Delst).toString();
text.append(str);
text.append(" ");
str = QVariant(Thetha).toString();
text.append(str);
text.append(" ");
str = QVariant(Cf).toString();
text.append(str);
text.append(" ");
str = QVariant(Ue).toString();
text.append(str);
text.append(" ");
str = QVariant(DUeDX).toString();
text.append(str);
text.append(" \n");
for(i=2 ; i <= Mmax ; i++){
U0[i]=U[i];
V0[i]=V[i];
}
goto Hezar;
navadnoh:
text.append(" i , Y , U , V \n");
for(i=1; i<= Mmax ; i++){
Y[i]=(i-1)*DY;
str = QVariant(i).toString();
text.append(str);
text.append(" ");
str = QVariant(Y[i]).toString();
text.append(str);
text.append(" ");
str = QVariant(U[i]).toString();
text.append(str);
text.append(" ");
str = QVariant(V[i]).toString();
text.append(str);
text.append(" \n");
}
ui->textEdit->setText(text);
}
There is a button in the form of the program that when I click it, it's supposed to do the calculation and show me the result but when I run the program and click on "calculate", get this message:
http://sl.uploads.im/hGcux.png
What's the problem?
I'm an aerospace enginer and today wrote a program to use it as a calculator for determining some parameter of boundary layer (https://en.wikipedia.org/wiki/Boundary_layer). it's simple and no need to make it complex. ok, enough.:) now about the program, this is my program:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtMath>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
// Sample input data
quint32 Mmax = 100, Mest=21;
quint32 Uinf = 10;
double_t Cnu = 0.0002 , Xi = 1 , Xf = 2, Fm1, Yod, st, ta, A, B, C, H1, H, F1, F2, Y[100] , U[100], U0[100], V[100], V0[100], Re, DX, DY=0.00112, Ue=1, DUeDX=-0.05, X, Delt=0.0224, Delst=0.00771, Thetha=0.00297, Cf=0.00297;
Re = Uinf/Cnu;
X=Xi;
quint32 i=0;
QString text = " Program ILBLE\n 2-D Boundary layer, incompressible laminar\n 1ST order\n Explicit Method\n Input: MMAX, Re, Dy\n";
text.append(" ");
QString str = QVariant(Mmax).toString();
text.append(str);
text.append(" ");
str = QVariant(Re).toString();
text.append(str);
text.append(" ");
str = QVariant(DY).toString();
text.append(str);
text.append(" \n Flat plate plus ramp flow\n");
for(i=1 ; i <= Mmax ; i++){
U[i]= Ue;
U0[i]=Ue;
V[i]=0;
V0[i]=0;
}
U[1]=0;
U0[1]=0;
Fm1= Mest-1;
for(i=2; i<=Mest; i++){
Yod=(i-1)/Fm1;
U0[i]=Ue*((1.5*Yod)-(0.5*qPow(Yod, 3)));
}
text.append(" X , Delt , Delst , Thetha , Cf , Ue , DUeDX");
str = QVariant(X).toString();
text.append(str);
text.append(" ");
str = QVariant(Delt).toString();
text.append(str);
text.append(" ");
str = QVariant(Delst).toString();
text.append(str);
text.append(" ");
str = QVariant(Thetha).toString();
text.append(str);
text.append(" ");
str = QVariant(Cf).toString();
text.append(str);
text.append(" ");
str = QVariant(Ue).toString();
text.append(str);
text.append(" ");
str = QVariant(DUeDX).toString();
text.append(str);
text.append(" \n");
Hezar:
DX=0.4*U0[2]*DY*DY*Re;
if(X <= Xf){goto navadnoh;}
if(X+DX > Xf){
DX=Xf-Xf;
}
X=X+DX;
Ue=1.05-(X/20);
DUeDX=-0.05;
U0[Mmax]=Ue;
//Explicit
st=0.5;
ta=0;
for(i=2; i <= Mmax-1 ; i++){
A=(1/Re)-(V0[i]*(DY/2));
B=(1/Re)+(V0[i]*(DY/2));
C=(Ue*DUeDX*(qPow(DY,2)))-2*U0[i]/Re;
H1=0.5*DY/DX;
H=DX/(U0[i]*DY*DY);
U[i]=U0[i]+H*((A*U0[i+1])+(B*U0[i-1])+C);
V[i]=V[i-1]-H1*(U[i]-U0[i]+U[i-1]-U0[i-1]);
F1=1-(U[i]/Ue);
F2=F1*U[i]/Ue;
st=st+F1;
ta=ta+F2;
}
//end
Delst=Delst*DY;
Thetha=Thetha*DY;
for(i=0;i<=Mmax ; i++){
if(U[i] > 0.99*Ue){
Mest=i;
break;
}
}
Delt=(Mest-1)*DY;
Cf= (4*U[2]-U[3])/(qPow(Ue,2)*DY*Re);
if(Cf <= 0.0001){
text.append(" Near seperation at X= ");
str = QVariant(X).toString();
text.append(str);
text.append(" \n");
goto navadnoh;
}
str = QVariant(X).toString();
text.append(str);
text.append(" ");
str = QVariant(Delt).toString();
text.append(str);
text.append(" ");
str = QVariant(Delst).toString();
text.append(str);
text.append(" ");
str = QVariant(Thetha).toString();
text.append(str);
text.append(" ");
str = QVariant(Cf).toString();
text.append(str);
text.append(" ");
str = QVariant(Ue).toString();
text.append(str);
text.append(" ");
str = QVariant(DUeDX).toString();
text.append(str);
text.append(" \n");
for(i=2 ; i <= Mmax ; i++){
U0[i]=U[i];
V0[i]=V[i];
}
goto Hezar;
navadnoh:
text.append(" i , Y , U , V \n");
for(i=1; i<= Mmax ; i++){
Y[i]=(i-1)*DY;
str = QVariant(i).toString();
text.append(str);
text.append(" ");
str = QVariant(Y[i]).toString();
text.append(str);
text.append(" ");
str = QVariant(U[i]).toString();
text.append(str);
text.append(" ");
str = QVariant(V[i]).toString();
text.append(str);
text.append(" \n");
}
ui->textEdit->setText(text);
}
There is a button in the form of the program that when I click it, it's supposed to do the calculation and show me the result but when I run the program and click on "calculate", get this message:
http://sl.uploads.im/hGcux.png
What's the problem?