Skip to content
Permalink
Browse files

refs #6667 Modified getNeutronAtom without exceptions to be really

without exceptions

As it is impossible to start Mantid in Debug mode as it throws thousand exceptions which are then catched, analyzed, reported and one has to wait for 1 min to start trivial program
  • Loading branch information
abuts committed Jul 5, 2013
1 parent 0033c8c commit 0df38d27c4d410c0320cb96774a08ca3818b16d0
@@ -106,6 +106,7 @@ namespace Mantid

MANTID_KERNEL_DLL std::ostream& operator<<(std::ostream& out, const NeutronAtom &atom);
MANTID_KERNEL_DLL NeutronAtom getNeutronAtom(const uint16_t z_number, const uint16_t a_number = 0);
MANTID_KERNEL_DLL const NeutronAtom getNeutronNoExceptions(const uint16_t z_number, const uint16_t a_number);

} //Namespace PhysicalConstants
} //Namespace Mantid
@@ -14,27 +14,14 @@ namespace PhysicalConstants

using std::string;

/// Get the corresponding neutronic atom
const NeutronAtom getNeutronNoExceptions(const uint16_t z, const uint16_t a)
{
try
{
return getNeutronAtom(z, a);
}
catch (std::runtime_error & )
{
return NeutronAtom(z, a,
NAN, NAN, NAN, NAN,
NAN, NAN, NAN, NAN); // set to junk value
}
}


Atom::Atom(const std::string& symbol, const uint16_t z, const uint16_t a,
const double abundance, const double mass, const double density) :
symbol(symbol), z_number(z), a_number(a), abundance(abundance),
mass(mass), mass_density(density),
number_density(density * N_A * 1.e-24/ mass), // Convert from cm^-3 to Angstroms^-3
neutron(getNeutronNoExceptions(z, a))
neutron(getNeutronNoExceptions(z, a)) /// Get the corresponding neutronic atom
{
}

@@ -693,6 +693,21 @@ NeutronAtom getNeutronAtom(const uint16_t z_number, const uint16_t a_number)

return *result;
}
const NeutronAtom getNeutronNoExceptions(const uint16_t z_number, const uint16_t a_number)
{

NeutronAtom temp(z_number, a_number,
NAN, NAN, NAN, NAN, NAN, NAN); // set to junk value

NeutronAtom *result = std::lower_bound(&(ATOMS[0]), &(ATOMS[NUM_ATOMS]), temp, compareAtoms);
if (result == &(ATOMS[NUM_ATOMS]) || result->z_number != z_number
|| result->a_number != a_number)
{
return temp;
}
else
return *result;
}

} // namespace PhysicalConstants
} // namespace Mantid

0 comments on commit 0df38d2

Please sign in to comment.
You can’t perform that action at this time.