LCOV - code coverage report
Current view: top level - pairinteraction - QuantumDefect.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 9 9 100.0 %
Date: 2024-04-29 00:41:50 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016 Sebastian Weber, Henri Menke. All rights reserved.
       3             :  *
       4             :  * This file is part of the pairinteraction library.
       5             :  *
       6             :  * The pairinteraction library is free software: you can redistribute it and/or modify
       7             :  * it under the terms of the GNU Lesser General Public License as published by
       8             :  * the Free Software Foundation, either version 3 of the License, or
       9             :  * (at your option) any later version.
      10             :  *
      11             :  * The pairinteraction library is distributed in the hope that it will be useful,
      12             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :  * GNU Lesser General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public License
      17             :  * along with the pairinteraction library. If not, see <http://www.gnu.org/licenses/>.
      18             :  */
      19             : 
      20             : #ifndef QUANTUM_DEFECT_H
      21             : #define QUANTUM_DEFECT_H
      22             : 
      23             : #include "SQLite.hpp"
      24             : #include "utils.hpp"
      25             : 
      26             : #include <string>
      27             : 
      28             : /** \brief Quantum defect storage
      29             :  *
      30             :  * The quantum defect queries a database for Rydberg-Ritz coefficients and
      31             :  * model potential parameters. The Rydberg-Ritz coefficients are not exposed to
      32             :  * the outside but included in the energy data member.
      33             :  *
      34             :  * The slight deviation from the hydrogen atom for Rydberg atoms are captured
      35             :  * in the so-called quantum defect. The hydrogen energy is given by \f$ E =
      36             :  * \mathrm{Ry}/n^2 \f$. For Rydberg atoms this is slightly modified to \f$ E^*
      37             :  * = \mathrm{Ry}/n^{*2} \f$ where \f$ n^* = n - \delta_{nlj} \f$. This
      38             :  * correction can be expanded in a series
      39             :  * \f[
      40             :  *      \delta_{nlj} = \delta_0
      41             :  *      + \frac{\delta_2}{(n-\delta_0)^2}
      42             :  *      + \frac{\delta_4}{(n-\delta_0)^4}
      43             :  *      + \frac{\delta_6}{(n-\delta_0)^6}
      44             :  *      + \cdots \;
      45             :  * \f]
      46             :  * The coefficients of the series \f$ \delta_i \f$ (Rydberg-Ritz coefficients)
      47             :  * are loaded from the database.
      48             :  *
      49             :  * The object also loads the parameters for the model potentials which are used
      50             :  * in the Numerov object.
      51             :  */
      52             : class QuantumDefect {
      53             : private:
      54             :     /** \brief Key type for quantum defect cache */
      55             :     struct Key {
      56             :         std::string species;
      57             :         int n;
      58             :         int l;
      59             :         double j;
      60             : 
      61             :         /** \brief Comparison for keys */
      62      164674 :         bool operator==(Key const &o) const {
      63      164674 :             return (species == o.species && n == o.n && l == o.l && j == o.j);
      64             :         }
      65             :     };
      66             : 
      67             :     //** \brief Hash for Key */
      68             :     struct Hash {
      69             :         /** \brief Hash the key using utils::hash_combine */
      70      167550 :         std::size_t operator()(Key const &key) const {
      71      167550 :             std::size_t seed = 0;
      72      167550 :             utils::hash_combine(seed, key.species);
      73      167550 :             utils::hash_combine(seed, key.n);
      74      167550 :             utils::hash_combine(seed, key.l);
      75      167550 :             utils::hash_combine(seed, key.j);
      76      167550 :             return seed;
      77             :         }
      78             :     };
      79             : 
      80             :     /** \brief Element in the quantum defect cache */
      81             :     struct Element {
      82             :         double ac;
      83             :         int Z;
      84             :         double a1, a2, a3, a4;
      85             :         double rc;
      86             :         double nstar;
      87             :         double energy;
      88             :     };
      89             : 
      90             :     Element e;
      91             : 
      92             :     void setup(sqlite3 * /*db*/, std::string const &db_name);
      93             : 
      94             :     QuantumDefect(std::string _species, int _n, int _l, double _j, std::nullptr_t);
      95             : 
      96             : public:
      97             :     /** \brief Constructor
      98             :      *
      99             :      * Save the input and query the database.
     100             :      *
     101             :      * \param[in] species   atomic species of the atom
     102             :      * \param[in] n         principal quantum number
     103             :      * \param[in] l         angular quantum number
     104             :      * \param[in] j         magnetic quantum number
     105             :      */
     106             :     QuantumDefect(std::string const &species, int n, int l, double j);
     107             : 
     108             :     /** \overload QuantumDefect(std::string const& species, int n, int l, double
     109             :      * j) */
     110             :     QuantumDefect(std::string const &species, int n, int l, double j, std::string const &database);
     111             : 
     112             :     /** \brief Atomic species */
     113             :     const std::string species;
     114             : 
     115             :     /** \brief Principal quantum number */
     116             :     const int n;
     117             : 
     118             :     /** \brief Angular quantum number */
     119             :     const int l;
     120             : 
     121             :     /** \brief Magnetic quantum number */
     122             :     const double j;
     123             : 
     124             :     /** \brief Polarizability */
     125             :     const double &ac;
     126             : 
     127             :     /** \brief Core charge */
     128             :     const int &Z;
     129             : 
     130             :     /** \brief Parameter of effective Coulomb potential */
     131             :     const double &a1;
     132             : 
     133             :     /** \brief Parameter of effective Coulomb potential */
     134             :     const double &a2;
     135             : 
     136             :     /** \brief Parameter of effective Coulomb potential */
     137             :     const double &a3;
     138             : 
     139             :     /** \brief Parameter of effective Coulomb potential */
     140             :     const double &a4;
     141             : 
     142             :     /** \brief Effective core size */
     143             :     const double &rc;
     144             : 
     145             :     /** \brief Effective principal quantum number */
     146             :     const double &nstar;
     147             : 
     148             :     /** \brief State energy */
     149             :     const double &energy;
     150             : };
     151             : 
     152             : /** \brief Returns only the energy of a state
     153             :  *
     154             :  * \warning This function has a considerable overhead because it allocates a new
     155             :  * quantum defect which triggers a database query. Use this function only for
     156             :  * debugging because many successive calls to this will cause a massive slow
     157             :  * down.
     158             :  *
     159             :  * \param[in] species   atomic species of the atom
     160             :  * \param[in] n         principal quantum number
     161             :  * \param[in] l         angular quantum number
     162             :  * \param[in] j         magnetic quantum number
     163             :  */
     164             : double energy_level(std::string const &species, int n, int l, double j,
     165             :                     std::string const &database = "");
     166             : 
     167             : double nstar(std::string const &species, int n, int l, double j, std::string const &database = "");
     168             : 
     169             : #endif // QUANTUM_DEFECT_H

Generated by: LCOV version 1.14