#include "nmDataAutomaticFitting.h" nmDataAutomaticFitting::nmDataAutomaticFitting() { // 初始化参数选择标志 m_permeabilitySelected = true; // 默认选中 m_skinSelected = true; // 默认选中 m_wellboreStorageSelected = true; // 默认选中 m_porositySelected = true; // 默认选中 m_initialPressureSelected = false; // 默认不选中 m_thicknessSelected = true; // 默认选中 m_ctSelected = false; // 默认不选中 m_cfSelected = false; // 默认不选中 m_soiSelected = false; // 默认不选中 m_swiSelected = false; // 默认不选中 m_sgiSelected = false; // 默认不选中 // 初始化参数最大值 m_permeabilityMax = nmDataAttribute("Permeability Max", 10.0, "Darcy"); // 1000 mD m_skinMax = nmDataAttribute("Skin Max", 10.0, ""); // 100 m_wellboreStorageMax = nmDataAttribute("Wellbore Storage Max", 2.0, "m3/MPa"); m_porosityMax = nmDataAttribute("Porosity Max", 0.5, ""); // 50% m_initialPressureMax = nmDataAttribute("Initial Pressure Max", 50.0, "MPa"); m_thicknessMax = nmDataAttribute("Thickness Max", 50.0, "m"); m_ctMax = nmDataAttribute("Ct Max", 1, ""); // 1/MPa m_cfMax = nmDataAttribute("Cf Max", 0.01, ""); // 1/MPa m_soiMax = nmDataAttribute("Soi Max", 1.0, ""); m_sgiMax = nmDataAttribute("Sgi Max", 1.0, ""); m_swiMax = nmDataAttribute("Swi Max", 1.0, ""); // 初始化参数最小值 m_permeabilityMin = nmDataAttribute("Permeability Min", 0.001, "Darcy"); // 0.001 mD m_skinMin = nmDataAttribute("Skin Min", -10.0, ""); // 允许负表皮 m_wellboreStorageMin = nmDataAttribute("Wellbore Storage Min", 1e-4, "m3/MPa"); m_porosityMin = nmDataAttribute("Porosity Min", 0.01, ""); // 1% m_initialPressureMin = nmDataAttribute("Initial Pressure Min", 0.1, "MPa"); m_thicknessMin = nmDataAttribute("Thickness Min", 2.0, "m"); m_ctMin = nmDataAttribute("Ct Min", 1e-4, ""); // 小正值 m_cfMin = nmDataAttribute("Cf Min", 1e-5, ""); // 小正值 m_soiMin = nmDataAttribute("Soi Min", 0.0, ""); m_sgiMin = nmDataAttribute("Sgi Min", 0.0, ""); m_swiMin = nmDataAttribute("Swi Min", 0.0, ""); // 初始化迭代参数 m_iterationCount = nmDataAttribute("Iteration Count", 20, ""); m_errorTolerance = nmDataAttribute("Error Tolerance", 0.02, ""); m_algorithmName = QString(tr("PSO (Particle Swarm Optimization)")); m_surrogateScreeningEnabled = false; } nmDataAutomaticFitting::~nmDataAutomaticFitting() { } nmDataAutomaticFitting::nmDataAutomaticFitting(const nmDataAutomaticFitting& other) { *this = other; } nmDataAutomaticFitting& nmDataAutomaticFitting::operator=(const nmDataAutomaticFitting& other) { if (this != &other) { // 复制参数选择标志 m_permeabilitySelected = other.m_permeabilitySelected; m_skinSelected = other.m_skinSelected; m_wellboreStorageSelected = other.m_wellboreStorageSelected; m_porositySelected = other.m_porositySelected; m_initialPressureSelected = other.m_initialPressureSelected; m_thicknessSelected = other.m_thicknessSelected; m_ctSelected = other.m_ctSelected; m_cfSelected = other.m_cfSelected; m_soiSelected = other.m_soiSelected; m_sgiSelected = other.m_sgiSelected; m_swiSelected = other.m_swiSelected; // 复制参数最大值 m_permeabilityMax = other.m_permeabilityMax; m_skinMax = other.m_skinMax; m_wellboreStorageMax = other.m_wellboreStorageMax; m_porosityMax = other.m_porosityMax; m_initialPressureMax = other.m_initialPressureMax; m_thicknessMax = other.m_thicknessMax; m_ctMax = other.m_ctMax; m_cfMax = other.m_cfMax; m_soiMax = other.m_soiMax; m_sgiMax = other.m_sgiMax; m_swiMax = other.m_swiMax; // 复制参数最小值 m_permeabilityMin = other.m_permeabilityMin; m_skinMin = other.m_skinMin; m_wellboreStorageMin = other.m_wellboreStorageMin; m_porosityMin = other.m_porosityMin; m_initialPressureMin = other.m_initialPressureMin; m_thicknessMin = other.m_thicknessMin; m_ctMin = other.m_ctMin; m_cfMin = other.m_cfMin; m_soiMin = other.m_soiMin; m_sgiMin = other.m_sgiMin; m_swiMin = other.m_swiMin; // 复制迭代参数 m_iterationCount = other.m_iterationCount; m_errorTolerance = other.m_errorTolerance; m_algorithmName = other.m_algorithmName; m_surrogateScreeningEnabled = other.m_surrogateScreeningEnabled; } return *this; } rapidjson::Value nmDataAutomaticFitting::ToJsonValue(rapidjson::Document::AllocatorType& allocator) const { rapidjson::Value fittingObject(rapidjson::kObjectType); // 序列化参数选择标志 fittingObject.AddMember("PermeabilitySelected", m_permeabilitySelected, allocator); fittingObject.AddMember("SkinSelected", m_skinSelected, allocator); fittingObject.AddMember("WellboreStorageSelected", m_wellboreStorageSelected, allocator); fittingObject.AddMember("PorositySelected", m_porositySelected, allocator); fittingObject.AddMember("InitialPressureSelected", m_initialPressureSelected, allocator); fittingObject.AddMember("ThicknessSelected", m_thicknessSelected, allocator); fittingObject.AddMember("CtSelected", m_ctSelected, allocator); fittingObject.AddMember("CfSelected", m_cfSelected, allocator); fittingObject.AddMember("SoiSelected", m_soiSelected, allocator); fittingObject.AddMember("SgiSelected", m_sgiSelected, allocator); fittingObject.AddMember("SwiSelected", m_swiSelected, allocator); // 序列化参数最大值 fittingObject.AddMember("PermeabilityMax", m_permeabilityMax.ToJsonValue(allocator), allocator); fittingObject.AddMember("SkinMax", m_skinMax.ToJsonValue(allocator), allocator); fittingObject.AddMember("WellboreStorageMax", m_wellboreStorageMax.ToJsonValue(allocator), allocator); fittingObject.AddMember("PorosityMax", m_porosityMax.ToJsonValue(allocator), allocator); fittingObject.AddMember("InitialPressureMax", m_initialPressureMax.ToJsonValue(allocator), allocator); fittingObject.AddMember("ThicknessMax", m_thicknessMax.ToJsonValue(allocator), allocator); fittingObject.AddMember("CtMax", m_ctMax.ToJsonValue(allocator), allocator); fittingObject.AddMember("CfMax", m_cfMax.ToJsonValue(allocator), allocator); fittingObject.AddMember("SoiMax", m_soiMax.ToJsonValue(allocator), allocator); fittingObject.AddMember("SgiMax", m_sgiMax.ToJsonValue(allocator), allocator); fittingObject.AddMember("SwiMax", m_swiMax.ToJsonValue(allocator), allocator); // 序列化参数最小值 fittingObject.AddMember("PermeabilityMin", m_permeabilityMin.ToJsonValue(allocator), allocator); fittingObject.AddMember("SkinMin", m_skinMin.ToJsonValue(allocator), allocator); fittingObject.AddMember("WellboreStorageMin", m_wellboreStorageMin.ToJsonValue(allocator), allocator); fittingObject.AddMember("PorosityMin", m_porosityMin.ToJsonValue(allocator), allocator); fittingObject.AddMember("InitialPressureMin", m_initialPressureMin.ToJsonValue(allocator), allocator); fittingObject.AddMember("ThicknessMin", m_thicknessMin.ToJsonValue(allocator), allocator); fittingObject.AddMember("CtMin", m_ctMin.ToJsonValue(allocator), allocator); fittingObject.AddMember("CfMin", m_cfMin.ToJsonValue(allocator), allocator); fittingObject.AddMember("SoiMin", m_soiMin.ToJsonValue(allocator), allocator); fittingObject.AddMember("SgiMin", m_sgiMin.ToJsonValue(allocator), allocator); fittingObject.AddMember("SwiMin", m_swiMin.ToJsonValue(allocator), allocator); // 序列化迭代参数 fittingObject.AddMember("IterationCount", m_iterationCount.ToJsonValue(allocator), allocator); fittingObject.AddMember("ErrorTolerance", m_errorTolerance.ToJsonValue(allocator), allocator); fittingObject.AddMember("AlgorithmName", rapidjson::Value(m_algorithmName.toStdString().c_str(), allocator).Move(), allocator); fittingObject.AddMember("SurrogateScreeningEnabled", m_surrogateScreeningEnabled, allocator); return fittingObject; } void nmDataAutomaticFitting::FromJsonValue(const rapidjson::Value& jsonValue) { // 反序列化参数选择标志 if (jsonValue.HasMember("PermeabilitySelected") && jsonValue["PermeabilitySelected"].IsBool()) { m_permeabilitySelected = jsonValue["PermeabilitySelected"].GetBool(); } if (jsonValue.HasMember("SkinSelected") && jsonValue["SkinSelected"].IsBool()) { m_skinSelected = jsonValue["SkinSelected"].GetBool(); } if (jsonValue.HasMember("WellboreStorageSelected") && jsonValue["WellboreStorageSelected"].IsBool()) { m_wellboreStorageSelected = jsonValue["WellboreStorageSelected"].GetBool(); } if (jsonValue.HasMember("PorositySelected") && jsonValue["PorositySelected"].IsBool()) { m_porositySelected = jsonValue["PorositySelected"].GetBool(); } if (jsonValue.HasMember("InitialPressureSelected") && jsonValue["InitialPressureSelected"].IsBool()) { m_initialPressureSelected = jsonValue["InitialPressureSelected"].GetBool(); } if (jsonValue.HasMember("ThicknessSelected") && jsonValue["ThicknessSelected"].IsBool()) { m_thicknessSelected = jsonValue["ThicknessSelected"].GetBool(); } if (jsonValue.HasMember("CtSelected") && jsonValue["CtSelected"].IsBool()) { m_ctSelected = jsonValue["CtSelected"].GetBool(); } if (jsonValue.HasMember("CfSelected") && jsonValue["CfSelected"].IsBool()) { m_cfSelected = jsonValue["CfSelected"].GetBool(); } if (jsonValue.HasMember("SoiSelected") && jsonValue["SoiSelected"].IsBool()) { m_soiSelected = jsonValue["SoiSelected"].GetBool(); } if (jsonValue.HasMember("SgoiSelected") && jsonValue["SgiSelected"].IsBool()) { m_soiSelected = jsonValue["SgiSelected"].GetBool(); } if (jsonValue.HasMember("SwiSelected") && jsonValue["SwiSelected"].IsBool()) { m_soiSelected = jsonValue["SwiSelected"].GetBool(); } // 反序列化参数最大值 if (jsonValue.HasMember("PermeabilityMax") && jsonValue["PermeabilityMax"].IsObject()) { m_permeabilityMax.FromJsonValue(jsonValue["PermeabilityMax"]); } if (jsonValue.HasMember("SkinMax") && jsonValue["SkinMax"].IsObject()) { m_skinMax.FromJsonValue(jsonValue["SkinMax"]); } if (jsonValue.HasMember("WellboreStorageMax") && jsonValue["WellboreStorageMax"].IsObject()) { m_wellboreStorageMax.FromJsonValue(jsonValue["WellboreStorageMax"]); } if (jsonValue.HasMember("PorosityMax") && jsonValue["PorosityMax"].IsObject()) { m_porosityMax.FromJsonValue(jsonValue["PorosityMax"]); } if (jsonValue.HasMember("InitialPressureMax") && jsonValue["InitialPressureMax"].IsObject()) { m_initialPressureMax.FromJsonValue(jsonValue["InitialPressureMax"]); } if (jsonValue.HasMember("ThicknessMax") && jsonValue["ThicknessMax"].IsObject()) { m_thicknessMax.FromJsonValue(jsonValue["ThicknessMax"]); } if (jsonValue.HasMember("CtMax") && jsonValue["CtMax"].IsObject()) { m_ctMax.FromJsonValue(jsonValue["CtMax"]); } if (jsonValue.HasMember("CfMax") && jsonValue["CfMax"].IsObject()) { m_cfMax.FromJsonValue(jsonValue["CfMax"]); } if (jsonValue.HasMember("SoiMax") && jsonValue["SoiMax"].IsObject()) { m_soiMax.FromJsonValue(jsonValue["SoiMax"]); } if (jsonValue.HasMember("SgiMax") && jsonValue["SgiMax"].IsObject()) { m_soiMax.FromJsonValue(jsonValue["SgiMax"]); } if (jsonValue.HasMember("SwiMax") && jsonValue["SwiMax"].IsObject()) { m_soiMax.FromJsonValue(jsonValue["SwiMax"]); } // 反序列化参数最小值 if (jsonValue.HasMember("PermeabilityMin") && jsonValue["PermeabilityMin"].IsObject()) { m_permeabilityMin.FromJsonValue(jsonValue["PermeabilityMin"]); } if (jsonValue.HasMember("SkinMin") && jsonValue["SkinMin"].IsObject()) { m_skinMin.FromJsonValue(jsonValue["SkinMin"]); } if (jsonValue.HasMember("WellboreStorageMin") && jsonValue["WellboreStorageMin"].IsObject()) { m_wellboreStorageMin.FromJsonValue(jsonValue["WellboreStorageMin"]); } if (jsonValue.HasMember("PorosityMin") && jsonValue["PorosityMin"].IsObject()) { m_porosityMin.FromJsonValue(jsonValue["PorosityMin"]); } if (jsonValue.HasMember("InitialPressureMin") && jsonValue["InitialPressureMin"].IsObject()) { m_initialPressureMin.FromJsonValue(jsonValue["InitialPressureMin"]); } if (jsonValue.HasMember("ThicknessMin") && jsonValue["ThicknessMin"].IsObject()) { m_thicknessMin.FromJsonValue(jsonValue["ThicknessMin"]); } if (jsonValue.HasMember("CtMin") && jsonValue["CtMin"].IsObject()) { m_ctMin.FromJsonValue(jsonValue["CtMin"]); } if (jsonValue.HasMember("CfMin") && jsonValue["CfMin"].IsObject()) { m_cfMin.FromJsonValue(jsonValue["CfMin"]); } if (jsonValue.HasMember("SoiMin") && jsonValue["SoiMin"].IsObject()) { m_soiMin.FromJsonValue(jsonValue["SoiMin"]); } if (jsonValue.HasMember("SgiMin") && jsonValue["SgiMin"].IsObject()) { m_soiMin.FromJsonValue(jsonValue["SgiMin"]); } if (jsonValue.HasMember("SwiMin") && jsonValue["SwiMin"].IsObject()) { m_soiMin.FromJsonValue(jsonValue["SwiMin"]); } // 反序列化迭代参数 if (jsonValue.HasMember("IterationCount") && jsonValue["IterationCount"].IsObject()) { m_iterationCount.FromJsonValue(jsonValue["IterationCount"]); } if (jsonValue.HasMember("ErrorTolerance") && jsonValue["ErrorTolerance"].IsObject()) { m_errorTolerance.FromJsonValue(jsonValue["ErrorTolerance"]); } if (jsonValue.HasMember("AlgorithmName") && jsonValue["AlgorithmName"].IsString()) { m_algorithmName = QString::fromUtf8(jsonValue["AlgorithmName"].GetString()); } if (jsonValue.HasMember("SurrogateScreeningEnabled") && jsonValue["SurrogateScreeningEnabled"].IsBool()) { m_surrogateScreeningEnabled = jsonValue["SurrogateScreeningEnabled"].GetBool(); } } // Getter and Setter implementations for parameter selection flags bool nmDataAutomaticFitting::getPermeabilitySelected() const { return m_permeabilitySelected; } void nmDataAutomaticFitting::setPermeabilitySelected(bool selected) { m_permeabilitySelected = selected; } bool nmDataAutomaticFitting::getSkinSelected() const { return m_skinSelected; } void nmDataAutomaticFitting::setSkinSelected(bool selected) { m_skinSelected = selected; } bool nmDataAutomaticFitting::getWellboreStorageSelected() const { return m_wellboreStorageSelected; } void nmDataAutomaticFitting::setWellboreStorageSelected(bool selected) { m_wellboreStorageSelected = selected; } bool nmDataAutomaticFitting::getPorositySelected() const { return m_porositySelected; } void nmDataAutomaticFitting::setPorositySelected(bool selected) { m_porositySelected = selected; } bool nmDataAutomaticFitting::getInitialPressureSelected() const { return m_initialPressureSelected; } void nmDataAutomaticFitting::setInitialPressureSelected(bool selected) { m_initialPressureSelected = selected; } bool nmDataAutomaticFitting::getThicknessSelected() const { return m_thicknessSelected; } void nmDataAutomaticFitting::setThicknessSelected(bool selected) { m_thicknessSelected = selected; } bool nmDataAutomaticFitting::getCtSelected() const { return m_ctSelected; } void nmDataAutomaticFitting::setCtSelected(bool selected) { m_ctSelected = selected; } bool nmDataAutomaticFitting::getCfSelected() const { return m_cfSelected; } void nmDataAutomaticFitting::setCfSelected(bool selected) { m_cfSelected = selected; } bool nmDataAutomaticFitting::getSoiSelected() const { return m_soiSelected; } void nmDataAutomaticFitting::setSoiSelected(bool selected) { m_soiSelected = selected; } bool nmDataAutomaticFitting::getSgiSelected() const { return m_sgiSelected; } void nmDataAutomaticFitting::setSgiSelected(bool selected) { m_sgiSelected = selected; } bool nmDataAutomaticFitting::getSwiSelected() const { return m_swiSelected; } void nmDataAutomaticFitting::setSwiSelected(bool selected) { m_swiSelected = selected; } // Getter and Setter implementations for Max values nmDataAttribute& nmDataAutomaticFitting::getPermeabilityMax() { return m_permeabilityMax; } void nmDataAutomaticFitting::setPermeabilityMax(const nmDataAttribute& permeabilityMax) { m_permeabilityMax = permeabilityMax; } nmDataAttribute& nmDataAutomaticFitting::getSkinMax() { return m_skinMax; } void nmDataAutomaticFitting::setSkinMax(const nmDataAttribute& skinMax) { m_skinMax = skinMax; } nmDataAttribute& nmDataAutomaticFitting::getWellboreStorageMax() { return m_wellboreStorageMax; } void nmDataAutomaticFitting::setWellboreStorageMax(const nmDataAttribute& wellboreStorageMax) { m_wellboreStorageMax = wellboreStorageMax; } nmDataAttribute& nmDataAutomaticFitting::getPorosityMax() { return m_porosityMax; } void nmDataAutomaticFitting::setPorosityMax(const nmDataAttribute& porosityMax) { m_porosityMax = porosityMax; } nmDataAttribute& nmDataAutomaticFitting::getInitialPressureMax() { return m_initialPressureMax; } void nmDataAutomaticFitting::setInitialPressureMax(const nmDataAttribute& initialPressureMax) { m_initialPressureMax = initialPressureMax; } nmDataAttribute& nmDataAutomaticFitting::getThicknessMax() { return m_thicknessMax; } void nmDataAutomaticFitting::setThicknessMax(const nmDataAttribute& thicknessMax) { m_thicknessMax = thicknessMax; } nmDataAttribute& nmDataAutomaticFitting::getCtMax() { return m_ctMax; } void nmDataAutomaticFitting::setCtMax(const nmDataAttribute& ctMax) { m_ctMax = ctMax; } nmDataAttribute& nmDataAutomaticFitting::getCfMax() { return m_cfMax; } void nmDataAutomaticFitting::setCfMax(const nmDataAttribute& cfMax) { m_cfMax = cfMax; } nmDataAttribute& nmDataAutomaticFitting::getSoiMax() { return m_soiMax; } void nmDataAutomaticFitting::setSoiMax(const nmDataAttribute& soiMax) { m_soiMax = soiMax; } nmDataAttribute& nmDataAutomaticFitting::getSgiMax() { return m_sgiMax; } void nmDataAutomaticFitting::setSgiMax(const nmDataAttribute& sgiMax) { m_sgiMax = sgiMax; } nmDataAttribute& nmDataAutomaticFitting::getSwiMax() { return m_swiMax; } void nmDataAutomaticFitting::setSwiMax(const nmDataAttribute& swiMax) { m_swiMax = swiMax; } // Getter and Setter implementations for Min values nmDataAttribute& nmDataAutomaticFitting::getPermeabilityMin() { return m_permeabilityMin; } void nmDataAutomaticFitting::setPermeabilityMin(const nmDataAttribute& permeabilityMin) { m_permeabilityMin = permeabilityMin; } nmDataAttribute& nmDataAutomaticFitting::getSkinMin() { return m_skinMin; } void nmDataAutomaticFitting::setSkinMin(const nmDataAttribute& skinMin) { m_skinMin = skinMin; } nmDataAttribute& nmDataAutomaticFitting::getWellboreStorageMin() { return m_wellboreStorageMin; } void nmDataAutomaticFitting::setWellboreStorageMin(const nmDataAttribute& wellboreStorageMin) { m_wellboreStorageMin = wellboreStorageMin; } nmDataAttribute& nmDataAutomaticFitting::getPorosityMin() { return m_porosityMin; } void nmDataAutomaticFitting::setPorosityMin(const nmDataAttribute& porosityMin) { m_porosityMin = porosityMin; } nmDataAttribute& nmDataAutomaticFitting::getInitialPressureMin() { return m_initialPressureMin; } void nmDataAutomaticFitting::setInitialPressureMin(const nmDataAttribute& initialPressureMin) { m_initialPressureMin = initialPressureMin; } nmDataAttribute& nmDataAutomaticFitting::getThicknessMin() { return m_thicknessMin; } void nmDataAutomaticFitting::setThicknessMin(const nmDataAttribute& thicknessMin) { m_thicknessMin = thicknessMin; } nmDataAttribute& nmDataAutomaticFitting::getCtMin() { return m_ctMin; } void nmDataAutomaticFitting::setCtMin(const nmDataAttribute& ctMin) { m_ctMin = ctMin; } nmDataAttribute& nmDataAutomaticFitting::getCfMin() { return m_cfMin; } void nmDataAutomaticFitting::setCfMin(const nmDataAttribute& cfMin) { m_cfMin = cfMin; } nmDataAttribute& nmDataAutomaticFitting::getSoiMin() { return m_soiMin; } void nmDataAutomaticFitting::setSoiMin(const nmDataAttribute& soiMin) { m_soiMin = soiMin; } nmDataAttribute& nmDataAutomaticFitting::getSgiMin() { return m_sgiMin; } void nmDataAutomaticFitting::setSgiMin(const nmDataAttribute& sgiMin) { m_sgiMin = sgiMin; } nmDataAttribute& nmDataAutomaticFitting::getSwiMin() { return m_swiMin; } void nmDataAutomaticFitting::setSwiMin(const nmDataAttribute& swiMin) { m_swiMin = swiMin; } // Getter and Setter implementations for iteration parameters nmDataAttribute& nmDataAutomaticFitting::getIterationCount() { return m_iterationCount; } void nmDataAutomaticFitting::setIterationCount(const nmDataAttribute& iterationCount) { m_iterationCount = iterationCount; } nmDataAttribute& nmDataAutomaticFitting::getErrorTolerance() { return m_errorTolerance; } void nmDataAutomaticFitting::setErrorTolerance(const nmDataAttribute& errorTolerance) { m_errorTolerance = errorTolerance; } QString nmDataAutomaticFitting::getAlgorithmName() const { return m_algorithmName; } void nmDataAutomaticFitting::setAlgorithmName(const QString& algorithmName) { m_algorithmName = algorithmName; } bool nmDataAutomaticFitting::getSurrogateScreeningEnabled() const { return m_surrogateScreeningEnabled; } void nmDataAutomaticFitting::setSurrogateScreeningEnabled(bool enabled) { m_surrogateScreeningEnabled = enabled; }