Mantid
Loading...
Searching...
No Matches
Atom.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#include "MantidKernel/Atom.h"
10#include <boost/python/class.hpp>
11#include <boost/python/dict.hpp>
12#include <boost/python/make_constructor.hpp>
13#include <boost/python/make_function.hpp>
14#include <boost/python/register_ptr_to_python.hpp>
15
18using namespace boost::python;
19
20namespace {
25dict neutron(const Atom &self) {
26 dict retval;
27 retval["coh_scatt_xs"] = self.neutron.coh_scatt_xs;
28 retval["inc_scatt_xs"] = self.neutron.inc_scatt_xs;
29 retval["tot_scatt_xs"] = self.neutron.tot_scatt_xs;
30 retval["abs_xs"] = self.neutron.abs_scatt_xs;
31
32 retval["coh_scatt_length_real"] = self.neutron.coh_scatt_length_real;
33 retval["coh_scatt_length_img"] = self.neutron.coh_scatt_length_img;
34 retval["inc_scatt_length_real"] = self.neutron.inc_scatt_length_real;
35 retval["inc_scatt_length_img"] = self.neutron.inc_scatt_length_img;
36
37 retval["tot_scatt_length"] = self.neutron.tot_scatt_length;
38 retval["coh_scatt_length"] = self.neutron.coh_scatt_length;
39 retval["inc_scatt_length"] = self.neutron.inc_scatt_length;
40
41 return retval;
42}
51static std::shared_ptr<Atom> setAtom(const std::string &symbol, const uint16_t a_number = 0,
52 const uint16_t z_number = 0) {
53 if (z_number > 0) {
54 Atom atom = getAtom(z_number, a_number);
55 return std::shared_ptr<Atom>(new Atom(atom));
56 }
57 // Returns Hydrogen by default
58 else if (symbol.empty()) {
59 Atom atom = getAtom(1, 0);
60 return std::shared_ptr<Atom>(new Atom(atom));
61 } else {
62 Atom atom = getAtom(symbol, a_number);
63 return std::shared_ptr<Atom>(new Atom(atom));
64 }
65}
66} // namespace
67
69 register_ptr_to_python<Atom *>();
70 register_ptr_to_python<std::shared_ptr<Atom>>();
71
72 class_<Atom, boost::noncopyable>("Atom", no_init) // No default constructor
73 .def("__init__",
74 make_constructor(&setAtom, default_call_policies(),
75 (arg("symbol") = "", arg("a_number") = 0, arg("z_number") = 0)),
76 "Constructor for Atom class")
77 .def_readonly("symbol", &Atom::symbol, "The element symbol of this atom")
78 .def_readonly("z_number", &Atom::z_number, "The atomic number (number of protons) of this atom")
79 .def_readonly("a_number", &Atom::a_number, "The mass number (number of nucleons) of this atom")
80 .def_readonly("abundance", &Atom::abundance, "The abundance of this atom")
81 .def_readonly("mass", &Atom::mass, "The relative atomic mass of this atom")
82 .def_readonly("mass_density", &Atom::mass_density, "The mass density of this atom in g/cm^3")
83 .def_readonly("number_density", &Atom::number_density, "The number density of this atom in cm^-3")
84 .def("neutron", &neutron, arg("self"), "Neutron cross-section information for this atom");
85}
void export_Atom()
Definition: Atom.cpp:68
Struture to hold the common information for an atom.
Definition: Atom.h:20
const std::string symbol
The atomic symbol. In other words the one or two character abbreviation.
Definition: Atom.h:31
const NeutronAtom neutron
Handle to class containing neutronic atomic properties.
Definition: Atom.h:57
const uint16_t z_number
The atomic number, or number of protons, for the atom.
Definition: Atom.h:34
const double abundance
The natural abundance of the isotope as a percentage between 0 and 100.
Definition: Atom.h:43
const uint16_t a_number
The total number of protons and neutrons, or mass number, for the atom for isotopic averages this is ...
Definition: Atom.h:38
const double mass
The atomic mass in units of 'u' (=1g/mol/Na).
Definition: Atom.h:47
const double number_density
The number density in units of cm-3 as calculated from the mass density.
Definition: Atom.h:54
const double mass_density
The atomic mass density in units of g/cm3.
Definition: Atom.h:50
MANTID_KERNEL_DLL const Atom & getAtom(const uint16_t z_number, const uint16_t a_number=0)
Definition: Atom.cpp:3167
double coh_scatt_length_real
The real part of the coherent scattering length in fm.
Definition: NeutronAtom.h:51
double tot_scatt_length
The total scattering length in fm.
Definition: NeutronAtom.h:75
double inc_scatt_length
The incoherent scattering length in fm.
Definition: NeutronAtom.h:81
double coh_scatt_length
The coherent scattering length in fm.
Definition: NeutronAtom.h:78
double coh_scatt_length_img
The imaginary part of the coherent scattering length in fm.
Definition: NeutronAtom.h:54
double inc_scatt_length_img
The imaginary part of the incoherent scattering length in fm.
Definition: NeutronAtom.h:60
double inc_scatt_xs
The incoherent scattering cross section in barns.
Definition: NeutronAtom.h:66
double tot_scatt_xs
The total scattering cross section in barns.
Definition: NeutronAtom.h:69
double abs_scatt_xs
The absorption cross section for 2200m/s neutrons in barns.
Definition: NeutronAtom.h:72
double inc_scatt_length_real
The real part of the incoherent scattering length in fm.
Definition: NeutronAtom.h:57
double coh_scatt_xs
The coherent scattering cross section in barns.
Definition: NeutronAtom.h:63