📄 dxlcglyltd.cpp
字号:
// dxlcglyltd.cpp : implementation file
//
#include "stdafx.h"
#include "Cvenus.h"
#include "dxlcglyltd.h"
#include "dxlyltd.h"
#include "yqsxz.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// dxlcglyltd
extern double ptidu[1000],dtidu[1000];
dxlcglyltd::dxlcglyltd()
{
}
dxlcglyltd::~dxlcglyltd()
{
}
extern char cGraphColor[][16];
extern int iGraphColorNum;
extern int g_iProgress ; // 计算进度
extern bool bFinishThread;
/////////////////////////////////////////////////////////////////////////////
// dxlcglyltd message handlers
void dxlcglyltd::dxlcglyltdjs()//多相流压力梯度
{
//深度梯度(0 To 2000) [[[[ sdtd[2000]
//压力梯度(0 To 2000) [[[[ yltd[2000]
//T地层 [[[[ tdiceng
//P井底 [[[[ pdiceng
//T井口 [[[[ tjingkou
//P井口 [[[[ pjingkou
//P梯度[1000] [[[[ ptidu[1000]
//D梯度[1000] [[[[ dtidu[1000]
//方法简写 [[[[ ffjx
//方法全称 [[[[ ffqc
double sdtd[2000],yltd[2000],MX[7];
CString GTY[1000],fileDialogFilter2,fileDialogExt2,title,title1;
CString title2,G4,ffjx,ffqc,templs1;
int TEMP,DR,NFPS,MMPF,i;
char temp[100];
double DVW,tdiceng,pdiceng,tjingkou,pjingkou,QG,GG,QW,GW,QO,OG;
double DIC,DIT1,DVT1,DIT2,DVT2,DIT3,DVT3,RR,H2S,CO2,N2,NaCl,TG;
double PN,P0,T0,DOL,L;
int iColorIndex = 0; // 颜色索引 lzj
// SetCursor(LoadCursor(NULL, IDC_WAIT));
g_iProgress = 35; // 计算进度
ENDCOMPUTE;
//赋初值
for(i=0;i<2000;i++)
{
sdtd[i]=0;
yltd[i]=0;
}
for(i=0;i<7;i++)
{
MX[i]=0;
}
TEMP=0;DR=0;NFPS=0;MMPF=0;i=0;
DVW=0;tdiceng=0;pdiceng=0;tjingkou=0;pjingkou=0;QG=0;GG=0;QW=0;GW=0;QO=0;OG=0;
DIC=0;DIT1=0;DVT1=0;DIT2=0;DVT2=0;DIT3=0;DVT3=0;RR=0;H2S=0;CO2=0;N2=0;NaCl=0;TG=0;
PN=0;P0=0;T0=0;DOL=0;L=0;
dxlyltd dxlyljs;
CString str;
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(1, 5);
DVW=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(2, 5);
tdiceng=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(3, 5);
pdiceng=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(4, 5);
tjingkou=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(5, 5);
pjingkou=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(6, 5);
QG=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(7, 5);
GG=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(8, 5);
QW=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(9, 5);
GW=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(10, 5);
QO=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(11, 5);
OG=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(12, 5);
DIC=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(13, 5);
DIT1=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(14, 5);
DVT1=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(15, 5);
DIT2=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(16, 5);
DVT2=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(17, 5);
DIT3=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(18, 5);
DVT3=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(19, 5);
RR=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(20, 5);
H2S=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(21, 5);
CO2=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(22, 5);
N2=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(23, 5);
NaCl=atof(str);
MX[1]=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page11.GetDlgItem(IDC_CHECK1))->GetCheck();
MX[2]=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page11.GetDlgItem(IDC_CHECK2))->GetCheck();
MX[3]=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page11.GetDlgItem(IDC_CHECK3))->GetCheck();
MX[4]=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page11.GetDlgItem(IDC_CHECK4))->GetCheck();
MX[5]=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page11.GetDlgItem(IDC_CHECK5))->GetCheck();
MX[6]=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page11.GetDlgItem(IDC_CHECK6))->GetCheck();
H2S = H2S / 100;
N2 = N2 / 100;
CO2 = CO2 / 100;
DIT1 = DIT1 / 1000;
DIT2 = DIT2 / 1000;
DIT3 = DIT3 / 1000;
DIC = DIC / 1000;
tjingkou = tjingkou + 273.15;
tdiceng = tdiceng + 273.15;
TG = (tdiceng - tjingkou) / DVW;
if( pjingkou == 0)
{
DR = -1;
ptidu[0] = pdiceng;
dtidu[0] = DVW;
yltd[0] = pdiceng;
}
else
{
DR = 1;
ptidu[0] = pjingkou;
dtidu[0] = 0;
yltd[0] = pjingkou;
}
sdtd[0] = dtidu[0];
/* fileDialogFilter2 ="Data files (*.RMG)|*.RMG|All files (*.*)|*.*||";
fileDialogExt2 = "RMG";
CFileDialog fileDialog2( FALSE,
fileDialogExt2, NULL,
0, fileDialogFilter2 );
fileDialog2.m_ofn.lpstrTitle="保存计算结果";
if( fileDialog2.DoModal() == IDCANCEL )
{
return;
}*/
CStdioFile f3;
CFileException exception3;
BOOL status1;
templs1 = ((CCVenusApp*)AfxGetApp())->GetMyAppPath();
templs1 += "\\tempfile.txt";
status1 = f3.Open(templs1,CFile::modeCreate|CFile::modeWrite);
if (!status1)
{
char s[100];
sprintf(s, "Error opening file for reading. Code:%d",
exception3.m_cause);
AfxMessageBox(s);
return;
}
// title="";
title="\t $$多相流压力梯度计算结果$0\n";
title1=" 深 度$7\t$13\t$12\t 压 力 (MPa)$12\t$12\t$12\t$14\n";
// title2="";
title2=" (m)$11" "\t" "H-B方法" "\t" "D-R方法" "\t" "ORK方法" "\t" "B-B方法" "\t" "M-B方法" "\t" "GWN方法""\n";
try
{
f3.WriteString("\n");
f3.WriteString(title);
f3.WriteString("\n");
f3.WriteString(title1);
f3.WriteString(title2);
}
catch (CFileException exception3)
{
AfxMessageBox("Error reading file");
return;
}
G4 = " m$11";
CStdioFile f4;
CFileException exception4;
/* title=fileDialog2.GetPathName();
title1=title.Left(title.GetLength()-3);
title=title1+"GMG";*/
// templs1.Empty();
templs1 = ((CCVenusApp*)AfxGetApp())->GetMyAppPath();
templs1 += "\\tempfile.gra";
status1 = f4.Open(templs1,CFile::modeCreate|CFile::modeWrite);
if (!status1)
{
char s[100];
sprintf(s, "Error opening file for reading. Code:%d",
exception4.m_cause);
AfxMessageBox(s);
return;
}
try
{
title="$$";
title=title+"多相流压力梯度计算结果图\n";
f4.WriteString(title);
f4.WriteString("深度最小值,m:\n");
f4.WriteString("深度最大值,m:\n");
f4.WriteString("压力最小值,℃:\n");
f4.WriteString("压力最大值,℃:\n");
f4.WriteString("H\n");
f4.WriteString("P\n");
f4.WriteString("H__m\n");
f4.WriteString("P__MPa\n");
f4.WriteString(" 0\n");
}
catch (CFileException exception4)
{
AfxMessageBox("Error reading file");
return;
}
g_iProgress = 50; // 计算进度
ENDCOMPUTE;
NFPS = 40;
for(MMPF=1;MMPF<=6;MMPF++)
{
PN = 0;
for(i=1;i<=4;i++)
{
if( DR == 1) //从上向下计算
{
if( i == 1) //计算第1级油管
{
P0 = pjingkou;
T0 = tjingkou;
DOL = DIT1;
L = DVT1;
}
else if( i == 2)//计算第2级油管
{
P0 = PN;
T0 = tjingkou + TG * DVT1;
DOL = DIT2;
L = DVT2;
}
else if( i == 3)//计算第3级油管
{
P0 = PN;
T0 = tjingkou + TG * (DVT1 + DVT2);
DOL = DIT3;
L = DVT3;
}
else //计算套管
{
P0 = PN;
T0 = tjingkou + TG * (DVT1 + DVT2 + DVT3);
DOL = DIC;
L = DVW - (DVT1 + DVT2 + DVT3);
}
}
else //从下向上计算
{
if( i == 1)//计算套管
{
P0 = pdiceng;
T0 = tdiceng;
DOL = DIC;
L = DVW - (DVT1 + DVT2 + DVT3);
}
else if( i == 2)//计算第3级油管
{
P0 = PN;
T0 = tjingkou + TG * (DVT1 + DVT2 + DVT3);
DOL = DIT3;
L = DVT3;
}
else if( i == 3)//计算第2级油管
{
P0 = PN;
T0 = tjingkou + TG * (DVT1 + DVT2);
DOL = DIT2;
L = DVT2;
}
else//计算第1级油管
{
P0 = PN;
T0 = tjingkou + TG * DVT1;
DOL = DIT1;
L = DVT1;
}
}
if( L > 0)
{
if( MMPF == 1 && MX[MMPF] == 1)
{
ffjx = "H-B";
ffqc = "Hagedorn和Brown方法\n";
PN=dxlyljs.HagedornBrown(P0, T0, TG, QG, QW, QO, GG, GW, OG, L, DOL, 0, RR, H2S, CO2, N2, NaCl, NFPS, DR, 1);
}
else if( MMPF == 2 && MX[MMPF] == 1)
{
ffjx = "D-R";
ffqc = "Duns和Ros方法\n";
PN=dxlyljs.DunsRos(P0, T0, TG, QG, QW, QO, GG, GW, OG, L, DOL, 0, RR, H2S, CO2, N2, NaCl, NFPS, DR, 1);
}
else if( MMPF == 3 && MX[MMPF] == 1)
{
ffjx = "ORK";
ffqc = "Orkiszewski方法\n";
PN=Orkiszewski(P0, T0, TG, QG, QW, QO, GG, GW, OG, L, DOL, 0, RR, H2S, CO2, N2, NaCl, NFPS, DR, 1);
}
else if( MMPF == 4 && MX[MMPF] == 1)
{
ffjx = "B-B";
ffqc = "Beggs和Brill方法\n";
PN=dxlyljs.BeggsBrill(P0, T0, TG, QG, QW, QO, GG, GW, OG, L, DOL, 0, RR, H2S, CO2, N2, NaCl, NFPS, DR, 1);
}
else if( MMPF == 5 && MX[MMPF] == 1)
{
ffjx = "M-B";
ffqc = "Mukherjee和Brill方法\n";
PN=dxlyljs.MukherjeeBrill(P0, T0, TG, QG, QW, QO, GG, GW, OG, L, DOL, 0, RR, H2S, CO2, N2, NaCl, NFPS, DR, 1);
}
else if( MMPF == 6 && MX[MMPF] == 1)
{
ffjx = "GWM";
ffqc = "SWPI和SPA方法\n";
PN=dxlyljs.SWPISPA(P0, T0, TG, QG, QW, QO, GG, GW, OG, L, DOL, 0, RR, H2S, CO2, N2, NaCl, NFPS, DR, 1);
}
for(int J=1;J<=NFPS;J++)
{
TEMP=int(100 * ptidu[J]);
yltd[(i - 1) * NFPS + J] = double(TEMP)/ 100.0;
sdtd[(i - 1) * NFPS + J] = sdtd[(i - 1) * NFPS + J - 1] + DR * L / NFPS;
}
}
}
if( NFPS > 1 && PN > 0)
{
for(i=0;i<=4 * NFPS;i++)
{
if( sdtd[i] == 0 && i > 1)
{
break;
}
gcvt(yltd[i],95,temp);
title=temp;
gcvt(sdtd[i],95,temp);
title1=temp;
title=" "+title+" "+title1+"\n";
try
{
f4.WriteString(title);
}
catch (CFileException exception4)
{
AfxMessageBox("Error reading file");
return;
}
}
try
{
f4.WriteString("-1 -1\n");
// f4.WriteString(" 0 1\n");
f4.WriteString(cGraphColor[iColorIndex++]);
iColorIndex %= iGraphColorNum;
f4.WriteString(ffqc);
}
catch (CFileException exception4)
{
AfxMessageBox("Error reading file");
return;
}
}
for(i=0;i<=4 * NFPS - 1;i++)
{
if( sdtd[i] == 0 && i > 1)
{
break;
}
if( MMPF == 1)
{
gcvt(sdtd[i],95,temp);
GTY[i] =temp;
}
if( MX[MMPF] == 1)
{
gcvt(yltd[i],95,temp);
title=temp;
GTY[i] = GTY[i] + "\t" + title;
}
else
{
GTY[i] = GTY[i] + "\t" + " /";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -