/* Macro-XS*/ MacroXs::MacroXs(const MacroXsObject* definition, int number_groups) : Material(definition), ngroups(number_groups), mfp(number_groups) { /* Get constants */ map<string,vector<double> > constant = definition->getConstant(); /* Get the number of groups and do some error checking */ map<string,vector<double> >::const_iterator it_xs = constant.begin(); int ngroup = number_groups; for(; it_xs != constant.end() ; ++it_xs) { string xs_name = (*it_xs).first; if(xs_name == "sigma_s") { int size = (*it_xs).second.size(); if(size != ngroup * ngroup) { throw Material::BadMaterialCreation(getUserId(), "Inconsistent number of groups in constant *" + xs_name + "*"); } } else { int size = (*it_xs).second.size(); if(size != ngroup) { throw Material::BadMaterialCreation(getUserId(), "Inconsistent number of groups in constant *" + xs_name + "*"); } } } /* ---- Capture reaction */ vector<double> sigma_a = constant["sigma_a"]; /* ---- Scattering cross section */ vector<double> sigma_s(ngroups); vector<double> scattering_matrix = constant["sigma_s"]; for(size_t i = 0 ; i < ngroups ; ++i) { double total_scat = 0; for(size_t j = 0 ; j < ngroups ; ++j) total_scat += scattering_matrix[i*ngroups + j]; sigma_s[i] = total_scat; } /* ---- Calculate mean free path */ vector<double> sigma_t(ngroups); for(size_t i = 0 ; i < ngroups ; ++i) { mfp[i] = 1.0 / (sigma_a[i] + sigma_s[i]); sigma_t[i] = sigma_a[i] + sigma_s[i]; } /* Get NU-sigma fission cross section */ nu_sigma_fission = constant["nu_sigma_f"]; /* ---- Create the isotope */ isotope = new MacroXsIsotope(getUserId(), constant, sigma_t); /* Set fissile flag */ fissile = isotope->isFissile(); }
Spectrum DensityRegion::tau(const Ray &r, float stepSize, float u) const { float t0, t1; float length = r.d.Length(); if (length == 0.f) return 0.f; Ray rn(r.o, r.d / length, r.mint * length, r.maxt * length, r.time); if (!IntersectP(rn, &t0, &t1)) return 0.; Spectrum tau(0.); t0 += u * stepSize; while (t0 < t1) { tau += sigma_t(rn(t0), -rn.d, r.time); t0 += stepSize; } return tau * stepSize; }
real Medium::absorption(const glm::vec3 & point) const { return sigma_s(point) / sigma_t(point); }