📄 qjlxpyljll.cpp
字号:
// qjlxpyljll.cpp : implementation file
//
#include "stdafx.h"
#include "Cvenus.h"
#include "qjlxpyljll.h"
#include "yqsxz.h"
#include "qjyljs.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// qjlxpyljll
qjlxpyljll::qjlxpyljll()
{
}
qjlxpyljll::~qjlxpyljll()
{
}
extern char cGraphColor[][16];
extern int iGraphColorNum;
extern int g_iProgress ; // 计算进度
extern bool bFinishThread;
/////////////////////////////////////////////////////////////////////////////
// qjlxpyljll message handlers
void qjlxpyljll::Onqjpy()
{
CString strAppPath;
strAppPath = ((CCVenusApp*)AfxGetApp())->GetMyAppPath();
CString strAppPath1 = strAppPath + "\\tempfile.txt";
CString strAppPath2 = strAppPath + "\\tempfile.gra";
TRACE(strAppPath2);
//DVW
//Prs
//T地层 [[[[ Tdcwd
//T井口 [[[[ Tjkwd
//AF
//BF
//C流动系数 [[[[ Cldxs
//N指数 [[[[ Nzs
//地层有效厚度 [[[[ dcyxhd
//气井供给边界半径 [[[[ qjggbjbj
//井底半径 [[[[ jdbj
//视表皮系数 [[[[ sbpxs
//有效渗透率 [[[[ yxstl
//Qtest
//Qgmax
//Pwftest
//Ptftest
//DIT
//DVT
//DIC
//GG
//CO2
//H2S
//N2
//LGR
//GL
//油水 [[[[ yhs
//G压力X [[[[ gyalix
//N计算点数 [[[[ njsds
//Q气量增值 [[[[ Qqlzz
CString fileDialogFilter2,fileDialogExt2;
CString A,B,templs1,templs2,title,title1,title2,title3,feng[5];
char Temp[100],Temp1[100];
double DVW,Prs,Tdcwd,Tjkwd,AF,BF,Cldxs,Nzs,dcyxhd,qjggbjbj;
double jdbj,sbpxs,yxstl,Qtest,Qgmax,Pwftest,Ptftest,DIT,DVT,DIC,GG,CO2,H2S,N2,LGR;
double GL,PC,TC,DIT10,DVT10,DIT20,DVT20,QG,gyalix,TG,RR,Tun,PD,Qgmax1,Qgmax2,Qgmax3;
double TR,PR,UG,Z,BT,Qqlzz,Q,P,T,WG,STL,WL,Vg,DIT0,RG,P0,T0,dit00,Pwh;
int yhs,njsds,i,J;
int iColorIndex = 0; // 颜色索引 lzj
g_iProgress = 15; // 计算进度
ENDCOMPUTE;
// SetCursor(LoadCursor(NULL, IDC_WAIT));
//赋初值
for(i=0;i<11;i++);
{
for(J=0;J<200;J++)
{
dJsjg[i][J]=0;
}
}
DVW=0;Prs=0;Tdcwd=0;Tjkwd=0;AF=0;BF=0;Cldxs=0;Nzs=0;dcyxhd=0;qjggbjbj=0;
jdbj=0;sbpxs=0;yxstl=0;Qtest=0;Qgmax=0;Pwftest=0;Ptftest=0;DIT=0;DVT=0;DIC=0;GG=0;CO2=0;H2S=0;N2=0;LGR=0;
GL=0;PC=0;TC=0;DIT10=0;DVT10=0;DIT20=0;DVT20=0;QG=0;gyalix=0;TG=0;RR=0;Tun=0;PD=0;Qgmax1=0;Qgmax2=0;Qgmax3=0;
TR=0;PR=0;UG=0;Z=0;BT=0;Qqlzz=0;Q=0;P=0;T=0;WG=0;STL=0;WL=0;Vg=0;DIT0=0;RG=0;P0=0;T0=0;dit00=0;Pwh=0;
yhs=0;njsds=0;i=0;J=0;
yqsxz csjs;
qjyljs qjyljsz;
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);
Prs=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(3, 5);
Tdcwd=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(4, 5);
Tjkwd=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(5, 5);
AF=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(6, 5);
BF=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(7, 5);
Cldxs=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(8, 5);
Nzs=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(9, 5);
dcyxhd=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(10, 5);
qjggbjbj=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(11, 5);
jdbj=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(12, 5);
sbpxs=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(13, 5);
yxstl=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(14, 5);
Qtest=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(15, 5);
Qgmax=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(16, 5);
Pwftest=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(17, 5);
Ptftest=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(18, 5);
DIT=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(19, 5);
DVT=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(20, 5);
DIC=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(21, 5);
GG=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(22, 5);
CO2=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(23, 5);
H2S=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(24, 5);
N2=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(25, 5);
LGR=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(26, 5);
GL=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(27, 5);
yhs=atoi(str);
//参数变换及计算有关参数
csjs.trqnjcs(GG, H2S, CO2,1);//临界csz
PC=csjs.Pc;//对比压力
TC=csjs.Tc;//对比温度
if(fabs(AF * BF) > 0)
{
Qgmax = (-AF + pow((pow(AF,2) + 4 * BF * (pow(Prs,2) - pow(0.0101,2))),0.5)) / 2 / BF;
}
else if( Qtest * Pwftest > 0 || Qtest * Ptftest > 0)
{
if( Pwftest <= 0)
{
DIT10 = DIT / 1000;
DVT10 = DVT;
DIT20 = DIC / 1000;
DVT20 = DVW - DVT;
QG = Qtest * 10000;
//Call 气井压力(G压力X, Ptftest, T井口, TG, DVT10, DIT10, 0, RR, QG, GG, LGR, GL, H2S, N2, CO2, 0, 1, 1)
gyalix=qjyljsz.qjyl(Ptftest, Tjkwd, TG, DVT10, DIT10, 0, RR, QG, GG, LGR, GL, H2S, N2, CO2,0, 0, 1, 1);
if( DVT20 == 0)
{
Pwftest = gyalix;
}
else
{
Tun = Tjkwd + TG * DVT10;
//Call 气井压力(Pwftest, G压力X, Tun, TG, DVT20, DIT20, 0, RR, QG, GG, LGR, GL, H2S, N2, CO2, 0, 1, 1)
Pwftest=qjyljsz.qjyl(gyalix, Tun, TG, DVT20, DIT20, 0, RR, QG, GG, LGR, GL, H2S, N2, CO2,0, 0, 1, 1);
}
}
if( Qgmax <= 0)
{
PD = (pow(Prs,2) - pow(Pwftest,2)) / pow(Prs,2);
Qgmax1 = Qtest / (1.8 * PD - 0.8 * pow(PD,2));
Qgmax2 = 6 * Qtest / (pow((1 + 48 * PD),0.5) - 1);
Qgmax3 = Qtest / 1.0434 / pow(PD,0.6594);
Qgmax = (Qgmax1 + Qgmax2 + Qgmax3) / 3;
}
Qgmax = Qgmax;
BF = ((pow(Prs,2) - pow(0.1,2)) / Qgmax - (pow(Prs,2) - pow(Pwftest,2)) / Qtest) / (Qgmax - Qtest);
AF = (pow(Prs,2) - pow(Pwftest,2) - BF * pow(Qtest,2)) / Qtest;
}
else if( Cldxs * Nzs > 0)
{
Qgmax = Cldxs * pow((pow(Prs,2) - pow(0.1,2)),Nzs);
}
else if( dcyxhd * qjggbjbj * jdbj * yxstl > 0)
{
TR = Tdcwd / TC;
PR = Prs / PC;
//Call 天然气的粘度(UG, PR, TR, CO2, H2S, N2, GG, T地层 - 273.15)
UG=csjs.trqnd(PR, TR, CO2, H2S, N2, GG, Tdcwd-273.15);
//Call 天然气偏差系数(Z, PR, TR)
Z=csjs.trqpcxs(PR, TR);
AF = 0.000127 * UG * Z * Tdcwd * (log(qjggbjbj / jdbj) / log(10) + sbpxs) / yxstl / dcyxhd;
BT = 76440000000.0 / pow(yxstl,1.5);
BF = 2.3336*pow(10,-21) * BT * GG * Tdcwd * Z * (1 / jdbj - 1 / qjggbjbj) / pow(dcyxhd,2);
Qgmax = (-AF + pow((pow(AF,2) + 4 * BF * (pow(Prs,2) - pow(0.0101,2))),0.5)) / 2 / BF;
}
else
{
MessageBox(NULL, "生产气井节点分析IPR参数值错误,请更正后再计算!","参数值错误",MB_ICONWARNING);
return;
}
Qgmax = int(100 * Qgmax) / 100.0;
g_iProgress = 35; // 计算进度
ENDCOMPUTE;
njsds = 100;
Qqlzz = Qgmax / njsds;
if( Qqlzz <= 0.25)
{
Qqlzz = 0.25;
}
else if( Qqlzz <= 0.5)
{
Qqlzz = 0.5;
}
else if( Qqlzz <= 1)
{
Qqlzz = 1;
}
else if( Qqlzz <= 2)
{
Qqlzz = 2;
}
else if( Qqlzz <= 5)
{
Qqlzz = 5;
}
else
{
Qqlzz = int(Qqlzz);
}
njsds = 1 + int(Qgmax / Qqlzz);
H2S = H2S / 100.0;
CO2 = CO2 / 100.0;
N2 = N2 / 100.0;
LGR = LGR / 10000.0;
DIC = DIC / 1000.0;
Tjkwd = Tjkwd + 273.15;
Tdcwd = Tdcwd + 273.15;
TG = (Tdcwd - Tjkwd) / DVW;
//Call 天然气的临界参数(PC, TC, GG, H2S, CO2, "干气")
csjs.trqnjcs(GG, H2S, CO2,1);//临界csz
PC=csjs.Pc;//对比压力
TC=csjs.Tc;//对比温度
//ReDim 结果(4, N计算点数 + 10)
for(i=0;i<10;i++)
{
for(J=0;J<njsds+10;J++)
{
dJsjg[i][J] = 0;
}
}
//打开保存计算的图形结果的文件
CStdioFile f4;
CFileException exception4;
BOOL status1;
// str = strAppPath + "\\tempfile.gra";
TRACE(strAppPath2);
status1 = f4.Open(strAppPath2,CFile::modeCreate|CFile::modeWrite);
if (!status1)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -