Hi,

On Montag, 31. Juli 2017 10:12:01 CEST you wrote:
> Thank you for your answer.  I've attached a minimum working example. As you
> can see, the residuals do not change after the update of the initial
> solution.
> In the example, the initial solution is (attempted) to be set to be equal
> to the final state.

sorry, but I cannot see that you change anything compared to the current 
solution before the call to convertInput(tmp_reservoir_state), so getting the 
same result is the expected behavior. Also, I still can't see how your code is 
supposed to be used without doing some guesswork of where it should go (I 
suppose the run() method of the simulator class?) it would be less confusing 
if you would send patches (i.e., the output of `git diff origin/master`).

I've attached a patch which probably does what you want. In particular, note 
that if you cannot guarantee a fixed number of changed variables of the result 
due to a single change of the initial condition, the problem is not sparse.

cheers
  Andreas

> 2017-07-28 11:41 GMT-03:00 Andreas Lauser <[email protected]>:
> > Hi Joakim,
> > 
> > it looks like you modify copies of the objects which are actually used by
> > the
> > simulator. I can't be too sure because the file which you attached is
> > incomplete.
> > 
> > cheers
> > 
> >   Andreas
> > 
> > On Donnerstag, 27. Juli 2017 16:15:32 CEST Joakim R. Andersen wrote:
> > > Hi, all.
> > > 
> > > I am trying to calculate the numerical Jacobian of the reservoir
> > 
> > residuals
> > 
> > > w.r.t. the initial state. To do this I need to replace the initial
> > 
> > solution
> > 
> > > of EBOS with a perturbed one. I've been trying for a while, and I am
> > > getting nowhere.
> > > 
> > > I've attached the code. It is placed at the end of "nonlinearIteration"
> > 
> > in
> > 
> > > "BlackoilModelEbos.hpp":
> > > 
> > > if (!report.converged) { ... }
> > > 
> > > else {
> > > // all the code goes here.
> > > }
> > > 
> > > I've also made the "nonlinearIteration" take the initial reservoir state
> > 
> > as
> > 
> > > an input. Thus, we have both the final state and the initial state when
> > 
> > the
> > 
> > > "else"-case is invoked.
> > > 
> > > Setting the initial solution as done in the attachment does not work.
> > > How
> > > can I pass this information further such that the "linearize()" function
> > > (the one that calculates the residuals and the Jacobian in EBOS) will be
> > > affected?
> > > 
> > > Let me be more precise. The code runs, and the initial solution is set,
> > 
> > but
> > 
> > > the "linearize()" function are not aware of the change.
> > > 
> > > 
> > > Best regards,
> > > Joakim R. Andersen
> > 
> > --
> > The Illuminati don't run the world. C programmers do.
> > 
> >         -- Daniel Angel Muñoz Trejo
> > 
> > _______________________________________________
> > Opm mailing list
> > [email protected]
> > http://opm-project.org/cgi-bin/mailman/listinfo/opm


-- 
The Illuminati don't run the world. C programmers do. 
        -- Daniel Angel Muñoz Trejo
diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp
index 90ff48d..aa3a88a 100644
--- a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp
+++ b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp
@@ -315,6 +315,8 @@ public:
             // \Note: The report steps are met in any case
             // \Note: The sub stepping will require a copy of the state variables
             if( adaptiveTimeStepping ) {
+                auto tmpState = state;
+
                 bool event = events.hasEvent(ScheduleEvents::NEW_WELL, timer.currentStepNum()) ||
                         events.hasEvent(ScheduleEvents::PRODUCTION_UPDATE, timer.currentStepNum()) ||
                         events.hasEvent(ScheduleEvents::INJECTION_UPDATE, timer.currentStepNum()) ||
@@ -323,6 +325,18 @@ public:
                                                          output_writer_.requireFIPNUM() ? &fipnum : nullptr );
                 report += stepReport;
                 failureReport_ += adaptiveTimeStepping->failureReport();
+
+                // this is a big fat hack!
+                const double eps = 100.0; // [Pa]
+                tmpState.pressure()[0] += eps;
+                stepReport = adaptiveTimeStepping->step( timer, *solver, tmpState, well_state, event, output_writer_,
+                                                         output_writer_.requireFIPNUM() ? &fipnum : nullptr );
+                // compare the difference between tmpState and state. the sensitivity of
+                // the oil pressure of the solution for this step w.r.t. the oil phase
+                // pressure of the first cell is approximately (tmpState.pressure() -
+                // state.pressure())/eps. All remaining quantities can be handled
+                // analogously
+
             }
             else {
                 // solve for complete report step

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Opm mailing list
[email protected]
http://opm-project.org/cgi-bin/mailman/listinfo/opm

Reply via email to