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

📄 scjjdfx.cpp

📁 这是本人两年前兼职为某个公司做的石油钻进设计软件
💻 CPP
📖 第 1 页 / 共 4 页
字号:
			DIT10 = DIT1;
		    DVT10 = DVT1;
			DVT20 = DVT2;
			DVT30 = LC;
		  }
		  for(J=0;J<=njsds;J++)
		  {
			  //		  	百分比 = Int(bfblj + BAC * ((i + 1) * njsds + J + 1))
			  //			If 主窗口.SSPanel1.FloodPercent < 百分比 Then 主窗口.SSPanel1.FloodPercent = 百分比
			  QG = int(1000 * qqlzz * J);
			  QG=QG/ 1000;
			  qqiliang = QG * 10000;
			  gylx=qjyljsz.qjyl(pjingkou, tjingkou, TG, DVT10, DIT10, 0, RR, qqiliang, GG, LGR, GL, H2S, N2, CO2, 0,0, 1, 1);
			  Tun = tjingkou + TG * DVT10;
			  gyali=qjyljsz.qjyl(gylx, Tun, TG, DVT20, DIT20, 0, RR, qqiliang, GG, LGR, GL, H2S, N2, CO2, 0,0, 1, 1);
			  Tun = tjingkou + TG * (DVT10 + DVT20);
			  P2=qjyljsz.qjyl(gyali, Tun, TG, DVT30, DIC0, 0, RR, qqiliang, GG, LGR, GL, H2S, N2, CO2, 0,0, 1, 1);
			  jieguo[i + 1][J] = int(100 * P2);
			  jieguo[i + 1][J]=jieguo[i + 1][J]/ 100;
			  try
			  {
				  gcvt(QG,100,temptp);
				  templs1=temptp;
				  gcvt(jieguo[i + 1][J],100,temptp1);
				  templs2=temptp1;
				  templs1=" "+templs1+"\t"+templs2+"\n";
				  f4.WriteString(templs1);
			  }
			  catch (CFileException exception4)
			  {
				  AfxMessageBox("Error reading file");
				  return;
			  } 
			  if( P2 > pdiceng)
			  {
				  break;
			  }
		  }
          try
		  {
			  f4.WriteString("-1\t-1\n");
			  f4.WriteString(cGraphColor[iColorIndex++]);
			  iColorIndex %= iGraphColorNum;
		  }
		  catch (CFileException exception4)
		  {
			  AfxMessageBox("Error reading file");
			  return;
		  }
		  if( i > 0)
		  {
			  gcvt(canshu[3][i],100,temptp);
			  templs1=temptp;
			  templs1.TrimLeft();
              templs1.TrimRight();
			  templs1="Dit="+templs1+"(mm)"+"\n";
              try
			  {
				  f4.WriteString(templs1);
			  }
			  catch (CFileException exception4)
			  {
				  AfxMessageBox("Error reading file");
				  return;
			  }
		  }
		  else
		  {
			  try
			  {
				  f4.WriteString("Dit=实际油管\n");
			  }
			  catch (CFileException exception4)
			  {
				  AfxMessageBox("Error reading file");
				  return;
			  }
		  }
		}
		  try
		  {
			  f4.WriteString("-10\t-10\n");
		  }
		  catch (CFileException exception4)
		  {
			  AfxMessageBox("Error reading file");
			  return;
		  }
	g_iProgress = 85;	// 计算进度
	ENDCOMPUTE;
        templs1="\t\t";
		templs1=templs1+ "[油管尺寸寸分析 (节点在井底)]$0"+"\n";
        templs2=" 气 量$7";
		templs2=templs2+ "\t" + "井底流压$7" + "\t" + "    在下列油管尺寸下的节点压力,MPa$13" + "\t" + "$12" + "\t" + "$12" + "\t" + "$12" + "\t" + "$14"+"\n";
        try
		{
           f3.WriteString(templs1);
           f3.WriteString(templs2);
		}
	    catch (CFileException exception4)
		{
			AfxMessageBox("Error reading file");
			return;
		}
		A = "万方/天$11";
		A=A+ "\t" + "MPa$11";
		for(i=1;i<=5;i++)
		{
		    gcvt(canshu[3][i],100,temptp);
			templs1=temptp;
			A = A + "\t" + templs1;
		}
        try
		{
		   A=A+"\n";
		   f3.WriteString(A);
		}
	    catch (CFileException exception3)
		{
		   AfxMessageBox("Error reading file");
		   return;
		}
		for(J=0;J<=njsds;J++)
		{
		  if( J > 0 && (jieguo[0][J] == 0 || jieguo[1][J] + jieguo[2][J] + jieguo[3][J] + jieguo[4][J] + jieguo[5][J] + jieguo[6][J] == 0))
		  {
			  break;
		  }
		  for(i=0;i<=6;i++)
		  {
		  	gcvt(jieguo[i][J],100,temptp);
			B=temptp;
			if( i == 0)
			{
				A = B;
			}
			else
			{
				A = A + "\t" + B;
			}
		  }
          try
		  {
		   A=A+"\n";
		   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<=njsds;J++)
		  {
		  	Q1 = jieguo[0][J - 1];
			Q2 = jieguo[0][J];
			PI1 = jieguo[1][J - 1];
			PI2 = jieguo[1][J];
			PO1 = jieguo[i + 1][J - 1];
			PO2 = jieguo[i + 1][J];
			if( J > 2 && PI2 * PO2 == 0)
			{
				break;
			}
			if( PI1 >= PO1 && PI2 <= PO2 || (PI1 <= PO1 && PI2 >= PO2))
			{
				jslzjd.qlzxjd(Q1, Q2, PI1, PO1, PI2, PO2);
				P=jslzjd.Y;
				Q=jslzjd.X;
				break;
			}
		  }
		  if( P > 0)
		  {
			  P = int(100 * P);
			  P=P/ 100;
		  }
		  if( Q > 0)
		  {
			  Q = int(100 * Q);
			  Q=Q/ 100;
		  }
		  gcvt(P,100,temptp);
		  templs1=temptp;
		  A1 = A1 + "\t" +templs1;
		  gcvt(Q,100,temptp);
		  templs1=temptp;
		  A2 = A2 + "\t" +templs1;
		}
        try
		{
			A1=A1+"\n";
			f3.WriteString(A1);
            A2=A2+"\n";
			f3.WriteString(A2);
            f3.WriteString("\n");
		}
	    catch (CFileException exception3)
		{
			 AfxMessageBox("Error reading file");
			 return;
		}
//		bfblj = bfblj + 98 * fxcsgs[3] / jszs;
	  }
      //------------------------//	
	g_iProgress = 90;	// 计算进度
	ENDCOMPUTE;
	  //油嘴尺寸  
	  if( cyzcc == 1)
	  {
        try
		{
			templs1="$$油管尺寸分析[油嘴上流压力~产气量]\n";
			f4.WriteString(templs1);
            f4.WriteString("节点压力最小值,MPa:\n");
			f4.WriteString("节点压力最大值,MPa:\n");
			f4.WriteString("产气量最小值,10^4m^3/d:\n");
			f4.WriteString("产气量最大值,10^4m^3/d:\n");
			f4.WriteString("Pn\n");
			f4.WriteString("Qg\n");
			f4.WriteString("Pn__MPa\n");
			f4.WriteString("Qg__10^4m^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<=njsds;J++)
			{
		       jieguo[i][J] = 0;
			}
		}
		BAC = 98 * fxcsgs[4] / jszs / (fxcsgs[4] + 1) / njsds;
		// 流入关系计算
		for(J=0;J<=njsds;J++)
		{
//		  百分比 = Int(bfblj + BAC * (J + 1))
//		  If 主窗口.SSPanel1.FloodPercent < 百分比 Then 主窗口.SSPanel1.FloodPercent = 百分比
		  QG = int(1000 * qqlzz * J);
		  QG=QG/ 1000;
		  qqiliang = QG * 10000;
		  if( AF * BF > 0)
		  {
			PWF = pow(pdiceng,2) - AF * QG - BF * pow(QG,2);
		  }
		  else if( CF * NF > 0)
		  {
			PWF = pow(pdiceng,2) - pow((QG / CF),(1 / NF));
		  }
		  if( PWF < 0)
		  {
			  break;
		  }
		  if( PWF > 0)
		  {
			  PWF = pow(PWF,0.5);
		  }
		  gylx=qjyljsz.qjyl(PWF, tdiceng, TG, LC, DIC, 0, RR, qqiliang, GG, LGR, GL, H2S, N2, CO2, 0,0, -1, 1);
		  if( gylx < 0.5)
		  {
			  jieguo[0][J] = QG;
			  jieguo[i + 1][J] = 0;
			  break;
		  }
		  Tun = tdiceng - TG * LC;
		  if( HCh >= DVT1)
		  {
			dshendu = DVT1 + DVT2 - HCh;
			gyali=qjyljsz.qjyl(gylx, Tun, TG, dshendu, DIT2, 0, RR, qqiliang, GG, LGR, GL, H2S, N2, CO2, 0,0, -1, 1);
			if( gyali < 0.5)
			{
				jieguo[0][J] = QG;
				jieguo[i + 1][J] = 0;
				break;
			}
		  }
		  else
		  {
			gyali=qjyljsz.qjyl(gylx, Tun, TG, DVT2, DIT2, 0, RR, qqiliang, GG, LGR, GL, H2S, N2, CO2, 0,0, -1, 1);
			if( gyali < 0.5)
			{
				jieguo[0][J] = QG;
				jieguo[i + 1][J] = 0;
				break;
			}
			Tun = tdiceng - TG * (LC + DVT2);
			if( HCh > 0)
			{
			  dshendu = DVT1 - HCh;
			  P2=qjyljsz.qjyl(gyali, Tun, TG, dshendu, DIT1, 0, RR, qqiliang, GG, LGR, GL, H2S, N2, CO2, 0,0, -1, 1);
			  if( P2 < 0.5)
			  {
				jieguo[0][J] = QG;
				jieguo[i + 1][J] = 0;
				break;
			  }
			  else
			  {
				jieguo[0][J] = QG;
				jieguo[1][J] = int(1000 * P2);
				jieguo[1][J]=jieguo[1][J]/ 1000;
			  }
			}
			else
			{
			  P2=qjyljsz.qjyl(gyali, Tun, TG, DVT1, DIT1, 0, RR, qqiliang, GG, LGR, GL, H2S, N2, CO2, 0,0, -1, 1);
			  if( P2 < 0.5)
			  {
				jieguo[0][J] = QG;
				jieguo[i + 1][J] = 0;
				break;
			  }
			  else
			  {
				jieguo[0][J] = QG;
				jieguo[1][J] = int(1000 * P2);
				jieguo[1][J]=jieguo[1][J]/ 1000;
			  }
			}
		  }
		  try
		  {
			  gcvt(jieguo[0][J],100,temptp);
			  templs1=temptp;
			  gcvt(jieguo[1][J],100,temptp1);
			  templs2=temptp1;
			  templs1=" "+templs1+"\t"+templs2+"\n";
			  f4.WriteString(templs1);
		  }
		  catch (CFileException exception4)
		  {
			AfxMessageBox("Error reading file");
			return;
		  }
    	  if( J == 0)
		  {
			  Pmax = P2;
		  }
		}
        try
		{
		  gcvt(QG,100,temptp);
		  templs1=temptp;
		  templs1=" "+templs1+"\t"+"0"+"\n";
		  f4.WriteString(templs1);
		  f4.WriteString("-1\t-1\n");
			f4.WriteString(cGraphColor[iColorIndex++]);
			iColorIndex %= iGraphColorNum;
          f4.WriteString("IPR");
		}
	    catch (CFileException exception4)
		{
			AfxMessageBox("Error reading file");
			return;
		}
	g_iProgress = 95;	// 计算进度
	ENDCOMPUTE;
		// 流出关系计算
		for(i=1;i<=5;i++)
		{
		  Doc = canshu[4][i];
		  if( Doc <= 0)
		  {
			  break;
		  }
		  pxlyl = phuiya;
		  pslyl = pxlyl;
		  for(J=0;J<=njsds;J++)
		  {
//		  	百分比 = Int(bfblj + BAC * (i * njsds + J + 1))
//			If 主窗口.SSPanel1.FloodPercent < 百分比 Then 主窗口.SSPanel1.FloodPercent = 百分比
			QG = int(1000 * qqlzz * J);
			QG=QG/ 1000;
			if( HCh > 0)
			{
			  qqiliang = QG * 10000;
			  if( DVT1 >= HCh)
			  {
				dshendu = HCh;
				pxlyl=qjyljsz.qjyl(phuiya, tjingkou, TG, dshendu, DIT1, 0, RR, qqiliang, GG, LGR, GL, H2S, N2, CO2, 0,0, 1, 1);
			  }
			  else
			  {
				gylx=qjyljsz.qjyl(phuiya, tjingkou, TG, DVT1, DIT1, 0, RR, qqiliang, GG, LGR, GL, H2S, N2, CO2, 0,0, 1, 1);
				Tun = tjingkou + TG * DVT10;
				dshendu = HCh - DVT1;
				pxlyl=qjyljsz.qjyl(gylx, Tun, TG, dshendu, DIT2, 0, RR, qqiliang, GG, LGR, GL, H2S, N2, CO2, 0,0, 1, 1);
			  }
			}
			if( QG == 0)
			{
			  pslyl = pxlyl;
			}
			else
			{
			  pylzj = 1.5;
			  DX = -1;
			  do
			  {
				pslyl = pslyl + pylzj;
				dylb = pxlyl / pslyl;
				PR = pslyl / PC;
				TR = tjingkou / TC;
				Z=csjs.trqpcxs(PR, TR);
				if( dylb < 0.55)
				{
				  qyzql = 0.19 * pow(Doc,2) * pslyl / pow((tjingkou * Z * GG),0.5);
				}
				else
				{
				  dylb = pow(dylb,1.5748) - pow(dylb,1.7874);
				  if( dylb <= 0)
				  {
					  dylb = 0;
				  }
				  qyzql = 0.8835 * pow(Doc,2) * pslyl * pow((dylb / (tjingkou * Z * GG)),0.5);
				}
				if( DX == -1 && qyzql > QG)
				{
				  pylzj = -0.618 * pylzj;
				}
				else if( DX == 1 && qyzql > QG)
				{
				  pylzj = 0.618 * pylzj;
				}
				else if( DX == 1 && qyzql < QG)
				{
				  pylzj = -0.618 * pylzj;
				}
				if( qyzql > QG)
				{
					DX = 1;
				}
				else
				{
					DX = -1;
				}
			  }
			  while(fabs(qyzql - QG) > 0.05);
			}
			jieguo[i + 1][J] = int(1000 * pslyl);
			jieguo[i + 1][J]=jieguo[i + 1][J]/ 1000;
		    try
			{
			  gcvt(QG,100,temptp);
			  templs1=temptp;
			  gcvt(jieguo[i + 1][J],100,temptp1);
			  templs2=temptp1;
			  templs1=" "+templs1+"\t"+templs2+"\n";
			  f4.WriteString(templs1);
  			}
			catch (CFileException exception4)
			{
				AfxMessageBox("Error reading file");
				return;
			}	
			if( pslyl > Pmax + 1)
			{
				break;
			}
		  }
          try
		  {
			  f4.WriteString("-1\t-1\n");
			f4.WriteString(cGraphColor[iColorIndex++]);
			iColorIndex %= iGraphColorNum;
			  gcvt(Doc,100,temptp);
			  templs1=temptp;
			  templs1.TrimLeft();
			  templs1.TrimRight();
			  templs1="Doc="+templs1+"(mm)\n";
			f4.WriteString(templs1);
		  }
		  catch (CFileException exception4)
		  {
				AfxMessageBox("Error reading file");
				return;
		  }
		}
			try
			{
			   f4.WriteString("-10\t-10\n");
			}
			catch (CFileException exception4)
			{
				AfxMessageBox("Error reading file");
				return;
			}
		templs1="\t\t";
		templs1=templs1+ "  [油嘴尺寸分析]$0"+"\n";
        templs2=" 气 量$7";
		templs2=templs2+ "\t" + "节点压力$7" + "\t" + "    在下列油嘴尺寸下的节点压力,MPa$13" + "\t" + "$12" + "\t" + "$12" + "\t" + "$12" + "\t" + "$14"+"\n";
		try
		{
          f3.WriteString(templs1);
		  f3.WriteString(templs2);
 		}
	    catch (CFileException exception4)
		{
			AfxMessageBox("Error reading file");
			return;
		}
		A = "万方/天$11";
		A=A+ "\t" + "MPa$11";
		for(i=1;i<=5;i++)
		{
           gcvt(canshu[4][i],100,temptp);
		   templs1=temptp;
		   A = A + "\t" + templs1;
		}
        try
		{
			A=A+"\n";
			f3.WriteString(A);
		}
	    catch (CFileException exception3)
		{
			 AfxMessageBox("Error reading file");
			 return;
		}
	    for(J=0;J<=njsds;J++)
		{
		  if( jieguo[0][J] + jieguo[1][J] == 0)
		  {
			  break;
		  }
		  for(i=0;i<=6;i++)
		  {
		  	gcvt(jieguo[i][J],100,temptp);
			B=temptp;
			if( i == 0)
			{
				A = B;
			}
			else
			{
				A = A + "\t" + B;
			}
		  }
          try
		  {
		     A=A+"\n";
			 f3.WriteString(A);
		  }
		  catch (CFileException exception3)
		  {
			 AfxMessageBox("Error reading file");
			 return;
		  }
		}
	g_iProgress = 100;	// 计算进度
	ENDCOMPUTE;
		A1= "节点压力$13";
		A1=A1+ "\t" + ",MPa$14";
		A2 = "井的产量$13";
		A2=A2+ "\t" + ",万m^3/d$14$14";
		for(i=1;i<=5;i++)
		{
		  P = 0;
		  Q = 0;
		  for(J=2;J<=njsds;J++)
		  {
		  	Q1 = jieguo[0][J - 1];
			Q2 = jieguo[0][J];
			PI1 = jieguo[1][J - 1];
			PI2 = jieguo[1][J];
			PO1 = jieguo[i + 1][J - 1];
			PO2 = jieguo[i + 1][J];
			if( J > 2 && PI2 * PO2 == 0)
			{
				break;
			}
			if( PI1 >= PO1 && PI2 <= PO2 || (PI1 <= PO1 && PI2 >= PO2))
			{
				jslzjd.qlzxjd(Q1, Q2, PI1, PO1, PI2, PO2);
				P=jslzjd.Y;
				Q=jslzjd.X;
				break;
			}
		  }
		  if( P > 0)
		  {
			  P = int(100 * P);
			  P=P/ 100;
		  }
		  if( Q > 0)
		  {
			  Q = int(100 * Q);
			  Q=Q/ 100;
		  }
		  gcvt(P,100,temptp);
		  templs1=temptp;
		  A1 = A1 + "\t" +templs1;
		  gcvt(Q,100,temptp);
		  templs1=temptp;
		  A2 = A2 + "\t" + templs1;
		}
		try
		{
   		     A1=A1+"\n";
		     f3.WriteString(A1);
             A2=A2+"\n";
		     f3.WriteString(A2);
		}
	    catch (CFileException exception3)
		{
			 AfxMessageBox("Error reading file");
			 return;
		}
	  }
	  try
	  {
//		 f3.WriteString("8\n");
	  }
	  catch (CFileException exception3)
	  {
		 AfxMessageBox("Error reading file");
		 return;
	  }
	  f3.Close();
	  f4.Close();
}





⌨️ 快捷键说明

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