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

📄 tgdata.cpp

📁 这是本人两年前兼职为某个公司做的石油钻进设计软件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
  	      gcvt(aqxs,20,Temp);
		  str1=Temp;
		  str="";
		  str =str+ "\t" + "设计安全系数$16" + "\t" + str1 + "$12" + "\t" + "" + "$14"+"\n";
		  try
		  {
				   f3.WriteString(str);
		  }
		  catch (CFileException exception3)
		  {
				   AfxMessageBox("Error reading file");
				   return;
		  }
		}
	  }
	  else if( aqxs > 0)
	  {
		if( klqd2 * dwcdzl2)
		{
		  changdu2 = int(100000 * klqd2 / dwcdzl2 / aqxs) / 100.00;
		  changdu1 = int(100 * (1000 * klqd1 - changdu2 * dwcdzl2) / dwcdzl1 / aqxs) / 100.00;
  	      gcvt(aqxs,20,Temp);
		  str1=Temp;
		  str="";
		  str =str+ "\t" + "选用安全系数$0" + "\t" + str1+ "$14"+"\n";
		  try
		  {
				   f3.WriteString(str);
		  }
		  catch (CFileException exception3)
		  {
				   AfxMessageBox("Error reading file");
				   return;
		  }
		  if( changdu1 > 0)
		  {
  	        gcvt(changdu1,20,Temp);
		    str1=Temp;
			str="";
			str = str+"\t" + "上段油管可下入深度$16" + "\t" + str1 + "$12" + "\t" + "m" + "$14"+"\n";
		    try
			{
				   f3.WriteString(str);
			}
		    catch (CFileException exception3)
			{
				   AfxMessageBox("Error reading file");
				   return;
			}
		  }
		  if( changdu2 > 0)
		  {
  	        gcvt(changdu2,20,Temp);
		    str1=Temp;
			str="";
			str =str+ "\t" + "下段油管可下入深度$16" + "\t" + str1 + "$12" + "\t" + "m" + "$14"+"\n";
		    try
			{
				   f3.WriteString(str);
			}
		    catch (CFileException exception3)
			{
				   AfxMessageBox("Error reading file");
				   return;
			}
		  }
		  tempdou=changdu2 + changdu1;
          gcvt(tempdou,20,Temp);
		  str1=Temp;
		  str="";
		  str =str+ "\t" + "油管可下入总深度$16" + "\t" + str1 + "$12" + "\t" + "m" + "$14"+"\n";
	      try
		  {
				   f3.WriteString(str);
		  }
		  catch (CFileException exception3)
		  {
				   AfxMessageBox("Error reading file");
				   return;
		  }
		}
		else
		{
		  changdu1 = int(100000 * klqd1 / dwcdzl1 / aqxs) / 100.00;
          gcvt(aqxs,20,Temp);
          str1=Temp;
		  str="";
    	  str =str+ "\t" + "选用安全系数$16" + "\t" + str1 + "$14"+"\n";
	      try
		  {
				   f3.WriteString(str);
		  }
		  catch (CFileException exception3)
		  {
				   AfxMessageBox("Error reading file");
				   return;
		  }
          gcvt(changdu1,20,Temp);
          str1=Temp;
		  str="";
		  str =str+ "\t" + "油管可下入总深度$16" + "\t" + str1 + "$12" + "\t" + "m" + "$14"+"\n";
	      try
		  {
				   f3.WriteString(str);
		  }
		  catch (CFileException exception3)
		  {
				   AfxMessageBox("Error reading file");
				   return;
		  }
		}
	  }
	  //Print #fn, "8" + "\t" + "20" + "\t" + "20" + "\t" + "10" + "\t" + "10"
	  f3.Close();
      m_bModify = true;
}

void CTGData::AddCal()
{
	CDaoDatabase Database;
	CDaoRecordset* pRecordset;
	CString		strQuery;
	CString		strError;
    COleVariant var;
    try {
      // nonexclusive, read-only
      Database.Open(m_strDatabase, FALSE, TRUE);
    }
    catch (CDaoException* e) {
      ::DaoErrorMsg(e);
      e->Delete();
      return;
    }
	pRecordset = new CDaoRecordset(&Database);

	double	 H, rc, rz, rt, psg, pph, rs, dyw, rhk, Hf, dyn, dtw;	\
	bool	fgq, zc;						\
	H = atof(m_strEdit[0]);   /*套管下深*/	\
	rc = atof(m_strEdit[1]);         /*产层压力梯度*/	\
	rz = atof(m_strEdit[2]);         /*钻井液压力梯度*/	\
	rt = atof(m_strEdit[3]);         /*天然气相对密度*/	\
	psg = atof(m_strEdit[4]);       /*增产措施施工压力*/	\
	pph = atof(m_strEdit[5]);      /*施工平衡压力*/	\
	rs = atof(m_strEdit[6]);       /*酸液压力梯度*/	\
	dyw = atof(m_strEdit[7]);      /*油管外径*/	\
	rhk = atof(m_strEdit[8]);      /*环空液柱压力梯度*/	\
	Hf = atof(m_strEdit[9]);      /*封隔器下深*/	\
	dyn = atof(m_strEdit[10]);     /*油管内径*/	\
	dtw = atof(m_strCombo1);   /*套管外径*/	\
	if(m_strCombo2.Compare(_T("0")) == 0)	\
		fgq = true;							\
	if(m_strCombo2.Compare(_T("1")) == 0)	\
		fgq = false; /*封隔器有无*/			\
	if(m_strCombo3.Compare(_T("0")) == 0)	\
		zc = true;							\
	if(m_strCombo3.Compare(_T("1")) == 0)	\
		zc = false; /*有无增产措施*/	\
	double	d[8], l[8][2];				\
	CString	x[8];						\
	for(int	i = 0; i<8; i++)			\
	{									\
		l[i][0] = atof(m_grid1[i][0]);	\
		l[i][1] = atof(m_grid1[i][1]);	\
		d[i] = atof(m_grid1[i][2]);		\
		x[i] = m_grid1[i][3];			\
	}									\

	double q[100], QQ[100], qdanzhong, b, c, dd, e, f, g, k, Pcmax, Pcc,  pi, Qe[100], Sii, Stt, Scc, Tb, Ai, Ao, Ap, pii, F1, F2, pia, poa, T;
	CString sj[100], sk[100], nn[100], ll[100][100], mm[100][100];
	int z, n;
	z = 8;
	Pcmax = H * rhk;
	f = H * (1 - rhk / 0.0785);
	QQ[0] = 0;
	Qe[0] = 0;
	for(n = 0; n<z; n++)
	{
		if(l[n][0] == 0)
			break;
		q[n] = 0;
			/*     Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
			Set mytable1 = mydb1.OpenRecordset("套管强度", dbOpenTable)
			Do While Not mytable1.EOF
			If mytable1!外径 = dtw And mytable1!壁厚 = d(n) Then
			qdanzhong = mytable1!公称重量
			End If
			mytable1.MoveNext
			Loop
			mytable1.Close
			mydb1.Close
		*/
		strQuery.Format("select [公称重量] from [套管强度] where [外径] = %10.2f and [壁厚] = %10.2f",
			dtw, d[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种外径或者\n套管强度(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_R4:
			qdanzhong = var.fltVal;
			break;
		case VT_R8:
			qdanzhong = var.dblVal;
			break;
		}
		pRecordset->Close();

		if(l[n][0] != 0 && l[n][0] <= f)
			QQ[n+1] = QQ[n] + 0.00981 * (l[n][0] - l[n][1]) * q[n];
		else if(l[n][1] <= f && f <= l[n][0])
			QQ[n+1] = QQ[n] + 0.00981 * (f - l[n][1]) * qdanzhong;
		else	
			QQ[n+1] = 0;
		TRACE("%f\n", QQ[n+1]);
//          Call 抗挤安全系数计算
/* Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
 Set mytable1 = mydb1.OpenRecordset("套管强度", dbOpenTable)
 Do While Not mytable1.EOF
    If mytable1!外径 = dtw And mytable1!壁厚 = d(n) Then
       qdanzhong = mytable1!公称重量
    End If
    mytable1.MoveNext
 Loop
 mytable1.Close
 mydb1.Close
*/
		strQuery.Format("select [公称重量] from [套管强度] where [外径] = %10.2f and [壁厚] = %10.2f",
			dtw, d[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种外径或者\n套管强度(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_R4:
			qdanzhong = var.fltVal;
			break;
		case VT_R8:
			qdanzhong = var.dblVal;
			break;
		}
		pRecordset->Close();


/*
 Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
 Set mytable1 = mydb1.OpenRecordset("截面积", dbOpenTable)
 Do While Not mytable1.EOF
    If mytable1!套管尺寸 = dtw And mytable1!套管壁厚 = d(n) Then
       b = mytable1!套管截面积
    End If
 mytable1.MoveNext
 Loop
 mytable1.Close
 mydb1.Close
*/
		strQuery.Format("select [套管截面积] from [截面积] where [套管尺寸] = %10.2f and [套管壁厚] = %10.2f",
			dtw, d[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种套管尺寸或者\n套管壁厚(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_R4:
			b = var.fltVal;
			break;
		case VT_R8:
			b = var.dblVal;
			break;
		}
		pRecordset->Close();

/*
 Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
 Set mytable1 = mydb1.OpenRecordset("套管强度", dbOpenTable)
 Do While Not mytable1.EOF
    If mytable1!公称重量 = qdanzhong And mytable1!钢级 = x(n) Then
       k = mytable1!抗挤强度
    End If
 mytable1.MoveNext
 Loop
 mytable1.Close
 mydb1.Close
*/
		strQuery.Format("select [抗挤强度] from [套管强度] where [公称重量] = %10.2f and [钢级] = \"%s\"",
			qdanzhong, x[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种外径或者\n钢级(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_R4:
			k = var.fltVal;
			break;
		case VT_R8:
			k = var.dblVal;
			break;
		}
		pRecordset->Close();

/*
 Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
 Set mytable1 = mydb1.OpenRecordset("最小屈服强度", dbOpenTable)
 Do While Not mytable1.EOF
    If mytable1!钢级 = x(n) Then
       c = mytable1!屈服强度
    End If
 mytable1.MoveNext
 Loop
 mytable1.Close
 mydb1.Close
*/
		strQuery.Format("select [屈服强度] from [最小屈服强度] where [钢级] = \"%s\"",
			x[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种钢级\n(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_I2:
			c = var.iVal;
			break;
		case VT_I4:
			c = var.lVal;
			break;
		}
		pRecordset->Close();


		Tb = 10 * QQ[n] / b;
		dd = Tb / c;
		int	ddi;
		ddi = int(dd * 1000 + 0.5);
		if((ddi % 2) != 0)
			ddi--;
		dd = double(ddi) / 1000;
 
/*
Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
Set mytable1 = mydb1.OpenRecordset("外挤压力系数K'", dbOpenTable)
Do While Not mytable1.EOF
    If mytable1!商 = dd Then
        e = mytable1!系数
    End If
mytable1.MoveNext
Loop
mytable1.Close
mydb1.Close
*/
		if(dd == 0)
			e = 0;
		else
		{
			
			strQuery.Format("select [系数] from [外挤压力系数K\'] where [商] = %10.3f",
				dd);
			TRACE(strQuery);
			try 
			{	
				pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
			}
			catch (CDaoException* e) {
				::DaoErrorMsg(e);
				e->Delete();
				return;
			}
			if(pRecordset->GetRecordCount() == 0)
			{
				strError.Format(_T("  输入参数错误:数据库中没有该种商\n(第%d项)!"),n+1);
				AfxMessageBox(strError, MB_ICONERROR);
				return;
			}
			
			pRecordset->MoveLast();
			var = pRecordset->GetFieldValue(0);
			TRACE("\n%ld\n",pRecordset->GetRecordCount());
			switch (var.vt) {
			case VT_R4:
				e = var.fltVal;
				break;
			case VT_R8:
				e = var.dblVal;
				break;
			}
			pRecordset->Close();
		}

		Pcc = e * k;
		if(l[n][0] <= f)
		{
			Scc = (Pcc / 1000) / ((Pcmax / H) * l[n][0]);
		}
		else if(l[n][1] <= f && f <= l[n][0])
		{
			Scc = (k / 1000) / ((Pcmax / H) * l[n][0]);
		}
		else
		{
			Scc = (k / 1000) / ((Pcmax / H) * l[n][0]);
		}
		Scc = int(Scc * 1000) / 1000.0;
		m_grid1[n][4].Format("%10.3f",Scc);
		// end 抗挤安全系数计算


        pi = pph - (rs - rhk) * l[n][0];
//        Call 抗内压安全系数计算
 /*   Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
    Set mytable1 = mydb1.OpenRecordset("套管强度", dbOpenTable)
    Do While Not mytable1.EOF
       If mytable1!钢级 = x(n) And mytable1!壁厚 = d(n) Then
          g = mytable1!抗内压力
       End If
       mytable1.MoveNext
    Loop
    mytable1.Close
    mydb1.Close
*/
		strQuery.Format("select [抗内压力] from [套管强度] where [壁厚] = %10.2f and [钢级] = \"%s\"",
			d[n], x[n]);
		TRACE(strQuery);
		try 
		{	
			pRecordset->Open(dbOpenDynaset, strQuery, dbReadOnly);
		}
		catch (CDaoException* e) {
			::DaoErrorMsg(e);
			e->Delete();
			return;
		}
		if(pRecordset->GetRecordCount() == 0)
		{
			strError.Format(_T("  输入参数错误:数据库中没有该种壁厚或者\n钢级(第%d项)!"),n+1);
			AfxMessageBox(strError, MB_ICONERROR);
			return;
		}
		
		pRecordset->MoveLast();
		var = pRecordset->GetFieldValue(0);
		TRACE("\n%ld\n",pRecordset->GetRecordCount());
		switch (var.vt) {
		case VT_R4:
			g = var.fltVal;
			break;
		case VT_R8:
			g = var.dblVal;
			break;
		}
		pRecordset->Close();

	
		if(!fgq)
		{
			Sii = (g / 1000) / pi;
		}
		else
			Sii = (g / 1000) / pi;
		
		Sii = int(Sii * 1000) / 1000.0;
		m_grid1[n][5].Format("%10.3f",Sii);
		//end 抗内压安全系数计算

		Qe[n+1] = Qe[n] + 0.00981 * q[n] * (l[n][00] - l[n][1]);
//         Call 增产抗拉安全系数计算
		Ai = 0.25 * 3.14 * dyn * dyn;			//油管内截面积
		Ao = 0.25 * 3.14 * dyw * dyw;			//油管外截面积
		Ap = 0.25 * 3.14 * (dtw - d[n]) *  (dtw - d[n]);	//套管内截面积
		pii = psg + (rs - rhk) * l[n][0];
		double	po;
		po = pph;
		F1 = ((Ap - Ai) * pii - (Ap - Ao) * po) * 0.001;
		pia = (pii + psg) / 2;
		poa = (psg + po) / 2;
		F2 = (0.64 * Ai * pia - 0.6 * Ao * poa) * 0.001;
		T = F1 + F2 - Qe[n+1];
		double	Pj;
/*
   Set mydb1 = OpenDatabase("D:\套管程序设计\数据.mdb")
    Set mytable1 = mydb1.OpenRecordset("套管强度", dbOpenTable)
    Do While Not mytable1.EOF
       If mytable1!钢级 = x(n) And mytable1!壁厚 = d(n) Then
          Pj = mytable1!抗拉强度

⌨️ 快捷键说明

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