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

DisableControl() and compute_well_qoi #73

Closed
miguelcorralesg opened this issue Oct 21, 2024 · 3 comments
Closed

DisableControl() and compute_well_qoi #73

miguelcorralesg opened this issue Oct 21, 2024 · 3 comments

Comments

@miguelcorralesg
Copy link

Hi Olav,

I'm trying to create an observation well to later use in an objective function alongside BottomHolePressureTarget. Based on previous discussions (in the issues thread with other user), you suggested using DisabledControl() to set up an observation well. However, when I implement the following and attempt to obtain the gradients, they come out as zero:

obs_1 = setup_well(g, K, [(1, ny, 1)], name = :Observation_1)
obs_ctrl = DisabledControl()
controls[:Observation_1] = obs_ctrl

function objective_function(model, state, Δt, step_i, forces)
    trat = JutulDarcy.compute_well_qoi(model, state, forces, :Observation_1, BottomHolePressureTarget)
    return (Δt * trat) / total_time
end

data_domain_with_gradients = JutulDarcy.reservoir_sensitivities(case, results, objective_function, include_parameters = true);
dk_obs1_bhp = data_domain_with_gradients[:permeability]

On the other hand, if I set the observation well with ProducerControl and DisabledTarget() (or set the target to zero), my gradient values are non-zero following the same objective function as before.

Could you please comment on whether the objective function is correctly set when using an observation well? or Are there any other potential issues or considerations I should be aware of?

@moyner
Copy link
Member

moyner commented Oct 21, 2024

I think there might be a subtle issue here where the disabled control will return a zero value for BHP. I think if you retrieve the BHP manually it will work:

bhp = first(state[:Observation_1].Pressure)

Going via the QOI code is not necessary in this case, since it does not make too much sense for observational wells.

You could also skip adding the observation well and instead do p = state.Reservoir.Pressure[some_cell] if you want to work with a grid-cell pressure.

@miguelcorralesg
Copy link
Author

Thank you for your response. My main point was that using the L2 norm as an objective function for observation wells helps to match more observed data, which is why I’m using the compute_well_qoi function, so I was hoping the function will do the job.

I found a workaround by setting the observation well as a producer and disabling the rate (idk if this is more appropriate), which allows me to obtain the gradient values (and not just zero values). However, as you suggested, accessing something like state.Reservoir.Pressure[some_cell] could also be a viable approach.

Thanks again!

@moyner
Copy link
Member

moyner commented Oct 21, 2024

I think both approaches will yield the same result, the main issue is that DisabledControl specifically skips computing the QOI - since it assumes that no pressure control is possible.

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