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

📄 zpjjdfx.cpp

📁 这是本人两年前兼职为某个公司做的石油钻进设计软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
				if( P > 0)
				{
					P = int(100 * P);
					P=P/ 100;
				}
				if( Q > 0)
				{
					Q = int(100 * Q);
					Q=Q/ 100;
				}
				gcvt(P,30,Temp);
				templs1=Temp;
				A1 = A1 + "\t" + templs1;
				gcvt(Q,30,Temp1);
				templs2=Temp1;
				A2 = A2 + "\t" + templs2;;
			}
			A1=A1+"\n";
			A2=A2+"\n";
			try
			{
				f3.WriteString(A1);
				f3.WriteString(A2);
				f3.WriteString("\n");
			}
			catch (CFileException exception3)
			{
				AfxMessageBox("Error reading file");
				return;
			}    
	  }
	  
	g_iProgress = 85;	// 计算进度
	ENDCOMPUTE;
	  //产液指数分析
	  if( Pcyzsfx == 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;
			  }
		  }
		  
		  //流入关系计算
		  Qzdz = 0;
		  Pzdz = 0;
		  for(i=1;i<=fxcsgs[5];i++)
		  {
			  if( i == 0)
			  {
				  cyzsz = PLI;
			  }
			  else
			  {
				  cyzsz = csz[5][i];   //分析的cyzsz
			  }
			  if( cyzsz <= 0)
			  {
				  break;
			  }
              rjIPR(cyzsz, qcs, pcs, Pdcyl, Pb, Fw);  
			  
			  for(J=0;J<=Pfxjsds*2;J++)
			  {
				  PWF=YQPWF(Rjsjg[0][J], cyzsz, QB, Qomax, Qtmax, Pdcyl, Pb, Fw);				
				  if( PWF <= 0)
				  {
					  PWF = 0;
					  break;
				  }
				  if( Rjsjg[0][J] <= 0)
				  {
					  PWF = 0;
					  break;
				  }
				  Rjsjg[i + 1][J] = PWF;
				  jsjg[0][J] = Rjsjg[0][J];
				  jsjg[1 + i][J] = Rjsjg[1 + i][J];
				  gcvt(Rjsjg[0][J],30,Temp);
				  templs1=Temp;
				  gcvt(Rjsjg[1 + i][J],30,Temp1);
				  templs2=Temp1;
				  templs1=" "+templs1+ " "+templs2+"\n";
				  try
				  {
					  f4.WriteString(templs1);
				  }
				  catch (CFileException exception4)
				  {
					  AfxMessageBox("Error reading file");
					  return;
				  }			  			
				  if( Qzdz <= Rjsjg[0][J])
				  {
					  Qzdz = Rjsjg[0][J];
				  }
				  if( Pzdz <= Rjsjg[1 + i][J])
				  {
					  Pzdz = Rjsjg[1 + i][J];
				  }
			  }
              try
			  {
				  f4.WriteString("-1 -1\n");
				  //  				   f4.WriteString(" 0             1\n");
				  f4.WriteString(cGraphColor[iColorIndex++]);
				  iColorIndex %= iGraphColorNum;
			  }
			  catch (CFileException exception4)
			  {
				  AfxMessageBox("Error reading file");
				  return;
			  }
			  if( i > 0)
			  {
				  gcvt(csz[5][i],30,Temp);
				  templs1=Temp;
                  templs1.TrimLeft();
                  templs1.TrimRight();
                  templs1="PLI="+templs1+"(m^3/d.MPa)"+"\n";
				  try
				  {
					  f4.WriteString(templs1);
				  }
				  catch (CFileException exception4)
				  {
					  AfxMessageBox("Error reading file");
					  return;
				  }
			  }
			  else
			  {
				  gcvt(PLI,30,Temp);
				  templs1=Temp;
                  templs1.TrimLeft();
                  templs1.TrimRight();
                  templs1="PLI="+templs1+"(m^3/d.MPa)"+"\n";
				  try
				  {
					  f4.WriteString(templs1);
				  }
				  catch (CFileException exception4)
				  {
					  AfxMessageBox("Error reading file");
					  return;
				  }
			  }
			  //			  百分比 = 百分比 + Int(1 + 100 / jszs / fxcsgs(5))
			  //			  主窗口.SSPanel1.FloodPercent = 百分比
			}
			
	g_iProgress = 90;	// 计算进度
	ENDCOMPUTE;
			//流出关系计算
			if( Nyglctx == 0)
			{
				//				goto Gyglc;
				Nyglctx = 1;
				if( Pygccfx == 1)
				{
					ni = fxcsgs[2];
				}
				else
				{
					ni = 0;
				}
				for(i=0;i<=ni;i++)
				{
					for(J=0;J<=Pfxjsds;J++)
					{
						QW = Rjsjg[0][J];
						QG = QW * GWR;
						P1 = Pjkyl;
						if( i == 0)
						{
							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);
								}
								if( K == 1 || (K > 1 && L > 0))
								{
									PN=dxl(MMPF,P1, T0, TG, QG, QW, 0, GG, GW, OG, L, DOL, 0, RR, H2S, CO2, N2, NaCl, 0, 1, 1);	
									P1 = PN;
								}
							}
						}
						else
						{
							DOL = csz[2][i] / 1000;
							PN=dxl(MMPF,P1, Tjkwd, TG, QG, QW, 0, GG, GW, OG, DVW, DOL, 0, RR, H2S, CO2, N2, NaCl, 0, 1, 1);	
							P1 = PN;
						}
						Tjsjg[1 + i][J] = int(1000 * P1);
						Tjsjg[1 + i][J]=Tjsjg[1 + i][J]/ 1000;
						if( Tjsjg[1 + i][J] > Pzdz)
						{
							break;
						}
						if( Rjsjg[0][J] > 500 || Rjsjg[0][J] > 0.25 * Qtmax)
						{
							if( Tjsjg[1 + i][J] < 0.5 * Tjsjg[1 + i][J - 1])
							{
								Tjsjg[1 + i][J] = 0;
								break;
							}
						}
					}
				}
			}
			for(J=2;J<=Pfxjsds;J++)
			{
				if( J > 2 && Tjsjg[1][J] <= 0)
				{
					break;
				}
				if( Tjsjg[1][J] > Pdcyl + 5)
				{
					break;
				}
				if( Rjsjg[0][J] > 500 || Rjsjg[0][J] > 0.25 * Qtmax)
				{
					if( Tjsjg[1][J] < 0.5 * Tjsjg[1][J - 1])
					{
						break;
					}
				}
				gcvt(Rjsjg[0][J],30,Temp);
				templs1=Temp;
				gcvt(Tjsjg[1][J],30,Temp1);
				templs2=Temp1;
				templs1=" "+templs1+ " "+templs2+"\n";
				try
				{
					f4.WriteString(templs1);
					
				}
				catch (CFileException exception4)
				{
					AfxMessageBox("Error reading file");
					return;
				}			  			
				jsjg[1][J] = Tjsjg[1][J];
				if( Qzdz <= Rjsjg[0][J] || Pzdz + 1 <= jsjg[1][J])
				{
					break;
				}
			}
			try
			{
				f4.WriteString("-1 -1\n");
				//				    f4.WriteString(" 0             1\n");
				f4.WriteString(cGraphColor[iColorIndex++]);
				iColorIndex %= iGraphColorNum;
				
				f4.WriteString("Dit=实际油管\n");
				f4.WriteString("-10 -10\n");
			}
			catch (CFileException exception4)
			{
				AfxMessageBox("Error reading file");
				return;
			}			  			
	g_iProgress = 95;	// 计算进度
	ENDCOMPUTE;
			//写入计算的数据jsjg
			title="\t\t";
			//			title=title+" [产液指$0" + "\t" + "数分析]$0"+"\n";
			title=title+" [产液指数分析]$0"+"\n";
			Title="";
			//			Title=Title+" 产水量$7" + "\t" + "油管压力$7" + "\t" + "    在下$13" + "\t" + "列产液指$12" + "\t" + "数下的节$12" + "\t" + "点压力,$12" + "\t" + "MPa$14"+"\n";
			Title=Title+" 产水量$7" + "\t" + "油管压力$7" + "\t" + "  在下列产液指数下的节点压力(MPa)$13" + "\t" + "$12" + "\t" + "$12" + "\t" + "$12" + "\t" + "$14"+"\n";
			try
			{
				f3.WriteString(title);
				f3.WriteString(Title);
			}
			catch (CFileException exception3)
			{
				AfxMessageBox("Error reading file");
				return;
			}    				
			A = "(m^3/d)$11\t(MPa)$11";
			for(i=1;i<=5;i++)
			{
				gcvt(csz[5][i],30,Temp);
				templs1=Temp;
				A = A + "\t" + templs1;
			}
			A=A+"\n";
			try
			{
				f3.WriteString(A);
			}
			catch (CFileException exception3)
			{
				AfxMessageBox("Error reading file");
				return;
			}    				
			for(J=0;J<=Pfxjsds;J++)
			{
				if( jsjg[0][J] == 0 || (jsjg[1][J] + jsjg[2][J] + jsjg[3][J] + jsjg[4][J] + jsjg[5][J] + jsjg[6][J]) == 0)
				{
					break;
				}
				for(i=0;i<=6;i++)
				{
					gcvt(jsjg[i][J],30,Temp);
					B = Temp;
					if( i == 0)
					{
						A = B;
					}
					else
					{
						A = A + "\t" + B;
					}
				}
				A=A+"\n";
				try
				{
					f3.WriteString(A);
				}
				catch (CFileException exception3)
				{
					AfxMessageBox("Error reading file");
					return;
				}    				
			}
			A1 = "节点压力(MPa)$13\t$14";
			A2 = "井产水量(m^3/d)$13\t$14";
			for(i=1;i<=5;i++)
			{
				P = 0;
				Q = 0;
				for(J=2;J<=Pfxjsds;J++)
				{
					Q1 = jsjg[0][J - 1];
					Q2 = jsjg[0][J];
					PI1 = jsjg[1][J - 1];
					PI2 = jsjg[1][J];
					PO1 = jsjg[i + 1][J - 1];
					PO2 = jsjg[i + 1][J];
					if( J > 2 && PI2 * PO2 == 0)
					{
						break;
					}
					if( PI1 >= PO1 && PI2 <= PO2 || (PI1 <= PO1 && PI2 >= PO2))
					{
						if( P > 0 && Q > 0)
						{
							qjd.qlzxjd(Q1, Q2, PI1, PO1, PI2, PO2);
							P=qjd.Y;
							Q=qjd.X;
							break;
						}
						qjd.qlzxjd(Q1, Q2, PI1, PO1, PI2, PO2);
						P=qjd.Y;
						Q=qjd.X;
					}
				}
				if( P > 0)
				{
					P = int(100 * P);
					P=P/ 100;
				}
				if( Q > 0)
				{
					Q = int(100 * Q);
					Q=Q/ 100;
				}
				gcvt(P,30,Temp);
				templs1=Temp;
				A1 = A1 + "\t" + templs1;
				gcvt(Q,30,Temp1);
				templs2=Temp1;
				A2 = A2 + "\t" + templs2;
			}
			A1=A1+"\n";
			A2=A2+"\n";
			try
			{
				f3.WriteString(A1);
				f3.WriteString(A2);
				//				f3.WriteString("8\n");
			}
			catch (CFileException exception3)
			{
				AfxMessageBox("Error reading file");
				return;
			}    
	  } 
	 g_iProgress = 100;	// 计算进度

}
void zpjjdfx::rjIPR(double PLI,double Qtest,double Ptest,double Prs,double Pb,double Fw)
{
	double FO,Cg,CD,A;
	QB=0;
	Qomax=0;
	FO = 1 - Fw;
	if(Fw == 1)
	{
		if(PLI > 0)
		{
			if(Pb > Prs)
			{
				QB = 0;
				Pb = Prs;
			}
			else
				QB = PLI * (Prs - Pb);
			Qomax = QB + PLI * Pb / 1.8;
			Cg = 0.001 * Qomax;
			CD = Fw * (0.001 * Qomax / PLI) + 0.125 * FO * Pb * (-1 + pow((81 - 80 * (0.999 * Qomax - QB) / (Qomax - QB)),0.5));
			Qtmax = Qomax + Fw * (Prs - Qomax / PLI) * Cg / CD;
			QB = 0;
			Qomax = 0;
		}
		else
		{
			Pb = Prs;
			A = 1 - 0.2 * (Ptest / Prs) - 0.8 * pow((Ptest / Prs),2);
			if(PLI== 0)
				PLI = Qtest / (Prs - Ptest);
			if(Qtmax == 0)
			{
				QB = 0;
				Qomax = 0;
				Qtmax = Qtest / A;
			}
			else
				Qtmax = Qtest / A * PLI / (Qtest / (Prs - Ptest));
		}
	}
	else
	{
		if(Prs >= Ptest && Ptest >= Pb)
		{
			if(PLI == 0)
				PLI = Qtest / (Prs - Ptest);
			QB = PLI * (Prs - Pb);
			Qomax = QB + PLI * Pb / 1.8;
			Cg = 0.001 * Qomax;
			CD = Fw * (0.001 * Qomax / PLI) + 0.125 * FO * Pb * (-1 + pow((81 - 80 * (0.999 * Qomax - QB) / (Qomax - QB)),0.5));
			Qtmax = Qomax + Fw * (Prs - Qomax / PLI) * Cg / CD;
		}
		else if(Prs >= Ptest && Prs >= Pb && Ptest < Pb)
		{
			A = 1 - 0.2 * (Ptest / Prs) - 0.8 * pow((Ptest / Prs),2);
			if(PLI == 0)
				PLI = Qtest / (FO * (Prs - Pb + Pb * A / 1.8) + Fw * (Prs - Ptest));
			QB = PLI * (Prs - Pb);
			Qomax = QB + PLI * Pb / 1.8;
			Cg = 0.001 * Qomax;
			CD = Fw * (0.001 * Qomax / PLI) + 0.125 * FO * Pb * (-1 + pow((81 - 80 * (0.999 * Qomax - QB) / (Qomax - QB)),0.5));
			Qtmax = Qomax + Fw * (Prs - Qomax / PLI) * Cg / CD;
		}
		else if(Prs >= Ptest && Prs <= Pb && Ptest < Pb)
		{
			Pb = Prs;
			A = 1 - 0.2 * (Ptest / Prs) - 0.8 * pow((Ptest / Prs),2);
			if(PLI == 0)
				PLI = Qtest / (FO * (Prs - Pb + Pb * A / 1.8) + Fw * (Prs - Ptest));
			QB = PLI * (Prs - Pb);
			Qomax = QB + PLI * Pb / 1.8;
			Cg = 0.001 * Qomax;
			CD = Fw * (0.001 * Qomax / PLI) + 0.125 * FO * Pb * (-1 + pow((81 - 80 * (0.999 * Qomax - QB) / (Qomax - QB)),0.5));
			Qtmax = Qomax + Fw * (Prs - Qomax / PLI) * Cg / CD;
		}
		else if(PLI > 0)
		{
			if(Pb > Prs)
			{
				QB = 0;
				Pb = Prs;
			}
			else
				QB = PLI * (Prs - Pb);
			Qomax = QB + PLI * Pb / 1.8;
			Cg = 0.001 * Qomax;
			CD = Fw * (0.001 * Qomax / PLI) + 0.125 * FO * Pb * (-1 + pow((81 - 80 * (0.999 * Qomax - QB) / (Qomax - QB)),0.5));
			Qtmax = Qomax + Fw * (Prs - Qomax / PLI) * Cg / CD;
		}
	}
	PLIZZZ=PLI;
}

void zpjjdfx::wlipr(double Prswl,double PLI,double QB,double Qomax,double Qtmax,double Prs,double Pb,double Fw)//未来IPR
{
    double FO,Cg,CD;
	if( Fw < 1)
	{
		FO = 1 - Fw;
		PLIwl = PLI * Prswl / Prs;
		if( Prswl > Pb)
		{
			Pbwl = Pb;
			QBwl = PLIwl * (Prswl - Pbwl);
			Qomaxwl = QBwl + PLIwl * Pbwl / 1.8;
		}
		else
		{
			Pbwl = Prswl;
			QBwl = 0;
			Qomaxwl = Qomax * pow((Prswl / Prs),3);
		}
		Cg = 0.001 * Qomaxwl;
		CD = Fw * (0.001 * Qomaxwl / PLIwl) + 0.125 * FO * Pbwl * (-1 + pow((81 - 80 * (0.999 * Qomaxwl - QBwl) / (Qomaxwl - QBwl)),0.5));
		Qtmaxwl = Qomaxwl + Fw * (Prswl - Qomaxwl / PLIwl) * Cg / CD;
	}
	else
	{
		QBwl = 0;
		Qomaxwl = 0;
		Qtmaxwl = Qtmax * pow((Prswl / Prs),3);
	}
}

double zpjjdfx::YQPWF(double Q,double PLI,double QB,double Qomax,dou

⌨️ 快捷键说明

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