Repository navigation
Conversation
New `weighted_adjoint` option: one adjoint solve per member returns the gradient of sum_i w_i d_i for given data weights (DataFrame or callable (forward_df, member)). With w = C_d^-1 (d_obs - d) this is minus the gradient of the data misfit, as needed by SVGD. The objective is cross-checked against sum(w d) before solving. Also: - Fix cumulative summary vectors (WOPT, ...) being 86400x too large in METRIC/FIELD (JutulDarcy integrates per-day rates over seconds). This changes the values returned for cumulative data types. - Detect LAB units. - Use isapprox for the report-time match in the rate objective. - Share perm-gradient and adjoint-storage setup between both adjoint modes. - Tests: agreement with per-datum sensitivities, linearity in callable weights, Stein's lemma check, and option validation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to Python-Ensemble-Toolbox/PET#207. Integrates #18 and #20 with their original commits. #19 is independent (OPM Flow). @MathiasMNilsen, review of the shared solve and summary-unit behavior would be welcome.
Entry points and behavior
JutulDarcy.run_vjp(state, weights)returns named(k, n)PET-state blocks. Several directions share one centre simulation.JutulDarcy.run_fwd_siminweighted_adjointmode evaluates the weights callback on the live member output and returns the named gradient Series with the forecast. Both use the same weighted well objective, gradient extraction and well-index chain rule. Weighted objectives are METRIC only. The existing per-datumadjointsinterface remains available.JutulDarcy.__call__runs serial calls directly and starts fresh processes for parallel ensembles, avoiding a fork of an initialized Julia runtime.extract_datatypesnow reads surface production/injection rates and totals from the SI summary and converts to the deck’s units, including well injection totals and field liquid production. This avoids hardcoding a correction to Jutul’s non-SI cumulative implementation. Previously METRIC/FIELD cumulative volumes in JutulDarcy 0.3.11 were 86,400× too large. LAB rates are per hour and volumes are cm³; SI is per second. Recheck workarounds applied to historical forecasts.Local verification
tests/test_jutul_darcy.py tests/test_jutul_vjp.py, using JutulDarcy 0.3.11 and bundled TINY. Covers a common weight vector through both interfaces, two batched directions versus finite differences, weighted versus per-datum adjoints, the parallel Stein check, and field/well rates and totals against SI across four reporting unit systems on one trajectory.test_npv_missing_columns_errorexpects aKeyErrorbut the NPV code warns and fills zeros. Reproduced on an untouched8e730a4checkout. No NPV or OPM changes.