void calculate_densities(MatrixScalar &densities, const Scalar &tot_dens, const VectorScalar &molar_frac, const Scalar &zmin,const Scalar &zmax,const Scalar &zstep, const VectorScalar &T, const VectorScalar &mm) { unsigned int iz(0); Scalar Mm; Antioch::set_zero(Mm); for(unsigned int s = 0; s < molar_frac.size(); s++) { Mm += molar_frac[s] * mm[s]; } Mm *= 1e-3;//to kg densities.clear(); densities.resize(molar_frac.size()); for(Scalar z = zmin; z <= zmax; z += zstep) { for(unsigned int s = 0; s < molar_frac.size(); s++) { densities[s].push_back(molar_frac[s] * barometry(zmin,z,T[iz],Mm,tot_dens)); } iz++; } return; }
typename Antioch::value_type<VectorScalar>::type k_photo(const VectorScalar &solar_lambda, const VectorScalar &solar_irr, const VectorScalar &sigma_lambda, const VectorScalar &sigma_sigma) { Antioch::SigmaBinConverter<VectorScalar> bin; VectorScalar sigma_rescaled(solar_lambda.size()); bin.y_on_custom_grid(sigma_lambda,sigma_sigma,solar_lambda,sigma_rescaled); typename Antioch::value_type<VectorScalar>::type _k(0.L); for(unsigned int il = 0; il < solar_irr.size() - 1; il++) { _k += sigma_rescaled[il] * solar_irr[il] * (solar_lambda[il+1] - solar_lambda[il]); } return _k; }
void read_hv_flux(VectorScalar &lambda, VectorScalar &phy1AU, const std::string &file) { std::string line; std::ifstream flux_1AU(file); getline(flux_1AU,line); while(!flux_1AU.eof()) { Scalar wv,ir,dirr; flux_1AU >> wv >> ir >> dirr; if(!lambda.empty() && wv == lambda.back())continue; lambda.push_back(wv);//nm phy1AU.push_back(ir);//W/m2/nm } flux_1AU.close(); return; }
void make_custom(unsigned int choice, VectorScalar & x, VectorScalar & y) { // sum_{bin} Delta x * y switch(choice) { case(0): // 9 bin contained in ref -> [2.5;8.5] within [1;10] { x.resize(9); y.resize(9); x[0] = 2.50L; y[0] = 2.25L/0.75L; // 0.50 * 2 + 0.25 * 5 x[1] = 3.25L; y[1] = 3.75L/0.75L; // 0.75 * 5 x[2] = 4.00L; y[2] = 6.00L/0.75L; // 0.75 * 8 x[3] = 4.75L; y[3] = 5.00L/0.75L; // 0.25 * 8 + 0.5 * 6 x[4] = 5.50L; y[4] = 5.50L/0.75L; // 0.25 * 6 + 0.25 * 10 x[5] = 6.25L; y[5] = 7.50L/0.75L; // 0.75 * 10 x[6] = 7.00L; y[6] = 5.25L/0.75L; // 0.75 * 7 x[7] = 7.75L; y[7] = 3.75L/0.75L; // 0.25 * 7 + 0.5 * 4 x[8] = 8.50L; y[8] = 0.00L/0.75L; // 0. (right stairs) break; } case(1):// 9 bin outside ref -> [0;12] containing [1;10] { x.resize(9); y.resize(9); x[0] = 0.00L; y[0] = 0.50L/1.50L; // 0.5 * 1 x[1] = 1.50L; y[1] = 2.50L/1.50L; // 0.5 * 1 + 2.0 * 1 x[2] = 3.00L; y[2] = 9.00L/1.50L; // 1.0 * 5 + 0.5 * 8 x[3] = 4.50L; y[3] = 10.0L/1.50L; // 0.5 * 8 + 1.0 * 6 x[4] = 6.00L; y[4] = 13.5L/1.50L; // 1.0 * 10 + 0.5 * 7 x[5] = 7.50L; y[5] = 7.50L/1.50L; // 0.50 * 7 + 1.0 * 4 x[6] = 9.00L; y[6] = 2.00L/1.50L; // 1.0 * 2 x[7] = 10.5L; y[7] = 0.00L/1.50L; // 0 x[8] = 12.0L; y[8] = 0.00L/1.50L; // 0. (right stairs) break; } case(2): // 5 bins beyond only min -> [-1;3.8] in [0;10] { x.resize(5); y.resize(5); x[0] = -1.00L; y[0] = 0.00L/1.20L; // 0 x[1] = 0.20L; y[1] = 0.40L/1.20L; // 0.4 * 1 x[2] = 1.40L; y[2] = 1.80L/1.20L; // 0.6 * 1 + 0.6 * 2 x[3] = 2.60L; y[3] = 4.80L/1.20L; // 0.4 * 2 + 0.8 * 5 x[4] = 3.80L; y[4] = 00.0L/1.20L; // 0. (right stairs) break; } case(3):// 6 bins beyond only max -> [2;10.75] in [0;10] { x.resize(6); y.resize(6); x[0] = 2.00L; y[0] = 5.75L/1.75L; // 1.00 * 2 + 0.75 * 5 x[1] = 3.75L; y[1] = 12.25L/1.75L; // 0.25 * 5 + 1.00 * 8 + 0.50 * 6 x[2] = 5.50L; y[2] = 14.75L/1.75L; // 0.50 * 6 + 1.00 * 10 + 0.25 * 7 x[3] = 7.25L; y[3] = 9.25L/1.75L; // 0.75 * 7 + 1.00 * 4 x[4] = 9.00L; y[4] = 2.00L/1.75L; // 1.00 * 2 x[5] = 10.75L; y[5] = 00.00L/1.75L; // 0. (right stairs) break; } } }
void read_temperature(VectorScalar &T0, VectorScalar &Tz, const std::string &file) { T0.clear(); Tz.clear(); std::string line; std::ifstream temp(file); getline(temp,line); while(!temp.eof()) { Scalar t,tz,dt,dtz; temp >> t >> tz >> dt >> dtz; T0.push_back(t); Tz.push_back(tz); } temp.close(); return; }
void read_crossSection(VectorScalar & lambda, VectorScalar & sigma, const std::string &file, unsigned int nbr) { lambda.clear(); sigma.clear(); std::string line; std::ifstream sig_f(file); getline(sig_f,line); while(!sig_f.eof()) { Scalar wv,sigt,sigbr; sig_f >> wv >> sigt; for(unsigned int i = 0; i < nbr; i++)sig_f >> sigbr; lambda.push_back(wv/10.);//A -> nm sigma.push_back(sigt*10.);//cm-2/A -> m-2/nm } sig_f.close(); return; }
void make_reference(VectorScalar & x, VectorScalar & y) { x.resize(10,0); y.resize(10,0); for(unsigned int i = 0; i < 10; i++) { x[i] = ((typename Antioch::value_type<VectorScalar>::type)(i+1)); } y[0] = 1.L; y[1] = 2.L; y[2] = 5.L; y[3] = 8.L; y[4] = 6.L; y[5] = 10.L; y[6] = 7.L; y[7] = 4.L; y[8] = 2.L; y[9] = 0.3L; }
void linear_interpolation(const VectorScalar &temp0, const VectorScalar &alt0, const VectorScalar &alt1, VectorScalar &temp1) { unsigned int j(0); typename Antioch::value_type<VectorScalar>::type a; typename Antioch::value_type<VectorScalar>::type b; temp1.resize(alt1.size()); for(unsigned int iz = 0; iz < alt1.size(); iz++) { while(alt0[j] < alt1[iz]) { j++; if(!(j < alt0.size()))break; } if(j == 0) { Antioch::set_zero(a); b = temp0[j]; }else if(j < alt0.size() - 1) { a = (temp0[j] - temp0[j-1])/(alt0[j] - alt0[j-1]); b = temp0[j] - a * alt0[j]; }else { Antioch::set_zero(a); b = temp0.back(); } temp1[iz] = a * alt1[iz] + b; } }