Switching a producer from rate to pressure control
Introduction WellsSchedule a producer at two different rates with the same minimum bottom-hole pressure (BHP). The well meets the first request and switches to pressure control when the second request would take it below the BHP limit.
julia
using Jutul, JutulDarcy
bar, day, darcy = si_units(:bar, :day, :darcy)
mesh = reservoir_mesh((3, 1, 1), (300.0, 100.0, 10.0))
domain = reservoir_domain(mesh; permeability = 0.1*darcy, porosity = 0.2)
producer = setup_well(domain, [3]; name = :Producer)
system = ImmiscibleSystem((AqueousPhase(), LiquidPhase()); reference_densities = [1000.0, 800.0])
model = setup_reservoir_model(domain, system; wells = [producer])
state0 = setup_reservoir_state(model; Pressure = 150*bar, Saturations = [1.0, 0.0])Dict{Any, Any} with 3 entries:
:Producer => Dict{Symbol, Any}(:PhaseMassDensities=>[0.0; 0.0;;], :Saturatio…
:Reservoir => Dict{Symbol, Any}(:PhaseMassMobilities=>[0.0 0.0 0.0; 0.0 0.0 0…
:Facility => Dict{Symbol, Any}(:TotalSurfaceMassRate=>[0.0], :SurfaceCompone…A pressure boundary supplies water at the opposite end of the reservoir. Negative rates denote production. Each entry in forces applies to one report step, with rates in m³/s and pressures in Pa.
julia
boundary = flow_boundary_condition([1], domain, 150*bar; fractional_flow = [1.0, 0.0])
requested_rates = [-10.0, -500.0] # m³/day
minimum_bhp = 140*bar
forces = map(requested_rates) do rate
control = Dict(:Producer => ProducerControl(TotalRateTarget(rate/day)))
limits = Dict(:Producer => (bhp = minimum_bhp,))
return setup_reservoir_forces(model; control, limits, bc = boundary)
end
case = JutulCase(model, [day, day], forces; state0)
result = simulate_reservoir(case; info_level = -1, error_on_incomplete = true)ReservoirSimResult with 2 entries:
wells (1 present):
:Producer
Results per well:
:wrat => Vector{Float64} of size (2,)
:factor => Vector{Float64} of size (2,)
:Aqueous_mass_rate => Vector{Float64} of size (2,)
:orat => Vector{Float64} of size (2,)
:bhp => Vector{Float64} of size (2,)
:mrat => Vector{Float64} of size (2,)
:lrat => Vector{Float64} of size (2,)
:mass_rate => Vector{Float64} of size (2,)
:rate => Vector{Float64} of size (2,)
:control => Vector{Symbol} of size (2,)
:Liquid_mass_rate => Vector{Float64} of size (2,)
:wcut => Vector{Float64} of size (2,)
states (Vector with 2 entries, reservoir variables for each state)
:Pressure => Vector{Float64} of size (3,)
:Saturations => Matrix{Float64} of size (2, 3)
:TotalMasses => Matrix{Float64} of size (2, 3)
time (report time for each state)
Vector{Float64} of length 2
result (extended states, reports)
SimResult with 2 entries
extra
Dict{Any, Any} with keys :simulator, :config
Completed at Nov. 17 2026 13:08 after 3 seconds, 703 milliseconds, 609.9 microseconds.Read the operating control and the actual well response at each report time. When the BHP limit is active, the well produces less than requested.
julia
operating_control = result.wells[:Producer, :control]
actual_rates = result.wells[:Producer, :rate] .* day
actual_bhp = result.wells[:Producer, :bhp] ./ bar
for i in eachindex(result.time)
println("Day $(result.time[i]/day), $(operating_control[i]) control: ",
"requested $(requested_rates[i]) m³/day, produced $(round(actual_rates[i]; digits = 1)) m³/day ",
"at $(round(actual_bhp[i]; digits = 1)) bar")
endDay 1.0, rate control: requested -10.0 m³/day, produced -10.0 m³/day at 146.7 bar
Day 2.0, bhp control: requested -500.0 m³/day, produced -26.6 m³/day at 140.0 barDownload this example
Download the Julia script or the Jupyter notebook.
This example took 14.945547961 seconds to complete.This page was generated using Literate.jl.