Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra_out error for setup_reservoir_model() #74

Open
gbruer15 opened this issue Oct 22, 2024 · 1 comment
Open

extra_out error for setup_reservoir_model() #74

gbruer15 opened this issue Oct 22, 2024 · 1 comment

Comments

@gbruer15
Copy link
Contributor

gbruer15 commented Oct 22, 2024

On version 0.2.35 of JutulDarcy, I'm getting an error when I try to have setup_reservoir_model() set up the parameters using extra_out=true.

using JutulDarcy
using JutulDarcy.Jutul
Darcy, bar, kg, meter, day, yr = si_units(:darcy, :bar, :kilogram, :meter, :day, :year)

nx = 10
nz = 5
cart_dims = (nx, 1, nz)
physical_dims = (1000.0, 1.0, 50.0)
mesh = CartesianMesh(cart_dims, physical_dims)
domain = reservoir_domain(mesh)

p0 = 120bar

Injector = setup_well(domain, [1], name = :Injector, simple_well = true)

bc = nothing
nstep = 1
dt = fill(1.0day, nstep)
rate_target = TotalRateTarget(1e-5)
I_ctrl = InjectorControl(rate_target, [0.0, 1.0],
    density = 630.0,
)
control = Dict(:Injector => I_ctrl)

extra_out = true ## Works for extra_out=false.
if extra_out
	model, parameters = setup_reservoir_model(
	    domain,
	    :co2brine;
	    wells = Injector,
	    thermal=false,
	    co2_physics=:immiscible,
	    extra_out=true,
	)
else
	model = setup_reservoir_model(
	    domain,
	    :co2brine;
	    wells = Injector,
	    thermal=false,
	    co2_physics=:immiscible,
	    extra_out=false,
	)
	parameters = setup_parameters(model);
end

state0 = setup_reservoir_state(model; Saturations=[1.0,0], Pressure=p0)

forces = setup_reservoir_forces(model; control, bc)

wd, states, t = simulate_reservoir(
    state0, model, dt; parameters, forces, max_timestep=90day
)

When extra_out=false, the output is normal.

╭────────────────┬──────────┬──────────────┬──────────╮
│ Iteration type │ Avg/step │ Avg/ministep │    Total │
│                │  1 steps │  1 ministeps │ (wasted) │
├────────────────┼──────────┼──────────────┼──────────┤
│ Newton         │      4.0 │          4.0 │    4 (0) │
│ Linearization  │      5.0 │          5.0 │    5 (0) │
│ Linear solver  │     18.0 │         18.0 │   18 (0) │
│ Precond apply  │     36.0 │         36.0 │   36 (0) │
╰────────────────┴──────────┴──────────────┴──────────╯
╭───────────────┬─────────┬────────────┬─────────╮
│ Timing type   │    Each │   Relative │   Total │
│               │ Seconds │ Percentage │ Seconds │
├───────────────┼─────────┼────────────┼─────────┤
│ Properties    │  0.0000 │     0.00 % │  0.0002 │
│ Equations     │  0.4125 │    23.42 % │  2.0625 │
│ Assembly      │  0.2352 │    13.35 % │  1.1759 │
│ Linear solve  │  0.0630 │     2.86 % │  0.2522 │
│ Linear setup  │  0.3194 │    14.50 % │  1.2775 │
│ Precond apply │  0.0049 │     1.98 % │  0.1748 │
│ Update        │  0.1133 │     5.14 % │  0.4531 │
│ Convergence   │  0.2134 │    12.11 % │  1.0670 │
│ Input/Output  │  0.0513 │     0.58 % │  0.0513 │
│ Other         │  0.5733 │    26.04 % │  2.2932 │
├───────────────┼─────────┼────────────┼─────────┤
│ Total         │  2.2019 │   100.00 % │  8.8075 │
╰───────────────┴─────────┴────────────┴─────────╯
ReservoirSimResult with 1 entry:

  wells (1 present):
    :Injector
    Results per well:
       :Vapor_mass_rate => Vector{Float64} of size (1,)
       :lrat => Vector{Float64} of size (1,)
       :orat => Vector{Float64} of size (1,)
       :control => Vector{Symbol} of size (1,)
       :bhp => Vector{Float64} of size (1,)
       :Liquid_mass_rate => Vector{Float64} of size (1,)
       :mass_rate => Vector{Float64} of size (1,)
       :rate => Vector{Float64} of size (1,)
       :grat => Vector{Float64} of size (1,)
       :gor => Vector{Float64} of size (1,)

  states (Vector with 1 entries, reservoir variables for each state)
    :PhaseMassDensities => Matrix{Float64} of size (2, 50)
    :Saturations => Matrix{Float64} of size (2, 50)
    :Pressure => Vector{Float64} of size (50,)
    :TotalMasses => Matrix{Float64} of size (2, 50)

  time (report time for each state)
     Vector{Float64} of length 1

  result (extended states, reports)
     SimResult with 1 entry

  extra
     Dict{Any, Any} with keys :simulator, :config

  Completed at Oct. 22 2024 13:10 after 8 seconds, 756 milliseconds, 212.7 microseconds.

When extra_out=true, there is an error.

julia> include("mfe.jl")
ERROR: LoadError: type NamedTuple has no field Temperature
Stacktrace:
  [1] getproperty
    @ ./Base.jl:37 [inlined]
  [2] update_secondary_variable!(array_target::Matrix{…}, rho_def::JutulDarcy.BrineCO2MixingDensities{…}, model::SimulationModel{…}, state::@NamedTuple{…}, ix::Base.OneTo{…})
    @ JutulDarcy ./none:0
  [3] macro expansion
    @ ~/.julia/packages/Jutul/VbNFh/src/variable_evaluation.jl:120 [inlined]
  [4] macro expansion
    @ ~/.julia/packages/TimerOutputs/NRdsv/src/TimerOutput.jl:253 [inlined]
  [5] update_secondary_variables_state!(state::@NamedTuple{…}, model::SimulationModel{…}, vars::OrderedCollections.OrderedDict{…})
    @ Jutul ~/.julia/packages/Jutul/VbNFh/src/variable_evaluation.jl:117
  [6] update_secondary_variables_state!(state::@NamedTuple{…}, model::SimulationModel{…})
    @ Jutul ~/.julia/packages/Jutul/VbNFh/src/variable_evaluation.jl:103
  [7] macro expansion
    @ ~/.julia/packages/TimerOutputs/NRdsv/src/TimerOutput.jl:253 [inlined]
  [8] initialize_storage!(storage::JutulStorage{…}, model::SimulationModel{…}; initialize_state0::Bool)
    @ Jutul ~/.julia/packages/Jutul/VbNFh/src/models.jl:400
  [9] initialize_storage!(storage::JutulStorage{Nothing}, model::SimulationModel{DiscretizedDomain{…}, ImmiscibleSystem{…}, FullyImplicitFormulation, DefaultContext})
    @ Jutul ~/.julia/packages/Jutul/VbNFh/src/models.jl:395
 [10] initialize_storage!(storage::JutulStorage{Nothing}, model::MultiModel{nothing, JutulStorage{…}, Vector{…}, Vector{…}, DefaultContext, Dict{…}}; kwarg::@Kwargs{})
    @ Jutul ~/.julia/packages/Jutul/VbNFh/src/multimodel/model.jl:562
 [11] initialize_storage!
    @ ~/.julia/packages/Jutul/VbNFh/src/multimodel/model.jl:560 [inlined]
 [12] macro expansion
    @ ~/.julia/packages/Jutul/VbNFh/src/simulator/simulator.jl:47 [inlined]
 [13] macro expansion
    @ ~/.julia/packages/TimerOutputs/NRdsv/src/TimerOutput.jl:253 [inlined]
 [14] simulator_storage(model::MultiModel{…}; state0::Dict{…}, parameters::Dict{…}, copy_state::Bool, mode::Symbol, specialize::Bool, prepare_step_handler::Missing, kwarg::@Kwargs{})
    @ Jutul ~/.julia/packages/Jutul/VbNFh/src/simulator/simulator.jl:46
 [15] simulator_storage
    @ ~/.julia/packages/Jutul/VbNFh/src/simulator/simulator.jl:16 [inlined]
 [16] Simulator(model::MultiModel{…}; extra_timing::Bool, executor::Jutul.DefaultExecutor, kwarg::@Kwargs{…})
    @ Jutul ~/.julia/packages/Jutul/VbNFh/src/simulator/types.jl:29
 [17] Simulator(case::JutulCase; kwarg::@Kwargs{extra_timing::Bool})
    @ Jutul ~/.julia/packages/Jutul/VbNFh/src/simulator/types.jl:39
 [18] setup_reservoir_simulator(case::JutulCase; mode::Symbol, method::Symbol, precond::Symbol, linear_solver::Symbol, max_timestep::Float64, max_dt::Float64, rtol::Nothing, initial_dt::Float64, target_ds::Float64, target_its::Int64, offset_its::Int64, tol_cnv::Float64, tol_mb::Float64, info_level::Int64, tol_cnv_well::Float64, tol_mb_well::Float64, tol_dp_well::Float64, inc_tol_dp_abs::Float64, inc_tol_dp_rel::Float64, failure_cuts_timestep::Bool, max_timestep_cuts::Int64, inc_tol_dz::Float64, set_linear_solver::Bool, timesteps::Symbol, relaxation::Bool, presolve_wells::Bool, parray_arg::Dict{…}, linear_solver_arg::Dict{…}, extra_timing_setup::Bool, nldd_partition::Missing, nldd_arg::Dict{…}, kwarg::@Kwargs{})
    @ JutulDarcy ~/.julia/packages/JutulDarcy/QOW7I/src/utils.jl:657
 [19] setup_reservoir_simulator
    @ ~/.julia/packages/JutulDarcy/QOW7I/src/utils.jl:610 [inlined]
 [20] #setup_reservoir_simulator#81
    @ ~/.julia/packages/JutulDarcy/QOW7I/src/utils.jl:516 [inlined]
 [21] simulate_reservoir(case::JutulCase; config::Missing, restart::Bool, simulator::Missing, kwarg::@Kwargs{max_timestep::Float64})
    @ JutulDarcy ~/.julia/packages/JutulDarcy/QOW7I/src/utils.jl:806
 [22] simulate_reservoir
    @ ~/.julia/packages/JutulDarcy/QOW7I/src/utils.jl:798 [inlined]
 [23] #simulate_reservoir#91
    @ ~/.julia/packages/JutulDarcy/QOW7I/src/utils.jl:795 [inlined]
 [24] top-level scope
    @ ~/a/curr_research/ensembles/JutulJUDIFilter.jl/examples/filter-comparison/tmp3.jl:55
 [25] include(fname::String)
    @ Base.MainInclude ./client.jl:489
 [26] top-level scope
    @ REPL[1]:1
in expression starting at /home/gbruer/a/curr_research/ensembles/JutulJUDIFilter.jl/examples/filter-comparison/tmp3.jl:55
Some type information was truncated. Use `show(err)` to see complete types.
moyner added a commit that referenced this issue Oct 23, 2024
@moyner
Copy link
Member

moyner commented Oct 23, 2024

Thanks for reporting this - it should be fixed by this commit on dev: 4f86848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants