Skip to content
Snippets Groups Projects
Atom.cpp 232 KiB
Newer Older
    Sn128, Sn129, Sn130, Sn131, Sn132, Sn133, Sn134, Sn135, Sn136, Sn137, Sn100,
    Sn101, Sn102, Sn103, Sn104, Sn105, Sn106, Sn107, Sn108, Sn109, Sn110, Sn111,
    Sn112, Sn113, Sn114, Sn115, Sn116, Sn117, Sn118, Sn119, Sn120, Sn121, Sn122,
    Sn123, Sn124, Sn125, Sn126, Sn127, Sb,    Sb128, Sb129, Sb130, Sb131, Sb132,
    Sb133, Sb134, Sb135, Sb136, Sb137, Sb138, Sb139, Sb103, Sb104, Sb105, Sb106,
    Sb107, Sb108, Sb109, Sb110, Sb111, Sb112, Sb113, Sb114, Sb115, Sb116, Sb117,
    Sb118, Sb119, Sb120, Sb121, Sb122, Sb123, Sb124, Sb125, Sb126, Sb127, Te,
    Te128, Te129, Te130, Te131, Te132, Te133, Te134, Te135, Te136, Te137, Te138,
    Te139, Te140, Te141, Te142, Te106, Te107, Te108, Te109, Te110, Te111, Te112,
    Te113, Te114, Te115, Te116, Te117, Te118, Te119, Te120, Te121, Te122, Te123,
    Te124, Te125, Te126, Te127, I,     I128,  I129,  I130,  I131,  I132,  I133,
    I134,  I135,  I136,  I137,  I138,  I139,  I140,  I141,  I142,  I143,  I144,
    I108,  I109,  I110,  I111,  I112,  I113,  I114,  I115,  I116,  I117,  I118,
    I119,  I120,  I121,  I122,  I123,  I124,  I125,  I126,  I127,  Xe,    Xe128,
    Xe129, Xe130, Xe131, Xe132, Xe133, Xe134, Xe135, Xe136, Xe137, Xe138, Xe139,
    Xe140, Xe141, Xe142, Xe143, Xe144, Xe145, Xe146, Xe147, Xe110, Xe111, Xe112,
    Xe113, Xe114, Xe115, Xe116, Xe117, Xe118, Xe119, Xe120, Xe121, Xe122, Xe123,
    Xe124, Xe125, Xe126, Xe127, Cs,    Cs128, Cs129, Cs130, Cs131, Cs132, Cs133,
    Cs134, Cs135, Cs136, Cs137, Cs138, Cs139, Cs140, Cs141, Cs142, Cs143, Cs144,
    Cs145, Cs146, Cs147, Cs148, Cs149, Cs150, Cs151, Cs112, Cs113, Cs114, Cs115,
    Cs116, Cs117, Cs118, Cs119, Cs120, Cs121, Cs122, Cs123, Cs124, Cs125, Cs126,
    Cs127, Ba,    Ba128, Ba129, Ba130, Ba131, Ba132, Ba133, Ba134, Ba135, Ba136,
    Ba137, Ba138, Ba139, Ba140, Ba141, Ba142, Ba143, Ba144, Ba145, Ba146, Ba147,
    Ba148, Ba149, Ba150, Ba151, Ba152, Ba153, Ba114, Ba115, Ba116, Ba117, Ba118,
    Ba119, Ba120, Ba121, Ba122, Ba123, Ba124, Ba125, Ba126, Ba127, La,    La128,
    La129, La130, La131, La132, La133, La134, La135, La136, La137, La138, La139,
    La140, La141, La142, La143, La144, La145, La146, La147, La148, La149, La150,
    La151, La152, La153, La154, La155, La117, La118, La119, La120, La121, La122,
    La123, La124, La125, La126, La127, Ce,    Ce128, Ce129, Ce130, Ce131, Ce132,
    Ce133, Ce134, Ce135, Ce136, Ce137, Ce138, Ce139, Ce140, Ce141, Ce142, Ce143,
    Ce144, Ce145, Ce146, Ce147, Ce148, Ce149, Ce150, Ce151, Ce152, Ce153, Ce154,
    Ce155, Ce156, Ce157, Ce119, Ce120, Ce121, Ce122, Ce123, Ce124, Ce125, Ce126,
    Ce127, Pr,    Pr128, Pr129, Pr130, Pr131, Pr132, Pr133, Pr134, Pr135, Pr136,
    Pr137, Pr138, Pr139, Pr140, Pr141, Pr142, Pr143, Pr144, Pr145, Pr146, Pr147,
    Pr148, Pr149, Pr150, Pr151, Pr152, Pr153, Pr154, Pr155, Pr156, Pr157, Pr158,
    Pr159, Pr121, Pr122, Pr123, Pr124, Pr125, Pr126, Pr127, Nd,    Nd128, Nd129,
    Nd130, Nd131, Nd132, Nd133, Nd134, Nd135, Nd136, Nd137, Nd138, Nd139, Nd140,
    Nd141, Nd142, Nd143, Nd144, Nd145, Nd146, Nd147, Nd148, Nd149, Nd150, Nd151,
    Nd152, Nd153, Nd154, Nd155, Nd156, Nd157, Nd158, Nd159, Nd160, Nd161, Nd126,
    Nd127, Pm,    Pm128, Pm129, Pm130, Pm131, Pm132, Pm133, Pm134, Pm135, Pm136,
    Pm137, Pm138, Pm139, Pm140, Pm141, Pm142, Pm143, Pm144, Pm145, Pm146, Pm147,
    Pm148, Pm149, Pm150, Pm151, Pm152, Pm153, Pm154, Pm155, Pm156, Pm157, Pm158,
    Pm159, Pm160, Pm161, Pm162, Pm163, Sm,    Sm130, Sm131, Sm132, Sm133, Sm134,
    Sm135, Sm136, Sm137, Sm138, Sm139, Sm140, Sm141, Sm142, Sm143, Sm144, Sm145,
    Sm146, Sm147, Sm148, Sm149, Sm150, Sm151, Sm152, Sm153, Sm154, Sm155, Sm156,
    Sm157, Sm158, Sm159, Sm160, Sm161, Sm162, Sm163, Sm164, Sm165, Eu,    Eu132,
    Eu133, Eu134, Eu135, Eu136, Eu137, Eu138, Eu139, Eu140, Eu141, Eu142, Eu143,
    Eu144, Eu145, Eu146, Eu147, Eu148, Eu149, Eu150, Eu151, Eu152, Eu153, Eu154,
    Eu155, Eu156, Eu157, Eu158, Eu159, Eu160, Eu161, Eu162, Eu163, Eu164, Eu165,
    Eu166, Eu167, Gd,    Gd136, Gd137, Gd138, Gd139, Gd140, Gd141, Gd142, Gd143,
    Gd144, Gd145, Gd146, Gd147, Gd148, Gd149, Gd150, Gd151, Gd152, Gd153, Gd154,
    Gd155, Gd156, Gd157, Gd158, Gd159, Gd160, Gd161, Gd162, Gd163, Gd164, Gd165,
    Gd166, Gd167, Gd168, Gd169, Tb,    Tb138, Tb139, Tb140, Tb141, Tb142, Tb143,
    Tb144, Tb145, Tb146, Tb147, Tb148, Tb149, Tb150, Tb151, Tb152, Tb153, Tb154,
    Tb155, Tb156, Tb157, Tb158, Tb159, Tb160, Tb161, Tb162, Tb163, Tb164, Tb165,
    Tb166, Tb167, Tb168, Tb169, Tb170, Tb171, Dy,    Dy140, Dy141, Dy142, Dy143,
    Dy144, Dy145, Dy146, Dy147, Dy148, Dy149, Dy150, Dy151, Dy152, Dy153, Dy154,
    Dy155, Dy156, Dy157, Dy158, Dy159, Dy160, Dy161, Dy162, Dy163, Dy164, Dy165,
    Dy166, Dy167, Dy168, Dy169, Dy170, Dy171, Dy172, Dy173, Ho,    Ho142, Ho143,
    Ho144, Ho145, Ho146, Ho147, Ho148, Ho149, Ho150, Ho151, Ho152, Ho153, Ho154,
    Ho155, Ho156, Ho157, Ho158, Ho159, Ho160, Ho161, Ho162, Ho163, Ho164, Ho165,
    Ho166, Ho167, Ho168, Ho169, Ho170, Ho171, Ho172, Ho173, Ho174, Ho175, Er,
    Er144, Er145, Er146, Er147, Er148, Er149, Er150, Er151, Er152, Er153, Er154,
    Er155, Er156, Er157, Er158, Er159, Er160, Er161, Er162, Er163, Er164, Er165,
    Er166, Er167, Er168, Er169, Er170, Er171, Er172, Er173, Er174, Er175, Er176,
    Er177, Tm,    Tm146, Tm147, Tm148, Tm149, Tm150, Tm151, Tm152, Tm153, Tm154,
    Tm155, Tm156, Tm157, Tm158, Tm159, Tm160, Tm161, Tm162, Tm163, Tm164, Tm165,
    Tm166, Tm167, Tm168, Tm169, Tm170, Tm171, Tm172, Tm173, Tm174, Tm175, Tm176,
    Tm177, Tm178, Tm179, Yb,    Yb148, Yb149, Yb150, Yb151, Yb152, Yb153, Yb154,
    Yb155, Yb156, Yb157, Yb158, Yb159, Yb160, Yb161, Yb162, Yb163, Yb164, Yb165,
    Yb166, Yb167, Yb168, Yb169, Yb170, Yb171, Yb172, Yb173, Yb174, Yb175, Yb176,
    Yb177, Yb178, Yb179, Yb180, Yb181, Lu,    Lu150, Lu151, Lu152, Lu153, Lu154,
    Lu155, Lu156, Lu157, Lu158, Lu159, Lu160, Lu161, Lu162, Lu163, Lu164, Lu165,
    Lu166, Lu167, Lu168, Lu169, Lu170, Lu171, Lu172, Lu173, Lu174, Lu175, Lu176,
    Lu177, Lu178, Lu179, Lu180, Lu181, Lu182, Lu183, Lu184, Hf,    Hf154, Hf155,
    Hf156, Hf157, Hf158, Hf159, Hf160, Hf161, Hf162, Hf163, Hf164, Hf165, Hf166,
    Hf167, Hf168, Hf169, Hf170, Hf171, Hf172, Hf173, Hf174, Hf175, Hf176, Hf177,
    Hf178, Hf179, Hf180, Hf181, Hf182, Hf183, Hf184, Hf185, Hf186, Ta,    Ta156,
    Ta157, Ta158, Ta159, Ta160, Ta161, Ta162, Ta163, Ta164, Ta165, Ta166, Ta167,
    Ta168, Ta169, Ta170, Ta171, Ta172, Ta173, Ta174, Ta175, Ta176, Ta177, Ta178,
    Ta179, Ta180, Ta181, Ta182, Ta183, Ta184, Ta185, Ta186, Ta187, Ta188, W,
    W158,  W159,  W160,  W161,  W162,  W163,  W164,  W165,  W166,  W167,  W168,
    W169,  W170,  W171,  W172,  W173,  W174,  W175,  W176,  W177,  W178,  W179,
    W180,  W181,  W182,  W183,  W184,  W185,  W186,  W187,  W188,  W189,  W190,
    Re,    Re160, Re161, Re162, Re163, Re164, Re165, Re166, Re167, Re168, Re169,
    Re170, Re171, Re172, Re173, Re174, Re175, Re176, Re177, Re178, Re179, Re180,
    Re181, Re182, Re183, Re184, Re185, Re186, Re187, Re188, Re189, Re190, Re191,
    Re192, Os,    Os162, Os163, Os164, Os165, Os166, Os167, Os168, Os169, Os170,
    Os171, Os172, Os173, Os174, Os175, Os176, Os177, Os178, Os179, Os180, Os181,
    Os182, Os183, Os184, Os185, Os186, Os187, Os188, Os189, Os190, Os191, Os192,
    Os193, Os194, Os195, Os196, Ir,    Ir165, Ir166, Ir167, Ir168, Ir169, Ir170,
    Ir171, Ir172, Ir173, Ir174, Ir175, Ir176, Ir177, Ir178, Ir179, Ir180, Ir181,
    Ir182, Ir183, Ir184, Ir185, Ir186, Ir187, Ir188, Ir189, Ir190, Ir191, Ir192,
    Ir193, Ir194, Ir195, Ir196, Ir197, Ir198, Ir199, Pt,    Pt168, Pt169, Pt170,
    Pt171, Pt172, Pt173, Pt174, Pt175, Pt176, Pt177, Pt178, Pt179, Pt180, Pt181,
    Pt182, Pt183, Pt184, Pt185, Pt186, Pt187, Pt188, Pt189, Pt190, Pt191, Pt192,
    Pt193, Pt194, Pt195, Pt196, Pt197, Pt198, Pt199, Pt200, Pt201, Pt202, Au,
    Au171, Au172, Au173, Au174, Au175, Au176, Au177, Au178, Au179, Au180, Au181,
    Au182, Au183, Au184, Au185, Au186, Au187, Au188, Au189, Au190, Au191, Au192,
    Au193, Au194, Au195, Au196, Au197, Au198, Au199, Au200, Au201, Au202, Au203,
    Au204, Au205, Hg,    Hg175, Hg176, Hg177, Hg178, Hg179, Hg180, Hg181, Hg182,
    Hg183, Hg184, Hg185, Hg186, Hg187, Hg188, Hg189, Hg190, Hg191, Hg192, Hg193,
    Hg194, Hg195, Hg196, Hg197, Hg198, Hg199, Hg200, Hg201, Hg202, Hg203, Hg204,
    Hg205, Hg206, Hg207, Hg208, Tl,    Tl177, Tl178, Tl179, Tl180, Tl181, Tl182,
    Tl183, Tl184, Tl185, Tl186, Tl187, Tl188, Tl189, Tl190, Tl191, Tl192, Tl193,
    Tl194, Tl195, Tl196, Tl197, Tl198, Tl199, Tl200, Tl201, Tl202, Tl203, Tl204,
    Tl205, Tl206, Tl207, Tl208, Tl209, Tl210, Pb,    Pb181, Pb182, Pb183, Pb184,
    Pb185, Pb186, Pb187, Pb188, Pb189, Pb190, Pb191, Pb192, Pb193, Pb194, Pb195,
    Pb196, Pb197, Pb198, Pb199, Pb200, Pb201, Pb202, Pb203, Pb204, Pb205, Pb206,
    Pb207, Pb208, Pb209, Pb210, Pb211, Pb212, Pb213, Pb214, Bi,    Bi185, Bi186,
    Bi187, Bi188, Bi189, Bi190, Bi191, Bi192, Bi193, Bi194, Bi195, Bi196, Bi197,
    Bi198, Bi199, Bi200, Bi201, Bi202, Bi203, Bi204, Bi205, Bi206, Bi207, Bi208,
    Bi209, Bi210, Bi211, Bi212, Bi213, Bi214, Bi215, Bi216, Po,    Po190, Po191,
    Po192, Po193, Po194, Po195, Po196, Po197, Po198, Po199, Po200, Po201, Po202,
    Po203, Po204, Po205, Po206, Po207, Po208, Po209, Po210, Po211, Po212, Po213,
    Po214, Po215, Po216, Po217, Po218, At,    At193, At194, At195, At196, At197,
    At198, At199, At200, At201, At202, At203, At204, At205, At206, At207, At208,
    At209, At210, At211, At212, At213, At214, At215, At216, At217, At218, At219,
    At220, At221, At222, At223, Rn,    Rn196, Rn197, Rn198, Rn199, Rn200, Rn201,
    Rn202, Rn203, Rn204, Rn205, Rn206, Rn207, Rn208, Rn209, Rn210, Rn211, Rn212,
    Rn213, Rn214, Rn215, Rn216, Rn217, Rn218, Rn219, Rn220, Rn221, Rn222, Rn223,
    Rn224, Rn225, Rn226, Rn227, Rn228, Fr,    Fr200, Fr201, Fr202, Fr203, Fr204,
    Fr205, Fr206, Fr207, Fr208, Fr209, Fr210, Fr211, Fr212, Fr213, Fr214, Fr215,
    Fr216, Fr217, Fr218, Fr219, Fr220, Fr221, Fr222, Fr223, Fr224, Fr225, Fr226,
    Fr227, Fr228, Fr229, Fr230, Fr231, Fr232, Ra,    Ra203, Ra204, Ra205, Ra206,
    Ra207, Ra208, Ra209, Ra210, Ra211, Ra212, Ra213, Ra214, Ra215, Ra216, Ra217,
    Ra218, Ra219, Ra220, Ra221, Ra222, Ra223, Ra224, Ra225, Ra226, Ra227, Ra228,
    Ra229, Ra230, Ra231, Ra232, Ra233, Ra234, Ac,    Ac207, Ac208, Ac209, Ac210,
    Ac211, Ac212, Ac213, Ac214, Ac215, Ac216, Ac217, Ac218, Ac219, Ac220, Ac221,
    Ac222, Ac223, Ac224, Ac225, Ac226, Ac227, Ac228, Ac229, Ac230, Ac231, Ac232,
    Ac233, Ac234, Ac235, Ac236, Th,    Th210, Th211, Th212, Th213, Th214, Th215,
    Th216, Th217, Th218, Th219, Th220, Th221, Th222, Th223, Th224, Th225, Th226,
    Th227, Th228, Th229, Th230, Th231, Th232, Th233, Th234, Th235, Th236, Th237,
    Th238, Pa,    Pa213, Pa214, Pa215, Pa216, Pa217, Pa218, Pa219, Pa220, Pa221,
    Pa222, Pa223, Pa224, Pa225, Pa226, Pa227, Pa228, Pa229, Pa230, Pa231, Pa232,
    Pa233, Pa234, Pa235, Pa236, Pa237, Pa238, Pa239, Pa240, U,     U218,  U219,
    U220,  U221,  U222,  U223,  U224,  U225,  U226,  U227,  U228,  U229,  U230,
    U231,  U232,  U233,  U234,  U235,  U236,  U237,  U238,  U239,  U240,  U241,
    U242,  Np,    Np225, Np226, Np227, Np228, Np229, Np230, Np231, Np232, Np233,
    Np234, Np235, Np236, Np237, Np238, Np239, Np240, Np241, Np242, Np243, Np244,
    Pu,    Pu228, Pu229, Pu230, Pu231, Pu232, Pu233, Pu234, Pu235, Pu236, Pu237,
    Pu238, Pu239, Pu240, Pu241, Pu242, Pu243, Pu244, Pu245, Pu246, Pu247, Am,
    Am231, Am232, Am233, Am234, Am235, Am236, Am237, Am238, Am239, Am240, Am241,
    Am242, Am243, Am244, Am245, Am246, Am247, Am248, Am249, Cm,    Cm233, Cm234,
    Cm235, Cm236, Cm237, Cm238, Cm239, Cm240, Cm241, Cm242, Cm243, Cm244, Cm245,
    Cm246, Cm247, Cm248, Cm249, Cm250, Cm251, Cm252};
/** The total number of atoms in the array. */
static const size_t NUM_ATOMS = 2845;

// ---------- END DO NOT EDIT AREA----------
/// Check if two atoms are not valid.
bool AtomEqualsWithNaN(const double left, const double right) {
Peterson, Peter's avatar
Peterson, Peter committed
  if (left == right)
    return true;
  if ((std::isnan)(left) && (std::isnan)(right))
Peterson, Peter's avatar
Peterson, Peter committed
    return true;
  return false;
}

bool operator==(const Atom &left, const Atom &right) {
Peterson, Peter's avatar
Peterson, Peter committed
  if (&left == &right)
    return true;

  if (left.z_number != right.z_number)
    return false;
  if (left.a_number != right.a_number)
    return false;
Peterson, Peter's avatar
Peterson, Peter committed
  if (!AtomEqualsWithNaN(left.abundance, right.abundance))
Peterson, Peter's avatar
Peterson, Peter committed
  if (!AtomEqualsWithNaN(left.mass, right.mass))
Peterson, Peter's avatar
Peterson, Peter committed
  if (!AtomEqualsWithNaN(left.mass_density, right.mass_density))
Peterson, Peter's avatar
Peterson, Peter committed
  if (!AtomEqualsWithNaN(left.number_density, right.number_density))
    return false;
  if (left.neutron != right.neutron)
    return false;

  // passes all of the tests
  return true;
}
bool operator!=(const Atom &left, const Atom &right) {
std::ostream &operator<<(std::ostream &out, const Atom &atom) {
  out << atom.symbol;
  if (atom.a_number != 0)
    out << atom.a_number;
/// Compare two atoms
bool compareAtoms(const Atom &left, const Atom &right) {
  if (left.z_number == right.z_number) {
    return (left.a_number < right.a_number);
    return (left.z_number < right.z_number);
  }
}

 * @param z_number :: Atomic number of the atom to get
 * @param a_number :: Mass number of the atom to get
 * @return The atom corresponding to the given Z and A
 */
Atom getAtom(const uint16_t z_number, const uint16_t a_number) {
  Atom temp("junk", z_number, a_number, NAN, NAN, NAN);
  Atom *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) {
    msg << "Failed to find an atom with z=" << z_number
        << " and a=" << a_number;
/**
 * @param symbol :: Chemical symbol of the atom to get
 * @param a_number :: Mass number of the atom to get
 * @return The atom corresponding to the given symbol and A
 */
Atom getAtom(const std::string &symbol, const uint16_t a_number) {
  // special cases for aliases
  if (symbol == "D")
  if (symbol == "T")
  for (auto &atom : ATOMS) {
    if (symbol == atom.symbol) {
      if (a_number == atom.a_number) {
        return atom;
  }

  // fail loudly
  std::stringstream msg;
  msg << "Failed to find an atom with symbol=" << symbol
      << " and a=" << a_number;
  throw std::runtime_error(msg.str());
}

} // namespace PhysicalConstants
} // namespace Mantid