diff --git a/image_analysis/structure_refinement/ModelScaleGPU.cu b/image_analysis/structure_refinement/ModelScaleGPU.cu index de11ff941..35ebf187f 100644 --- a/image_analysis/structure_refinement/ModelScaleGPU.cu +++ b/image_analysis/structure_refinement/ModelScaleGPU.cu @@ -373,6 +373,14 @@ struct ModelScaleGPU::LevMarRun { done = true; return; } + // As LevMarFit (ModelScaling.cpp): a fit that has walked to where k_overall exp(-B s^2) |F| underflows at + // every reflection has no step left - the squares in alpha are all 0 while beta keeps a residue, and the + // solve throws on that. It ends here, at its best so far. J^T J is summed in float, so its squares + // underflow once |F| k_aniso is below about 1e-22 everywhere, still far from any scale a fit can end at. + if (alpha[0] == 0) { + done = true; + return; + } const size_t na = beta.size(); std::vector temp_alpha = alpha; for (size_t j = 0; j < na; j++)