📄 zpjjdfx.cpp
字号:
// zpjjdfx.cpp : implementation file
//
#include "stdafx.h"
#include "Cvenus.h"
#include "zpjjdfx.h"
#include "yqsxz.h"
#include "LZXJD.h"
#include "math.h"
#include "dxlyltd.h"
#include "direct.h"//用于得到系统路径
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern int g_iProgress ; // 计算进度
extern bool bFinishThread;
/////////////////////////////////////////////////////////////////////////////
// zpjjdfx
zpjjdfx::zpjjdfx()
{
}
zpjjdfx::~zpjjdfx()
{
}
extern char cGraphColor[][16];
extern int iGraphColorNum;
/////////////////////////////////////////////////////////////////////////////
// zpjjdfx message handlers
void zpjjdfx::ZPJJDJS()
{
//P分析计算的点数 [[[[ Pfxjsds
double csz[8][8];
double Rjsjg[21][501];
double jsjg[21][501];
double Tjsjg[21][501];
double DVW,Pdcyl,Pjkyl,Tdcwd,Tjkwd,PLI,qcs,pcs,GWR,Pb;
double Fw,DIC,DIT1,DVT1,DIT2,DVT2,RR,Dvc,Doc,Psep,OG,GG,CO2,H2S,cyzsz;
double N2,GW,NaCl,DLTQ,RR1,RR2,RR3,TG,PC,TC,Qzdz,Pzdz,PWF,Prswl;
double P0,QO,QW,QG,P1,L,DOL,T0,PN,P,Q,Q1,Q2,PI1,PI2,PO1,PO2,DIT,GWR1;
double pliwl,qbwl,qomaxwl,qtmaxwl,pbwl;
CString fileDialogFilter2,fileDialogExt2;
CString A,B,templs1,templs2,A1,A2,jsff,title,Title;
char Temp[100],Temp1[100];
int fxcsgs[8],J,i,K,Pjkylfx,Pygccfx,Pdcylfx,Pqybfx,Pcyzsfx,MMPF,jszs;
int Pfxjsds,Ndclrtx,Nyglctx,ni;
int iColorIndex = 0; // 颜色索引 lzj
// SetCursor(LoadCursor(NULL, IDC_WAIT));
//赋初值
Qomax=0;Qtmax=0;QB=0;PLIZZZ=0;PLIwl=0;QBwl=0;Qomaxwl=0;Qtmaxwl=0;Pbwl=0;
for(i=0;i<8;i++)
{
for(J=0;J<8;J++)
{
csz[i][J]=0;
}
}
for(i=0;i<21;i++)
{
for(J=0;J<501;J++)
{
Rjsjg[i][J]=0;
jsjg[i][J]=0;
Tjsjg[i][J]=0;
}
}
DVW=0;Pdcyl=0;Pjkyl=0;Tdcwd=0;Tjkwd=0;PLI=0;qcs=0;pcs=0;GWR=0;Pb=0;
Fw=0;DIC=0;DIT1=0;DVT1=0;DIT2=0;DVT2=0;RR=0;Dvc=0;Doc=0;Psep=0;
OG=0;GG=0;CO2=0;H2S=0;cyzsz=0;N2=0;GW=0;NaCl=0;DLTQ=0;RR1=0;RR2=0;
RR3=0;TG=0;PC=0;TC=0;Qzdz=0;Pzdz=0;PWF=0;Prswl=0;P0=0;QO=0;QW=0;
QG=0;P1=0;L=0;DOL=0;T0=0;PN=0;P=0;Q=0;Q1=0;Q2=0;PI1=0;PI2=0;PO1=0;
PO2=0;DIT=0;GWR1=0;pliwl=0;qbwl=0;qomaxwl=0;qtmaxwl=0;pbwl=0;
yqsxz csjs;
LZXJD qjd;
Ndclrtx=0;//修改
Nyglctx=0;
g_iProgress = 5; // 计算进度
ENDCOMPUTE;
//-----------------------
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);
Pjkyl=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(4, 5);
Tdcwd=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);
qcs=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(8, 5);
pcs=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);
DIC=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(11, 5);
DIT1=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(12, 5);
DVT1=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(13, 5);
DIT2=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(14, 5);
DVT2=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(15, 5);
RR=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(16, 5);
Dvc=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(17, 5);
Doc=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(18, 5);
Psep=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(19, 5);
GG=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(20, 5);
CO2=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(21, 5);
H2S=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);
GW=atof(str);
str = ((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_grid.GetTextRC(24, 5);
NaCl=atof(str);
int k=24;
for(i=1;i<=5;i++)
{
for(int 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_Page2.GetDlgItem(IDC_CHECK1))->GetCheck();
Pygccfx = ((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page2.GetDlgItem(IDC_CHECK2))->GetCheck();
Pdcylfx = ((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page2.GetDlgItem(IDC_CHECK3))->GetCheck();
Pqybfx = ((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page2.GetDlgItem(IDC_CHECK4))->GetCheck();
Pcyzsfx = ((CButton*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page2.GetDlgItem(IDC_CHECK5))->GetCheck();
MMPF = ((CComboBox*)((CCVenusApp*)AfxGetApp())->m_pMainDlg->m_Page2.GetDlgItem(IDC_COMBO1))->GetCurSel();
MMPF=MMPF+1;
//--------------------------
for(i=1;i<=5;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<=5;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] * 2;
}
if( Pdcylfx == 1)
{
jszs = jszs + 2;
}
if(Pqybfx == 1)
{
jszs = jszs + fxcsgs[4];
}
if( Pcyzsfx == 1)
{
jszs = jszs + fxcsgs[5];
}
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多相流方法";
}
Fw = 1;
Pb = Pdcyl;
rjIPR(PLI, qcs, pcs, Pdcyl, Pb, Fw);
//打开保存计算结果的文件
/* fileDialogFilter2 ="Data files (*.RNW)|*.RNW|All files (*.*)|*.*||";
fileDialogExt2 = "RNW";
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(fileDialog2.GetPathName(),CFile::modeCreate|CFile::modeWrite);
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
{
f3.WriteString("\n");
// title="$$";
// title="\t"+title+"\t"+" 节点分$0"+"\t"+"析计算结$0"+"\t"+"果$0"+"\n";
title="\t\t$$节点分析计算结果$0\n";
f3.WriteString(title);
f3.WriteString("\n");
}
catch (CFileException exception3)
{
AfxMessageBox("Error reading file");
return;
}
//打开保存计算的图形结果的文件
CStdioFile f4;
CFileException exception4;
/* templs1=fileDialog2.GetPathName();
templs2=templs1.Left(templs1.GetLength()-3);
templs1=templs2+"GNW";
status1 = f4.Open(templs1,CFile::modeCreate|CFile::modeWrite);*/
// 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;
}
//参数变换及计算有关参数值
Rjsjg[0][0] = int(0.05 * Qtmax);
if( Rjsjg[0][0] > 2)
{
Rjsjg[0][0] = 2;
}
for(J=1;J<=500;J++)//修改了J的最大值
{
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] > 5 * Qtmax)
{
break;
}
}
H2S = H2S / 100;
CO2 = CO2 / 100;
N2 = N2 / 100;
if( RR == 0)
{
RR1 = 0.05 / (DIT1 + 0.000001);
RR2 = 0.05 / (DIT2 + 0.000001);
RR3 = 0.05 / (DIC + 0.000001);
}
else
{
RR1 = RR;
RR2 = RR;
RR3 = RR;
}
DIT1 = DIT1 / 1000;
DIT2 = DIT2 / 1000;
DIC = DIC / 1000;
Tjkwd = Tjkwd + 273.15;
Tdcwd = Tdcwd + 273.15;
TG = (Tdcwd - Tjkwd) / DVW;
csjs.trqnjcs(GG, H2S, CO2,1);//临界参数
PC=csjs.Pc;//对比压力
TC=csjs.Tc;//对比温度
g_iProgress = 10; // 计算进度
ENDCOMPUTE;
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;
}
}
//流入关系计算
if( Ndclrtx == 0)
{
// goto Gdclr;
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;
}
wlipr(Prswl, PLI, QB, Qomax, Qtmax, Pdcyl, Pb, Fw);
pliwl=PLIwl;
qbwl=QBwl;
qomaxwl=Qomaxwl;
qtmaxwl=Qtmaxwl;
pbwl=Pbwl;
for(J=0;J<=Pfxjsds;J++)
{
PWF=YQPWF(Rjsjg[0][J], pliwl, qbwl, qomaxwl, qtmaxwl, Prswl, Pbwl, Fw);
if( PWF <= 0)
{
PWF = 0;
Rjsjg[i + 1][J] = 0.1;
break;
}
else
{
Rjsjg[i + 1][J] = PWF;
}
}
}
}
Qzdz = 0;
Pzdz = 0;
for(J=0;J<=Pfxjsds;J++)
{
if( J > 2 && Rjsjg[1][J] <= 0)
{
break;
}
gcvt(Rjsjg[0][J],30,Temp);
templs1=Temp;
//templs1.Format("%f", Rjsjg[0][J]);
gcvt(Rjsjg[1][J],30,Temp1);
templs2=Temp1;
templs1=" "+templs1+" "+templs2+"\n";
try
{
f4.WriteString(templs1);
}
catch (CFileException exception4)
{
AfxMessageBox("Error reading file");
return;
}
jsjg[0][J] = Rjsjg[0][J];
jsjg[1][J] = Rjsjg[1][J];
if( Qzdz <= Rjsjg[0][J])
{
Qzdz = Rjsjg[0][J];
}
if( Pzdz <= Rjsjg[1][J])
{
Pzdz = Rjsjg[1][J];
}
}
try
{
f4.WriteString("-1 -1\n");
// f4.WriteString(" 0 1\n");
f4.WriteString(cGraphColor[iColorIndex++]);
iColorIndex %= iGraphColorNum;
gcvt(Pdcyl,30,Temp);
templs1=Temp;
templs1.TrimLeft();
templs1.TrimRight();
templs1="IPR[Prs="+templs1+"(MPa)]"+"\n";
f4.WriteString(templs1);
}
catch (CFileException exception4)
{
AfxMessageBox("Error reading file");
return;
}
g_iProgress = 18; // 计算进度
ENDCOMPUTE;
//流出关系计算
for(i=1;i<=fxcsgs[1];i++)
{
P0 = csz[1][i]; //分析的井口压力值
if( P0 == 0)
{
break;
}
for(J=2;J<=Pfxjsds;J++)
{
QW = Rjsjg[0][J];
QG = QW * GWR;
P1 = P0;
for(K=1;K<=3;K++)
{
if( K == 1)
{
L = DVT1;
DOL = DIT1;
T0 = Tjkwd;
}
else if( K == 2)
{
L = DVT2;
DOL = DIT2;
T0 = Tjkwd + TG * DVT1;
}
else if( K == 3)
{
L = DVW - DVT1 - DVT2;
DOL = DIC;
T0 = Tjkwd + TG * (DVT1 + DVT2);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -