From 0545843091a19b4c26e93e6a76877f4404eff283 Mon Sep 17 00:00:00 2001 From: "Bruno M. Pacheco" Date: Thu, 26 Oct 2023 16:42:59 -0300 Subject: [PATCH 1/3] standardize wells' secondary variables overwriting in setup_case_from_mrst Now all overwriting is done through `set_secondary_variables!`. PhaseViscosities was also being overwritten twice. --- src/input_simulation/mrst_input.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/input_simulation/mrst_input.jl b/src/input_simulation/mrst_input.jl index 18d655d2..417b3d08 100644 --- a/src/input_simulation/mrst_input.jl +++ b/src/input_simulation/mrst_input.jl @@ -865,16 +865,15 @@ function setup_case_from_mrst(casename; wells = :ms, param_w = setup_parameters(wi) if typeof(wi.system) == typeof(model.system) - sv[:PhaseMassDensities] = sv_m[:PhaseMassDensities] + set_secondary_variables!(wi, PhaseMassDensities = sv_m[:PhaseMassDensities]) if haskey(sv, :ShrinkageFactors) - sv[:ShrinkageFactors] = sv_m[:ShrinkageFactors] + set_secondary_variables!(wi, ShrinkageFactors = sv_m[:ShrinkageFactors]) end if haskey(sv_m, :PhaseViscosities) set_secondary_variables!(wi, PhaseViscosities = sv_m[:PhaseViscosities]) else set_parameters(wi, PhaseViscosities = prm[:PhaseViscosities]) end - sv[:PhaseViscosities] = sv_m[:PhaseViscosities] if haskey(param_w, :Temperature) param_w[:Temperature] = param_res[:Temperature][res_cells] end From 4965765ebc1b0ec4741028654445b44e40370953 Mon Sep 17 00:00:00 2001 From: "Bruno M. Pacheco" Date: Thu, 26 Oct 2023 16:48:17 -0300 Subject: [PATCH 2/3] remove useless variable in `setup_case_from_mrst` `pw` was being overwritten further down in the code, with no uses. --- src/input_simulation/mrst_input.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/input_simulation/mrst_input.jl b/src/input_simulation/mrst_input.jl index 417b3d08..ca1f846d 100644 --- a/src/input_simulation/mrst_input.jl +++ b/src/input_simulation/mrst_input.jl @@ -878,7 +878,6 @@ function setup_case_from_mrst(casename; wells = :ms, param_w[:Temperature] = param_res[:Temperature][res_cells] end end - pw = wi.primary_variables models[sym] = wi ctrl = mrst_well_ctrl(model, wdata, is_comp, rhoS) if isa(ctrl, InjectorControl) From ba0cb41c0b756e1ed7e6136c0c447e8cfd5e6902 Mon Sep 17 00:00:00 2001 From: "Bruno M. Pacheco" Date: Fri, 10 Nov 2023 15:01:54 -0300 Subject: [PATCH 3/3] remove more useless variables improve readability by removing the proxy variables for `wi.secondary_variables` and `model.secondary_variables` --- src/input_simulation/mrst_input.jl | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/input_simulation/mrst_input.jl b/src/input_simulation/mrst_input.jl index bfde88d5..6656b6ad 100644 --- a/src/input_simulation/mrst_input.jl +++ b/src/input_simulation/mrst_input.jl @@ -856,23 +856,18 @@ function setup_case_from_mrst(casename; wells = :ms, sym = well_symbols[i] wi, wdata, res_cells = get_well_from_mrst_data(mrst_data, sys, i, W_data = first_well_set, extraout = true, well_type = wells, context = w_context, use_lengths = use_well_lengths) - param_w = setup_parameters(wi) - - sv = wi.secondary_variables - sv_m = model.secondary_variables - prm = model.parameters param_w = setup_parameters(wi) if typeof(wi.system) == typeof(model.system) - set_secondary_variables!(wi, PhaseMassDensities = sv_m[:PhaseMassDensities]) - if haskey(sv, :ShrinkageFactors) - set_secondary_variables!(wi, ShrinkageFactors = sv_m[:ShrinkageFactors]) + set_secondary_variables!(wi, PhaseMassDensities = model.secondary_variables[:PhaseMassDensities]) + if haskey(wi.secondary_variables, :ShrinkageFactors) + set_secondary_variables!(wi, ShrinkageFactors = model.secondary_variables[:ShrinkageFactors]) end - if haskey(sv_m, :PhaseViscosities) - set_secondary_variables!(wi, PhaseViscosities = sv_m[:PhaseViscosities]) + if haskey(model.secondary_variables, :PhaseViscosities) + set_secondary_variables!(wi, PhaseViscosities = model.secondary_variables[:PhaseViscosities]) else - set_parameters(wi, PhaseViscosities = prm[:PhaseViscosities]) + set_parameters(wi, PhaseViscosities = model.parameters[:PhaseViscosities]) end if haskey(param_w, :Temperature) param_w[:Temperature] = param_res[:Temperature][res_cells]