forked from sintefmath/JutulDarcy.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintro_example.jl
79 lines (64 loc) · 2.26 KB
/
intro_example.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using JutulDarcy, Jutul
Darcy, bar, kg, meter, day = si_units(:darcy, :bar, :kilogram, :meter, :day)
nx = ny = 25
nz = 10
cart_dims = (nx, ny, nz)
physical_dims = (1000.0, 1000.0, 100.0).*meter
g = CartesianMesh(cart_dims, physical_dims)
domain = reservoir_domain(g, permeability = 0.3Darcy, porosity = 0.2)
Injector = setup_vertical_well(domain, 1, 1, name = :Injector);
Producer = setup_well(domain, (nx, ny, 1), name = :Producer);
phases = (LiquidPhase(), VaporPhase())
rhoLS = 1000.0kg/meter^3
rhoGS = 100.0kg/meter^3
reference_densities = [rhoLS, rhoGS]
sys = ImmiscibleSystem(phases, reference_densities = reference_densities)
model, parameters = setup_reservoir_model(domain, sys, wells = [Injector, Producer])
c = [1e-6, 1e-4]/bar
density = ConstantCompressibilityDensities(
p_ref = 100*bar,
density_ref = reference_densities,
compressibility = c
)
kr = BrooksCoreyRelativePermeabilities(sys, [2.0, 3.0])
replace_variables!(model, PhaseMassDensities = density, RelativePermeabilities = kr);
state0 = setup_reservoir_state(model,
Pressure = 120bar,
Saturations = [1.0, 0.0]
)
# ### Set up schedule with driving forces
nstep = 25
dt = fill(365.0day, nstep)
pv = pore_volume(model, parameters)
inj_rate = 1.5*sum(pv)/sum(dt)
rate_target = TotalRateTarget(inj_rate)
I_ctrl = InjectorControl(rate_target, [0.0, 1.0], density = rhoGS)
bhp_target = BottomHolePressureTarget(100bar)
P_ctrl = ProducerControl(bhp_target)
controls = Dict(:Injector => I_ctrl, :Producer => P_ctrl)
forces = setup_reservoir_forces(model, control = controls)
wd, states, t = simulate_reservoir(state0, model, dt, parameters = parameters, forces = forces)
##
wd(:Producer)
##
wd(:Injector, :bhp)
# ### Plot the well rates
using GLMakie
grat = wd[:Producer, :grat]
lrat = wd[:Producer, :lrat]
bhp = wd[:Injector, :bhp]
fig = Figure(size = (1200, 400))
ax = Axis(fig[1, 1],
title = "Injector",
xlabel = "Time / days",
ylabel = "Bottom hole pressure / bar")
lines!(ax, t/day, bhp./bar)
ax = Axis(fig[1, 2],
title = "Producer",
xlabel = "Time / days",
ylabel = "Production rate / m³/day")
lines!(ax, t/day, abs.(grat).*day)
lines!(ax, t/day, abs.(lrat).*day)
fig
# ### Launch interactive plotting of reservoir values
plot_reservoir(model, states, key = :Saturations, step = 3)