diff --git a/.integrated_tests.yaml b/.integrated_tests.yaml index b6441b60bc5..74cea56702e 100644 --- a/.integrated_tests.yaml +++ b/.integrated_tests.yaml @@ -1,6 +1,6 @@ baselines: bucket: geosx - baseline: integratedTests/baseline_integratedTests-pr4108-17561-eb62184 + baseline: integratedTests/baseline_integratedTests-pr3996-17639-718fc69 allow_fail: all: '' diff --git a/BASELINE_NOTES.md b/BASELINE_NOTES.md index ad8d56fdeb3..e700a96f185 100644 --- a/BASELINE_NOTES.md +++ b/BASELINE_NOTES.md @@ -4,6 +4,10 @@ Notes This file is designed to track changes to the integrated test baselines. Any developer who updates the baseline ID in the .integrated_tests.yaml file is expected to create an entry in this file with the pull request number, date, and their justification for rebaselining. These notes should be in reverse-chronological order, and use the following time format: (YYYY-MM-DD). +PR #3996 (2026-09-20) +===================== +Switch the single-phase reactive transport solver to a molality-based primary +species concentration by introducing solventMassFraction. PR #3994 (2026-09-03) ===================== diff --git a/inputFiles/singlePhaseReactiveTransport/ChainSerial_1DAllKinetic_base.xml b/inputFiles/singlePhaseReactiveTransport/ChainSerial_1DAllKinetic_base.xml index 27df60a6124..694fecc4544 100644 --- a/inputFiles/singlePhaseReactiveTransport/ChainSerial_1DAllKinetic_base.xml +++ b/inputFiles/singlePhaseReactiveTransport/ChainSerial_1DAllKinetic_base.xml @@ -7,7 +7,7 @@ name="SinglePhaseReactiveFlow" discretization="singlePhaseTPFA" targetRegions="{ Medium, Source }" - initialDt="1e-5" + initialDt="1e-10" writeLinearSystem="0" logLevel="1"> + maxAllowedResidualNorm="1e10"/> @@ -37,6 +37,7 @@ + + chemicalSystemType="chainSerialAllKinetic" + solventMassFraction="0.001"/> + @@ -25,17 +26,17 @@ maxTime="400"> diff --git a/inputFiles/singlePhaseReactiveTransport/ChainSerial_1DAllKinetic_smoke.xml b/inputFiles/singlePhaseReactiveTransport/ChainSerial_1DAllKinetic_smoke.xml new file mode 100644 index 00000000000..4ebc3d6c238 --- /dev/null +++ b/inputFiles/singlePhaseReactiveTransport/ChainSerial_1DAllKinetic_smoke.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputFiles/singlePhaseReactiveTransport/ChainSerial_initialLogConc.xml b/inputFiles/singlePhaseReactiveTransport/ChainSerial_initialLogConc.xml new file mode 100644 index 00000000000..1368324cd18 --- /dev/null +++ b/inputFiles/singlePhaseReactiveTransport/ChainSerial_initialLogConc.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/inputFiles/singlePhaseReactiveTransport/MoMaSEasy_1DAdvective_base.xml b/inputFiles/singlePhaseReactiveTransport/MoMaSEasy_1DAdvective_base.xml index 220cbce513c..b970a81a6b8 100644 --- a/inputFiles/singlePhaseReactiveTransport/MoMaSEasy_1DAdvective_base.xml +++ b/inputFiles/singlePhaseReactiveTransport/MoMaSEasy_1DAdvective_base.xml @@ -43,6 +43,7 @@ + + chemicalSystemType="momasEasy" + solventMassFraction="0.001"/> + + chemicalSystemType="momasEasy" + solventMassFraction="0.001"/> + + chemicalSystemType="momasEasy" + solventMassFraction="0.001"/> + + chemicalSystemType="momasMedium" + solventMassFraction="0.001"/> ReactiveSinglePhaseFluid< BASE >:: ReactiveSinglePhaseFluid( string const & name, Group * const parent ): @@ -43,6 +41,13 @@ ReactiveSinglePhaseFluid( string const & name, Group * const parent ): setDescription( "Chemical System type. Available options are: " "``" + EnumStrings< ChemicalSystemType >::concat( "|" ) + "``" ); + this->registerWrapper( viewKeyStruct::solventMassFractionString(), &m_solventMassFraction ). + setApplyDefaultValue( 1.0 ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Mass fraction of solvent in the solution [-]. Species molality [mol/kg solvent] " + "times this fraction is the amount per kg of solution, and times the fluid density " + "the amount per m^3 of solution. The default of 1 is a dilute aqueous solution." ); + this->template registerField< fields::reactivefluid::initialPrimarySpeciesConcentration >( &m_initialPrimarySpeciesConcentration ); this->template registerField< fields::reactivefluid::secondarySpeciesConcentration >( &m_secondarySpeciesConcentration ); this->template registerField< fields::reactivefluid::primarySpeciesAggregateConcentration >( &m_primarySpeciesAggregateConcentration ); @@ -69,6 +74,7 @@ deliverClone( string const & name, Group * const parent ) const newConstitutiveRelation.m_numPrimarySpecies = m_numPrimarySpecies; newConstitutiveRelation.m_numSecondarySpecies = m_numSecondarySpecies; newConstitutiveRelation.m_numKineticReactions = m_numKineticReactions; + newConstitutiveRelation.m_solventMassFraction = m_solventMassFraction; return clone; } @@ -116,6 +122,11 @@ void ReactiveSinglePhaseFluid< BASE >::postInputInitialization() m_numKineticReactions = 0; break; } + + GEOS_THROW_IF( m_solventMassFraction <= 0.0 || m_solventMassFraction > 1.0, + GEOS_FMT( "{}: invalid value of attribute '{}', expected a value in (0, 1]", + this->getDataContext(), viewKeyStruct::solventMassFractionString() ), + InputError ); } template< typename BASE > diff --git a/src/coreComponents/constitutive/fluid/reactivefluid/ReactiveSinglePhaseFluid.hpp b/src/coreComponents/constitutive/fluid/reactivefluid/ReactiveSinglePhaseFluid.hpp index 6346d030c4f..ee846698e6c 100644 --- a/src/coreComponents/constitutive/fluid/reactivefluid/ReactiveSinglePhaseFluid.hpp +++ b/src/coreComponents/constitutive/fluid/reactivefluid/ReactiveSinglePhaseFluid.hpp @@ -113,6 +113,15 @@ class ReactiveSinglePhaseFluid : public BASE integer numKineticReactions() const { return m_numKineticReactions; } + /** + * @brief Mass fraction of solvent in the solution [-]. + * + * HPCReact is a molality based library: concentrations, equilibrium constants and mass-action + * quotients are all on the molal scale [mol/kg solvent]. With w this fraction and rho the solution + * density, moles per kg of solution are m w and moles per m^3 of solution are m w rho. + */ + real64 solventMassFraction() const { return m_solventMassFraction; } + /** * @brief Kernel wrapper class for ReactiveSinglePhaseFluid. */ @@ -235,7 +244,6 @@ class ReactiveSinglePhaseFluid : public BASE { using namespace hpcReact::geochemistry; using namespace hpcReact::MoMasBenchmark; - using namespace hpcReact::bulkGeneric; using namespace hpcReact::ChainGeneric; switch( m_chemicalSystemType ) { @@ -330,6 +338,7 @@ class ReactiveSinglePhaseFluid : public BASE struct viewKeyStruct : ConstitutiveBase::viewKeyStruct { static constexpr char const * chemicalSystemNameString() { return "chemicalSystemType"; } + static constexpr char const * solventMassFractionString() { return "solventMassFraction"; } }; protected: @@ -365,6 +374,10 @@ class ReactiveSinglePhaseFluid : public BASE array4d< real64, constitutive::reactivefluid::LAYOUT_SPECIES_DC > m_dAggregateSpeciesRates_dLogPrimarySpeciesConcentrations; ChemicalSystemType m_chemicalSystemType; + + /// Mass fraction of solvent in the solution [-], constant; for the carbonate brine EQ3/6 gives 0.898 + /// TODO: depends on concentration, w = 1 / (1 + sum_i m_i M_i) + real64 m_solventMassFraction; }; // these aliases are useful in constitutive dispatch diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.cpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.cpp index 77f4e9b9e96..0d2632b065a 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransport.cpp @@ -127,12 +127,22 @@ void SinglePhaseReactiveTransport::registerDataOnMesh( Group & meshBodies ) [&]( localIndex const, ElementSubRegionBase & subRegion ) { + string const reactiveFluidModelName = m_isThermal? getConstitutiveName< reactivefluid::ReactiveThermalCompressibleSinglePhaseFluid >( subRegion ): + getConstitutiveName< reactivefluid::ReactiveCompressibleSinglePhaseFluid >( subRegion ); + if( m_reactiveFluidModelName.empty() ) { - m_reactiveFluidModelName = m_isThermal? getConstitutiveName< reactivefluid::ReactiveThermalCompressibleSinglePhaseFluid >( subRegion ): - getConstitutiveName< reactivefluid::ReactiveCompressibleSinglePhaseFluid >( subRegion ); + m_reactiveFluidModelName = reactiveFluidModelName; } + // The number of species, the dof layout and the molality-to-molarity conversion factor are all taken from a single reactive + // fluid model, and the flux kernels are launched per stencil rather than per region, so every subregion + // must share that model. + GEOS_THROW_IF_NE_MSG( reactiveFluidModelName, m_reactiveFluidModelName, + GEOS_FMT( "SinglePhaseReactiveTransport {}: all regions must use the same reactive fluid model, but {} uses a different one", + getDataContext(), subRegion.getDataContext() ), + InputError ); + // If at least one region has a diffusion model, consider it enabled for all string const diffusionName = getConstitutiveName< DiffusionBase >( subRegion ); if( !diffusionName.empty() ) @@ -461,6 +471,11 @@ void SinglePhaseReactiveTransport::assembleFluxTerms( real64 const dt, } } + ConstitutiveManager const & cm = domain.getConstitutiveManager(); + real64 const solventMassFraction = + m_isThermal ? cm.getConstitutiveRelation< reactivefluid::ReactiveThermalCompressibleSinglePhaseFluid >( m_reactiveFluidModelName ).solventMassFraction() + : cm.getConstitutiveRelation< reactivefluid::ReactiveCompressibleSinglePhaseFluid >( m_reactiveFluidModelName ).solventMassFraction(); + forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&]( string const &, MeshLevel const & mesh, string_array const & ) @@ -481,6 +496,7 @@ void SinglePhaseReactiveTransport::assembleFluxTerms( real64 const dt, FluxComputeKernelFactory::createAndLaunch< parallelDevicePolicy<> >( m_numPrimarySpecies, m_hasDiffusion, mobilePrimarySpeciesFlags.toViewConst(), + solventMassFraction, dofManager.rankOffset(), dofKey, getName(), @@ -496,6 +512,7 @@ void SinglePhaseReactiveTransport::assembleFluxTerms( real64 const dt, FluxComputeKernelFactory::createAndLaunch< parallelDevicePolicy<> >( m_numPrimarySpecies, m_hasDiffusion, mobilePrimarySpeciesFlags.toViewConst(), + solventMassFraction, dofManager.rankOffset(), dofKey, getName(), @@ -552,15 +569,20 @@ void SinglePhaseReactiveTransport::updateSpeciesAmount( ElementSubRegionBase & s getConstitutiveModel< reactivefluid::ReactiveThermalCompressibleSinglePhaseFluid >( subRegion, subRegion.getReference< string >( viewKeyStruct::fluidNamesString() ) ); arrayView3d< real64 const, reactivefluid::USD_SPECIES > const primarySpeciesAggregateConcentration = fluid.primarySpeciesAggregateConcentration(); arrayView3d< real64 const, reactivefluid::USD_SPECIES > const primarySpeciesAggregateConcentration_n = fluid.primarySpeciesAggregateConcentration_n(); + arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > const density = fluid.density(); + arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > const density_n = fluid.density_n(); + real64 const solventMassFraction = fluid.solventMassFraction(); + // moles in the pore volume: molality * solvent mass fraction * density * pore volume forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOS_HOST_DEVICE ( localIndex const ei ) { for( integer is = 0; is < numPrimarySpecies; ++is ) { - primarySpeciesAggregateMole[ei][is] = porosity[ei][0] * ( volume[ei] + deltaVolume[ei] ) * primarySpeciesAggregateConcentration[ei][0][is]; + primarySpeciesAggregateMole[ei][is] = porosity[ei][0] * ( volume[ei] + deltaVolume[ei] ) * primarySpeciesAggregateConcentration[ei][0][is] * solventMassFraction * density[ei][0]; + // the previous amount is not written to restart files and is rebuilt here after a restart if( isZero( primarySpeciesAggregateMole_n[ei][is] ) ) - primarySpeciesAggregateMole_n[ei][is] = porosity_n[ei][0] * volume[ei] * primarySpeciesAggregateConcentration_n[ei][0][is]; + primarySpeciesAggregateMole_n[ei][is] = porosity_n[ei][0] * volume[ei] * primarySpeciesAggregateConcentration_n[ei][0][is] * solventMassFraction * density_n[ei][0]; } } ); } @@ -570,15 +592,20 @@ void SinglePhaseReactiveTransport::updateSpeciesAmount( ElementSubRegionBase & s getConstitutiveModel< reactivefluid::ReactiveCompressibleSinglePhaseFluid >( subRegion, subRegion.getReference< string >( viewKeyStruct::fluidNamesString() ) ); arrayView3d< real64 const, reactivefluid::USD_SPECIES > const primarySpeciesAggregateConcentration = fluid.primarySpeciesAggregateConcentration(); arrayView3d< real64 const, reactivefluid::USD_SPECIES > const primarySpeciesAggregateConcentration_n = fluid.primarySpeciesAggregateConcentration_n(); + arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > const density = fluid.density(); + arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > const density_n = fluid.density_n(); + real64 const solventMassFraction = fluid.solventMassFraction(); + // moles in the pore volume: molality * solvent mass fraction * density * pore volume forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOS_HOST_DEVICE ( localIndex const ei ) { for( integer is = 0; is < numPrimarySpecies; ++is ) { - primarySpeciesAggregateMole[ei][is] = porosity[ei][0] * ( volume[ei] + deltaVolume[ei] ) * primarySpeciesAggregateConcentration[ei][0][is]; + primarySpeciesAggregateMole[ei][is] = porosity[ei][0] * ( volume[ei] + deltaVolume[ei] ) * primarySpeciesAggregateConcentration[ei][0][is] * solventMassFraction * density[ei][0]; + // the previous amount is not written to restart files and is rebuilt here after a restart if( isZero( primarySpeciesAggregateMole_n[ei][is] ) ) - primarySpeciesAggregateMole_n[ei][is] = porosity_n[ei][0] * volume[ei] * primarySpeciesAggregateConcentration_n[ei][0][is]; + primarySpeciesAggregateMole_n[ei][is] = porosity_n[ei][0] * volume[ei] * primarySpeciesAggregateConcentration_n[ei][0][is] * solventMassFraction * density_n[ei][0]; } } ); } @@ -603,7 +630,7 @@ void SinglePhaseReactiveTransport::updateKineticReactionMolarIncrements( real64 { for( integer r = 0; r < numKineticReactions; ++r ) { - kineticReactionMolarIncrements[ei][r] = dt* kineticReactionRates[ei][0][r]; + kineticReactionMolarIncrements[ei][r] = dt * kineticReactionRates[ei][0][r]; } } ); } @@ -617,7 +644,7 @@ void SinglePhaseReactiveTransport::updateKineticReactionMolarIncrements( real64 { for( integer r = 0; r < numKineticReactions; ++r ) { - kineticReactionMolarIncrements[ei][r] = dt* kineticReactionRates[ei][0][r]; + kineticReactionMolarIncrements[ei][r] = dt * kineticReactionRates[ei][0][r]; } } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransportFields.hpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransportFields.hpp index 28c72f5c170..4a0115f36b5 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransportFields.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseReactiveTransportFields.hpp @@ -41,23 +41,23 @@ DECLARE_FIELD( logPrimarySpeciesConcentration, 0, LEVEL_0, WRITE_AND_READ, - "Natural log of primary species concentration (molarity)" ); + "Natural log of primary species concentration (molality)" ); DECLARE_FIELD( logPrimarySpeciesConcentration_n, "logPrimarySpeciesConcentration_n", array2dLayoutComp, 0, - LEVEL_0, + NOPLOT, WRITE_AND_READ, - "Natural log of primary species concentration (molarity) at the previous converged time step" ); + "Natural log of primary species concentration (molality) at the previous converged time step" ); DECLARE_FIELD( bcLogPrimarySpeciesConcentration, "bcLogPrimarySpeciesConcentration", array2dLayoutComp, 0, - LEVEL_0, + NOPLOT, WRITE_AND_READ, - "Boundary condition for natural log of primary species concentration (molarity)" ); + "Boundary condition for natural log of primary species concentration (molality)" ); DECLARE_FIELD( primarySpeciesAggregateMole, "primarySpeciesAggregateMole", @@ -71,8 +71,8 @@ DECLARE_FIELD( primarySpeciesAggregateMole_n, "primarySpeciesAggregateMole_n", array2dLayoutComp, 0, - LEVEL_0, - WRITE_AND_READ, + NOPLOT, + NO_WRITE, "Aggregate amount of primary species in mole at the previous converged time step" ); DECLARE_FIELD( kineticReactionMolarIncrements, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/AccumulationKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/AccumulationKernels.hpp index 28c3b1cc181..117ea50f94a 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/AccumulationKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/AccumulationKernels.hpp @@ -82,6 +82,9 @@ class AccumulationKernel : public singlePhaseBaseKernels::AccumulationKernel< SU arrayView1d< real64 > const & localRhs ) : Base( rankOffset, dofKey, subRegion, localMatrix, localRhs ), m_dt( dt ), + m_solventMassFraction( fluid.solventMassFraction() ), + m_density( fluid.density() ), + m_dDensity( fluid.dDensity() ), m_volume( subRegion.getElementVolume() ), m_deltaVolume( subRegion.template getField< fields::flow::deltaVolume >() ), m_porosity( solid.getPorosity() ), @@ -160,8 +163,9 @@ class AccumulationKernel : public singlePhaseBaseKernels::AccumulationKernel< SU void computeAccumulation( localIndex const ei, StackVariables & stack ) const { - // Residual[is] += (primarySpeciesAggregateConcentration[is] * stack.poreVolume - primarySpeciesAggregateMole_n[is]) - // - dt * m_volume * primarySpeciesKineticRate[is] // To Check: what's the unit of the kinetic rate + // Residual[is] += (primarySpeciesAggregateConcentration[is] * solventMassFraction * density * stack.poreVolume - + // primarySpeciesAggregateMole_n[is]) + // - dt * m_volume * primarySpeciesKineticRate[is] Base::computeAccumulation( ei, stack ); @@ -183,14 +187,17 @@ class AccumulationKernel : public singlePhaseBaseKernels::AccumulationKernel< SU // Step 2.1: residual // Primary species mole amount in pore volume stack.localResidual[is+numEqn-numSpecies] -= m_primarySpeciesAggregateMole_n[ei][is]; - stack.localResidual[is+numEqn-numSpecies] += m_primarySpeciesAggregateConcentration[ei][0][is] * stack.poreVolume; + // moles of species per m^3 of solution: molality * solvent mass fraction * density + real64 const aggregateConcMolarity = m_primarySpeciesAggregateConcentration[ei][0][is] * m_solventMassFraction * m_density[ei][0]; + stack.localResidual[is+numEqn-numSpecies] += aggregateConcMolarity * stack.poreVolume; // Reaction term stack.localResidual[is+numEqn-numSpecies] -= m_dt * ( m_volume[ei] + m_deltaVolume[ei] ) * m_primarySpeciesAggregateKineticRate[ei][0][is]; // Step 2.1: jacobian - // Drivative of primary species amount in pore volume wrt pressure - stack.localJacobian[is+numEqn-numSpecies][0] += stack.dPoreVolume_dPres * m_primarySpeciesAggregateConcentration[ei][0][is] + // Derivative of primary species amount in pore volume wrt pressure + stack.localJacobian[is+numEqn-numSpecies][0] += stack.dPoreVolume_dPres * aggregateConcMolarity + + stack.poreVolume * m_primarySpeciesAggregateConcentration[ei][0][is] * m_solventMassFraction * m_dDensity[ei][0][DerivOffset::dP] /* + stack.poreVolume * m_dTotalPrimarySpeciesConcentration_dPres[ei][is] */; // // Derivative of reaction term wrt pressure // stack.localJacobian[is+numEqn-numSpecies][0] -= m_dt * ( m_volume[ei] + m_deltaVolume[ei] ) * @@ -201,13 +208,8 @@ class AccumulationKernel : public singlePhaseBaseKernels::AccumulationKernel< SU { stack.localJacobian[is+numEqn-numSpecies][js+numDof-numSpecies] = /* stack.dPoreVolume_dLogPrimaryConc[js] * m_primarySpeciesAggregateConcentration[ei][0][is] - + */stack.poreVolume * dPrimarySpeciesAggregateConcentration_dLogPrimarySpeciesConcentrations[is][js]; // To - // check - // if - // the - // permutation - // is - // consistent + + */stack.poreVolume * dPrimarySpeciesAggregateConcentration_dLogPrimarySpeciesConcentrations[is][js] * + m_solventMassFraction * m_density[ei][0]; stack.localJacobian[is+numEqn-numSpecies][js+numDof-numSpecies] -= m_dt * ( m_volume[ei] + m_deltaVolume[ei] ) * dPrimarySpeciesAggregateKineticRate_dLogPrimaryConc[is][js]; } @@ -245,6 +247,13 @@ class AccumulationKernel : public singlePhaseBaseKernels::AccumulationKernel< SU /// Time step size real64 const m_dt; + /// Mass fraction of solvent in the solution [-]; molality times this fraction times density is the molarity + real64 const m_solventMassFraction; + + /// View on the fluid density and its derivatives + arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > const m_density; + arrayView3d< real64 const, constitutive::singlefluid::USD_FLUID_DER > const m_dDensity; + /// View on the element volumes arrayView1d< real64 const > const m_volume; arrayView1d< real64 const > const m_deltaVolume; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/DirichletFluxComputeKernel.hpp b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/DirichletFluxComputeKernel.hpp index 80ff9bce9ba..97eae3adeda 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/DirichletFluxComputeKernel.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/DirichletFluxComputeKernel.hpp @@ -117,6 +117,7 @@ class DirichletFluxComputeKernel : public singlePhaseFVMKernels::DirichletFluxCo ReactiveSinglePhaseFluidAccessors const & reactiveSinglePhaseFluidAccessors, PermeabilityAccessors const & permeabilityAccessors, arrayView1d< integer const > const & mobilePrimarySpeciesFlags, + real64 const & solventMassFraction, real64 const & dt, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) @@ -135,7 +136,8 @@ class DirichletFluxComputeKernel : public singlePhaseFVMKernels::DirichletFluxCo m_primarySpeciesMobileAggregateConc( reactiveSinglePhaseFluidAccessors.get( fields::reactivefluid::primarySpeciesMobileAggregateConcentration {} ) ), m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc( reactiveSinglePhaseFluidAccessors.get( fields::reactivefluid::dPrimarySpeciesMobileAggregateConcentration_dLogPrimarySpeciesConcentrations {} ) ), - m_mobilePrimarySpeciesFlags( mobilePrimarySpeciesFlags ) + m_mobilePrimarySpeciesFlags( mobilePrimarySpeciesFlags ), + m_solventMassFraction( solventMassFraction ) {} /** @@ -186,25 +188,24 @@ class DirichletFluxComputeKernel : public singlePhaseFVMKernels::DirichletFluxCo real64 const & dens_up, real64 const & dDens_dP_up ) { - GEOS_UNUSED_VAR( kf ); + GEOS_UNUSED_VAR( kf, dens_up, dDens_dP_up ); real64 speciesFlux[numSpecies]{}; real64 dSpeciesFlux_dP[numSpecies]{}; real64 dSpeciesFlux_dLogConc[numSpecies][numSpecies]{}; + // the mass flux carries molality * solvent mass fraction moles per kg of solution for( integer is = 0; is < numSpecies; ++is ) { - real64 const aggregateConc_i = m_primarySpeciesMobileAggregateConc[seri][sesri][sei][0][is]; - speciesFlux[is] = aggregateConc_i / dens_up * fluxVal * mobility_up; + real64 const aggregateConcPerMass_i = m_primarySpeciesMobileAggregateConc[seri][sesri][sei][0][is] * m_solventMassFraction; + speciesFlux[is] = aggregateConcPerMass_i * fluxVal * mobility_up; - dSpeciesFlux_dP[is] = aggregateConc_i / dens_up * dFlux_dP * mobility_up - + aggregateConc_i / dens_up * fluxVal * dMobility_dP_up - - aggregateConc_i * fluxVal * mobility_up * dDens_dP_up / (dens_up * dens_up); + dSpeciesFlux_dP[is] = aggregateConcPerMass_i * ( dFlux_dP * mobility_up + fluxVal * dMobility_dP_up ); for( integer js = 0; js < numSpecies; ++js ) { - real64 const dAggregateConc_i_dLogConc_j = m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc[seri][sesri][sei][0][is][js]; - dSpeciesFlux_dLogConc[is][js] += dAggregateConc_i_dLogConc_j / dens_up * fluxVal * mobility_up; + real64 const dAggregateConcPerMass_i_dLogConc_j = m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc[seri][sesri][sei][0][is][js] * m_solventMassFraction; + dSpeciesFlux_dLogConc[is][js] += dAggregateConcPerMass_i_dLogConc_j * fluxVal * mobility_up; } } @@ -267,6 +268,9 @@ class DirichletFluxComputeKernel : public singlePhaseFVMKernels::DirichletFluxCo /// Array of flags to indicate mobile primary species arrayView1d< integer const > const m_mobilePrimarySpeciesFlags; + /// Mass fraction of solvent in the solution [-]; molality times this fraction is the amount per kg of solution + real64 const m_solventMassFraction; + }; @@ -344,6 +348,7 @@ class DirichletFluxComputeKernelFactory reactiveFluidAccessors, permeabilityAccessors, mobilePrimarySpeciesFlags, + reactiveFluid.solventMassFraction(), dt, localMatrix, localRhs ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/FluxComputeKernel.hpp b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/FluxComputeKernel.hpp index a408c29aa0d..c2ad0d8a66e 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/FluxComputeKernel.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/FluxComputeKernel.hpp @@ -122,6 +122,7 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E * @param[in] porosityAccessors * @param[in] hasDiffusion the flag to turn on diffusion calculation * @param[in] mobilePrimarySpeciesFlags the array of flags to indicate mobile primary species + * @param[in] solventMassFraction mass fraction of solvent in the solution [-] * @param[in] dt time step size * @param[inout] localMatrix the local CRS matrix * @param[inout] localRhs the local right-hand side vector @@ -138,6 +139,7 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E PorosityAccessors const & porosityAccessors, integer const & hasDiffusion, arrayView1d< integer const > const & mobilePrimarySpeciesFlags, + real64 const & solventMassFraction, real64 const & dt, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) @@ -159,7 +161,8 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E m_dDiffusivity_dTemp( diffusionAccessors.get( fields::diffusion::dDiffusivity_dTemperature {} ) ), m_referencePorosity( porosityAccessors.get( fields::porosity::referencePorosity {} ) ), m_hasDiffusion( hasDiffusion ), - m_mobilePrimarySpeciesFlags( mobilePrimarySpeciesFlags ) + m_mobilePrimarySpeciesFlags( mobilePrimarySpeciesFlags ), + m_solventMassFraction( solventMassFraction ) {} /** @@ -208,7 +211,6 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E StackVariables & stack, FUNC && kernelOp = NoOpFunc{} ) const { - using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >; // *********************************************** // First, we call the base computeFlux to compute: // 1) massFlux and its derivatives, @@ -243,26 +245,22 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E localIndex const esr_up = sesri[k_up]; localIndex const ei_up = sei[k_up]; - real64 const fluidDens_up = m_dens[er_up][esr_up][ei_up][0]; - real64 const dDens_dPres = m_dDens[er_up][esr_up][ei_up][0][DerivOffset::dP]; - - // compute species fluxes and derivatives using upstream cell concentration + // compute species fluxes and derivatives using upstream cell concentration: the mass flux carries + // molality * solvent mass fraction moles per kg of solution, so the density does not enter for( integer is = 0; is < numSpecies; ++is ) { - real64 const aggregateConc_i = m_primarySpeciesMobileAggregateConc[er_up][esr_up][ei_up][0][is]; - speciesFlux[is] = aggregateConc_i / fluidDens_up * fluxVal; + real64 const aggregateConcPerMass_i = m_primarySpeciesMobileAggregateConc[er_up][esr_up][ei_up][0][is] * m_solventMassFraction; + speciesFlux[is] = aggregateConcPerMass_i * fluxVal; for( integer ke = 0; ke < numFluxSupportPoints; ++ke ) { - dSpeciesFlux_dP[ke][is] += aggregateConc_i / fluidDens_up * dFlux_dP[ke]; + dSpeciesFlux_dP[ke][is] += aggregateConcPerMass_i * dFlux_dP[ke]; } - dSpeciesFlux_dP[k_up][is] += -aggregateConc_i * fluxVal * dDens_dPres / (fluidDens_up * fluidDens_up); - for( integer js = 0; js < numSpecies; ++js ) { - real64 const dAggregateConc_i_dLogConc_j = m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc[er_up][esr_up][ei_up][0][is][js]; - dSpeciesFlux_dLogConc[k_up][is][js] += dAggregateConc_i_dLogConc_j / fluidDens_up * fluxVal; + real64 const dAggregateConcPerMass_i_dLogConc_j = m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc[er_up][esr_up][ei_up][0][is][js] * m_solventMassFraction; + dSpeciesFlux_dLogConc[k_up][is][js] += dAggregateConcPerMass_i_dLogConc_j * fluxVal; } } @@ -291,7 +289,7 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E } // Customize the kernel with this lambda - kernelOp( k, seri, sesri, sei, connectionIndex, alpha, mobility, potGrad, fluxVal, dFlux_dP, fluidDens_up ); + kernelOp( k, seri, sesri, sei, connectionIndex, alpha, mobility, potGrad, fluxVal, dFlux_dP ); } ); } @@ -308,6 +306,7 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E StackVariables & stack, FUNC && kernelOp = NoOpFunc{} ) const { + using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >; if( m_hasDiffusion ) { // ***************************************************** @@ -334,7 +333,7 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E // clear working arrays real64 diffusionFlux[numSpecies]{}; real64 speciesGrad[numSpecies]{}; - // real64 dDiffusionFlux_dP[numFluxSupportPoints][numSpecies]{}; // Turn on if diffusionFlux is pressure-dependent + real64 dDiffusionFlux_dP[numFluxSupportPoints][numSpecies]{}; real64 dDiffusionFlux_dLogConc[numFluxSupportPoints][numSpecies][numSpecies]{}; real64 const diffusionTrans[numFluxSupportPoints] = { stack.diffusionTransmissibility[connectionIndex][0], @@ -344,25 +343,27 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E // loop over primary species for( integer is = 0; is < numSpecies; ++is ) { - // real64 dSpeciesGrad_i_dP[numFluxSupportPoints]{}; // Turn on if speciesGrad is pressure-dependent + real64 dSpeciesGrad_i_dP[numFluxSupportPoints]{}; real64 dSpeciesGrad_i_dLogConc[numFluxSupportPoints][numSpecies]{}; - // Step 2: compute species gradient + // Step 2: compute the gradient of the molarity, molality * solvent mass fraction * density for( integer ke = 0; ke < numFluxSupportPoints; ++ke ) { localIndex const er = seri[ke]; localIndex const esr = sesri[ke]; localIndex const ei = sei[ke]; - real64 const aggregateConc_i = m_primarySpeciesMobileAggregateConc[er][esr][ei][0][is]; + real64 const aggregateConcPerMass_i = m_primarySpeciesMobileAggregateConc[er][esr][ei][0][is] * m_solventMassFraction; + real64 const dens = m_dens[er][esr][ei][0]; - speciesGrad[is] += diffusionTrans[ke] * aggregateConc_i; + speciesGrad[is] += diffusionTrans[ke] * aggregateConcPerMass_i * dens; + dSpeciesGrad_i_dP[ke] += diffusionTrans[ke] * aggregateConcPerMass_i * m_dDens[er][esr][ei][0][DerivOffset::dP]; for( integer js = 0; js < numSpecies; ++js ) { - real64 const dAggregateConc_i_dLogConc_j = m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc[er][esr][ei][0][is][js]; + real64 const dAggregateConcPerMass_i_dLogConc_j = m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc[er][esr][ei][0][is][js] * m_solventMassFraction; - dSpeciesGrad_i_dLogConc[ke][js] += diffusionTrans[ke] * dAggregateConc_i_dLogConc_j; + dSpeciesGrad_i_dLogConc[ke][js] += diffusionTrans[ke] * dAggregateConcPerMass_i_dLogConc_j * dens; } } @@ -379,6 +380,7 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E // add contributions of the derivatives of component fractions wrt pressure/component fractions for( integer ke = 0; ke < numFluxSupportPoints; ke++ ) { + dDiffusionFlux_dP[ke][is] += m_referencePorosity[er_up][esr_up][ei_up] * dSpeciesGrad_i_dP[ke]; for( integer js = 0; js < numSpecies; ++js ) { dDiffusionFlux_dLogConc[ke][is][js] += m_referencePorosity[er_up][esr_up][ei_up] * dSpeciesGrad_i_dLogConc[ke][js]; @@ -395,8 +397,8 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E for( integer ke = 0; ke < numFluxSupportPoints; ++ke ) { localIndex const localDofIndexPres = k[ke] * numDof; - // stack.localFluxJacobian[eqIndex0][localDofIndexPres] += m_dt * dDiffusionFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is]; - // stack.localFluxJacobian[eqIndex1][localDofIndexPres] -= m_dt * dDiffusionFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is]; + stack.localFluxJacobian[eqIndex0][localDofIndexPres] += m_dt * dDiffusionFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is]; + stack.localFluxJacobian[eqIndex1][localDofIndexPres] -= m_dt * dDiffusionFlux_dP[ke][is] * m_mobilePrimarySpeciesFlags[is]; for( integer js = 0; js < numSpecies; ++js ) { @@ -500,6 +502,9 @@ class FluxComputeKernel : public singlePhaseFVMKernels::FluxComputeKernel< NUM_E /// Array of flags to indicate mobile primary species arrayView1d< integer const > const m_mobilePrimarySpeciesFlags; + + /// Mass fraction of solvent in the solution [-]; molality times this fraction is the amount per kg of solution + real64 const m_solventMassFraction; }; /** @@ -516,6 +521,7 @@ class FluxComputeKernelFactory * @param[in] numSpecies the number of primary species * @param[in] hasDiffusion the flag of adding diffusion term * @param[in] mobilePrimarySpeciesFlags the array of flags to indicate mobile primary species + * @param[in] solventMassFraction mass fraction of solvent in the solution [-] * @param[in] rankOffset the offset of my MPI rank * @param[in] dofKey string to get the element degrees of freedom numbers * @param[in] solverName name of the solver (to name accessors) @@ -530,6 +536,7 @@ class FluxComputeKernelFactory createAndLaunch( integer const numSpecies, integer const hasDiffusion, arrayView1d< integer const > const mobilePrimarySpeciesFlags, + real64 const solventMassFraction, globalIndex const rankOffset, string const & dofKey, string const & solverName, @@ -561,7 +568,7 @@ class FluxComputeKernelFactory KernelType kernel( rankOffset, stencilWrapper, dofNumberAccessor, flowAccessors, reactiveFlowAccessors, fluidAccessors, reactiveFluidAccessors, permAccessors, diffusionAccessors, porosityAccessors, hasDiffusion, mobilePrimarySpeciesFlags, - dt, localMatrix, localRhs ); + solventMassFraction, dt, localMatrix, localRhs ); KernelType::template launch< POLICY >( stencilWrapper.size(), kernel ); } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/SourceFluxComputeKernel.hpp b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/SourceFluxComputeKernel.hpp index 1ef58f942aa..94a41eeea30 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/SourceFluxComputeKernel.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/SourceFluxComputeKernel.hpp @@ -74,6 +74,7 @@ class SourceFluxComputeKernel m_elemGhostRank( elemGhostRank ), m_rhsContributionArrayView( rhsContributionArrayView ), m_sizeScalingFactor( sizeScalingFactor ), + m_solventMassFraction( fluid.solventMassFraction() ), m_primarySpeciesAggregateConcentration( fluid.primarySpeciesAggregateConcentration() ), m_dPrimarySpeciesAggregateConcentration_dLogPrimarySpeciesConcentrations( fluid.dPrimarySpeciesAggregateConcentration_dLogPrimarySpeciesConcentrations() ), m_density( fluid.density() ), @@ -149,14 +150,15 @@ class SourceFluxComputeKernel { real64 const scaledInflowMass = stack.totalInflowMass / m_sizeScalingFactor; + // the inflow mass carries molality * solvent mass fraction moles per kg of solution for( integer i = 0; i < numSpecies; ++i ) { - stack.localSpeciesRhs[i] += m_primarySpeciesAggregateConcentration[ei][0][i] / m_density[ei][0] * scaledInflowMass; - stack.localSpeciesJacobian[i][0] += -m_primarySpeciesAggregateConcentration[ei][0][i] * m_dDensity[ei][0][DerivOffset::dP] / (m_density[ei][0] * m_density[ei][0]) * scaledInflowMass; + stack.localSpeciesRhs[i] += m_primarySpeciesAggregateConcentration[ei][0][i] * m_solventMassFraction * scaledInflowMass; for( integer j = 0; j < numSpecies; ++j ) { - stack.localSpeciesJacobian[i][j+numDof-numSpecies] += m_dPrimarySpeciesAggregateConcentration_dLogPrimarySpeciesConcentrations[ei][0][i][j] / m_density[ei][0] * scaledInflowMass; + stack.localSpeciesJacobian[i][j+numDof-numSpecies] += m_dPrimarySpeciesAggregateConcentration_dLogPrimarySpeciesConcentrations[ei][0][i][j] * m_solventMassFraction * + scaledInflowMass; } } } @@ -237,6 +239,9 @@ class SourceFluxComputeKernel /// size scaling factor real64 const m_sizeScalingFactor; + /// Mass fraction of solvent in the solution [-]; molality times this fraction is the amount per kg of solution + real64 const m_solventMassFraction; + // View on the total concentration of ions that contain the primary species arrayView3d< real64 const, constitutive::reactivefluid::USD_SPECIES > const m_primarySpeciesAggregateConcentration; // View on the derivatives of total ion concentration for the primary species wrt log of primary species concentration diff --git a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalAccumulationKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalAccumulationKernels.hpp index 33fa2ac0f3b..92ecf6d6c20 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalAccumulationKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalAccumulationKernels.hpp @@ -53,6 +53,9 @@ class AccumulationKernel : public singlePhaseReactiveBaseKernels::AccumulationKe using Base::m_volume; using Base::m_deltaVolume; using Base::m_primarySpeciesAggregateConcentration; + using Base::m_solventMassFraction; + using Base::m_density; + using Base::m_dDensity; /// Note: Derivative lineup only supports dP & dT, not component terms using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >; @@ -160,9 +163,11 @@ class AccumulationKernel : public singlePhaseReactiveBaseKernels::AccumulationKe // Step 3: assemble the derivatives of the species amount balance equation w.r.t temperature for( integer is = 0; is < numSpecies; ++is ) { - // Drivative of primary species amount in pore volume wrt temperature - stack.localJacobian[is+numEqn-numSpecies][numDof-numSpecies-1] += stack.dPoreVolume_dTemp * m_primarySpeciesAggregateConcentration[ei][0][is] - /* + stack.poreVolume * + // Derivative of primary species amount in pore volume wrt temperature + real64 const aggregateConcMolality = m_primarySpeciesAggregateConcentration[ei][0][is] * m_solventMassFraction; + stack.localJacobian[is+numEqn-numSpecies][numDof-numSpecies-1] += ( stack.dPoreVolume_dTemp * m_density[ei][0] + + stack.poreVolume * m_dDensity[ei][0][DerivOffset::dT] ) * aggregateConcMolality + /* + stack.poreVolume * m_density[ei][0] * m_solventMassFraction * m_dPrimarySpeciesAggregateConcentration_dTemp[ei][is] */; // // Derivative of reaction term wrt temperature // stack.localJacobian[is+numEqn-numSpecies][numDof-numSpecies-1] -= m_dt * ( m_volume[ei] + m_deltaVolume[ei] ) * diff --git a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalDirichletFluxComputeKernel.hpp b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalDirichletFluxComputeKernel.hpp index 7a87bdfbc50..72e43913d9c 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalDirichletFluxComputeKernel.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalDirichletFluxComputeKernel.hpp @@ -86,6 +86,9 @@ class DirichletFluxComputeKernel : public singlePhaseReactiveFVMKernels::Dirichl using Base::m_sei; using Base::m_facePres; using Base::m_faceGravCoef; + using Base::m_solventMassFraction; + using Base::m_primarySpeciesMobileAggregateConc; + using Base::m_mobilePrimarySpeciesFlags; using ReactiveSinglePhaseFlowAccessors = typename Base::ReactiveSinglePhaseFlowAccessors; using ReactiveSinglePhaseFluidAccessors = typename Base::ReactiveSinglePhaseFluidAccessors; @@ -137,6 +140,7 @@ class DirichletFluxComputeKernel : public singlePhaseReactiveFVMKernels::Dirichl PermeabilityAccessors const & permeabilityAccessors, ThermalConductivityAccessors const & thermalConductivityAccessors, arrayView1d< integer const > const & mobilePrimarySpeciesFlags, + real64 const & solventMassFraction, real64 const & dt, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) @@ -152,6 +156,7 @@ class DirichletFluxComputeKernel : public singlePhaseReactiveFVMKernels::Dirichl reactiveSinglePhaseFluidAccessors, permeabilityAccessors, mobilePrimarySpeciesFlags, + solventMassFraction, dt, localMatrix, localRhs ), @@ -230,10 +235,11 @@ class DirichletFluxComputeKernel : public singlePhaseReactiveFVMKernels::Dirichl // Compute the derivatives of the (upwinded) energy flux wrt pressure and temperature + real64 dFlux_dT = mobility_up * dF_dT; if( f >= 0 ) // the element is upstream { real64 const dFlux_dP = mobility_up * dF_dP + dMobility_dP_up * f; - real64 const dFlux_dT = mobility_up * dF_dT + m_dMob[er][esr][ei][DerivOffset::dT] * f; + dFlux_dT += m_dMob[er][esr][ei][DerivOffset::dT] * f; stack.dEnergyFlux_dP += dFlux_dP * enthalpy + flux * m_dEnthalpy[er][esr][ei][0][DerivOffset::dP]; stack.dEnergyFlux_dT += dFlux_dT * enthalpy + flux * m_dEnthalpy[er][esr][ei][0][DerivOffset::dT]; @@ -241,12 +247,18 @@ class DirichletFluxComputeKernel : public singlePhaseReactiveFVMKernels::Dirichl else { real64 const dFlux_dP = mobility_up * dF_dP; - real64 const dFlux_dT = mobility_up * dF_dT; stack.dEnergyFlux_dP += dFlux_dP * enthalpy; stack.dEnergyFlux_dT += dFlux_dT * enthalpy; } + // derivative of the species flux, molality * solvent mass fraction * mass flux, wrt temperature + for( integer is = 0; is < numSpecies; ++is ) + { + real64 const aggregateConcPerMass_i = m_primarySpeciesMobileAggregateConc[er][esr][ei][0][is] * m_solventMassFraction; + stack.localFluxJacobian[numEqn - numSpecies + is][numDof - numSpecies - 1] += m_dt * aggregateConcPerMass_i * dFlux_dT * m_mobilePrimarySpeciesFlags[is]; + } + // Contribution of energy conduction through the solid phase real64 thermalTrans = 0.0; real64 dThermalTrans_dThermalCond[3]{}; @@ -392,6 +404,7 @@ class DirichletFluxComputeKernelFactory permeabilityAccessors, thermalConductivityAccessors, mobilePrimarySpeciesFlags, + reactiveFluid.solventMassFraction(), dt, localMatrix, localRhs ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalFluxComputeKernel.hpp b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalFluxComputeKernel.hpp index d436b261628..cf07b134b11 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalFluxComputeKernel.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalFluxComputeKernel.hpp @@ -89,6 +89,7 @@ class FluxComputeKernel : public singlePhaseReactiveFVMKernels::FluxComputeKerne using Base::m_primarySpeciesMobileAggregateConc; using Base::m_referencePorosity; using Base::m_mobilePrimarySpeciesFlags; + using Base::m_solventMassFraction; using ThermalSinglePhaseFlowAccessors = StencilAccessors< fields::flow::temperature >; @@ -121,6 +122,7 @@ class FluxComputeKernel : public singlePhaseReactiveFVMKernels::FluxComputeKerne * @param[in] thermalConductivityAccessors accessor for wrappers registered by the thermal conductivity model * @param[in] hasDiffusion the flag to turn on diffusion calculation * @param[in] mobilePrimarySpeciesFlags the array of flags to indicate mobile primary species + * @param[in] solventMassFraction mass fraction of solvent in the solution [-] * @param[in] dt time step size * @param[inout] localMatrix the local CRS matrix * @param[inout] localRhs the local right-hand side vector @@ -140,6 +142,7 @@ class FluxComputeKernel : public singlePhaseReactiveFVMKernels::FluxComputeKerne ThermalConductivityAccessors const & thermalConductivityAccessors, integer const & hasDiffusion, arrayView1d< integer const > const & mobilePrimarySpeciesFlags, + real64 const & solventMassFraction, real64 const & dt, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) @@ -155,6 +158,7 @@ class FluxComputeKernel : public singlePhaseReactiveFVMKernels::FluxComputeKerne porosityAccessors, hasDiffusion, mobilePrimarySpeciesFlags, + solventMassFraction, dt, localMatrix, localRhs ), @@ -233,8 +237,7 @@ class FluxComputeKernel : public singlePhaseReactiveFVMKernels::FluxComputeKerne real64 const mobility, real64 const & potGrad, real64 const & fluxVal, - real64 const (&dFlux_dP)[2], - real64 const fluidDens_up ) + real64 const (&dFlux_dP)[2] ) { // Step 1: compute the derivatives of the (upwinded) massFlux wrt temperature // -------------------------------------------------------------------------- @@ -315,28 +318,25 @@ class FluxComputeKernel : public singlePhaseReactiveFVMKernels::FluxComputeKerne real64 dSpeciesFlux_dT[numFluxSupportPoints][numSpecies]{}; { - // Step 2.1: compute the derivatives of the upstream density wrt temperature - // choose upstream cell + // Step 2.1: choose upstream cell; the mass flux carries molality * solvent mass fraction moles per kg + // of solution, so the density does not enter and only the mass flux depends on temperature localIndex const k_up = (potGrad >= 0) ? 0 : 1; localIndex const er_up = seri[k_up]; localIndex const esr_up = sesri[k_up]; localIndex const ei_up = sei[k_up]; - real64 const dDens_dTemp = m_dDens[er_up][esr_up][ei_up][0][DerivOffset::dT]; - // Step 2.2: compute speciesFlux derivative wrt temperature for( integer is = 0; is < numSpecies; ++is ) { - real64 const aggregateConc_i = m_primarySpeciesMobileAggregateConc[er_up][esr_up][ei_up][0][is]; + real64 const aggregateConcPerMass_i = m_primarySpeciesMobileAggregateConc[er_up][esr_up][ei_up][0][is] * m_solventMassFraction; // real64 const dAggregateConc_i_dTemp = m_dPrimarySpeciesMobileAggregateConcentration_dTemp[er_up][esr_up][ei_up][is]; - // dSpeciesFlux_dT[k_up][is] += dAggregateConc_i_dTemp * fluxVal / fluidDens_up; - dSpeciesFlux_dT[k_up][is] += -aggregateConc_i * fluxVal * dDens_dTemp / (fluidDens_up * fluidDens_up); + // dSpeciesFlux_dT[k_up][is] += dAggregateConc_i_dTemp * m_solventMassFraction * fluxVal; for( integer ke = 0; ke < numFluxSupportPoints; ++ke ) { - dSpeciesFlux_dT[ke][is] += aggregateConc_i / fluidDens_up * dFlux_dT[ke]; + dSpeciesFlux_dT[ke][is] += aggregateConcPerMass_i * dFlux_dT[ke]; } } } @@ -468,6 +468,7 @@ class FluxComputeKernel : public singlePhaseReactiveFVMKernels::FluxComputeKerne void computeDiffusion( localIndex const iconn, StackVariables & stack ) const { + using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >; Base::computeDiffusion( iconn, stack, [&] ( integer const is, localIndex const (&k)[2], localIndex const (&seri)[2], @@ -489,7 +490,10 @@ class FluxComputeKernel : public singlePhaseReactiveFVMKernels::FluxComputeKerne // dSpeciesGrad_dT[ke] += stack.diffusionTransmissibility[connectionIndex][ke] // * m_dPrimarySpeciesMobileAggregateConcentration_dTemp[er][esr][ei][is]; - dSpeciesGrad_dT[ke] += stack.dDiffusionTrans_dT[connectionIndex][ke] * m_primarySpeciesMobileAggregateConc[er][esr][ei][0][is]; + // molarity is molality * solvent mass fraction * density, so both the transmissibility and the density vary with temperature + real64 const aggregateConcPerMass_i = m_primarySpeciesMobileAggregateConc[er][esr][ei][0][is] * m_solventMassFraction; + dSpeciesGrad_dT[ke] += stack.dDiffusionTrans_dT[connectionIndex][ke] * aggregateConcPerMass_i * m_dens[er][esr][ei][0] + + stack.diffusionTransmissibility[connectionIndex][ke] * aggregateConcPerMass_i * m_dDens[er][esr][ei][0][DerivOffset::dT]; } for( integer ke = 0; ke < numFluxSupportPoints; ke++ ) @@ -588,6 +592,7 @@ class FluxComputeKernelFactory createAndLaunch( integer const numSpecies, integer const hasDiffusion, arrayView1d< integer const > const mobilePrimarySpeciesFlags, + real64 const solventMassFraction, globalIndex const rankOffset, string const & dofKey, string const & solverName, @@ -622,7 +627,7 @@ class FluxComputeKernelFactory KernelType kernel( rankOffset, stencilWrapper, dofNumberAccessor, flowAccessors, reactiveFlowAccessors, thermalFlowAccessors, fluidAccessors, reactiveFluidAccessors, thermalFluidAccessors, permAccessors, diffusionAccessors, porosityAccessors, thermalConductivityAccessors, - hasDiffusion, mobilePrimarySpeciesFlags, dt, localMatrix, localRhs ); + hasDiffusion, mobilePrimarySpeciesFlags, solventMassFraction, dt, localMatrix, localRhs ); KernelType::template launch< POLICY >( stencilWrapper.size(), kernel ); } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalSourceFluxComputeKernel.hpp b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalSourceFluxComputeKernel.hpp index 5fa7f2c201c..4184f7de27b 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalSourceFluxComputeKernel.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/kernels/singlePhase/reactive/ThermalSourceFluxComputeKernel.hpp @@ -45,9 +45,6 @@ class SourceFluxComputeKernel : public singlePhaseReactiveBaseKernels::SourceFlu using Base::numDof; using Base::numEqn; using Base::m_sizeScalingFactor; - using Base::m_primarySpeciesAggregateConcentration; - using Base::m_density; - using Base::m_dDensity; using Base::m_localMatrix; using Base::m_localRhs; @@ -119,12 +116,6 @@ class SourceFluxComputeKernel : public singlePhaseReactiveBaseKernels::SourceFlu stack.localEnergyRhs += m_enthalpy[ei][0] * scaledInflowMass; stack.localEnergyJacobian[0] = scaledInflowMass * m_dEnthalpy[ei][0][DerivOffset::dP]; stack.localEnergyJacobian[numDof-numSpecies-1] = scaledInflowMass * m_dEnthalpy[ei][0][DerivOffset::dT]; - - for( integer i = 0; i < numSpecies; ++i ) - { - stack.localSpeciesJacobian[i][numDof-numSpecies-1] += -m_primarySpeciesAggregateConcentration[ei][0][i] * m_dDensity[ei][0][DerivOffset::dT] / (m_density[ei][0] * m_density[ei][0]) * - scaledInflowMass; - } } /** diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index a516ce0f2f4..c719a937ad1 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -8830,6 +8830,8 @@ If you want to do a three-phase simulation, please use instead wettingIntermedia + + + + diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index cf0ac4ad56b..7082b1875de 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -3153,7 +3153,7 @@ A field can represent a physical variable. (pressure, temperature, global compos - + @@ -3161,9 +3161,9 @@ A field can represent a physical variable. (pressure, temperature, global compos - + - + @@ -3218,7 +3218,7 @@ A field can represent a physical variable. (pressure, temperature, global compos - + @@ -3226,9 +3226,9 @@ A field can represent a physical variable. (pressure, temperature, global compos - + - +