diff --git a/.gitignore b/.gitignore index 64aa844c..1c8c4b5f 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,6 @@ Scripts/symbolic_hermitians/__pycache__ .cproject .project .pydevproject -.settings \ No newline at end of file +.settings +.vscode +Source/generated_files \ No newline at end of file diff --git a/Source/FlavoredNeutrinoContainerInit.cpp b/Source/FlavoredNeutrinoContainerInit.cpp index d93580e3..3014b623 100644 --- a/Source/FlavoredNeutrinoContainerInit.cpp +++ b/Source/FlavoredNeutrinoContainerInit.cpp @@ -36,6 +36,49 @@ Gpu::ManagedVector > uniform_sphere_xyz(int nphi_at_equator){ return xyz; } +// residual for the root finder +// Z needs to be bigger if residual is positive +// Minerbo (1978) (unfortunately under Elsevier paywall) +// Can also see Richers (2020) https://ui.adsabs.harvard.edu/abs/2020PhRvD.102h3017R +// Eq.41 (where a is Z), but in the non-degenerate limit +// k->0, eta->0, N->Z/(4pi sinh(Z)) (just to make it integrate to 1) +// minerbo_residual is the "f" equation between eq.42 and 43 +Real minerbo_residual(const Real fluxfac, const Real Z){ + return fluxfac - 1.0/std::tanh(Z) + 1.0 / Z; +} +Real minerbo_residual_derivative(const Real fluxfac, const Real Z){ + return 1.0/(std::sinh(Z)*std::sinh(Z)) - 1.0/(Z*Z); +} +Real minerbo_Z(const Real fluxfac){ + // hard-code in these parameters because they are not + // really very important... + Real maxresidual = 1e-6; + Real maxcount = 20; + Real minfluxfac = 1e-3; + + // set the initial conditions + Real Z = 1.0; + + // catch the small flux factor case to prevent nans + if(fluxfac < minfluxfac) + Z = 3.*fluxfac; + else{ + Real residual = 1.0; + int count = 0; + while(std::abs(residual)>maxresidual and countmaxresidual) + amrex::Error("Failed to converge on a solution."); + } + + amrex::Print() << "fluxfac="<