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

📄 slb.cpp

📁 这是本人两年前兼职为某个公司做的石油钻进设计软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	  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;
	  }
	  try
	  {
		  f3.WriteString("\n");
		  //			title="";
		  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+"GNJ";			  
	  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;
	   }
	   //参数变换及计算有关参数
	   if( RR == 0)
	   {
		   RR = 0.0008;
	   }
	   DIT = DIT / 1000;
	   DIC = DIC / 1000;
	   DOT = DOT / 1000;
	   H2S = H2S / 100;
	   CO2 = CO2 / 100;
	   N2 = N2 / 100;
	   //射流泵损失系数(Kj, Ks, Kt, Kd, Ktd, Ic, GWR, 0.3, Ra, D损失系数)
	   slbssxs(GWR, 0.3, Ra, dssxs);
	   Kj=KJ;
	   Ks=KS;
	   Kt=KT;
	   Kd=KD;
	   Ktd=KTD;
	   Ic=IC;
	   //天然气的临界参数(PC, TC, GG, H2S, CO2, "干气")
	   csjs.trqnjcs(GG, H2S, CO2,1);
	   PC=csjs.Pc;//对比压力
	   TC=csjs.Tc;//对比温度
	   TG = (tdiceng - tjingkou) / DVW;
	   tjingkou = tjingkou + 273.15;
	   tdiceng = tdiceng + 273.15;
	   TJP = tjingkou + TG * DJP;
	   k=int(10000 * pow((pzzj[NJ] / hdzj[NT]),2));
	   Ra = double(k) / 10000.0;
	   gcvt(NJ,95,temp);
	   title=temp;
	   title.TrimLeft();
	   if( NT == NJ - 1)
	   {  
		   JPt = title + "X";
	   }
	   else if( NT == NJ)
	   {
		   
		   JPt = title + "A";
	   }
	   else if( NT == NJ + 1)
	   {
		   JPt = title + "B";
	   }
	   else if( NT == NJ + 2)
	   {
		   JPt = title + "C";
	   }
	   else if( NT == NJ + 3)
	   {
		   JPt = title + "D";
	   }
	   else
	   {
		   JPt = title + "E";
	   }
	   AJ = 3.14159 / 4 * pow(pzzj[NJ],2);  //实际喷嘴的面积
	   
	   DLTP = 0.25;
	   k=int(Prs / DLTP);
	   djsylds = k + 1;
	   
	   pzuida = Prs;
	   for(i=1;i<=5;i++)
	   {
		   if( pzuida < canshu[2][i])
		   {
			   pzuida = canshu[2][i];
		   }
	   }
	   //主窗口.SSPanel1.FloodPercent = 1
	   //百分比累计 = 1
	   
	   //开始分析计算
	   for(i=1;i<=6;i++)
	   {
		   for(int ii=0;ii<=19;ii++)
		   {
			   for(JJ=0;JJ<=199;JJ++)
			   {
				   jieguo[ii][JJ] = 0;
			   }
		   }
		   title="";
		   switch(i)
		   {
		   case 1:
			   if( fjkyl == 0)
			   {
				   goto nonecomp;
			   }
			   try
			   {
				   f3.WriteString("\n");
				   title=title+"\t\t\t"+"[井口压力分析]$0\n";
				   f3.WriteString(title);
			   }
			   catch (CFileException exception3)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   try
			   {
				   title="$$";
				   title=title+"射流泵排水采气井口压力分析\n";
				   f4.WriteString(title);
			   }
			   catch (CFileException exception4)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   fxcs0 = "井口压力";
			   fxcs = "Pwh=";
			   BFB[i] = 1;
			   break;
		   case 2:
			   if( fdcyl == 0)
			   {
				   goto nonecomp;
			   }
			   try
			   {
				   f3.WriteString("\n");
				   title=title+"\t\t\t"+"[地层压力分析]$0"+"\n";
				   f3.WriteString(title);
			   }
			   catch (CFileException exception3)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   try
			   {
				   title="$$";
				   title=title+"射流泵排水采气地层压力分析\n";
				   f4.WriteString(title);
			   }
			   catch (CFileException exception4)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   fxcs0 = "地层压力";
			   fxcs = "Pr=";
			   BFB[i] = 1;
			   break;
		   case 3:
			   if( fcyzs == 0)
			   {
				   goto nonecomp;
			   }
			   try
			   {
				   f3.WriteString("\n");
				   title=title+"\t\t\t"+"[产液指数分析]$0"+"\n";
				   f3.WriteString(title);
			   }
			   catch (CFileException exception3)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   try
			   {
				   title="$$";
				   title=title+"射流泵排水采气产液指数分析\n";
				   f4.WriteString(title);
			   }
			   catch (CFileException exception4)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   fxcs0 = "产液指数";
			   fxcs = "PLI=";
			   BFB[i] = 1;
			   break;
		   case 4:
			   if( fqsb == 0)
			   {
				   goto nonecomp;
			   }
			   try
			   {
				   f3.WriteString("\n");
				   title=title+"\t\t\t"+"[气水比分析]$0"+"\n";
				   f3.WriteString(title);
			   }
			   catch (CFileException exception3)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   title1="";
			   try
			   {
				   title="$$";
				   title=title+"射流泵排水采气气水比分析\n";
				   f4.WriteString(title);
			   }
			   catch (CFileException exception4)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   fxcs0 = "气水比";
			   fxcs = "GWR=";
			   BFB[i] = 1;
			   break;
		   case 5:
			   if( fbgsd == 0)
			   {
				   goto nonecomp;
			   }
			   try
			   {
				   f3.WriteString("\n");
				   title=title+"\t\t\t"+"[泵挂深度分析]$0"+"\n";
				   f3.WriteString(title);
			   }
			   catch (CFileException exception3)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   try
			   {
				   title="$$";
				   title=title+"射流泵排水采气泵挂深度分析\n";
				   f4.WriteString(title);
			   }
			   catch (CFileException exception4)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   fxcs0 = "泵挂深度";
			   fxcs = "Djp=";
			   BFB[i] = 1;
			   break;
		   case 6:
			   if( fdmby == 0)
			   {
				   goto nonecomp;
			   }
			   try
			   {
				   f3.WriteString("\n");
				   title=title+"\t\t\t"+"[地面泵压分析]$0"+"\n";
				   f3.WriteString(title);
			   }
			   catch (CFileException exception3)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   try
			   {
				   title="$$";
				   title=title+"射流泵排水采气地面泵压分析\n";
				   f4.WriteString(title);
			   }
			   catch (CFileException exception4)
			   {
				   AfxMessageBox("Error reading file");
				   return;
			   }
			   fxcs0 = "地面泵压";
			   fxcs = "Pp=";
			   BFB[i] = 1;
			   break;
		}
		try
		{
			f4.WriteString("节点压力最小值,MPa:\n");
            f4.WriteString("节点压力最大值,MPa:\n");
            f4.WriteString("产水量最小值,m^3/d:\n");
            f4.WriteString("产水量最大值,m^3/d:\n");
            f4.WriteString("Pn\n");
            f4.WriteString("Qw\n");
            f4.WriteString("Pn__MPa\n");
            f4.WriteString("Qw__m^3/d\n");
            f4.WriteString(" 1\n");
		}
		catch (CFileException exception4)
		{
			AfxMessageBox("Error reading file");
			return;
		}
        A="";
		A = A+" 节 点$7" + "\t" + " 气 蚀$7";
		for(JJ=1;JJ<=fxcsgs[i];JJ++)
		{
			gcvt(canshu[i][JJ],95,temp);
			title=temp;
			title.TrimLeft();
			A = A + "\t" + fxcs0 + "=" + title+ "$5" + "\t"  + "$6";
		}
		A=A+"\n";
		try
		{
			f3.WriteString(A);
		}
		catch (CFileException exception3)
		{
			AfxMessageBox("Error reading file");
			return;
		}
		A="";
		A =A+ " 压 力$3" + "\t" + " 排水量$3";
		for(JJ=1;JJ<=fxcsgs[i];JJ++)
		{
			A = A + "\t" + " 井  的$7" + "\t" + " 泵  的$7";
		}
		A=A+"\n";
		try
		{
			f3.WriteString(A);
		}
		catch (CFileException exception3)
		{
			AfxMessageBox("Error reading file");
			return;
		}
		A="";
		A =A+ "  MPa$11" + "\t" + " m^3/d$11";
		for(JJ=1;JJ<=fxcsgs[i];JJ++)
		{
			A = A + "\t" + " 产水量$11" + "\t" + " 排水量$11";
		}
		A=A+"\n";
		try
		{
			f3.WriteString(A);
		}
		catch (CFileException exception3)
		{
			AfxMessageBox("Error reading file");
			return;
		}
		//If i > 1 Then 百分比累计 = 百分比累计 + 99 * 分析参数个数(i - 1) / 计算总数 * BFB(i - 1)
		double	dAddStep, dAddTotal;
		dAddStep = 45.0 / djsylds; dAddTotal = g_iProgress;
        for(J=1;J<=2 * djsylds;J++, g_iProgress = int(dAddTotal+=dAddStep))		
		{
	ENDCOMPUTE;
			//If J < D计算压力点数 Then 百分比 = Int(百分比累计 + 99 * 分析参数个数(i) / 计算总数 * J / D计算压力点数)
			//主窗口.SSPanel1.FloodPercent = 百分比      
			PS = 5 + J * DLTP;
			if( i == 2)
			{
				if( PS > pzuida + 1)
				{
					break;
				}
			}
			else
			{
				if( PS > Prs + 1)
				{
					break;
				}
			}
			jieguo[0][J] = PS;
			for(int K=1;K<=fxcsgs[i];K++)
			{
				if( i != 1)//分析井口压力
				{
					jkyl = Pwh;
				}
				else
				{
					jkyl = canshu[1][K];
				}
				if( i != 2)//分析地层压力
				{
					dcyl = Prs;
				}
				else
				{
					dcyl = canshu[2][K];
				}
				if( i != 3)//分析产液指数
				{
					cyzs = PLI;
				}
				else
				{
					cyzs = canshu[3][K];
				}
				if( i != 4)//分析产气量
				{
					qishuibi = GWR;
				}
				else
				{
					qishuibi = canshu[4][K];
				}
				if( i != 5)//分析泵挂深度
				{
					bgsd = DJP;
				}
				else
				{
					bgsd = canshu[5][K];
				}
				if( i != 6)//分析地面泵压
				{
					dmby = Pft;
				}
				else
				{
					dmby = canshu[6][K];
				}
				//计算流入关系(IPR)和气蚀关系
				if( ((i == 1 || i == 6) && K == 1) || (i == 4 && (K == 1 || DVW > DJP)) || i == 2 || i == 3 || i == 5)
				{
					//入井动态关系IPR(产液指数, QB, Qomax, Qtmax, q测试, p测试, Prs, Pb, Fw)
					zpjjs.rjIPR(cyzs, qceshi, pceshi, Prs, Pb, Fw);

⌨️ 快捷键说明

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