diff --git a/opm/material/constraintsolvers/ChiFlash.hpp b/opm/material/constraintsolvers/ChiFlash.hpp index 77d691cd6..dac866b30 100644 --- a/opm/material/constraintsolvers/ChiFlash.hpp +++ b/opm/material/constraintsolvers/ChiFlash.hpp @@ -178,6 +178,12 @@ public: std::cout << "********" << std::endl; } + // all the solution should be processed in scalar form + // now we should update the derivatives + // TODO: should be able the handle the derivatives directly, which will affect the final organization + // of the code + updateDerivatives_(fluid_state_scalar, fluid_state); + // Update phases /* typename FluidSystem::template ParameterCache paramCache; paramCache.updatePhase(fluid_state, oilPhaseIdx); @@ -956,6 +962,26 @@ protected: } } + template + static void updateDerivatives_(const FlashFluidStateScalar& fluid_state_scalar, + FlashFluidState& fluid_state) + { + // getting the secondary Jocobian matrix + constexpr size_t num_equations = numMisciblePhases * numMiscibleComponents + 1; + constexpr size_t secondary_num_pv = numComponents + 1; + using SecondaryEval = Opm::DenseAd::Evaluation; // three z and one pressure + using SecondaryComponentVector = Dune::FieldVector; + using SecondaryFlashFluidState = Opm::CompositionalFluidState; + + SecondaryFlashFluidState secondary_fluid_state; + SecondaryComponentVector secondary_z; + + // TODO: trying to get the secondary matrix here, + // TODO: then getting the primary matrix, + // TODO: then beginning from that point + + } + /* template static void evalJacobian(const ComponentVector& globalComposition, const Vector& x, diff --git a/tests/test_chiflash.cpp b/tests/test_chiflash.cpp index 2db9429d4..6f126ac6b 100644 --- a/tests/test_chiflash.cpp +++ b/tests/test_chiflash.cpp @@ -104,6 +104,14 @@ void testChiFlash() } } zInit /= sumMoles; + // initialize the derivatives + // TODO: the derivative eventually should be from the reservoir flow equations + Evaluation z_last = 1.; + for (unsigned compIdx = 0; compIdx < numComponents - 1; ++compIdx) { + zInit[compIdx] = Evaluation::createVariable(Opm::getValue(zInit[compIdx]), compIdx + 1); + z_last -= zInit[compIdx]; + } + zInit[numComponents - 1] = z_last; } // TODO: only, p, z need the derivatives.