mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Fix bugs in saturation initialisation and helpers.
This commit is contained in:
parent
66d5ccbd6c
commit
f8f9dc538a
@ -661,12 +661,20 @@ namespace Opm
|
|||||||
|
|
||||||
// Create the equation f(s) = pc1(s) + pc2(1-s) - target_pc
|
// Create the equation f(s) = pc1(s) + pc2(1-s) - target_pc
|
||||||
const PcEqSum f(props, phase1, phase2, cell, target_pc);
|
const PcEqSum f(props, phase1, phase2, cell, target_pc);
|
||||||
const int max_iter = 30;
|
const double f0 = f(smin);
|
||||||
const double tol = 1e-6;
|
const double f1 = f(smax);
|
||||||
int iter_used = -1;
|
if (f0 <= 0.0) {
|
||||||
typedef RegulaFalsi<WarnAndContinueOnError> ScalarSolver;
|
return smin;
|
||||||
const double sol = ScalarSolver::solve(f, smin, smax, max_iter, tol, iter_used);
|
} else if (f1 > 0.0) {
|
||||||
return sol;
|
return smax;
|
||||||
|
} else {
|
||||||
|
const int max_iter = 30;
|
||||||
|
const double tol = 1e-6;
|
||||||
|
int iter_used = -1;
|
||||||
|
typedef RegulaFalsi<ThrowOnError> ScalarSolver;
|
||||||
|
const double sol = ScalarSolver::solve(f, smin, smax, max_iter, tol, iter_used);
|
||||||
|
return sol;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -760,35 +768,38 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector< std::vector<double> > phase_saturations = phase_pressures; // Just to get the right size.
|
std::vector< std::vector<double> > phase_saturations = phase_pressures; // Just to get the right size.
|
||||||
|
double smin[BlackoilPhases::MaxNumPhases] = { 0.0 };
|
||||||
|
double smax[BlackoilPhases::MaxNumPhases] = { 0.0 };
|
||||||
|
|
||||||
|
const bool water = reg.phaseUsage().phase_used[BlackoilPhases::Aqua];
|
||||||
|
const bool gas = reg.phaseUsage().phase_used[BlackoilPhases::Vapour];
|
||||||
const int oilpos = reg.phaseUsage().phase_pos[BlackoilPhases::Liquid];
|
const int oilpos = reg.phaseUsage().phase_pos[BlackoilPhases::Liquid];
|
||||||
|
const int waterpos = reg.phaseUsage().phase_pos[BlackoilPhases::Aqua];
|
||||||
|
const int gaspos = reg.phaseUsage().phase_pos[BlackoilPhases::Vapour];
|
||||||
std::vector<double>::size_type local_index = 0;
|
std::vector<double>::size_type local_index = 0;
|
||||||
for (typename CellRange::const_iterator ci = cells.begin(); ci != cells.end(); ++ci, ++local_index) {
|
for (typename CellRange::const_iterator ci = cells.begin(); ci != cells.end(); ++ci, ++local_index) {
|
||||||
const int cell = *ci;
|
const int cell = *ci;
|
||||||
|
props.satRange(1, &cell, smin, smax);
|
||||||
// Find saturations from pressure differences by
|
// Find saturations from pressure differences by
|
||||||
// inverting capillary pressure functions.
|
// inverting capillary pressure functions.
|
||||||
double sw = 0.0;
|
double sw = 0.0;
|
||||||
if (reg.phaseUsage().phase_used[BlackoilPhases::Aqua]) {
|
if (water) {
|
||||||
const int waterpos = reg.phaseUsage().phase_pos[BlackoilPhases::Aqua];
|
|
||||||
const double pcov = phase_pressures[oilpos][local_index] - phase_pressures[waterpos][local_index];
|
const double pcov = phase_pressures[oilpos][local_index] - phase_pressures[waterpos][local_index];
|
||||||
sw = satFromPc(props, waterpos, cell, pcov);
|
sw = satFromPc(props, waterpos, cell, pcov);
|
||||||
phase_saturations[waterpos][local_index] = sw;
|
phase_saturations[waterpos][local_index] = sw;
|
||||||
}
|
}
|
||||||
double sg = 0.0;
|
double sg = 0.0;
|
||||||
if (reg.phaseUsage().phase_used[BlackoilPhases::Vapour]) {
|
if (gas) {
|
||||||
const int gaspos = reg.phaseUsage().phase_pos[BlackoilPhases::Vapour];
|
|
||||||
// Note that pcog is defined to be (pg - po), not (po - pg).
|
// Note that pcog is defined to be (pg - po), not (po - pg).
|
||||||
const double pcog = phase_pressures[gaspos][local_index] - phase_pressures[oilpos][local_index];
|
const double pcog = phase_pressures[gaspos][local_index] - phase_pressures[oilpos][local_index];
|
||||||
const double increasing = true; // pcog(sg) expected to be increasing function
|
const double increasing = true; // pcog(sg) expected to be increasing function
|
||||||
sg = satFromPc(props, gaspos, cell, pcog, increasing);
|
sg = satFromPc(props, gaspos, cell, pcog, increasing);
|
||||||
phase_saturations[gaspos][local_index] = sg;
|
phase_saturations[gaspos][local_index] = sg;
|
||||||
}
|
}
|
||||||
if (sg > 0.0 && sw > 0.0) {
|
if (gas && water && sg > smin[gaspos] && sw > smin[waterpos]) {
|
||||||
// Overlapping gas-oil and oil-water transition
|
// Overlapping gas-oil and oil-water transition
|
||||||
// zones. Must recalculate using gas-water
|
// zones. Must recalculate using gas-water
|
||||||
// capillary pressure.
|
// capillary pressure.
|
||||||
const int waterpos = reg.phaseUsage().phase_pos[BlackoilPhases::Aqua];
|
|
||||||
const int gaspos = reg.phaseUsage().phase_pos[BlackoilPhases::Vapour];
|
|
||||||
const double pcgw = phase_pressures[gaspos][local_index] - phase_pressures[waterpos][local_index];
|
const double pcgw = phase_pressures[gaspos][local_index] - phase_pressures[waterpos][local_index];
|
||||||
sw = satFromSumOfPcs(props, waterpos, gaspos, cell, pcgw);
|
sw = satFromSumOfPcs(props, waterpos, gaspos, cell, pcgw);
|
||||||
sg = 1.0 - sw;
|
sg = 1.0 - sw;
|
||||||
@ -797,6 +808,7 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
phase_saturations[oilpos][local_index] = 1.0 - sw - sg;
|
phase_saturations[oilpos][local_index] = 1.0 - sw - sg;
|
||||||
}
|
}
|
||||||
|
return phase_saturations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user