Skip to content

Commit

Permalink
Merge pull request #42 from temken/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
temken authored Jan 5, 2023
2 parents 3b37c1b + b961b49 commit 658c42a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/obscura/Target_Atom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ struct Atomic_Electron
double binding_energy;
unsigned int number_of_secondary_electrons;

bool have_warned = false;

Atomic_Electron(std::string element, int N, int L, double Ebinding, double kMin, double kMax, double qMin, double qMax, unsigned int neSecondary = 0);

double Atomic_Response_Function(int response, double q, double E);
Expand Down
21 changes: 18 additions & 3 deletions src/Target_Atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,18 @@ Atomic_Electron::Atomic_Electron(std::string element, int N, int L, double Ebind
double Atomic_Electron::Atomic_Response_Function(int response, double q, double E)
{
double k = sqrt(2.0 * mElectron * E);
if(q > q_max || k > k_max || k < k_min)
if(q > q_max || k > 1.000001 * k_max || k < 0.999999 * k_min)
{
std::cerr << "Warning in Atomic_Response_Function() : q = " << q / keV << " keV or k = " << k / keV << "keV out of range for " << name << ". Returning 0." << std::endl;
if(!have_warned)
{
std::cerr << "Warning in Atomic_Response_Function(): Arguments of response " << response << " of " << name << " are out of bound." << std::endl;
if(q > q_max)
std::cerr << "\tq = " << q / keV << " keV\ttabulated q domain: [" << q_min / keV << ", " << q_max / keV << "] keV" << std::endl;
if(k > k_max || k < k_min)
std::cerr << "\tk = " << k / keV << " keV\ttabulated k domain: [" << k_min / keV << ", " << k_max / keV << "] keV" << std::endl;
std::cerr << "\tReturning 0. (This warning will not be repeated for " << name << ".)" << std::endl;
have_warned = true;
}
return 0.0;
}
else if(response == 1)
Expand All @@ -65,7 +74,13 @@ double Atomic_Electron::Atomic_Response_Function(int response, double q, double
return atomic_response_interpolations[response - 1](k, q);
else
{
std::cerr << "Warning in Atomic_Response_Function " << response << ": q = " << q / keV << " is below q_min. Returning 0." << std::endl;
if(!have_warned)
{
std::cerr << "Warning in Atomic_Response_Function(): Arguments of response " << response << " of " << name << " are out of bound." << std::endl
<< "\tq = " << q / keV << " keV\ttabulated q domain: [" << q_min / keV << ", " << q_max / keV << "] keV" << std::endl
<< "\tReturning 0. (This warning will not be repeated for " << name << ".)" << std::endl;
have_warned = true;
}
return 0.0;
}
}
Expand Down

0 comments on commit 658c42a

Please sign in to comment.