97 const MaterialLawParams& matParams,
98 bool isInEquilibrium =
false)
100 using FsToolbox = MathToolbox<typename FluidState::Scalar>;
104 for (
unsigned phaseIdx = 1; phaseIdx < numPhases; ++phaseIdx) {
105 assert(fluidState.temperature(0) == fluidState.temperature(phaseIdx));
111 if (isInEquilibrium) {
118 typename FluidSystem::template ParameterCache<Scalar> paramCache;
119 CompositionalFluidState<Scalar, FluidSystem> fsFlash;
123 fsFlash.assign(fluidState);
126 paramCache.updateAll(fsFlash);
127 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
128 const Scalar rho = FluidSystem::density(fsFlash, paramCache, phaseIdx);
129 fsFlash.setDensity(phaseIdx, rho);
133 ComponentVector globalMolarities(0.0);
134 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
135 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
136 globalMolarities[compIdx] +=
137 FsToolbox::value(fsFlash.saturation(phaseIdx)) *
138 FsToolbox::value(fsFlash.molarity(phaseIdx, compIdx));
143 NcpFlash::template solve<MaterialLaw>(fsFlash, matParams, paramCache, globalMolarities);
156 void assignNaive(
const FluidState& fluidState,
unsigned refPhaseIdx = 0)
158 using FsToolbox = MathToolbox<typename FluidState::Scalar>;
162 EnergyModule::setPriVarTemperatures(*
this, fluidState);
165 typename FluidSystem::template ParameterCache<Scalar> paramCache;
166 paramCache.updatePhase(fluidState, refPhaseIdx);
167 const Scalar pRef = FsToolbox::value(fluidState.pressure(refPhaseIdx));
168 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
171 const Scalar fugCoeff =
172 FluidSystem::template fugacityCoefficient<FluidState, Scalar>(fluidState,
176 (*this)[fugacity0Idx + compIdx] =
177 fugCoeff * fluidState.moleFraction(refPhaseIdx, compIdx) * pRef;
181 (*this)[pressure0Idx] = FsToolbox::value(fluidState.pressure(0));
184 for (
unsigned phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx) {
185 (*this)[saturation0Idx + phaseIdx] = FsToolbox::value(fluidState.saturation(phaseIdx));