⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slbdtfx.cpp

📁 这是本人两年前兼职为某个公司做的石油钻进设计软件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	   AfxMessageBox(szMsg);
	   return;
	}

	stdfRes.WriteString(_T("\n"));
	if(dblFW == 1)
		stdfRes.WriteString(_T("\t\t射流泵排水采气动态分析计算结果$0\n"));
	else
		stdfRes.WriteString(_T("\t\t射流泵排水采油动态分析计算结果$0\n"));

	// 打开保存计算的图形结果的文件
	CStdioFile stdfGraph;
	
	if(((CCVenusApp*)AfxGetApp())->m_cBaseFileLeft.IsEmpty())
	{	
		strTemp = ((CCVenusApp*)AfxGetApp())->GetOpenFileName(2);
		if(strTemp.IsEmpty()) return;
	}
	else
	{
		strTemp = ((CCVenusApp*)AfxGetApp())->m_cBaseFileLeft +  _T(".GSJ");
	}

	bStatus = stdfGraph.Open(strTemp,CFile::modeCreate|CFile::modeWrite);
	if(!bStatus)
	{
	   TCHAR szMsg[100];
	   sprintf(szMsg, "Error opening file for reading. Code:%d",
		   fe.m_cause);
	   AfxMessageBox(szMsg);
	   return;
	}
	
	// 参数变换及计算有关参数
	if(dblRR == 0)
		dblRR = 0.0008;

	dblDIT = dblDIT / 1000;
	dblDIC = dblDIC / 1000;
	dblDOT = dblDOT / 1000;
	dblH2S = dblH2S / 100;
	dblCO2 = dblCO2 / 100;
	dblN2 = dblN2 / 100;
	
	// Call 射流泵损失系数(dblKj, dblKs, dblKt, dblKd, dblKtd, dblIc, GLR, 0.3, dblRa, D损失系数)
	
	slb SHlb;
	double dblRa = 0;
	double dblKJ = 0;
	double dblKS = 0;
	double dblKT = 0;
	double dblKD = 0;
	double dblKTD = 0;
	double dblIC = 0;
	double dblPC = 0;
	double dblTC = 0;
	double dblTG = 0;
	double dblTJP = 0;

	SHlb.slbssxs(dblGLR, 0.3, dblRa, int(dblDSSXS));
	dblKJ = SHlb.KJ;
	dblKS = SHlb.KS;
	dblKT = SHlb.KT;
	dblKD = SHlb.KD;
	dblKTD = SHlb.KTD;
	dblIC = SHlb.IC;

	//天然气的临界参数(PC, TC, dblGG, dblH2S, dblCO2, "干气")
	csjs.trqnjcs(dblGG, dblH2S, dblCO2,1);
	dblPC = csjs.Pc;//对比压力
	dblTC = csjs.Tc;//对比温度
	
	dblTG = (dblTDC - dblTJK)/ dblDVW;
	dblTJK += 273.15;
	dblTDC += 273.15;
	dblTJP = dblTJK + dblTG * dblDJP;
	
	CString strJPT;
	strTemp.Format(_T("%d"), iNJ);
	dblRa = 10000 * pow(dblPzzj[iNJ] / dblHdzj[iNT], 2) / 10000;
	if(iNT == iNJ -1)
		strJPT = strTemp + _T("X");
	else if(iNT == iNJ)
		strJPT = strTemp + _T("A");
	else if(iNT == iNJ + 1)
		strJPT = strTemp + _T("B");
	else if(iNT == iNJ + 2)
		strJPT = strTemp + _T("C");
	else if(iNT == iNJ + 3)
		strJPT = strTemp + _T("D");
	else
		strJPT = strTemp + _T("E");

	double dblAJ = 0;
	double dblDLTP = 0;
	dblAJ = 3.14159 / 4 * pow(dblPzzj[iNJ], 2);
	dblDLTP = 0.25;
	int iDJYLDS = int(dblPrs / dblDLTP) + 1;

	double dblPMax = 0;
	dblPMax = dblPrs;
	for(iTemp01 = 0; iTemp01 < 5; iTemp01++)
	{
		if(dblPMax < dblCSZ[1][iTemp01])
			dblPMax = dblCSZ[1][iTemp01];

	}

  // 主窗口.SSPanel1.FloodPercent = 1
  //百分比累计 = 1
	int iPercent = 1;

	CString strFxcs0,strFxcs, strA,strA1,strA2;
	double dblBFB[7],dblPY[7],dblQX[7];
	double dblQ = 0;
	double dblQ1 = 0;
	double dblQ2 = 0;
	double dblPI1 = 0;
	double dblPO1 = 0;
	double dblPI2 = 0;
	double dblPO2 = 0;
	double dblPS = 0;
	double dblPN = 0;
	double dblQG = 0;
	double dblQW = 0;
	double dblQS = 0;
	double dblQN = 0;
	double dblDOL = 0;
	double dblPWF = 0;
	double dblJKYL,dblDCYL,dblCYZS,dblQYB,dblBGSD,dblDMBY,dblQS0,dblNDO;
	double dblPLIWL,dblQBWL,dblQoMaxWL,dblQtMaxWL,dblPBWL,dblQNW,dblQNO,dblNLG;
	double dblDIL,dblQO,dblL1,dblL2,dblT0,dblPcom,dblQSC,dblKj,dblQN0,dblVf;
	double dblM,dblM0,dblKs,dblKt,dblKd,dblKtd,dblIc,dblPD,dblH,dblX1,dblX2,dblP,dblQXMax,dblPYMax;

	int iK, iYjjsdds,iColorIndex;
	CString strDDLY;
	qjyhsj qjyljsz;
	LZXJD lzxjdjs;
	


   for(iTemp02=0;iTemp02<=19;iTemp02++)
   {
	   for(iTemp03=0;iTemp03<=199;iTemp03++)
	   {
		   dblResult[iTemp02][iTemp03] = 0;
	   }
   }

   g_iProgress = 10;

//	AfxMessageBox(strA1);
	//开始分析计算
	for(iTemp01=1;iTemp01<=6;iTemp01++)
	{  // dblResult[20][200]
//		AfxMessageBox(strA1);
	   strTitle="";
	   switch(iTemp01)
	   {
//AfxMessageBox(strA1);
	   case 1:
		   if( dblFPJK == 0)
		   {
			   continue;
		   }
		   try
		   {
			   stdfRes.WriteString("\n");
			   strTitle=strTitle+"\t\t\t"+"[井口压力分析]$0\n";
			   stdfRes.WriteString(strTitle);
		   }
		   catch (CFileException exception3)
		   {
			   AfxMessageBox("Error reading file");
			   return;
		   }
		   try
		   {
			   strTitle="$$";
			   strTitle=strTitle+"射流泵排水采气井口压力分析 \n";
			   stdfGraph.WriteString(strTitle);
		   }
		   catch (CFileException exception4)
		   {
			   AfxMessageBox("Error reading file");
			   return;
		   }
		   strFxcs0 = "井口压力";
		   strFxcs = "Pwh=";
		   dblBFB[iTemp01] = 1;
		   break;
	   case 2:
		   if( dblFPDC == 0)
		   {
			   continue;
		   }
		   try
		   {
			   stdfRes.WriteString("\n");
			   strTitle=strTitle+"\t\t\t[地层压力分析]$0"+"\n";
			   stdfRes.WriteString(strTitle);
		   }
		   catch (CFileException exception3)
		   {
			   AfxMessageBox("Error reading file");
			   return;
		   }
		   try
		   {
			   strTitle="$$";
			   strTitle=strTitle+"射流泵排水采气地层压力分析\n";
			   stdfGraph.WriteString(strTitle);
		   }
		   catch (CFileException exception4)
		   {
			   AfxMessageBox("Error reading file");
			   return;
		   }
		   strFxcs0 = "地层压力";
		   strFxcs = "Pr=";
		   dblBFB[iTemp01] = 1;
		   break;
	   case 3:
		   if( dblFCYZS == 0)
		   {
			   continue;
		   }
		   try
		   {
			   stdfRes.WriteString("\n");
			   strTitle=strTitle+"\t\t\t"+"[产液指数分析]$0"+"\n";
			   stdfRes.WriteString(strTitle);
		   }
		   catch (CFileException exception3)
		   {
			   AfxMessageBox("Error reading file");
			   return;
		   }
		   try
		   {
			   strTitle="$$";
			   strTitle=strTitle+"射流泵排水采气产液指数分析\n";
			   stdfGraph.WriteString(strTitle);
		   }
		   catch (CFileException exception4)
		   {
			   AfxMessageBox("Error reading file");
			   return;
		   }
		   strFxcs0 = "产液指数";
		   strFxcs = "PLI=";
		   dblBFB[iTemp01] = 1;
		   break;
	   case 4:
		   if( dblFQYB == 0)
		   {
			   continue;
		   }
		   try
		   {
			   stdfRes.WriteString("\n");
			   strTitle=strTitle+"\t\t\t"+"[气液比分析]$0"+"\n";
			   stdfRes.WriteString(strTitle);
		   }
		   catch (CFileException exception3)
		   {
			   AfxMessageBox("Error reading file");
			   return;
		   }
		   strTitle1="";
		   try
		   {
			   strTitle="$$";
			   strTitle=strTitle+"射流泵排水采气气液比分析\n";
			   stdfGraph.WriteString(strTitle);
		   }
		   catch (CFileException exception4)
		   {
			   AfxMessageBox("Error reading file");
			   return;
		   }
		   strFxcs0 = "气液比";
		   strFxcs = "GLR=";
		   dblBFB[iTemp01] = 1;
		   break;
	   case 5:
		   if( dblFBGSD == 0)
		   {
			   continue;
		   }
		   try
		   {
			   stdfRes.WriteString("\n");
			   strTitle=strTitle+"\t\t\t"+"[泵挂深度分析]$0"+"\n";
			   stdfRes.WriteString(strTitle);
		   }
		   catch (CFileException exception3)
		   {
			   AfxMessageBox("Error reading file");
			   return;
		   }
		   try
		   {
			   strTitle="$$";
			   strTitle=strTitle+"射流泵排水采气泵挂深度分析\n";
			   stdfGraph.WriteString(strTitle);
		   }
		   catch (CFileException exception4)
		   {
			   AfxMessageBox("Error reading file");
			   return;
		   }
		   strFxcs0 = "泵挂深度";
		   strFxcs = "Djp=";
		   dblBFB[iTemp01] = 1;
		   break;
	   case 6:
		   if( dblFDMBY == 0)
		   {

			   continue;
		   }
		   try
		   {
			   stdfRes.WriteString("\n");
			   strTitle=strTitle+"\t\t\t[地面泵压分析]$0\n";
			   stdfRes.WriteString(strTitle);
		   }
		   catch (CFileException exception3)
		   {
			   AfxMessageBox("Error reading file");
			   return;
		   }
		   try
		   {
			   strTitle="$$";
			   strTitle=strTitle+"射流泵排水采气地面泵压分析\n";
			   stdfGraph.WriteString(strTitle);
		   }
		   catch (CFileException exception4)
		   {
			   AfxMessageBox("Error writing file");
			   return;
		   }
		   strFxcs0 = "地面泵压";
		   strFxcs = "Pp=";
		   dblBFB[iTemp01] = 1;
		   break;
//AfxMessageBox(strA1);
		}	// switch

//AfxMessageBox(strA1);
		try
		{
			stdfGraph.WriteString("节点压力最小值,MPa:\n");
			stdfGraph.WriteString("节点压力最大值,MPa:\n");
			stdfGraph.WriteString("产水量最小值,m^3/d:\n");
			stdfGraph.WriteString("产水量最大值,m^3/d:\n");
			stdfGraph.WriteString("Pn \n");
			stdfGraph.WriteString("Qw \n");
			stdfGraph.WriteString("Pn__MPa \n");
			stdfGraph.WriteString("Qw__m^3/d \n");
			stdfGraph.WriteString(" 1 \n");
		}
		catch (CFileException exception4)
		{
			AfxMessageBox("Error writing file");
			return;
		}

//AfxMessageBox(strA1);
		strA="";
		strA = strA+" 节 点$7\t 气 蚀$7";
		for(iTemp03=1;iTemp03<=iFXCount[iTemp01];iTemp03++)
		{
			gcvt(dblCSZ[iTemp01][iTemp03],95,szTemp);
			strTitle=szTemp;
			strTitle.TrimLeft();
			strA = strA + "\t" + strFxcs0 + "=" + strTitle+ "$5\t$6";
		}
		strA=strA+"\n";
		try
		{
			stdfRes.WriteString(strA);
		}
		catch (CFileException exception3)
		{
			AfxMessageBox("Error reading file");
			return;
		}
		strA="";
		strA =strA+ " 压 力$3\t 排水量$3";
		for(iTemp03=1;iTemp03<=iFXCount[iTemp01];iTemp03++)
		{
			strA = strA + "\t 井  的$7\t 泵  的$7";
		}
		strA=strA+"\n";
		try
		{
			stdfRes.WriteString(strA);
		}
		catch (CFileException exception3)
		{
			AfxMessageBox("Error reading file");
			return;
		}
		strA="";
		strA =strA+ "  MPa$11\t m^3/d$11";
		for(iTemp03=1;iTemp03<=iFXCount[iTemp01];iTemp03++)
		{
			strA = strA + "\t 产水量$11\t 排水量$11";
		}
		strA=strA+"\n";
		try
		{
			stdfRes.WriteString(strA);
		}
		catch (CFileException exception3)
		{
			AfxMessageBox("Error writing file");
			return;
		}
		//If iTemp01 > 1 Then 百分比累计 = 百分比累计 + 99 * 分析参数个数(iTemp01 - 1) / 计算总数 * dblBFB(iTemp01 - 1)
	//AfxMessageBox(strA1);
		for(iTemp04=1;iTemp04<=2 * iDJYLDS;iTemp04++ )		
		{
			//If iTemp04 < D计算压力点数 Then 百分比 = Int(百分比累计 + 99 * 分析参数个数(iTemp01) / 计算总数 * iTemp04 / D计算压力点数)
			//主窗口.SSPanel1.FloodPercent = 百分比      
			dblPS = 1.25 + iTemp04 * dblDLTP;
			if( iTemp01 == 2)
			{
				if( dblPS > dblPMax + 1)
				{
					break;
				}
			}
			else
			{
				if( dblPS > dblPrs + 1)
				{
					break;
				}
			}
			dblResult[0][iTemp04] = dblPS;
			for(int iTemp05=1;iTemp05<=iFXCount[iTemp01];iTemp05++)
			{
				if( iTemp01 != 1)//分析井口压力
				{
					dblJKYL = dblPwh;
				}
				else
				{
					dblJKYL = dblCSZ[1][iTemp05];
				}
				if( iTemp01 != 2)//分析地层压力
				{
					dblDCYL = dblPrs;
				}
				else
				{
					dblDCYL = dblCSZ[2][iTemp05];
				}
				if( iTemp01 != 3)//分析产液指数
				{
					dblCYZS = dblPLI;
				}
				else
				{
					dblCYZS = dblCSZ[3][iTemp05];
				}
				if( iTemp01 != 4)//分析产气量
				{
					dblQYB = dblGLR;
				}
				else
				{
					dblQYB = dblCSZ[4][iTemp05];
				}
				if( iTemp01 != 5)//分析泵挂深度
				{
					dblBGSD = dblDJP;
				}
				else
				{
					dblBGSD = dblCSZ[5][iTemp05];
				}
				if( iTemp01 != 6)//分析地面泵压
				{
					dblDMBY = dblPft;
				}
				else
				{
					dblDMBY = dblCSZ[6][iTemp05];
				}
				//计算流入关系(IPR)和气蚀关系
				if( ((iTemp01 == 1 || iTemp01 == 6) && iTemp05 == 1) || (iTemp01 == 4 && (iTemp05 == 1 || dblDVW > dblDJP)) || iTemp01 == 2 || iTemp01 == 3 || iTemp01 == 5)
				{
					//入井动态关系IPR(产液指数, QB, Qomax, Qtmax, q测试, p测试, dblPrs, Pb, dblFW)
					zpjjs.rjIPR(dblCYZS, dblQCS, dblPCS, dblPrs, dblPB, dblFW);
					dblQB=zpjjs.QB;
					dblQoMax=zpjjs.Qomax;
					dblQtMax=zpjjs.Qtmax;
					dblCYZS=zpjjs.PLIZZZ;
					dblQS0 = 0;
					dblNDO = 0;
					do
					{
						dblNDO = dblNDO + 1;
						dblQS = (dblQS + dblQS0) / 2;
						dblQS0 = dblQS;
						dblQW = dblQS * dblFW;
						dblQO = dblQS * (1 - dblFW);
						dblQG = dblQS * dblQYB;
						dblTJP = dblTJK + dblTG * dblBGSD;
						dblL1 = dblDVT - dblBGSD;
						dblL2 = dblDVW - dblDVT;
						if( dblL1 < 0)
						{
							dblL2 = dblL2 - dblL1;
							dblL1 = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -