📄 qjjjdfx.cpp
字号:
// qjjjdfx.cpp : implementation file
//
#include "stdafx.h"
#include "Cvenus.h"
#include "qjjjdfx.h"
#include "yqsxz.h"
#include "zpjjdfx.h"
#include "LZXJD.h"
#include "qjyljs.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// qjjjdfx
extern double ptidu[1000],dtidu[1000];
qjjjdfx::qjjjdfx()
{
}
qjjjdfx::~qjjjdfx()
{
}
extern char cGraphColor[][16];
extern int iGraphColorNum;
extern int g_iProgress ; // 计算进度
extern bool bFinishThread;
/////////////////////////////////////////////////////////////////////////////
// qjjjdfx message handlers
void qjjjdfx::qjjjdfxjs() //气举井节点分析
{ // 必须先调试自喷井节点分析
//结果[20][1000] [[[[ jieguo[20][1000]
//R结果[20][1000] [[[[ rjieguo[20][1000]
//参数[7][5] [[[[ canshu[7][5]
//G深度[500] [[[[ gshendu[500]
//G多相流压力[500] [[[[ gdxlyl[500]
//G注气压力[500] [[[[ gzqyl[500]
//分析参数个数[7] [[[[ fxcsgs[7]
//注入气量 [[[[ zrql
//注气点压力 [[[[ zqdyl
//注气点深度 [[[[ zqdsd
//井口压力 [[[[ jkyl
double jsjg[20][1000], Rjsjg[20][1000];
double csz[10][8];
CString fileDialogFilter2,fileDialogExt2,caption,title,title1;
CString A,B,templs1,templs2,A1,A2,CYCQ,jsff,sfyszqtd,JCL;
char w[5],Temp[100],Temp1[100];
int fxcsgs[8],J,i,K,Pjkylfx,Pygccfx,Pdcylfx,Pcyzsfx,MMPF,jszs;
int Pfxjsds,Ndclrtx,ni;
double DVW,Pdcyl,Tdcwd,Pjkyy,Tjkwd,PLI,Qtmax,qcscl,pcsyl,GWR,Pb;
double Fw,DVT,DIT,DOT,RR,DIC,OG,GG,CO2,H2S,N2,GW,NaCl,PIN,QIN,Pgzyc;
int Pqyb,Pzqlfx,Pzqylfx,j,ii;
double TG,PC,TC,DLTQ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ax=0;pliwl=0;
qbwl=0;qomaxwl=0;qtmaxwl=0;pbwl=0;
w[5]='j';//如果不在前面定义Temp[100]的前面任意加一个其它字符数组,程序会出错
yqsxz csjs;
zpjjdfx zpjjs;
qjyljs qjyljsz;
LZXJD jslzjd;
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);
Pdcyl=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);
Pjkyy=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(5, 5);
Tjkwd=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(6, 5);
PLI=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(7, 5);
qcscl=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(8, 5);
pcsyl=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(9, 5);
GWR=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(10, 5);
DVT=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(11, 5);
DIT=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(12, 5);
DOT=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(13, 5);
RR=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(14, 5);
DIC=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(15, 5);
GG=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(16, 5);
CO2=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(17, 5);
H2S=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(18, 5);
N2=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(19, 5);
GW=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(20, 5);
NaCl=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(21, 5);
PIN=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(22, 5);
QIN=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(22, 5);
Pgzyc=atof(str);
int k=23;
for(i=1;i<=7;i++)
{
for(j=1;j<=5;j++)
{
k=k+1;
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(k, 5);
csz[i][j]=atof(str);
}
}
Pjkylfx=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page3.GetDlgItem(IDC_CHECK1))->GetCheck();
Pygccfx=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page3.GetDlgItem(IDC_CHECK2))->GetCheck();
Pdcylfx=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page3.GetDlgItem(IDC_CHECK3))->GetCheck();
Pcyzsfx=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page3.GetDlgItem(IDC_CHECK4))->GetCheck();
Pqyb=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page3.GetDlgItem(IDC_CHECK5))->GetCheck();
Pzqlfx=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page3.GetDlgItem(IDC_CHECK6))->GetCheck();
Pzqylfx=((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page3.GetDlgItem(IDC_CHECK7))->GetCheck();
MMPF=((CComboBox*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page3.GetDlgItem(IDC_COMBO1))->GetCurSel();
MMPF=MMPF+1;
RG=0;//RG没有赋值
//参数排列,确保0在后面
for(i=1;i<=7;i++)
{
for(J=1;J<=4;J++)
{
if( csz[i][J] == 0)
{
for(K=J+1;K<=5;K++)
{
if( csz[i][K] >= 0)
{
csz[i][J] = csz[i][K];
csz[i][K] = 0;
break;
}
}
}
}
}
for(i=1;i<=7;i++)
{
fxcsgs[i] = 0;
for(J=1;J<=5;J++)
{
if( csz[i][J] > 0)
{
fxcsgs[i] = fxcsgs[i] + 1;
}
}
}
jszs = 0;
if( Pjkylfx == 1)
{
jszs = jszs + fxcsgs[1];
}
if( Pygccfx == 1)
{
jszs = jszs + fxcsgs[2] + 1;
}
if( Pdcylfx == 1)
{
jszs = jszs + 1;
}
if( Pcyzsfx == 1)
{
jszs = jszs + 1;
}
if( Pqyb == 1)
{
jszs = jszs + fxcsgs[5];
}
if( Pzqlfx == 1)
{
jszs = jszs + fxcsgs[6];
}
if( Pzqylfx == 1)
{
jszs = jszs + fxcsgs[7];
}
//确定多相流计算方法
if( MMPF == 1)
{
jsff = "Hagedorn和Brown多相流方法";
}
else if( MMPF == 2)
{
jsff = "Duns和Ros多相流方法";
}
else if( MMPF == 3)
{
jsff = "Orkiszewski多相流方法";
}
else if( MMPF == 4)
{
jsff = "Beggs和Brill多相流方法";
}
else if( MMPF == 5)
{
jsff = "Mukherjee和Brill多相流方法";
}
else if( MMPF == 6)
{
jsff = "SWPI和SPA多相流方法";
}
g_iProgress = 5; // 计算进度
ENDCOMPUTE;
//变换含水率,如果 Fw=1 为排水采气,否则为采油
Fw = 1;
Pb = Pdcyl;
// 入井动态关系IPR(PLI, QB, Qomax, Qtmax, qcscl, pcsyl, Pdcyl, Pb, Fw);
zpjjs.rjIPR(PLI,qcscl, pcsyl, Pdcyl, Pb, Fw);
PLI=zpjjs.PLIZZZ;
Qtmax=zpjjs.Qtmax;
Qomax=zpjjs.Qomax;
QB=zpjjs.QB;
//参数变换及计算有关参数
H2S = H2S / 100;
CO2 = CO2 / 100;
N2 = N2 / 100;
if( RR == 0)
{
RR = 0.05 / DIT;
}
DIT = DIT / 1000;
DOT = DOT / 1000;
DIC = DIC / 1000;
Tjkwd = Tjkwd + 273.15;
Tdcwd = Tdcwd + 273.15;
TG = (Tdcwd - Tjkwd) / DVW;
QIN = QIN * 10000;
// 天然气的临界参数(PC, TC, GG, H2S, CO2, "干气");
csjs.trqnjcs(GG, H2S, CO2,1);//临界参数
PC=csjs.Pc;//对比压力
TC=csjs.Tc;//对比温度
//确定分析的产水量值
Rjsjg[0][0] = int(0.05 * Qtmax);
if( Rjsjg[0][0] > 5)
{
Rjsjg[0][0] = 5;
}
for(J=1;J<=500;J++)
{
if( Rjsjg[0][J - 1] < 5)
{
DLTQ = 0.5;
}
else if( Rjsjg[0][J - 1] < 10)
{
DLTQ = 1;
}
else if( Rjsjg[0][J - 1] < 50)
{
DLTQ = 2;
}
else if( Rjsjg[0][J - 1] < 200)
{
DLTQ = 5;
}
else if( Rjsjg[0][J - 1] < 1000)
{
DLTQ = 10;
}
else if( Rjsjg[0][J - 1] < 5000)
{
DLTQ = 20;
}
else
{
DLTQ = 50;
}
Rjsjg[0][J] = Rjsjg[0][J - 1] + DLTQ;
Pfxjsds = J;
if( Rjsjg[0][J] >= 2*Qtmax)
{
break;
}
}
//打开文件,写入设计结果
//数据结果文件
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;
}
try
{
// title="$$";
// title="\t"+title+"\t"+"井气举排$0"+"\t"+"水采气节$0"+"\t"+"点分析计$0"+"\t"+"算结果$0\n";
title="\t$$气举排水采气节点分析计算结果$0\n";
f3.WriteString("\n");
f3.WriteString(title);
f3.WriteString("\n");
}
catch (CFileException exception3)
{
AfxMessageBox("Error reading file");
return;
}
//图形结果文件
CStdioFile f4;
CFileException exception4;
// 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;
}
// 主窗口.SSPanel1.FloodPercent = 1
if( Pjkylfx == 1)
{
//分析井口压力对气举排液量的影响
try
{
title="$$";
title=title+"气举排水采气井口压力分析图[" + jsff + "]"+"\n";
f4.WriteString(title);
f4.WriteString("节点压力最小值,MPa:\n");
f4.WriteString("节点压力最大值,MPa:\n");
f4.WriteString("产液量最小值,m^3/d:\n");
f4.WriteString("产液量最大值,m^3/d:\n");
f4.WriteString("Pwf\n");
f4.WriteString("Ql\n");
f4.WriteString("Pwf__MPa\n");
f4.WriteString("Ql__m^3/d\n");
f4.WriteString(" 1\n");
}
catch (CFileException exception4)
{
AfxMessageBox("Error reading file");
return;
}
for(i=0;i<=10;i++)
{
for(J=0;J<=Pfxjsds;J++)
{
jsjg[i][J] = 0;
}
}
g_iProgress = 10; // 计算进度
ENDCOMPUTE;
//流入关系计算
if( Ndclrtx == 0)
{
// 计算地层流入曲线;
Ndclrtx = 1;
if( Pdcylfx == 1)
{
ni = 5;
}
else
{
ni = 0;
}
for(i=0;i<=ni;i++)
{
if( i == 0)
{
Prswl = Pdcyl;
}
else
{
Prswl = csz[3][i]; //分析的地层压力值
}
if( Prswl <= 0)
{
break;
}
zpjjs.wlipr(Prswl, PLI, QB, Qomax, Qtmax, Pdcyl, Pb, Fw);
pliwl=zpjjs.PLIwl;
qbwl=zpjjs.QBwl;
qomaxwl=zpjjs.Qomaxwl;
qtmaxwl=zpjjs.Qtmaxwl;
pbwl=zpjjs.Pbwl;
for(J=0;J<=Pfxjsds;J++)
{
PWF=zpjjs.YQPWF(Rjsjg[0][J], pliwl, qbwl, qomaxwl, qtmaxwl, Prswl, pbwl, Fw);
if( PWF <= 0)
{
PWF = 0;
break;
}
else
{
Rjsjg[i + 1][J] = PWF;
}
}
}
}
for(J=0;J<=Pfxjsds;J++)
{
if( J > 2 && Rjsjg[1][J] <= 0)
{
break;
}
if( Rjsjg[0][J] <= Qtmax)
{
gcvt(Rjsjg[0][J],100,Temp);
title=Temp;
gcvt(Rjsjg[1][J],100,Temp1);
title1=Temp1;
title=" "+title+" "+title1+"\n";
try
{
f4.WriteString(title);
}
catch (CFileException exception4)
{
AfxMessageBox("Error reading file");
return;
}
jsjg[0][J] = Rjsjg[0][J];
jsjg[1][J] = Rjsjg[1][J];
}
}
gcvt(Pdcyl,100,Temp);
title=Temp;
title.TrimRight();
title.TrimLeft();
title="IPR[Prs="+title+"(MPa)]"+"\n";
try
{
f4.WriteString("-1 -1\n");
// f4.WriteString(" 0 1\n");
f4.WriteString(cGraphColor[iColorIndex++]);
iColorIndex %= iGraphColorNum;
f4.WriteString(title);
}
catch (CFileException exception4)
{
AfxMessageBox("Error reading file");
return;
}
//流出关系计算
ygnj = DIT;
qyb = GWR;
zrql = QIN;
zryl = PIN;
gzsd = DVT;
sfyszqtd = "否";
for(ii=1;ii<=5;ii++)
{
jkyl = csz[1][ii]; //分析的井口压力值
if( jkyl == 0)
{
break;
}
for(J=0;J<=Pfxjsds;J++)
{
if( Rjsjg[0][J] <= Qtmax)
{
// 计算油管流出曲线;
if( sfyszqtd != "是")
{
// 计算注气压力梯度;
sfyszqtd = "是";
if( ygnj <= 0.0433)
{
ygwj = 0.0603;
}
else if( ygnj <= 0.0507)
{
ygwj = 0.0603;
}
else if( ygnj <= 0.062)
{
ygwj = 0.076;
}
else if( ygnj <= 0.0762)
{
ygwj = 0.0889;
}
else if( ygnj <= 0.0889)
{
ygwj = 0.1016;
}
else
{
ygwj = ygnj + 0.014;
}
dtidu[0]=0;
P=qjyljsz.qjyl(zryl, Tjkwd, TG, gzsd, DIC, ygwj, RR, zrql, GG, 0, 1, H2S, N2, CO2,0, 100, 1, -1);
for(i=1;i<=100;i++)
{
Gsd[i] = dtidu[i];
Gzqyl[i] = ptidu[i] - Pgzyc;
}
}
if( zrql == 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -