/** * Calculates the integrated weights/energies for setup 3 * @author Tobias Weber * @date jun-20 * @license GPLv2 (see 'LICENSE' file) */ #include "core/heli.h" #include "core/skx.h" #include "tlibs2/libs/phys.h" #include #include namespace hist = boost::histogram; using t_real = double; using t_cplx = std::complex; using t_vec = ublas::vector; const auto g_j = t_cplx(0,1); #include "core/skx_default_gs.cxx" const t_real g_T = 28.5; const t_real g_eps = 1e-5; #define E_BINS 200 #define NUM_ANGLES 512 #define COL_SIZE 15 void calc_disp( t_real Gx, t_real Gy, t_real Gz, t_real Bx, t_real By, t_real Bz, t_real Px, t_real Py, t_real Pz, t_real q, int iProj=1) { Skx skx; Heli heli; std::vector> fourier_skx; fourier_skx.reserve(_skxgs_allcomps.size()/3); for(std::size_t comp=0; comp<_skxgs_allcomps.size(); comp+=3) fourier_skx.push_back(tl2::make_vec>({_skxgs_allcomps[comp], _skxgs_allcomps[comp+1], _skxgs_allcomps[comp+2]})); skx.SetFourier(fourier_skx); skx.SetProjNeutron(iProj!=0); heli.SetProjNeutron(iProj!=0); skx.SetT(-1000.); heli.SetT(g_T); skx.SetB(25.); heli.SetB(0.17); skx.GenFullFourier(); skx.SetFilterZeroWeight(1); heli.SetFilterZeroWeight(1); skx.SetWeightEps(1e-6); heli.SetWeightEps(1e-6); skx.SetCoords(Bx,By,Bz, Px,Py,Pz); heli.SetCoords(Bx,By,Bz); skx.SetG(Gx, Gy, Gz); heli.SetG(Gx, Gy, Gz); t_real Erange = 0.1; t_real angle_offs = 90/180.*M_PI; t_real angle_begin = -135/180.*M_PI + angle_offs; t_real angle_end = 135/180.*M_PI + angle_offs; t_real angle_delta = 2*M_PI/t_real(NUM_ANGLES); auto histWeightsNSF = hist::make_histogram(hist::axis::regular(E_BINS, -Erange, Erange, "E")); auto histWeightsSF = hist::make_histogram(hist::axis::regular(E_BINS, -Erange, Erange, "E")); auto histWeightsHeliNSF = hist::make_histogram(hist::axis::regular(E_BINS, -Erange, Erange, "E")); auto histWeightsHeliSF = hist::make_histogram(hist::axis::regular(E_BINS, -Erange, Erange, "E")); std::ofstream ofstr_raw("weightsum_skx.dat"); std::ofstream ofstr_raw_heli("weightsum_heli.dat"); // write file header for(std::ostream* ostr : {&ofstr_raw, &ofstr_raw_heli}) { ostr->precision(8); (*ostr) << std::left << std::setw(COL_SIZE) << "# angle" << " " << std::left << std::setw(COL_SIZE) << "qh" << " " << std::left << std::setw(COL_SIZE) << "qk" << " " << std::left << std::setw(COL_SIZE) << "ql" << " " << std::left << std::setw(COL_SIZE) << "E" << " " << std::left << std::setw(COL_SIZE) << "wSF1" << " " << std::left << std::setw(COL_SIZE) << "wSF2" << " " << std::left << std::setw(COL_SIZE) << "wNSF" << "\n"; } for(t_real angle=angle_begin; anglebin().lower() + 0.5*(iterNSF->bin().upper() - iterNSF->bin().lower()); t_real w_nsf = **iterNSF / t_real{E_BINS}; t_real E_h = iterHeliSF->bin().lower() + 0.5*(iterHeliSF->bin().upper() - iterHeliSF->bin().lower()); t_real w_h = **iterHeliSF / t_real{E_BINS}; t_real E_h_nsf = iterHeliNSF->bin().lower() + 0.5*(iterHeliNSF->bin().upper() - iterHeliNSF->bin().lower()); t_real w_h_nsf = **iterHeliNSF / t_real{E_BINS}; if(!tl2::float_equal(E, E_h, g_eps) || !tl2::float_equal(E, E_h_nsf, g_eps) || !tl2::float_equal(E, E_nsf, g_eps)) { std::cerr << "Energy binning mismatch: " << E << " != " << E_h << std::endl; break; } t_real bose = tl2::bose(E, g_T); ofstrBinned << std::left << std::setw(COL_SIZE) << E << " " << std::left << std::setw(COL_SIZE) << bose << " " << std::left << std::setw(COL_SIZE) << w << " " << std::left << std::setw(COL_SIZE) << w_nsf << " " << std::left << std::setw(COL_SIZE) << (w + w_nsf) << " " << std::left << std::setw(COL_SIZE) << (w + w_nsf)*bose << " " << std::left << std::setw(COL_SIZE) << w_h << " " << std::left << std::setw(COL_SIZE) << w_h_nsf << " " << std::left << std::setw(COL_SIZE) << (w_h + w_h_nsf) << " " << std::left << std::setw(COL_SIZE) << (w_h + w_h_nsf)*bose << std::endl; ++iterHeliSF; ++iterHeliNSF; ++iterNSF; } } int main() { // equivalent to the used setup around (000) t_real Gx = 1., Gy = 1., Gz = 0.; t_real Bx = 0., By = 0., Bz = 1.; t_real q = 0.0123; int proj = 1; calc_disp(Gx,Gy,Gz, Bx,By,Bz, 1,0,0, q, proj); return 0; }