diff --git a/src/include/ic1ion.hpp b/src/include/ic1ion.hpp index 0680dd2..d92d887 100644 --- a/src/include/ic1ion.hpp +++ b/src/include/ic1ion.hpp @@ -111,6 +111,7 @@ class ic1ion : public cfpars { std::vector< std::vector > calculate_moments(RowMatrixXcd ev); std::vector calculate_boltzmann( // Calculates the Boltzmann factor exp(-E/kT) VectorXd en, double T); + std::vector get_states(); }; // class ic1ion diff --git a/src/libmcphase/CMakeLists.txt b/src/libmcphase/CMakeLists.txt index f7c68ba..e409e37 100644 --- a/src/libmcphase/CMakeLists.txt +++ b/src/libmcphase/CMakeLists.txt @@ -4,6 +4,7 @@ set(LIBMCPHASE_PYTHON_SOURCES pycfpars.cpp pycf1ion.cpp pyic1ion.cpp + pyicstates.cpp ) target_sources(${LIBMCPHASE_PYTHON_MODULE} PRIVATE ${LIBMCPHASE_PYTHON_SOURCES}) target_link_libraries(${LIBMCPHASE_PYTHON_MODULE} PUBLIC ${LIBMCPHASE_CXX_LIBRARIES}) diff --git a/src/libmcphase/libmcphase.cpp b/src/libmcphase/libmcphase.cpp index 79a47e7..aeee661 100644 --- a/src/libmcphase/libmcphase.cpp +++ b/src/libmcphase/libmcphase.cpp @@ -13,6 +13,7 @@ namespace py = pybind11; void wrap_cfpars(py::module &); void wrap_cf1ion(py::module &); void wrap_ic1ion(py::module &); +void wrap_icstates(py::module &); PYBIND11_MODULE(libmcphase, m) { m.doc() = "Python bindings for libMcPhase"; @@ -20,6 +21,7 @@ PYBIND11_MODULE(libmcphase, m) { wrap_cfpars(m); wrap_cf1ion(m); wrap_ic1ion(m); + wrap_icstates(m); } diff --git a/src/libmcphase/pyic1ion.cpp b/src/libmcphase/pyic1ion.cpp index 0d89c58..e3dafed 100644 --- a/src/libmcphase/pyic1ion.cpp +++ b/src/libmcphase/pyic1ion.cpp @@ -64,7 +64,8 @@ void wrap_ic1ion(py::module &m) { .def("magnetisation", [](ic1ion &self, std::vector H, std::vector Hdir, double T, std::string unit) { return self.magnetisation(H, Hdir, T, set_enum(unit, mag_unit_names, "Invalid magnetic unit, must be one of: 'bohr', 'cgs', or 'SI'")); }) .def("susceptibility", [](ic1ion &self, std::vector T, std::vector Hdir, std::string unit) { return self.susceptibility(T, Hdir, - set_enum(unit, mag_unit_names, "Invalid magnetic unit, must be one of: 'bohr', 'cgs', or 'SI'")); }); + set_enum(unit, mag_unit_names, "Invalid magnetic unit, must be one of: 'bohr', 'cgs', or 'SI'")); }) + .def("get_states", &ic1ion::get_states, "Gets the list of states for this ion configuration"); } diff --git a/src/libmcphase/pyicstates.cpp b/src/libmcphase/pyicstates.cpp new file mode 100644 index 0000000..7db88be --- /dev/null +++ b/src/libmcphase/pyicstates.cpp @@ -0,0 +1,49 @@ +/* pyicstates.cpp + * + * Python bindings for the fstates class of libMcPhase + * + * (C) 2020 Duc Le - duc.le@stfc.ac.uk + * This program is licensed under the GNU General Purpose License, version 3. Please see the LICENSE file + */ + +#include "ic_states.hpp" +#include + +namespace py = pybind11; +using namespace libMcPhase; + +void wrap_icstates(py::module &m) { + + py::class_ pyicstate(m, "ic_state"); + + py::enum_(pyicstate, "orbital") + .value("S", orbital::S) + .value("P", orbital::P) + .value("D", orbital::D) + .value("F", orbital::F) + .value("Fp", orbital::Fp) + .value("G", orbital::G) + .value("Gp", orbital::Gp) + .value("H", orbital::H) + .value("Hp", orbital::Hp) + .value("I", orbital::I) + .value("Ip", orbital::Ip) + .value("K", orbital::K) + .value("Kp", orbital::Kp) + .value("L", orbital::L) + .value("Lp", orbital::Lp) + .value("M", orbital::M) + .value("N", orbital::N) + .value("O", orbital::O) + .value("Q", orbital::Q) + .export_values(); + + pyicstate + .def_property_readonly("S2", [](const fstates_t &self){ return self.S2; }, "Twice the total spin momentum") + .def_property_readonly("L", [](const fstates_t &self){ return (int)abs(self.L); }, "The orbital momentum") + .def_property_readonly("id", [](const fstates_t &self){ return self.id; }, "id string") + .def_property_readonly("J2", [](const fstates_t &self){ return self.J2; }, "Twice the total momentum") + .def_property_readonly("mJ2", [](const fstates_t &self){ return self.mJ2; }, "Twice the total azimuth momentum"); +} + + diff --git a/src/singleion/ic1ion.cpp b/src/singleion/ic1ion.cpp index 03729e4..1057824 100644 --- a/src/singleion/ic1ion.cpp +++ b/src/singleion/ic1ion.cpp @@ -117,6 +117,7 @@ void ic1ion::set_name(const std::string &ionname) { m_ham_calc = false; m_ev_calc = false; m_tensorops.clear(); + m_conf = fconf(m_n, 1, m_l); } void ic1ion::set_coulomb(const std::vector val, ic1ion::CoulombType type) { @@ -168,6 +169,13 @@ void ic1ion::set_spinorbit(double val, ic1ion::SpinOrbType type) { } } +std::vector ic1ion::get_states() { + if (m_conf.states.empty()) { + m_conf = fconf(m_n, 1, m_l); + } + return m_conf.states; +} + // --------------------------------------------------------------------------------------------------------------- // // Constructors for the ic1ion class // --------------------------------------------------------------------------------------------------------------- //