OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | List of all members
olb::AdsorptionReaction< T, DESCRIPTOR > Class Template Reference

Describes adsorption reactions in conjunction with a Isotherm class. More...

#include <adsorptionReaction.h>

+ Inheritance diagram for olb::AdsorptionReaction< T, DESCRIPTOR >:
+ Collaboration diagram for olb::AdsorptionReaction< T, DESCRIPTOR >:

Public Member Functions

 AdsorptionReaction (AdsorptionConverter< T, DESCRIPTOR > const &converter, Isotherm< T > const *isotherm, T k_f, T D_s, T c_0, T r_p)
 
getSurfaceLoading (T soluteConcentration)
 Get surface loading without film diffusion.
 
getSurfaceLoading (T soluteConcentration, T particleLoading, T particleConcentration)
 Get surface loading with film diffusion.
 
Vector< T, 2 > getReactionRate (T soluteConcentration, T particleLoading, T particleConcentration)
 Calculates reaction rate in lattice units.
 
getPhysFilmTransferConstant ()
 
getPhysSurfaceTransferConstant ()
 
getPhysSurfaceDiffusionConstant ()
 
void print (std::ostream &clout)
 
void write (std::string const &fileName)
 
filmDiffBoundary (T c_s_, T args[])
 equations for surface concentration
 

Public Attributes

k_f {}
 
D_s {}
 
c_0 {}
 
r_p {}
 
q_0 {}
 
k_s {}
 

Protected Attributes

bool externalMassTransferEnabled = false
 
const AdsorptionConverter< T, DESCRIPTOR > _unitConverter
 
const Isotherm< T > * isotherm
 

Detailed Description

template<typename T, typename DESCRIPTOR>
class olb::AdsorptionReaction< T, DESCRIPTOR >

Describes adsorption reactions in conjunction with a Isotherm class.

Template Parameters
T
DESCRIPTOR
See also
Isotherm

Definition at line 47 of file adsorptionReaction.h.

Constructor & Destructor Documentation

◆ AdsorptionReaction()

template<typename T , typename DESCRIPTOR >
olb::AdsorptionReaction< T, DESCRIPTOR >::AdsorptionReaction ( AdsorptionConverter< T, DESCRIPTOR > const & converter,
Isotherm< T > const * isotherm,
T k_f,
T D_s,
T c_0,
T r_p )
inline

Definition at line 63 of file adsorptionReaction.h.

63 :
64 _unitConverter(converter),
66 {
67 // calculate lattice values
68 T conversionFactorLength = _unitConverter.getConversionFactorLength();
69 this->k_f = k_f * _unitConverter.getConversionFactorTime() * 3 / r_p;
70 this->D_s = D_s / (conversionFactorLength*conversionFactorLength) * _unitConverter.getConversionFactorTime();
71 this->c_0 = c_0 / _unitConverter.getConversionFactorDensity();
72 this->r_p = r_p / conversionFactorLength;
73 this->k_s = 15 * this->D_s / (this->r_p * this->r_p);
74 this->q_0 = this->isotherm->getLoading(c_0) / _unitConverter.getConversionFactorParticleDensity();
76 }
const Isotherm< T > * isotherm
const AdsorptionConverter< T, DESCRIPTOR > _unitConverter

References olb::AdsorptionReaction< T, DESCRIPTOR >::_unitConverter, olb::AdsorptionReaction< T, DESCRIPTOR >::c_0, olb::AdsorptionReaction< T, DESCRIPTOR >::D_s, olb::AdsorptionReaction< T, DESCRIPTOR >::externalMassTransferEnabled, olb::Isotherm< T >::getLoading(), olb::AdsorptionReaction< T, DESCRIPTOR >::k_f, olb::AdsorptionReaction< T, DESCRIPTOR >::k_s, olb::AdsorptionReaction< T, DESCRIPTOR >::q_0, and olb::AdsorptionReaction< T, DESCRIPTOR >::r_p.

+ Here is the call graph for this function:

Member Function Documentation

◆ filmDiffBoundary()

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::filmDiffBoundary ( T c_s_,
T args[] )
inline

equations for surface concentration

Definition at line 184 of file adsorptionReaction.h.

184 {
185 T q = args[0];
186 T c = args[1];
187 T particleConcentration = args[2];
188 auto c_s = c_s_;
189 T q_s = this->isotherm->getLoading(c_s);
190 T equation = this->k_f * (c - c_s) - this->k_s * (particleConcentration * q_s - q);
191 return equation;
192 }
platform_constant int c[Q][D]
constexpr int q() any_platform

References olb::Isotherm< T >::getLoading(), olb::AdsorptionReaction< T, DESCRIPTOR >::k_f, and olb::AdsorptionReaction< T, DESCRIPTOR >::k_s.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPhysFilmTransferConstant()

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::getPhysFilmTransferConstant ( )
inline

Definition at line 143 of file adsorptionReaction.h.

143 {
144 return this->k_f / _unitConverter.getConversionFactorTime();
145 }

References olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorTime(), and olb::AdsorptionReaction< T, DESCRIPTOR >::k_f.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPhysSurfaceDiffusionConstant()

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::getPhysSurfaceDiffusionConstant ( )
inline

Definition at line 150 of file adsorptionReaction.h.

150 {
151 return this->D_s * _unitConverter.getConversionFactorLength() * _unitConverter.getConversionFactorLength() / _unitConverter.getConversionFactorTime();
152 }

References olb::AdsorptionReaction< T, DESCRIPTOR >::_unitConverter, olb::AdsorptionReaction< T, DESCRIPTOR >::D_s, and olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorLength().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPhysSurfaceTransferConstant()

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::getPhysSurfaceTransferConstant ( )
inline

Definition at line 146 of file adsorptionReaction.h.

146 {
147 return this->k_s / _unitConverter.getConversionFactorTime();
148 }

References olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorTime(), and olb::AdsorptionReaction< T, DESCRIPTOR >::k_s.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getReactionRate()

template<typename T , typename DESCRIPTOR >
Vector< T, 2 > olb::AdsorptionReaction< T, DESCRIPTOR >::getReactionRate ( T soluteConcentration,
T particleLoading,
T particleConcentration )
inline

Calculates reaction rate in lattice units.

Parameters
soluteConcentration
particleLoading
particleConcentration
Returns
change in solute concentration

Definition at line 126 of file adsorptionReaction.h.

126 {
127 T surfaceLoad;
128 particleConcentration *= _unitConverter.getConversionFactorParticleDensity(); // convert to kg/m^3
129 soluteConcentration *= _unitConverter.getConversionFactorDensity(); // convert to g/m^3
130 particleLoading *= _unitConverter.getConversionFactorParticleDensity(); // convert to g/m^3
132 surfaceLoad = this->getSurfaceLoading(soluteConcentration, particleLoading, particleConcentration);
133 } else {
134 surfaceLoad = this->getSurfaceLoading(soluteConcentration);
135 }
136
137 T reactionRate = this->k_s * (surfaceLoad * particleConcentration - particleLoading);
138 Vector<T, 2> reactionRates(reactionRate / _unitConverter.getConversionFactorDensity(), // solute
139 reactionRate / _unitConverter.getConversionFactorParticleDensity()); // loading
140 return reactionRates;
141 }
T getSurfaceLoading(T soluteConcentration)
Get surface loading without film diffusion.

References olb::AdsorptionReaction< T, DESCRIPTOR >::_unitConverter, olb::AdsorptionReaction< T, DESCRIPTOR >::externalMassTransferEnabled, olb::AdsorptionReaction< T, DESCRIPTOR >::getSurfaceLoading(), and olb::AdsorptionReaction< T, DESCRIPTOR >::k_s.

+ Here is the call graph for this function:

◆ getSurfaceLoading() [1/2]

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::getSurfaceLoading ( T soluteConcentration)
inline

Get surface loading without film diffusion.

Parameters
soluteConcentration
Returns
loading in g/m^3

Definition at line 84 of file adsorptionReaction.h.

84 {
85 if (soluteConcentration < 0) return 0; // prevent nan
86 T load = this->isotherm->getLoading(soluteConcentration);
87 if (load < 0) load = 0;
88 return load;
89 }

References olb::Isotherm< T >::getLoading().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSurfaceLoading() [2/2]

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::getSurfaceLoading ( T soluteConcentration,
T particleLoading,
T particleConcentration )
inline

Get surface loading with film diffusion.

Solves implicit boundary condition for surface concentration

Parameters
soluteConcentration
particleLoading
particleConcentration
Returns
T

Definition at line 101 of file adsorptionReaction.h.

101 {
102 if (soluteConcentration < 0) return 0; // prevent nan
103 // using D = double; // because fsolve is hardcoded in double type
104
105 // previous surface concentration as initial guess
106 T surfaceConcentration = soluteConcentration;
107 T args[] = {particleLoading, soluteConcentration, particleConcentration};
108 for(int i = 0; i<100; i++){
109 //ADf<T,1> y0_ad = iniAD(surfaceConcentration);
110 //ADf<T,1> y1_ad = filmDiffBoundary(y0_ad, args);
111 //surfaceConcentration -= filmDiffBoundary(surfaceConcentration, args) / y1_ad.d(0);
112
113 T dCs = surfaceConcentration/1E8;
114 surfaceConcentration -= 2.*dCs*filmDiffBoundary(surfaceConcentration, args)/(filmDiffBoundary(surfaceConcentration + dCs, args) - filmDiffBoundary(surfaceConcentration - dCs, args));
115 }
116 T load = isotherm->getLoading(surfaceConcentration);
117 if (load < 0) load = 0;
118 return load;
119 }
T filmDiffBoundary(T c_s_, T args[])
equations for surface concentration

References olb::AdsorptionReaction< T, DESCRIPTOR >::filmDiffBoundary(), and olb::AdsorptionReaction< T, DESCRIPTOR >::isotherm.

+ Here is the call graph for this function:

◆ print()

template<typename T , typename DESCRIPTOR >
void olb::AdsorptionReaction< T, DESCRIPTOR >::print ( std::ostream & clout)
inline

Definition at line 154 of file adsorptionReaction.h.

154 {
155 clout << "----------------- Reaction information -----------------" << std::endl;
156 clout << "-- Parameters:" << std::endl;
157 clout << "Particle diameter(m): d_p= " << this->r_p*2 * _unitConverter.getConversionFactorLength() << std::endl;
158 clout << "Film diffusion constant(m/s): k_f*= " << getPhysFilmTransferConstant() << std::endl;
159 clout << "Surface diffusion constant(m^2/s): D_s= " << getPhysSurfaceDiffusionConstant() << std::endl;
160 clout << "Initial solute concentration(mg/mL): c_0= " << this->c_0 * _unitConverter.getConversionFactorDensity() << std::endl;
161 clout << "Equilibrium surface loading(mg/g): q_0= " << this->q_0 * _unitConverter.getConversionFactorParticleDensity() << std::endl;
162 clout << "lattice Equilibrium surface loading: q_0= " << this->q_0 << std::endl;
163 clout << "Surface Mass transfer coefficient(m/s): k_s*= " << getPhysSurfaceTransferConstant() << std::endl;
164 clout << "-------------------------------------------------------------" << std::endl;
165 this->isotherm->print(clout);
166 }

References olb::AdsorptionReaction< T, DESCRIPTOR >::c_0, olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorDensity(), olb::UnitConverter< T, DESCRIPTOR >::getConversionFactorLength(), olb::AdsorptionConverter< T, DESCRIPTOR >::getConversionFactorParticleDensity(), olb::AdsorptionReaction< T, DESCRIPTOR >::getPhysFilmTransferConstant(), olb::AdsorptionReaction< T, DESCRIPTOR >::getPhysSurfaceDiffusionConstant(), olb::AdsorptionReaction< T, DESCRIPTOR >::getPhysSurfaceTransferConstant(), olb::Isotherm< T >::print(), olb::AdsorptionReaction< T, DESCRIPTOR >::q_0, and olb::AdsorptionReaction< T, DESCRIPTOR >::r_p.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write()

template<typename T , typename DESCRIPTOR >
void olb::AdsorptionReaction< T, DESCRIPTOR >::write ( std::string const & fileName)
inline

Definition at line 168 of file adsorptionReaction.h.

168 {
169 std::string dataFile = singleton::directories().getLogOutDir() + fileName + ".dat";
170
171 if (singleton::mpi().isMainProcessor()) {
172 std::ofstream fout(dataFile.c_str(), std::ios::app);
173 if (!fout) {
174 std::cout << "error write() function: can not open std::ofstream" << std::endl;
175 }
176 else {
177 this->print( fout );
178 fout.close();
179 }
180 }
181 }
void print(std::ostream &clout)
std::string getLogOutDir() const
Definition singleton.h:89
MpiManager & mpi()
Directories & directories()
Definition singleton.h:150

References olb::singleton::directories(), olb::singleton::Directories::getLogOutDir(), olb::singleton::mpi(), and olb::AdsorptionReaction< T, DESCRIPTOR >::print().

+ Here is the call graph for this function:

Member Data Documentation

◆ _unitConverter

template<typename T , typename DESCRIPTOR >
const AdsorptionConverter<T, DESCRIPTOR> olb::AdsorptionReaction< T, DESCRIPTOR >::_unitConverter
protected

Definition at line 51 of file adsorptionReaction.h.

◆ c_0

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::c_0 {}

Definition at line 57 of file adsorptionReaction.h.

57{}; // initial concentration (mg/L)

◆ D_s

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::D_s {}

Definition at line 56 of file adsorptionReaction.h.

56{}; // surface diffusion constant (m^2/s)

◆ externalMassTransferEnabled

template<typename T , typename DESCRIPTOR >
bool olb::AdsorptionReaction< T, DESCRIPTOR >::externalMassTransferEnabled = false
protected

Definition at line 50 of file adsorptionReaction.h.

◆ isotherm

template<typename T , typename DESCRIPTOR >
const Isotherm<T>* olb::AdsorptionReaction< T, DESCRIPTOR >::isotherm
protected

Definition at line 52 of file adsorptionReaction.h.

◆ k_f

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::k_f {}

Definition at line 55 of file adsorptionReaction.h.

55{}; // film diffusion mass transfer coefficient (m/s)

◆ k_s

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::k_s {}

Definition at line 60 of file adsorptionReaction.h.

60{}; // surface diffusion mass transfer coefficient (1/s)

◆ q_0

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::q_0 {}

Definition at line 59 of file adsorptionReaction.h.

59{}; // equilibrium surface loading (mg/g)

◆ r_p

template<typename T , typename DESCRIPTOR >
T olb::AdsorptionReaction< T, DESCRIPTOR >::r_p {}

Definition at line 58 of file adsorptionReaction.h.

58{}; // particle radius (m)

The documentation for this class was generated from the following file: