コード例 #1
0
void RegressionTest::deviationsForCell(double val1, double val2, const std::string& keyword, int occurrence1, int occurrence2, size_t cell, bool allowNegativeValues) {
    double absTolerance = getAbsTolerance();
    double relTolerance = getRelTolerance();
    if (!allowNegativeValues) {
        if (val1 < 0) {
            if (std::abs(val1) > absTolerance) {
                printValuesForCell(keyword, occurrence1, occurrence2, cell, val1, val2);
                OPM_THROW(std::runtime_error, "Negative value in first file, "
                        << "which in absolute value exceeds the absolute tolerance of " << absTolerance << ".");
            }
            val1 = 0;
        }
        if (val2 < 0) {
            if (std::abs(val2) > absTolerance) {
                printValuesForCell(keyword, occurrence1, occurrence2, cell, val1, val2);
                OPM_THROW(std::runtime_error, "Negative value in second file, "
                        << "which in absolute value exceeds the absolute tolerance of " << absTolerance << ".");
            }
            val2 = 0;
        }
    }
    Deviation dev = calculateDeviations(val1, val2);
    if (dev.abs > absTolerance && dev.rel > relTolerance) {
        printValuesForCell(keyword, occurrence1, occurrence2, cell, val1, val2);
        OPM_THROW(std::runtime_error, "Deviations exceed tolerances."
                << "\nThe absolute deviation is " << dev.abs << ", and the tolerance limit is " << absTolerance << "."
                << "\nThe relative deviation is " << dev.rel << ", and the tolerance limit is " << relTolerance << ".");
    }
    if (dev.abs != -1) {
        absDeviation.push_back(dev.abs);
    }
    if (dev.rel != -1) {
        relDeviation.push_back(dev.rel);
    }
}
コード例 #2
0
int IntegrationTest::checkDeviation(const Deviation& deviation){
    double absTol = getAbsTolerance();
    double relTol = getRelTolerance();
    if (deviation.rel> relTol && deviation.abs > absTol){
        return 1;
    }
    return 0;
}
コード例 #3
0
void IntegrationTest::findGreatestErrorRatio(const WellProductionVolume& volume,
                                             double &greatestRatio,
                                             const char* currentKeyword,
                                             std::string &greatestErrorRatio){
    if (volume.total != 0 && (volume.total - volume.error > getAbsTolerance()) ){
        if(volume.error/volume.total > greatestRatio){
            greatestRatio = volume.error/volume.total;
            std::string currentKeywordStr(currentKeyword);
            greatestErrorRatio = currentKeywordStr;
        }
    }
}
コード例 #4
0
WellProductionVolume IntegrationTest::getWellProductionVolume(const char * keyword){
    double total = integrate(*referenceVec, *referenceDataVec);
    double error = integrateError(*referenceVec, *referenceDataVec,
                                  *checkVec, *checkDataVec);
    WellProductionVolume wPV;
    wPV.total = total;
    wPV.error = error;
    if(wPV.total != 0 && wPV.total-wPV.error > getAbsTolerance()){
        if( (wPV.error/wPV.total > getRelTolerance()) && throwExceptionForTooGreatErrorRatio){
            OPM_THROW(std::runtime_error, "For the keyword "<< keyword << " the error ratio was " << wPV.error/wPV.total << " which is greater than the tolerance " << getRelTolerance());
        }
    }
    return wPV;
}
コード例 #5
0
void IntegrationTest::setCellVolumes() {
    double absTolerance = getAbsTolerance();
    double relTolerance = getRelTolerance();
    const unsigned int globalGridCount1 = ecl_grid_get_global_size(ecl_grid1);
    const unsigned int activeGridCount1 = ecl_grid_get_active_size(ecl_grid1);
    const unsigned int globalGridCount2 = ecl_grid_get_global_size(ecl_grid2);
    const unsigned int activeGridCount2 = ecl_grid_get_active_size(ecl_grid2);
    if (globalGridCount1 != globalGridCount2) {
        OPM_THROW(std::runtime_error, "In grid file:"
                << "\nCells in first file: "  << globalGridCount1
                << "\nCells in second file: " << globalGridCount2
                << "\nThe number of global cells differ.");
    }
    if (activeGridCount1 != activeGridCount2) {
        OPM_THROW(std::runtime_error, "In grid file:"
                << "\nCells in first file: "  << activeGridCount1
                << "\nCells in second file: " << activeGridCount2
                << "\nThe number of active cells differ.");
    }
    for (unsigned int cell = 0; cell < globalGridCount1; ++cell) {
        const double cellVolume1 = ecl_grid_get_cell_volume1(ecl_grid1, cell);
        const double cellVolume2 = ecl_grid_get_cell_volume1(ecl_grid2, cell);
        Deviation dev = calculateDeviations(cellVolume1, cellVolume2);
        if (dev.abs > absTolerance && dev.rel > relTolerance) {
            int i, j, k;
            ecl_grid_get_ijk1(ecl_grid1, cell, &i, &j, &k);
            // Coordinates from this function are zero-based, hence incrementing
            i++, j++, k++;
            OPM_THROW(std::runtime_error, "In grid file: Deviations of cell volume exceed tolerances. "
                    << "\nFor cell with coordinate (" << i << ", " << j << ", " << k << "):"
                    << "\nCell volume in first file: "  << cellVolume1
                    << "\nCell volume in second file: " << cellVolume2
                    << "\nThe absolute deviation is " << dev.abs << ", and the tolerance limit is " << absTolerance << "."
                    << "\nThe relative deviation is " << dev.rel << ", and the tolerance limit is " << relTolerance << ".");
        } // The second input case is used as reference.
        cellVolumes.push_back(cellVolume2);
    }
}