1+ #include " model/ColumnModel1D.hpp"
2+ #ifdef ENABLE_2D_MODELS
3+ #include " model/ColumnModel2D.hpp"
4+ #include " model/GeneralRateModel2D.hpp"
5+ #endif
6+ #include " model/GeneralRateModel.hpp"
7+ #include " model/LumpedRateModelWithoutPores.hpp"
8+ #include " model/LumpedRateModelWithoutPoresDG.hpp"
9+ #include " model/LumpedRateModelWithPores.hpp"
10+ #include " CompileTimeConfig.hpp"
11+ #include " LoggingUtils.hpp"
12+ #include " Logging.hpp"
13+
14+
15+ namespace cadet
16+ {
17+ namespace model
18+ {
19+
20+ IUnitOperation* selectAxialFlowColumnUnitOperation (UnitOpIdx uoId, IParameterProvider& paramProvider)
21+ {
22+ IUnitOperation* model = nullptr ;
23+
24+ std::string uoType = paramProvider.getString (" UNIT_TYPE" );
25+
26+ if (uoType == " COLUMN_MODEL_1D" )
27+ {
28+ if (paramProvider.exists (" particle_type_000" ))
29+ {
30+ paramProvider.pushScope (" discretization" );
31+ const std::string discName = paramProvider.getString (" SPATIAL_METHOD" );
32+ paramProvider.popScope ();
33+
34+ paramProvider.pushScope (" particle_type_000" );
35+
36+ if (paramProvider.getString (" PARTICLE_TYPE" ) == " EQUILIBRIUM_PARTICLE" )
37+ {
38+ if (discName == " DG" )
39+ model = new LumpedRateModelWithoutPoresDG (uoId);
40+ else if (discName == " FV" )
41+ model = createAxialFVLRM (uoId);
42+ else
43+ LOG (Error) << " Unknown bulk discretization type " << discName << " for unit " << uoId;
44+ }
45+ else if (discName == " FV" )
46+ {
47+ if (paramProvider.getString (" PARTICLE_TYPE" ) == " HOMOGENEOUS_PARTICLE" )
48+ model = createAxialFVLRMP (uoId);
49+ else if (paramProvider.getString (" PARTICLE_TYPE" ) == " GENERAL_RATE_PARTICLE" )
50+ model = createAxialFVGRM (uoId);
51+ }
52+ else
53+ model = new ColumnModel1D (uoId);
54+
55+ paramProvider.popScope ();
56+ }
57+ else
58+ model = new ColumnModel1D (uoId);
59+ }
60+ #ifdef ENABLE_2D_MODELS
61+ else if (uoType.find (" _2D" ) != std::string::npos)
62+ {
63+ paramProvider.pushScope (" discretization" );
64+ const std::string discName = paramProvider.getString (" SPATIAL_METHOD" );
65+ paramProvider.popScope ();
66+
67+ if (discName == " DG" )
68+ model = new ColumnModel2D (uoId);
69+ else if (discName == " FV" )
70+ {
71+ if (uoType != " GENERAL_RATE_MODEL_2D" )
72+ LOG (Error) << uoType + " has no FV implementation for the bulk phase, but was specified as such for unit " << uoId;
73+ else
74+ model = new GeneralRateModel2D (uoId);
75+ }
76+ else
77+ LOG (Error) << " Unknown bulk discretization type " << discName << " for unit " << uoId;
78+ }
79+ #endif
80+ else
81+ {
82+ paramProvider.pushScope (" discretization" );
83+ const std::string discName = paramProvider.getString (" SPATIAL_METHOD" );
84+ paramProvider.popScope ();
85+
86+ if (discName == " DG" )
87+ {
88+ if (uoType == " LUMPED_RATE_MODEL_WITHOUT_PORES" )
89+ model = new LumpedRateModelWithoutPoresDG (uoId);
90+ else if (uoType == " LUMPED_RATE_MODEL_WITH_PORES" || uoType == " GENERAL_RATE_MODEL" )
91+ model = new ColumnModel1D (uoId);
92+ }
93+ else if (discName == " FV" )
94+ {
95+ if (uoType == " LUMPED_RATE_MODEL_WITHOUT_PORES" )
96+ model = createAxialFVLRM (uoId);
97+ else if (uoType == " LUMPED_RATE_MODEL_WITH_PORES" )
98+ model = createAxialFVLRMP (uoId);
99+ else if (uoType == " GENERAL_RATE_MODEL" )
100+ model = createAxialFVGRM (uoId);
101+ }
102+ else
103+ LOG (Error) << " Unknown bulk discretization type " << discName << " for unit " << uoId;
104+ }
105+
106+ return model;
107+ }
108+
109+ IUnitOperation* selectRadialFlowColumnUnitOperation (UnitOpIdx uoId, IParameterProvider& paramProvider)
110+ {
111+ IUnitOperation* model = nullptr ;
112+
113+ std::string uoType = paramProvider.getString (" UNIT_TYPE" );
114+
115+ if (uoType == " COLUMN_MODEL_1D" )
116+ {
117+ if (paramProvider.exists (" particle_type_000" ))
118+ {
119+ paramProvider.pushScope (" discretization" );
120+ const std::string discName = paramProvider.getString (" SPATIAL_METHOD" );
121+ paramProvider.popScope ();
122+
123+ if (discName == " DG" )
124+ LOG (Error) << " Radial flow not implemented for DG discretization yet, was called for unit " << uoId;
125+ else if (discName != " FV" )
126+ LOG (Error) << " Unknown bulk discretization type " << discName << " for unit " << uoId;
127+
128+ paramProvider.pushScope (" particle_type_000" );
129+
130+ if (paramProvider.getString (" PARTICLE_TYPE" ) == " EQUILIBRIUM_PARTICLE" )
131+ model = createRadialFVLRM (uoId);
132+ if (paramProvider.getString (" PARTICLE_TYPE" ) == " HOMOGENEOUS_PARTICLE" )
133+ model = createRadialFVLRMP (uoId);
134+ else if (paramProvider.getString (" PARTICLE_TYPE" ) == " GENERAL_RATE_PARTICLE" )
135+ model = createRadialFVGRM (uoId);
136+
137+ paramProvider.popScope ();
138+ }
139+ else
140+ model = createRadialFVLRM (uoId); // LRM used for npartype = 0
141+ }
142+ else
143+ {
144+ paramProvider.pushScope (" discretization" );
145+ const std::string discName = paramProvider.getString (" SPATIAL_METHOD" );
146+
147+ if (discName == " DG" )
148+ LOG (Error) << " Radial flow not implemented for DG discretization yet, was called for unit " << uoId;
149+ else if (discName == " FV" )
150+ {
151+ if (uoType == " RADIAL_LUMPED_RATE_MODEL_WITHOUT_PORES" )
152+ model = createRadialFVLRM (uoId);
153+ else if (uoType == " RADIAL_LUMPED_RATE_MODEL_WITH_PORES" )
154+ model = createRadialFVLRMP (uoId);
155+ else if (uoType == " RADIAL_GENERAL_RATE_MODEL" )
156+ model = createRadialFVGRM (uoId);
157+ }
158+ else
159+ LOG (Error) << " Unknown bulk discretization type " << discName << " for unit " << uoId;
160+
161+ paramProvider.popScope ();
162+ }
163+
164+ return model;
165+ }
166+
167+ void registerColumnModel (std::unordered_map<std::string, std::function<IUnitOperation* (UnitOpIdx, IParameterProvider&)>>& models)
168+ {
169+ models[ColumnModel1D::identifier ()] = selectAxialFlowColumnUnitOperation;
170+ models[" COLUMN_MODEL_1D" ] = selectAxialFlowColumnUnitOperation;
171+
172+ models[ColumnModel2D::identifier ()] = selectAxialFlowColumnUnitOperation;
173+ models[" COLUMN_MODEL_2D" ] = selectAxialFlowColumnUnitOperation;
174+
175+ models[LumpedRateModelWithoutPoresDG::identifier ()] = selectAxialFlowColumnUnitOperation;
176+ models[" LRM_DG" ] = selectAxialFlowColumnUnitOperation;
177+
178+ typedef GeneralRateModel<parts::AxialConvectionDispersionOperator> AxialGRM;
179+ typedef GeneralRateModel<parts::RadialConvectionDispersionOperator> RadialGRM;
180+
181+ models[AxialGRM::identifier ()] = selectAxialFlowColumnUnitOperation;
182+ models[" GRM" ] = selectAxialFlowColumnUnitOperation;
183+
184+ models[RadialGRM::identifier ()] = selectRadialFlowColumnUnitOperation;
185+ models[" RGRM" ] = selectRadialFlowColumnUnitOperation;
186+
187+ models[GeneralRateModel2D::identifier ()] = selectAxialFlowColumnUnitOperation;
188+ models[" GRM2D" ] = selectAxialFlowColumnUnitOperation;
189+
190+ typedef LumpedRateModelWithPores<parts::AxialConvectionDispersionOperator> AxialLRMP;
191+ typedef LumpedRateModelWithPores<parts::RadialConvectionDispersionOperator> RadialLRMP;
192+
193+ models[AxialLRMP::identifier ()] = selectAxialFlowColumnUnitOperation;
194+ models[" LRMP" ] = selectAxialFlowColumnUnitOperation;
195+
196+ models[RadialLRMP::identifier ()] = selectRadialFlowColumnUnitOperation;
197+ models[" RLRMP" ] = selectRadialFlowColumnUnitOperation;
198+
199+ typedef LumpedRateModelWithoutPores<parts::AxialConvectionDispersionOperatorBase> AxialLRM;
200+ typedef LumpedRateModelWithoutPores<parts::RadialConvectionDispersionOperatorBase> RadialLRM;
201+
202+ models[AxialLRM::identifier ()] = selectAxialFlowColumnUnitOperation;
203+ models[" LRM" ] = selectAxialFlowColumnUnitOperation;
204+ models[" DPFR" ] = selectAxialFlowColumnUnitOperation;
205+
206+ models[RadialLRM::identifier ()] = selectRadialFlowColumnUnitOperation;
207+ models[" RLRM" ] = selectRadialFlowColumnUnitOperation;
208+ }
209+
210+ } // namespace model
211+
212+ } // namespace cadet
0 commit comments