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

multiple well gradients #60

Closed
zhen0z opened this issue Sep 23, 2024 · 7 comments
Closed

multiple well gradients #60

zhen0z opened this issue Sep 23, 2024 · 7 comments

Comments

@zhen0z
Copy link

zhen0z commented Sep 23, 2024

Hi,

I'm working on using the sensitivity functionality and wanted to check if it's possible to compute gradients using multiple wells. The original example is as follows:

gradient

function objective_function(model, state, Δt, step_i, forces)
grat = JutulDarcy.compute_well_qoi(model, state, forces, :Producer, SurfaceGasRateTarget)
return Δtgrat/(inj_ratesum(dt))
end
data_domain_with_gradients = JutulDarcy.reservoir_sensitivities(case, result, objective_function, include_parameters = true)

is it possible to do somthing like this:

gradient

function objective_function(model, state, Δt, step_i, forces)
grat = JutulDarcy.compute_well_qoi(model, state, forces, [:Producer1,:Producer2], [SurfaceGasRateTarget,SurfaceGasRateTarget])
return Δtgrat/(inj_ratesum(dt))
end
data_domain_with_gradients = JutulDarcy.reservoir_sensitivities(case, result, objective_function, include_parameters = true)

Thanks,
Zhen

@moyner
Copy link
Member

moyner commented Sep 23, 2024

Yes, this should be possible. Try something like this:

function objective_function(model, state, Δt, step_i, forces)
    grat = 0
    for w in  [:Producer1,:Producer2]
         grat += JutulDarcy.compute_well_qoi(model, state, forces, w, SurfaceGasRateTarget)
    end
    return Δt*grat/(inj_rate*sum(dt))
end
data_domain_with_gradients = JutulDarcy.reservoir_sensitivities(case, result, objective_function, include_parameters = true)

I have not tested this code, but if you can find the ECMOR paper there is an example for the Norne model where we do this kind of setup over all producers.

@zhen0z
Copy link
Author

zhen0z commented Sep 24, 2024

Thanks, that's very helpful, and I have another two small problems:

First, if I have some observation data, should I do this:
function objective_function(model, state, Δt, step_i, forces)
grat = 0
for w in [:Producer1,:Producer2]
grat += JutulDarcy.compute_well_qoi(model, state, forces, w, SurfaceGasRateTarget)
end
grat = grat .- observation_data
return Δtgrat/(inj_ratesum(dt))
end

Second problem, I'd like to set the production rate to zero and use the bottom hole pressure (BHP) of the producer as the objective function, treating it like a monitoring well. Could I do that?

Thanks!

@moyner
Copy link
Member

moyner commented Sep 24, 2024

Your observation data looks good to be - but you may have to use step_i to pick the right observations for that time-step (unless your observed rates are constant). The objective function is called for each report step in the simulation.

You can set DisabledControl instead for the well to treat it as an observation well. The BHP will still be updated.

Hope this helps!

@zhen0z
Copy link
Author

zhen0z commented Sep 24, 2024

Thanks for the explanation, use DisabledControl is straightforward.

However, for the observation data, let's say I have a time series surface gas production rate observation, and I want to minimize the summation of the differences between the simulated surface gas production rate and the observed surface gas production rate. how should I incorporate it?

@moyner
Copy link
Member

moyner commented Sep 24, 2024

It is a bit tricky to explain without a full script, but if your case has time steps passed as dt and dt has length 10 then step_i passed to your objective will vary from 1 to 10. You can use this index to pick the correct observations from however you have it stored, for example by making a function get_gas_rates_for_step(step_i) and calling it inside the objective function.

@zhen0z
Copy link
Author

zhen0z commented Sep 24, 2024 via email

@moyner
Copy link
Member

moyner commented Sep 25, 2024

That's great! I'll close this issue now. Feel free to reopen or add another issue if you have follow up questions.

@moyner moyner closed this as completed Sep 25, 2024
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