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

📄 oilminuspressview.cpp

📁 这是本人两年前兼职为某个公司做的石油钻进设计软件
💻 CPP
字号:
// OilMinusPressView.cpp : implementation file
//

#include "stdafx.h"
#include "CVenus.h"
#include "MainFrm.h"
#include "OilMinusPressView.h"
#include	"ChildFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// COilMinusPressView

IMPLEMENT_DYNCREATE(COilMinusPressView, CFormView)

COilMinusPressView::COilMinusPressView()
	: CFormView(COilMinusPressView::IDD)
{
	//{{AFX_DATA_INIT(COilMinusPressView)
	m_bSand = FALSE;
	m_fClay = 0.0f;
	m_fDeep = 0.0f;
	m_fDepth = 0.0f;
	m_fElasticity = 0.0f;
	m_fPMax = 0.0f;
	m_fPMin = 0.0f;
	m_fPossion = 0.0f;
	m_fPRec = 0.0f;
	m_fPRecMax = 0.0f;
	m_fMinusPress = 0.0f;
	m_fPress = 0.0f;
	m_fWater = 0.0f;
	//}}AFX_DATA_INIT
}

COilMinusPressView::~COilMinusPressView()
{
}

void COilMinusPressView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COilMinusPressView)
	DDX_Check(pDX, IDC_CHECK_SAND, m_bSand);
	DDX_Text(pDX, IDC_EDIT_CLAY, m_fClay);
	DDX_Text(pDX, IDC_EDIT_DEEP, m_fDeep);
	DDX_Text(pDX, IDC_EDIT_DEPTH, m_fDepth);
	DDX_Text(pDX, IDC_EDIT_ELASTICITY, m_fElasticity);
	DDX_Text(pDX, IDC_EDIT_PMAX, m_fPMax);
	DDX_Text(pDX, IDC_EDIT_PMIN, m_fPMin);
	DDX_Text(pDX, IDC_EDIT_POSSION, m_fPossion);
	DDX_Text(pDX, IDC_EDIT_PREC, m_fPRec);
	DDX_Text(pDX, IDC_EDIT_PRECMAX, m_fPRecMax);
	DDX_Text(pDX, IDC_EDIT_MINUSPRESS, m_fMinusPress);
	DDX_Text(pDX, IDC_EDIT_PRESS, m_fPress);
	DDX_Text(pDX, IDC_EDIT_WATER, m_fWater);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COilMinusPressView, CFormView)
	ON_WM_CONTEXTMENU()
	//{{AFX_MSG_MAP(COilMinusPressView)
	ON_WM_CREATE()
	ON_COMMAND(ID_SPD_CACL, OnSpdCacl)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COilMinusPressView diagnostics

#ifdef _DEBUG
void COilMinusPressView::AssertValid() const
{
	CFormView::AssertValid();
}

void COilMinusPressView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// COilMinusPressView message handlers

int COilMinusPressView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CFormView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	CMainFrame*	wnd = (CMainFrame*)AfxGetMainWnd();
	if(wnd->m_bSelected == FALSE)
	{
		MessageBox("请先在参数优选中选择一种射孔弹 !","工程信息");
		return -1;
	}
/*	CString cstrProjectName;
	CSpdDoc* pDoc = (CSpdDoc*)GetDocument();
	cstrProjectName = pDoc->m_cstrTitle +" - [油井负压设计]";
	pDoc->SetTitle (cstrProjectName);
*/
	GetParentFrame()->SetWindowText(_T("油井负压设计"));
	if(wnd->m_structMinusPressPara.bState == TRUE)
	{
		m_bSand = wnd->m_structMinusPressPara.bSand ;
		m_fClay = wnd->m_structMinusPressPara.fClay ;
		m_fElasticity = wnd->m_structMinusPressPara.fElasticity ;
		m_fPossion = wnd->m_structMinusPressPara.fPossion ;
		m_fWater = wnd->m_structMinusPressPara.fWater ;
		m_fPress = wnd->m_structMinusPressPara.fPress ;
		m_fMinusPress = wnd->m_structMinusPressPara.fMinusPress ;
		m_cstrShotModel = wnd->m_structSelectedPara.strModel ;
		if(wnd->m_structMinusPressResult.bState == TRUE)
		{
			m_fDepth = wnd->m_structMinusPressResult.fDepth ;
			m_fDeep = wnd->m_structMinusPressResult.fDeep ;
			m_fPMin = wnd->m_structMinusPressResult.fPMin ;
			m_fPMax = wnd->m_structMinusPressResult.fPMax ;
			m_fPRec = wnd->m_structMinusPressResult.fPRec ;
			m_fPRecMax = wnd->m_structMinusPressResult.fPRecMax ;
		}
	}
	else
	{
		m_cstrShotModel = wnd->m_structSelectedPara.strModel ;
	}

		for(int iTemp=0;iTemp<wnd->m_structBDTTable.lCount;iTemp++)
		{
			if(m_cstrShotModel.Compare(wnd->m_structSDT[iTemp].strModel) == 0)
			{
				wnd->m_structMinusPressPara.fDiameter = wnd->m_structSDT[iTemp].fDiameter ;
				wnd->m_structMinusPressPara.fPressDeep = wnd->m_structSDT[iTemp].fPressDeep ;
				wnd->m_structMinusPressPara.fPressLong = wnd->m_structSDT[iTemp].fPressLong ;
				break;
			}
		}
	return 0;
}



void COilMinusPressView::OnSpdCacl() 
{
	// TODO: Add your command handler code here
	CMainFrame*	wnd = (CMainFrame*)AfxGetMainWnd();

	if(wnd->m_structBDTTable.bState == FALSE)
	{
		MessageBox("请输入源数据 !","工程信息");
		return ;
	}
	if(wnd->m_structBDTTable.fStratumFilterPercent == 0)
	{
		MessageBox("请输入地层渗透率 !","工程信息");
		return;
	}
	if(wnd->m_structBDTTable.fStratumHolePercent == 0)
	{
		MessageBox("请输入地层孔隙度 !","工程信息");
		return;
	}
	if(wnd->m_structBDTTable.fStratumAverPress == 0)
	{
		MessageBox("请输入地层平均压力 !","工程信息");
		return;
	}
	if(wnd->m_structBDTTable.fCannulaPressResistance == 0)
	{
		MessageBox("请输入地层套管抗积压强度 !","工程信息");
		return;
	}
	if(wnd->m_structBDTTable.fFloorOilPorportion == 0)
	{
		MessageBox("请输入地层原油比重 !","工程信息");
		return;
	}
	if(wnd->m_structBDTTable.fStratumOilStiff == 0)
	{
		MessageBox("请输入地层原油粘度 !","工程信息");
		return;
	}
	if(wnd->m_structBDTTable.fStratumCentralDepth == 0)
	{
		MessageBox("请输入地层中部深度 !","工程信息");
		return;
	}
	UpdateData(TRUE);
	if(m_fClay == 0)
	{
		MessageBox("请输入地层粘土含量 !","工程信息");
		UpdateData(FALSE);
		return;
	}
	if(m_fElasticity == 0)
	{
		MessageBox("请输入岩石弹性模量 !","工程信息");
		UpdateData(FALSE);
		return;
	}
	if(m_fPossion == 0)
	{
		MessageBox("请输入岩石泊松比 !","工程信息");
		UpdateData(FALSE);
		return;
	}
	if(m_cstrShotModel.Compare (_T("未选择")) == 0)
	{
		MessageBox("请选择一种射孔弹 !","工程信息");
		UpdateData(FALSE);
		return;
	}

	float porsity;
	float pe = wnd->m_structBDTTable.fStratumAverPress ;				//地层压力
	porsity = wnd->m_structBDTTable.fStratumHolePercent ;
	pe = (float)((pe * 14.7 ) * 9.869) ;
	float vsh = m_fClay;					//地层粘土含量
	float e = m_fElasticity;				//岩石弹性模量
	float possion = m_fPossion;				//岩石泊松比
	//计算Pmax
	e = (float)(e * 14.7 * 9.869 / 1000000.0);
	float kb = (float)(e / (3 * (1 - 2 * possion)));
	float cu = (float)((114 + 97 * vsh) * kb * e);
	float angle = (float)(57.8 - 1.05 * porsity);
	angle = (float)(angle /180 * 3.1415926);
	float sing = (float)(4 * sin(angle) / (1 - sin(angle)));
	float div = (float)(tan(angle) / cu);
	float pee = pe * div;
	float pww = (float)(0.5 * pe * div);
	float step1 = (float)0.1;
	
	float fTemp,fun0,pw;
	while(true)
	{
		fun0 = sing - (pee - pww );
		pw = pww - fun0;
		if(pww < fun0)
			pw = pww - step1 * fun0;
		fTemp = pw - pww;
		if(fTemp < 0) fTemp = -fTemp;
		if(fTemp <= 0.0001 ) break;
		pww = pw;
	}
	pw = pw / div;

	float dpmax = (float)((pe - pw ) / (14.7 * 9.869 ));
	if(dpmax > wnd->m_structBDTTable.fCannulaPressResistance )
		dpmax = (float)(0.8 * wnd->m_structBDTTable.fCannulaPressResistance);
	m_fPMax = dpmax;
	//计算Pmin
	float k = (float)(wnd->m_structBDTTable.fStratumFilterPercent 
		* 1000 * (1 - wnd->m_structMinusPressPara.fPressLong ));
	if(k < 10 ) k = 10;
	float miuo1 = wnd->m_structBDTTable.fStratumOilStiff ;					//原油粘度
	float miuo = (float)(4.2 + (miuo1 - 15) / 80) ;
	float density = wnd->m_structBDTTable.fFloorOilPorportion ;
	float r1 = (float)(wnd->m_structMinusPressPara.fDiameter / 20);
	float r2 = (float)(wnd->m_structMinusPressPara.fPressDeep / 10);
	r2 = r1 + r2;
//	float reynold = (float)0.05;						//雷若数 ?????????????????
	
	e = (float)1.05;
	float c = (float)(2.33e+10);
	float a1 = (float)(3.1252e+12 * miuo * miuo * 0.05 * r2 / (c * pow(k ,(2 - e )) * density ));
	float a2 = (float)(log(r2 / r1) / log(10));
	float a3 = (float)(0.05 * r2 * (1/r1 - 1/r2));
	float dpmin = (float)(a1 * (a2 + a3));

	m_fPMin = dpmin;

	if(dpmin > dpmax)
		m_fPRecMax = (float)(0.6 * dpmax);
	else
	{
		if(!m_bSand)
			m_fPRecMax = (float)(0.4 * dpmin + 0.6 * dpmax);
		else
			m_fPRecMax = (float)(0.8 * dpmin + 0.2 * dpmax);
	}

	m_fPRec = wnd->m_structBDTTable.fStratumAverPress ;
	//计算掏空深度
	float h = wnd->m_structBDTTable.fStratumCentralDepth ;
	float l = (float)(h - (h * m_fPress - m_fMinusPress * 100) / m_fWater);
	if(l < 0) l = 0;
	if(l > h) l = h;
	m_fDepth = l;
	//计算液垫高度
	h = wnd->m_structBDTTable.fStratumCentralDepth ;
	l = (float)((h * m_fPress - m_fMinusPress * 100) / m_fWater);
	if(l < 0) l = 0;
	if(l > h) l = h;
	m_fDeep = l;
	
	//修改
	wnd->m_structMinusPressPara.bSand = m_bSand;
	wnd->m_structMinusPressPara.bState = TRUE;
	wnd->m_structMinusPressPara.fClay = m_fClay;
	wnd->m_structMinusPressPara.fElasticity = m_fElasticity;
	wnd->m_structMinusPressPara.fMinusPress = m_fMinusPress;
	wnd->m_structMinusPressPara.fPossion = m_fPossion;
	wnd->m_structMinusPressPara.fPress = m_fPress;
	wnd->m_structMinusPressPara.fWater = m_fWater;
	wnd->m_structMinusPressResult.bState = TRUE;
	wnd->m_structMinusPressResult.fDeep = m_fDeep;
	wnd->m_structMinusPressResult.fDepth = m_fDepth;
	wnd->m_structMinusPressResult.fPMax = m_fPMax;
	wnd->m_structMinusPressResult.fPMin = m_fPMin;
	wnd->m_structMinusPressResult.fPRec = m_fPRec;
	wnd->m_structMinusPressResult.fPRecMax = m_fPRecMax;
	UpdateData(FALSE);
	
}

#include "resource.h"
void COilMinusPressView::OnContextMenu(CWnd*, CPoint point)
{
	// CG: This block was added by the Pop-up Menu component	{		if (point.x == -1 && point.y == -1){			//keystroke invocation			CRect rect;			GetClientRect(rect);			ClientToScreen(rect);			point = rect.TopLeft();			point.Offset(5, 5);		}		CMenu menu;		VERIFY(menu.LoadMenu(IDR_POPUP_SPD));		CMenu* pPopup = menu.GetSubMenu(3);		ASSERT(pPopup != NULL);		CWnd* pWndPopupOwner = this;		while (pWndPopupOwner->GetStyle() & WS_CHILD)			pWndPopupOwner = pWndPopupOwner->GetParent();		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,			pWndPopupOwner);	}
}

⌨️ 快捷键说明

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