|
|
|
|
|
#include "nmWxWellboreStorageCalculator.h"
|
|
|
|
|
|
#include "nmWxWellboreStorageCalculatorVolume.h"
|
|
|
|
|
|
#include "nmWxWellboreStorageCalculatorTubingData.h"
|
|
|
|
|
|
#include "nmWellboreStorageUiSupport.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <QButtonGroup>
|
|
|
|
|
|
#include <QGroupBox>
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
|
#include <QRadioButton>
|
|
|
|
|
|
#include <QStackedWidget>
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
|
|
|
|
nmWxWellboreStorageCalculator::nmWxWellboreStorageCalculator(QWidget* pParent)
|
|
|
|
|
|
: iDlgBase(pParent), m_dWellboreStorage(-1.0)
|
|
|
|
|
|
{
|
|
|
|
|
|
initUI();
|
|
|
|
|
|
initConnections();
|
|
|
|
|
|
calculateWellboreStorage();
|
|
|
|
|
|
adjustSize();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nmWxWellboreStorageCalculator::~nmWxWellboreStorageCalculator()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxWellboreStorageCalculator::initUI()
|
|
|
|
|
|
{
|
|
|
|
|
|
setWindowTitle(tr("Wellbore Storage Calculator"));
|
|
|
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
|
|
QVBoxLayout* pMain = new QVBoxLayout(this);
|
|
|
|
|
|
pMain->setContentsMargins(12, 10, 12, 0);
|
|
|
|
|
|
pMain->setSpacing(8);
|
|
|
|
|
|
|
|
|
|
|
|
QGroupBox* pModes = new QGroupBox(tr("Calculation Mode"), this);
|
|
|
|
|
|
pModes->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
|
QHBoxLayout* pModeLayout = new QHBoxLayout(pModes);
|
|
|
|
|
|
pModeLayout->setContentsMargins(8, 15, 8, 10);
|
|
|
|
|
|
QRadioButton* pClosed = new QRadioButton(tr("Closed chamber"), pModes);
|
|
|
|
|
|
QRadioButton* pLiquid = new QRadioButton(tr("Changing liquid level"), pModes);
|
|
|
|
|
|
m_pModeButtonGroup = new QButtonGroup(this);
|
|
|
|
|
|
m_pModeButtonGroup->addButton(pClosed, 0);
|
|
|
|
|
|
m_pModeButtonGroup->addButton(pLiquid, 1);
|
|
|
|
|
|
pClosed->setChecked(true);
|
|
|
|
|
|
pModeLayout->addWidget(pClosed);
|
|
|
|
|
|
pModeLayout->addWidget(pLiquid);
|
|
|
|
|
|
pMain->addWidget(pModes);
|
|
|
|
|
|
|
|
|
|
|
|
m_pStackedWidget = new QStackedWidget(this);
|
|
|
|
|
|
m_pStackedWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
|
QWidget* pClosedPage = new QWidget(m_pStackedWidget);
|
|
|
|
|
|
QGridLayout* pClosedGrid = nmWellboreStorageUi::form(pClosedPage);
|
|
|
|
|
|
m_pTestedVolumeField = new nmWellboreStorageUnitField(pClosedPage, "m^3");
|
|
|
|
|
|
m_pCompressibilityField = new nmWellboreStorageUnitField(pClosedPage, "1/MPa");
|
|
|
|
|
|
m_pTestedVolumeField->addTo(pClosedGrid, 0, tr("Tested volume"));
|
|
|
|
|
|
m_pCompressibilityField->addTo(pClosedGrid, 1, tr("Fluid compressibility"));
|
|
|
|
|
|
m_pTestedVolumeField->setValue(0.317975);
|
|
|
|
|
|
m_pCompressibilityField->setValue(0.725189);
|
|
|
|
|
|
m_pVolumeButton = new QPushButton(tr("Calculate volume"), pClosedPage);
|
|
|
|
|
|
m_pVolumeButton->setAutoDefault(false);
|
|
|
|
|
|
m_pVolumeButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
|
// 操作按钮横跨标签、数值和单位三列,随页面宽度伸展。
|
|
|
|
|
|
pClosedGrid->addWidget(m_pVolumeButton, 2, 0, 1, 3);
|
|
|
|
|
|
m_pStackedWidget->addWidget(pClosedPage);
|
|
|
|
|
|
|
|
|
|
|
|
QWidget* pLiquidPage = new QWidget(m_pStackedWidget);
|
|
|
|
|
|
QGridLayout* pLiquidGrid = nmWellboreStorageUi::form(pLiquidPage);
|
|
|
|
|
|
m_pTubingIdField = new nmWellboreStorageUnitField(pLiquidPage, "m");
|
|
|
|
|
|
m_pDensityField = new nmWellboreStorageUnitField(pLiquidPage, "kg/m^3");
|
|
|
|
|
|
m_pTubingIdField->addTo(pLiquidGrid, 0, tr("Tubing I.D."));
|
|
|
|
|
|
m_pDensityField->addTo(pLiquidGrid, 1, tr("Fluid density"));
|
|
|
|
|
|
m_pTubingIdField->setValue(0.09144);
|
|
|
|
|
|
m_pDensityField->setValue(1000.0);
|
|
|
|
|
|
m_pTubingButton = new QPushButton(tr("Select tubing"), pLiquidPage);
|
|
|
|
|
|
m_pTubingButton->setAutoDefault(false);
|
|
|
|
|
|
m_pTubingButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
|
// 操作按钮横跨标签、数值和单位三列,随页面宽度伸展。
|
|
|
|
|
|
pLiquidGrid->addWidget(m_pTubingButton, 2, 0, 1, 3);
|
|
|
|
|
|
m_pStackedWidget->addWidget(pLiquidPage);
|
|
|
|
|
|
pMain->addWidget(m_pStackedWidget);
|
|
|
|
|
|
|
|
|
|
|
|
QGroupBox* pResult = new QGroupBox(tr("Result"), this);
|
|
|
|
|
|
QGridLayout* pResultGrid = nmWellboreStorageUi::form(pResult);
|
|
|
|
|
|
m_pStorageField = new nmWellboreStorageUnitField(pResult, "m^3/MPa", true);
|
|
|
|
|
|
m_pStorageField->addTo(pResultGrid, 0, tr("Wellbore storage"));
|
|
|
|
|
|
pMain->addWidget(pResult);
|
|
|
|
|
|
pMain->addStretch(1);
|
|
|
|
|
|
|
|
|
|
|
|
QWidget* pFooter = new QWidget(this);
|
|
|
|
|
|
pFooter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
|
QHBoxLayout* pFooterLayout = new QHBoxLayout(pFooter);
|
|
|
|
|
|
pFooterLayout->setContentsMargins(4, 5, 4, 5);
|
|
|
|
|
|
m_pRefreshButton = new QPushButton(tr("Recalculate"), pFooter);
|
|
|
|
|
|
m_pRefreshButton->setIcon(zxLoadIcon("NmWellboreStorageRefresh"));
|
|
|
|
|
|
m_pRefreshButton->setAutoDefault(false);
|
|
|
|
|
|
pFooterLayout->addWidget(m_pRefreshButton);
|
|
|
|
|
|
QDialogButtonBox* pButtons = nmWellboreStorageUi::buttons(pFooter, tr("OK"), tr("Cancel"));
|
|
|
|
|
|
m_pOkButton = pButtons->button(QDialogButtonBox::Ok);
|
|
|
|
|
|
pFooterLayout->addWidget(pButtons, 1);
|
|
|
|
|
|
pMain->addWidget(pFooter);
|
|
|
|
|
|
connect(pButtons, SIGNAL(accepted()), this, SLOT(accept()));
|
|
|
|
|
|
connect(pButtons, SIGNAL(rejected()), this, SLOT(reject()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxWellboreStorageCalculator::initConnections()
|
|
|
|
|
|
{
|
|
|
|
|
|
connect(m_pModeButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(onModeChanged(int)));
|
|
|
|
|
|
connect(m_pVolumeButton, SIGNAL(clicked()), this, SLOT(onClosedChamberCalculateClicked()));
|
|
|
|
|
|
connect(m_pTubingButton, SIGNAL(clicked()), this, SLOT(onChangingLiquidLevelCalculateClicked()));
|
|
|
|
|
|
connect(m_pRefreshButton, SIGNAL(clicked()), this, SLOT(onInputChanged()));
|
|
|
|
|
|
nmWellboreStorageUnitField* fields[] = { m_pTestedVolumeField, m_pCompressibilityField,
|
|
|
|
|
|
m_pTubingIdField, m_pDensityField, m_pStorageField };
|
|
|
|
|
|
for (int i = 0; i < 5; ++i) {
|
|
|
|
|
|
if (i < 4) connect(fields[i]->editor(), SIGNAL(textChanged(QString)), this, SLOT(onInputChanged()));
|
|
|
|
|
|
connect(fields[i]->unitCombo(), SIGNAL(currentIndexChanged(int)), this, SLOT(onUnitChanged()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxWellboreStorageCalculator::onModeChanged(int nMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pStackedWidget->setCurrentIndex(nMode);
|
|
|
|
|
|
calculateWellboreStorage();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxWellboreStorageCalculator::onInputChanged()
|
|
|
|
|
|
{
|
|
|
|
|
|
calculateWellboreStorage();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxWellboreStorageCalculator::onUnitChanged()
|
|
|
|
|
|
{
|
|
|
|
|
|
nmWellboreStorageUnitField* fields[] = { m_pTestedVolumeField, m_pCompressibilityField,
|
|
|
|
|
|
m_pTubingIdField, m_pDensityField, m_pStorageField };
|
|
|
|
|
|
for (int i = 0; i < 5; ++i) {
|
|
|
|
|
|
if (sender() == fields[i]->unitCombo()) {
|
|
|
|
|
|
fields[i]->changeUnit();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
calculateWellboreStorage();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool nmWxWellboreStorageCalculator::calculateWellboreStorage()
|
|
|
|
|
|
{
|
|
|
|
|
|
double dFirst = 0.0, dSecond = 0.0, dStorage = -1.0;
|
|
|
|
|
|
bool bValid = false;
|
|
|
|
|
|
if (m_pStackedWidget->currentIndex() == 0) {
|
|
|
|
|
|
bValid = m_pTestedVolumeField->read(dFirst) && dFirst > 0.0
|
|
|
|
|
|
&& m_pCompressibilityField->read(dSecond) && dSecond >= 0.0;
|
|
|
|
|
|
// 密闭井筒 C = V * Cf;m³ × 1/MPa 直接得到 m³/MPa。
|
|
|
|
|
|
if (bValid) dStorage = dFirst * dSecond;
|
|
|
|
|
|
} else if (m_pStackedWidget->currentIndex() == 1) {
|
|
|
|
|
|
bValid = m_pTubingIdField->read(dFirst) && dFirst > 0.0
|
|
|
|
|
|
&& m_pDensityField->read(dSecond) && dSecond > 0.0;
|
|
|
|
|
|
if (bValid) {
|
|
|
|
|
|
// 液面变化 C = A/(rho*g);框架把每米液柱压差从 Pa 转为 MPa。
|
|
|
|
|
|
// 通过压力单位组换算,兼容未配置 m³/Pa 的旧井储单位表。
|
|
|
|
|
|
const double dRadius = dFirst * 0.5;
|
|
|
|
|
|
double dPressurePerMeter = 0.0;
|
|
|
|
|
|
bValid = nmWellboreStorageUi::convert(dSecond * 9.80665, "Pa", "MPa", dPressurePerMeter)
|
|
|
|
|
|
&& dPressurePerMeter > 0.0;
|
|
|
|
|
|
if (bValid) dStorage = acos(-1.0) * dRadius * dRadius / dPressurePerMeter;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
bValid = bValid && qIsFinite(dStorage) && dStorage >= 0.0;
|
|
|
|
|
|
if (bValid) bValid = m_pStorageField->setValue(dStorage);
|
|
|
|
|
|
if (!bValid) m_pStorageField->clear();
|
|
|
|
|
|
m_dWellboreStorage = bValid ? dStorage : -1.0;
|
|
|
|
|
|
m_pOkButton->setEnabled(bValid);
|
|
|
|
|
|
return bValid;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double nmWxWellboreStorageCalculator::getWellboreStorageValue() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_dWellboreStorage;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxWellboreStorageCalculator::accept()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 不从只读显示文本取结果,保证精度及显示单位不影响回填。
|
|
|
|
|
|
if (calculateWellboreStorage()) iDlgBase::accept();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxWellboreStorageCalculator::onClosedChamberCalculateClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
nmWxWellboreStorageCalculatorVolume oDialog(this);
|
|
|
|
|
|
oDialog.setSegments(m_vecVolumeSegments);
|
|
|
|
|
|
if (oDialog.exec() != QDialog::Accepted) return;
|
|
|
|
|
|
const double dVolume = oDialog.getCalculatedVolume();
|
|
|
|
|
|
if (dVolume <= 0.0 || !qIsFinite(dVolume)) return;
|
|
|
|
|
|
if (m_pTestedVolumeField->setValue(dVolume)) m_vecVolumeSegments = oDialog.segments();
|
|
|
|
|
|
calculateWellboreStorage();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nmWxWellboreStorageCalculator::onChangingLiquidLevelCalculateClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
nmWxWellboreStorageCalculatorTubingData oDialog(this);
|
|
|
|
|
|
double dCurrentId = 0.0;
|
|
|
|
|
|
if (m_pTubingIdField->read(dCurrentId)) oDialog.setSelectedTubingID(dCurrentId);
|
|
|
|
|
|
if (oDialog.exec() != QDialog::Accepted) return;
|
|
|
|
|
|
const double dId = oDialog.getSelectedTubingID();
|
|
|
|
|
|
if (dId <= 0.0 || !qIsFinite(dId)) return;
|
|
|
|
|
|
m_pTubingIdField->setValue(dId);
|
|
|
|
|
|
calculateWellboreStorage();
|
|
|
|
|
|
}
|