From 7c2fcaf5c38a67030acc7d23a962d7e3fd9ba56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Sun, 8 Sep 2024 14:21:14 +0200 Subject: [PATCH 1/6] Guard against zero trans in partitioner --- src/utils.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils.jl b/src/utils.jl index 64361ff7..d7baf4fa 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1335,6 +1335,7 @@ function partitioner_input(model, parameters; conn = :trans) if conn == :unit T = ones(Int, length(trans)) else + trans = max.(trans, 1e-20) if conn == :trans T = copy(trans) T = length(T)*T./sum(T) From e8de350b080af03a9ef6894259201d8efff290be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Sun, 8 Sep 2024 16:41:35 +0200 Subject: [PATCH 2/6] Fix to initialization of immiscible co2 models --- src/init/init.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/init/init.jl b/src/init/init.jl index e225b94c..a88b2eb9 100644 --- a/src/init/init.jl +++ b/src/init/init.jl @@ -265,6 +265,7 @@ function parse_state0_equil(model, datafile; normalize = :sum) has_oil = haskey(datafile["RUNSPEC"], "OIL") has_gas = haskey(datafile["RUNSPEC"], "GAS") + is_co2 = has_gas = haskey(datafile["RUNSPEC"], "JUTUL_CO2BRINE") is_single_phase = (has_water + has_oil + has_gas) == 1 sys = model.system @@ -435,7 +436,12 @@ function parse_state0_equil(model, datafile; normalize = :sum) contacts = [] contacts_pc = [] elseif nph == 2 - if has_oil && has_gas + if is_co2 + contacts = (woc, ) + # TODO: Check sign here. Usually these models are + # initialized without CO2. + contacts_pc = (woc_pc, ) + elseif has_oil && has_gas contacts = (goc, ) contacts_pc = (goc_pc, ) else From 286acb44b6a7064cb47176c2a2b24d3307c375d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Sun, 8 Sep 2024 16:41:43 +0200 Subject: [PATCH 3/6] Fix to fault plotting --- src/ext.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ext.jl b/src/ext.jl index 1ac57090..c16548f6 100644 --- a/src/ext.jl +++ b/src/ext.jl @@ -164,7 +164,7 @@ function plot_faults!(ax, mesh::UnstructuredMesh; kwarg...) if length(v) == 0 continue end - plot_mesh!(ax, mesh; faces = v, color = i, colorrange = (1, n), kwarg...) + plot_mesh!(ax, mesh; faces = v, color = i, colorrange = (1, max(n, 2)), kwarg...) i += 1 end end From aaf85ec80830925d20901252042d793653b89dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Sun, 8 Sep 2024 16:41:48 +0200 Subject: [PATCH 4/6] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 167335d5..73f23923 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JutulDarcy" uuid = "82210473-ab04-4dce-b31b-11573c4f8e0a" authors = ["Olav Møyner "] -version = "0.2.29" +version = "0.2.30" [deps] Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" From 0d8e08cd5aeafba14325d013b290fe09251ec2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Sun, 8 Sep 2024 17:09:09 +0200 Subject: [PATCH 5/6] Patch bc fluxes to handle AD and use MVector/SVector --- src/forces/bc.jl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/forces/bc.jl b/src/forces/bc.jl index 1d5db579..f93e1f83 100644 --- a/src/forces/bc.jl +++ b/src/forces/bc.jl @@ -165,7 +165,6 @@ function Jutul.apply_forces_to_equation!(acc, storage, model::SimulationModel{D, end function compute_bc_mass_fluxes(bc, state, nph) - # Get reservoir properties p = state.Pressure mu = state.PhaseViscosities @@ -181,7 +180,8 @@ function compute_bc_mass_fluxes(bc, state, nph) Δp = p[c] - bc.pressure q_tot = T_f*Δp - q = Vector{typeof(q_tot)}(undef, nph) + num_t = Base.promote_type(typeof(q_tot), eltype(kr), eltype(mu), eltype(rho)) + q = zeros(MVector{nph, num_t}) if q_tot > 0 # Pressure inside is higher than outside, flow out from domain for ph in 1:nph @@ -222,12 +222,10 @@ function compute_bc_mass_fluxes(bc, state, nph) end end - return q - + return SVector{nph, num_t}(q) end function compute_bc_heat_fluxes(bc, state, nph) - q = compute_bc_mass_fluxes(bc, state, nph) c = bc.cell From 0d055b140eb709bd66a2f5f05303e4f2b13271e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Sun, 8 Sep 2024 18:13:20 +0200 Subject: [PATCH 6/6] Fix typo in new init code for CO2 --- src/init/init.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init/init.jl b/src/init/init.jl index a88b2eb9..4c0d75bc 100644 --- a/src/init/init.jl +++ b/src/init/init.jl @@ -265,7 +265,7 @@ function parse_state0_equil(model, datafile; normalize = :sum) has_oil = haskey(datafile["RUNSPEC"], "OIL") has_gas = haskey(datafile["RUNSPEC"], "GAS") - is_co2 = has_gas = haskey(datafile["RUNSPEC"], "JUTUL_CO2BRINE") + is_co2 = haskey(datafile["RUNSPEC"], "JUTUL_CO2BRINE") is_single_phase = (has_water + has_oil + has_gas) == 1 sys = model.system