@@ -20,7 +20,10 @@ namespace Cantera
20
20
21
21
Flow1D::Flow1D (ThermoPhase* ph, size_t nsp, size_t points) :
22
22
Domain1D (nsp+c_offset_Y, points),
23
- m_nsp (nsp)
23
+ m_nsp (nsp),
24
+ m_radiation (make_unique<Radiation1D>(ph, ph->pressure (), points,
25
+ [this](const double * x, size_t j) {return this ->T (x,j);},
26
+ [this ](const double * x, size_t k, size_t j) {return this ->X (x,k,j);}))
24
27
{
25
28
m_points = points;
26
29
@@ -82,70 +85,6 @@ Flow1D::Flow1D(ThermoPhase* ph, size_t nsp, size_t points) :
82
85
gr.push_back (1.0 *ng/m_points);
83
86
}
84
87
setupGrid (m_points, gr.data ());
85
-
86
- // Parse radiation data from the YAML file
87
- for (auto & name : m_thermo->speciesNames ()) {
88
- auto & data = m_thermo->species (name)->input ;
89
- if (data.hasKey (" radiation" )) {
90
- cout << " Radiation data found for species " << name << endl;
91
- m_absorptionSpecies.insert ({name, m_thermo->speciesIndex (name)});
92
- if (data[" radiation" ].hasKey (" fit-type" )) {
93
- m_PMAC[name][" fit-type" ] = data[" radiation" ][" fit-type" ].asString ();
94
- } else {
95
- throw InputFileError (" Flow1D::Flow1D" , data,
96
- " No 'fit-type' entry found for species '{}'" , name);
97
- }
98
-
99
- // This is the direct tabulation of the optical path length
100
- if (data[" radiation" ][" fit-type" ] == " table" ) {
101
- if (data[" radiation" ].hasKey (" temperatures" )) {
102
- cout << " Storing temperatures for species " << name << endl;
103
- // Each species may have a specific set of temperatures that are used
104
- m_PMAC[name][" temperatures" ] = data[" radiation" ][" temperatures" ].asVector <double >();
105
- } else {
106
- throw InputFileError (" Flow1D::Flow1D" , data,
107
- " No 'temperatures' entry found for species '{}'" , name);
108
- }
109
- if (data[" radiation" ].hasKey (" data" )) {
110
- cout << " Storing data for species " << name << endl;
111
- // This data is the Plank mean absorption coefficient
112
- m_PMAC[name][" coefficients" ] = data[" radiation" ][" data" ].asVector <double >();
113
- } else {
114
- throw InputFileError (" Flow1D::Flow1D" , data,
115
- " No 'data' entry found for species '{}'" , name);
116
- }
117
- } else if (data[" radiation" ][" fit-type" ] == " polynomial" ) {
118
- cout << " Polynomial fit found for species " << name << endl;
119
- if (data[" radiation" ].hasKey (" data" )) {
120
- cout << " Storing data for species " << name << endl;
121
- m_PMAC[name][" coefficients" ] = data[" radiation" ][" data" ].asVector <double >();
122
- } else {
123
- throw InputFileError (" Flow1D::Flow1D" , data,
124
- " No 'data' entry found for species '{}'" , name);
125
- }
126
- } else {
127
- throw InputFileError (" Flow1D::Flow1D" , data,
128
- " Invalid 'fit-type' entry found for species '{}'" , name);
129
- }
130
- }
131
- }
132
-
133
- // Polynomial coefficients for CO2 and H2O (backwards compatibility)
134
- // Check if "CO2" is already in the map, if not, add the polynomial fit data
135
- if (!m_PMAC.hasKey (" CO2" )) {
136
- const std::vector<double > c_CO2 = {18.741 , -121.310 , 273.500 , -194.050 , 56.310 ,
137
- -5.8169 };
138
- m_PMAC[" CO2" ][" fit-type" ] = " polynomial" ;
139
- m_PMAC[" CO2" ][" coefficients" ] = c_CO2;
140
- }
141
-
142
- // Check if "H2O" is already in the map, if not, add the polynomial fit data
143
- if (!m_PMAC.hasKey (" H2O" )) {
144
- const std::vector<double > c_H2O = {-0.23093 , -1.12390 , 9.41530 , -2.99880 ,
145
- 0.51382 , -1.86840e-5 };
146
- m_PMAC[" H2O" ][" fit-type" ] = " polynomial" ;
147
- m_PMAC[" H2O" ][" coefficients" ] = c_H2O;
148
- }
149
88
}
150
89
151
90
Flow1D::Flow1D (shared_ptr<ThermoPhase> th, size_t nsp, size_t points)
@@ -527,70 +466,7 @@ void Flow1D::updateDiffFluxes(const double* x, size_t j0, size_t j1)
527
466
528
467
void Flow1D::computeRadiation (double * x, size_t jmin, size_t jmax)
529
468
{
530
- // Variable definitions for the Planck absorption coefficient and the
531
- // radiation calculation:
532
- double k_P_ref = 1.0 *OneAtm;
533
-
534
- // Calculation of the two boundary values
535
- double boundary_Rad_left = m_epsilon_left * StefanBoltz * pow (T (x, 0 ), 4 );
536
- double boundary_Rad_right = m_epsilon_right * StefanBoltz * pow (T (x, m_points - 1 ), 4 );
537
-
538
- double coef = 0.0 ;
539
- for (size_t j = jmin; j < jmax; j++) {
540
- // calculation of the mean Planck absorption coefficient
541
- double k_P = 0 ;
542
-
543
- for (const auto & [sp_name, sp_idx] : m_absorptionSpecies) {
544
- if (m_PMAC[sp_name][" fit-type" ].asString () == " table" ) {
545
- // temperature table interval search
546
- int T_index = 0 ;
547
- const int OPL_table_size = m_PMAC[sp_name][" temperatures" ].asVector <double >().size ();
548
- for (int k = 0 ; k < OPL_table_size; k++) {
549
- if (T (x, j) < m_PMAC[sp_name][" temperatures" ].asVector <double >()[k]) {
550
- if (T (x, j) < m_PMAC[sp_name][" temperatures" ].asVector <double >()[0 ]) {
551
- T_index = 0 ; // lower table limit
552
- }
553
- else {
554
- T_index = k;
555
- }
556
- break ;
557
- }
558
- else {
559
- T_index=OPL_table_size-1 ; // upper table limit
560
- }
561
- }
562
-
563
- // absorption coefficient for specie
564
- double k_P_specie = 0.0 ;
565
- if ((T_index == 0 ) || (T_index == OPL_table_size-1 )) {
566
- coef=log (1.0 /m_PMAC[sp_name][" coefficients" ].asVector <double >()[T_index]);
567
- }
568
- else {
569
- coef=log (1.0 /m_PMAC[sp_name][" coefficients" ].asVector <double >()[T_index-1 ])+
570
- (log (1.0 /m_PMAC[sp_name][" coefficients" ].asVector <double >()[T_index])-log (1.0 /m_PMAC[sp_name][" coefficients" ].asVector <double >()[T_index-1 ]))*
571
- (T (x, j)-m_PMAC[sp_name][" temperatures" ].asVector <double >()[T_index-1 ])/(m_PMAC[sp_name][" temperatures" ].asVector <double >()[T_index]-m_PMAC[sp_name][" temperatures" ].asVector <double >()[T_index-1 ]);
572
- }
573
- k_P_specie = exp (coef);
574
-
575
- k_P_specie /= k_P_ref;
576
- k_P += m_press * X (x, m_absorptionSpecies[sp_name], j) * k_P_specie;
577
- } else if (m_PMAC[sp_name][" fit-type" ].asString () == " polynomial" ) {
578
- double k_P_specie = 0.0 ;
579
- for (size_t n = 0 ; n <= 5 ; n++) {
580
- k_P_specie += m_PMAC[sp_name][" coefficients" ].asVector <double >()[n] * pow (1000 / T (x, j), (double ) n);
581
- }
582
- k_P_specie /= k_P_ref;
583
- k_P += m_press * X (x, m_absorptionSpecies[sp_name], j) * k_P_specie;
584
- }
585
- }
586
-
587
- // Calculation of the radiative heat loss term
588
- double radiative_heat_loss = 2 * k_P *(2 * StefanBoltz * pow (T (x, j), 4 )
589
- - boundary_Rad_left - boundary_Rad_right);
590
-
591
- // set the radiative heat loss vector
592
- m_qdotRadiation[j] = radiative_heat_loss;
593
- }
469
+ m_radiation->computeRadiation (x, jmin, jmax, m_qdotRadiation);
594
470
}
595
471
596
472
void Flow1D::evalContinuity (double * x, double * rsd, int * diag,
@@ -1182,16 +1058,7 @@ bool Flow1D::doElectricField(size_t j) const
1182
1058
1183
1059
void Flow1D::setBoundaryEmissivities (double e_left, double e_right)
1184
1060
{
1185
- if (e_left < 0 || e_left > 1 ) {
1186
- throw CanteraError (" Flow1D::setBoundaryEmissivities" ,
1187
- " The left boundary emissivity must be between 0.0 and 1.0!" );
1188
- } else if (e_right < 0 || e_right > 1 ) {
1189
- throw CanteraError (" Flow1D::setBoundaryEmissivities" ,
1190
- " The right boundary emissivity must be between 0.0 and 1.0!" );
1191
- } else {
1192
- m_epsilon_left = e_left;
1193
- m_epsilon_right = e_right;
1194
- }
1061
+ m_radiation->setBoundaryEmissivities (e_left, e_right);
1195
1062
}
1196
1063
1197
1064
void Flow1D::fixTemperature (size_t j)
0 commit comments