📄 gasminuspressview.cpp
字号:
// GasMinusPressView.cpp : implementation file
//
#include "stdafx.h"
#include "CVenus.h"
#include "MainFrm.h"
#include "GasMinusPressView.h"
#include "ChildFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGasMinusPressView
IMPLEMENT_DYNCREATE(CGasMinusPressView, CFormView)
CGasMinusPressView::CGasMinusPressView()
: CFormView(CGasMinusPressView::IDD)
{
//{{AFX_DATA_INIT(CGasMinusPressView)
m_bSand = FALSE;
m_fClay = 0.0f;
m_fDeep = 0.0f;
m_fDepth = 0.0f;
m_fElasticity = 0.0f;
m_fMinusPress = 0.0f;
m_fPMax = 0.0f;
m_fPMin = 0.0f;
m_fPossion = 0.0f;
m_fPress = 0.0f;
m_fWater = 0.0f;
m_fPRec = 0.0f;
m_fPRecMax = 0.0f;
//}}AFX_DATA_INIT
}
CGasMinusPressView::~CGasMinusPressView()
{
}
void CGasMinusPressView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGasMinusPressView)
DDX_Control(pDX, IDC_EDIT_PRECMAX, m_ctrlPRecMax);
DDX_Control(pDX, IDC_STATIC_PRECMAX, m_ctrlStaticPRecMax);
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_MINUSPRESS, m_fMinusPress);
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_PRESS, m_fPress);
DDX_Text(pDX, IDC_EDIT_WATER, m_fWater);
DDX_Text(pDX, IDC_EDIT_PREC, m_fPRec);
DDX_Text(pDX, IDC_EDIT_PRECMAX, m_fPRecMax);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGasMinusPressView, CFormView)
ON_WM_CONTEXTMENU()
//{{AFX_MSG_MAP(CGasMinusPressView)
ON_WM_CREATE()
ON_COMMAND(ID_SPD_CACL, OnSpdCacl)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGasMinusPressView diagnostics
#ifdef _DEBUG
void CGasMinusPressView::AssertValid() const
{
CFormView::AssertValid();
}
void CGasMinusPressView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CGasMinusPressView message handlers
int CGasMinusPressView::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;
}
float CGasMinusPressView::zfact(float tf1, float tp1, float rg)
{
float zf,tpc,ppc;
if(rg>=0.7)
{
tpc = (float)(92.2+176.6*rg);
ppc = (float)(4.881-0.3861*rg);
}
else
{
tpc = (float)(92.2+176.7*rg);
ppc = (float)(4.788-0.248*rg);
}
float tpr = tf1/tpc;
float ppr = tp1/ppc;
float a1 = (float)0.31506237;
float a2 = (float)-1.0467099;
float a3 = (float)-0.57832729;
float a4 = (float)0.53530771;
float a5 = (float)-0.61232032;
float a6 = (float)-0.10488813;
float a7 = (float)0.681570009;
float a8 = (float)0.68446549;
float b1 = (float)(-0.27*ppr/tpr);
float b2 = (float)(a1+a2/tpr+a3/pow(tpr,3));
float b3 = a4+a5/tpr;
float b4 = a5*a6/tpr;
float b5 = (float)(a7/pow(tpr,3));
float fo = (float)(0.27*ppr/tpr);
float ff,df,stpp,f1,fTemp;
do
{
ff = (float)(fo+b1+b2*fo*fo+b3*pow(fo,3)+
b4*pow(fo,6)+b5*pow(fo,3)*
(1+a8*fo*fo)*exp(-a8*fo*fo));
df = (float)(1+2*b2*fo+3*b3*fo*fo+6*b4*pow(fo,5)+
b5*(3*fo*fo+3*a8*pow(fo,4)-2*a8*a8*pow(fo,6))
*exp(-a8*fo*fo));
if(fo<(ff/df))
{
stpp = (float)0.001;
f1 = fo - stpp*ff/df;
}
else
f1 = fo - ff/df;
fTemp = f1-fo;
if(fTemp<0) fTemp = -fTemp;
if(fTemp<=0.0001)
break;
fo = f1;
}while(true);
zf = (float)(1+b2*fo+b3*fo*fo+b4*pow(fo,5)+b5*pow(fo,2)*
(1+a8*fo*fo)*exp(-a8*fo*fo));
return zf;
}
float CGasMinusPressView::viscosity(float tf1, float pt1, float zf, float rg)
{
float m = (float)(rg*28.97);
float k = (float)((9.4+0.02*m)*pow(1.8*tf1,1.5)/(209+19*m+1.8*tf1));
float x = (float)(3.5+986/(1.8*tf1)+0.01*m);
float y = (float)(2.4-0.2*x);
float rr = (float)(zf*tf1);
float dd = (float)(3.4844*pt1*rg/rr);
float visg = (float)(k*0.0001*exp(x*pow(dd,y)));
return visg;
}
float CGasMinusPressView::indexx(float t, float p, float rg)
{
float p1 = (float)(p+5);
float p2 = (float)(p-5);
float den1 = density(t,p1,rg);
float den2 = density(t,p2,rg);
float m = (float)(log(den1/den2)/log(p1/p2));
return m;
}
float CGasMinusPressView::density(float t, float p, float rg)
{
float tf1 = (float)((t-492)/1.8+273.15);
float tp1 = (float)(p/14.7/9.869);
float z = zfact(tf1,tp1,rg);
float den = (float)(2.7*0.016*p*rg/(z*t));
return den;
}
void CGasMinusPressView::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.fStratumTemp == 0)
{
MessageBox("请输入地层温度 !","工程信息");
return;
}
if(wnd->m_structBDTTable.fFloorGasPorportion == 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;
}
UpdateData(FALSE);
//*****************************************
float r1 = (float)(wnd->m_structMinusPressPara.fDiameter / 20);
float r2 = (float)(wnd->m_structMinusPressPara.fPressDeep / 10);
r2 = r1 + r2;
float vsh = wnd->m_structMinusPressPara.fClay ;
float pe = wnd->m_structBDTTable.fStratumAverPress ;
float t = wnd->m_structBDTTable.fStratumTemp ;
float rg = wnd->m_structBDTTable.fFloorGasPorportion ;
float fi = (float)(wnd->m_structBDTTable.fStratumHolePercent * 100);
float ky = (float)(wnd->m_structBDTTable.fStratumFilterPercent * 1000);
float e = wnd->m_structMinusPressPara.fElasticity ;
float po = wnd->m_structMinusPressPara.fPossion ;
//计算PMin*********************
float fun[3];
float k = ky;
float reynold;
if(k>0.1 && k<= 0.5)
reynold = (float)(0.231+0.0216*(1-k)/k);
else if(k>0.5 && k <= 1)
reynold = (float)(0.173+0.105*(1-k));
else if(k>1 && k<10)
reynold = (float)(0.176+0.13*k/10);
else if(k>=10 && k<50)
{
reynold = (float)0.3;
for(int i = 1;i<(int)(k/10)-1;i++)
reynold = (float)(reynold+0.13/(2*i));
}
else if(k>=50 && k<100)
reynold = (float)(0.4452+0.008*((int)((k-50)/10)+(k-50)/15));
else if(k>=100 && k<160)
reynold = (float)(0.51+(k-100)/20*0.02);
else if(k>=160)
reynold = (float)(0.57+(k-160)/20*0.01);
float beta = (float)1.5;
float pw = (float)(2900/pow(k,0.36)/14.7/9.869);
float ddp = (float)0.001;
float a1,a2,a3,a4,a5;
a3 = (float)(r2*log(r2/r1));
a4 = (float)(reynold*r2*(r2/r1 -1));
int i;
float dp,z,miuo,pww,fTemp;
do
{
for(i=0;i<3;i++)
{
if(i==1)
dp = ddp;
else
dp = -ddp;
if(i==0)
dp = (float)0;
fTemp = (float)(0.5*(pw+dp+pe));
z = zfact(t,fTemp,rg);
miuo = viscosity(t,fTemp,z,rg);
a1 = (float)(pe*pe-(pw+dp)*(pw+dp));
a2 = (float)(75.088*miuo*miuo*z*t*reynold);
a5 = (float)(rg*pow(k,(2-beta)));
fun[i] = (float)(a1-(a3+a4)*a2/a5);
}
pww = (float)(pw-2*fun[0]*ddp/(fun[1]-fun[2]));
if(pww<0)
pww = (float)(pw - 0.0001*2*fun[0]/(fun[1]-fun[2]));
pw = pww;
fTemp = fun[0];
if(fTemp<0) fTemp = -fTemp;
}while(fTemp>0.0001);
fTemp = (float)(pe-pw);
if(fTemp<0) fTemp = -fTemp;
float dpmin = fTemp*100;
float dp1;
if(k<1)
{
dp1 = (float)(17240/k/1000+0.5*k);
dpmin = dp1;
}
//计算PMax*********************
pe = (float)(pe*14.7*9.869);
t = (float)(1.8*(t-273.15)+32+460);
e = (float)(e*14.7*9.869/1000000);
float kb = (float)(e/(3*(1-2*po)));
float cu = (float)((114+97*vsh)*kb*e);
float angle = (float)(57.8 - 1.05*fi);
angle = (float)(angle/180*3.1415926);
float sing = (float)(4*sin(angle)/(1-sin(angle)));
float div = (float)(tan(angle)/cu);
float m = indexx(t,pe,rg);
m = (float)(m/15);
float pee = (float)pow(pe*div,(int)(m+1));
pww = (float)pow(0.5*pe*div,(int)(m+1));
float step1 = (float)0.001;
float fun0,fun1;
do
{
fun0 = (float)(sing-(pee-pww)*pow(pww,(int)((-m/(m+1))/(m+1))));
fun1 = (float)(pow(pww,(int)((-m/(m+1))))+m*(pee-pww)*
pow(pww,(int)(-(2*m+1)/(m+1)))/pow(m+1,2));
pw = pww - fun0/fun1;
if(pww<fun0/fun1)
pw = pww-step1*fun0/fun1;
fTemp = pw - pww;
if(fTemp<0) fTemp = -fTemp;
if(fTemp<=0.0001) break;
pww = pw;
}while(true);
pw = (float)(pow(pw,(int)(1/(m+1)))/div);
fTemp = pe - pw;
if(fTemp<0) fTemp = -fTemp;
float dpmax = (float)(fTemp/14.7/9.869);
if(dpmax>wnd->m_structBDTTable.fCannulaPressResistance)
dpmax = wnd->m_structBDTTable.fCannulaPressResistance;
//**计算PRec
float purec;
UpdateData();
if(dpmin>dpmax)
purec = (float)(0.6*dpmax);
else if(m_bSand == FALSE)
purec = (float)(0.4*dpmin+0.6*dpmax);
else
purec = (float)(0.8*dpmin+0.2*dpmax);
//******
m_fPMin = dpmin;//(float)((int)(dpmin*100)/100);
m_fPMax = dpmax;//(float)((int)(dpmax*100)/100);
m_fPRec = purec;//(float)((int)(purec*100)/100);
if(purec>wnd->m_structBDTTable.fStratumAverPress)
{
m_ctrlStaticPRecMax.ShowWindow(true);
m_ctrlPRecMax.ShowWindow(true);
m_fPRecMax = wnd->m_structBDTTable.fStratumAverPress;
}
else
{
m_ctrlStaticPRecMax.ShowWindow(false);
m_ctrlPRecMax.ShowWindow(false);
}
//******
//***************************************
//计算井筒掏空深度和液垫高度
float l1 = (float)(wnd->m_structBDTTable.fStratumCentralDepth -
(wnd->m_structBDTTable.fStratumCentralDepth*m_fPress-m_fMinusPress*100)/m_fWater);
if(l1<0) l1 = 0;
if(l1>wnd->m_structBDTTable.fStratumCentralDepth) l1 = wnd->m_structBDTTable.fStratumCentralDepth;
m_fDepth = l1;
//
float l2 = (float)((wnd->m_structBDTTable.fStratumCentralDepth*m_fPress-m_fMinusPress*100)/m_fWater);
if(l2<0) l2 = 0;
if(l2>wnd->m_structBDTTable.fStratumCentralDepth) l2 = wnd->m_structBDTTable.fStratumCentralDepth;
m_fDeep = l2;
//修改
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 CGasMinusPressView::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 + -