|
| 1 | +/** |
| 2 | + * @file cell_tools.h |
| 3 | + * @brief Free function tools for extracting cell/atom information. |
| 4 | + */ |
| 5 | +#ifndef CELL_TOOLS_H |
| 6 | +#define CELL_TOOLS_H |
| 7 | + |
| 8 | +#include <string> |
| 9 | +#include <vector> |
| 10 | + |
| 11 | +#include "source_base/vector3.h" |
| 12 | +#include "source_cell/atom_spec.h" |
| 13 | + |
| 14 | +/** |
| 15 | + * @brief Free functions for extracting atom/orbital info from Atom array. |
| 16 | + */ |
| 17 | +namespace unitcell |
| 18 | +{ |
| 19 | + /// @brief Get atom labels for each atom type. |
| 20 | + /// @param atoms atom pointer [in] |
| 21 | + /// @param ntype number of atom types [in] |
| 22 | + /// @return vector of atom labels, one per type |
| 23 | + std::vector<std::string> get_atomLabels(const Atom* atoms, const int ntype); |
| 24 | + |
| 25 | + /// @brief Get atom counts (number of atoms) for each atom type. |
| 26 | + /// @param atoms atom pointer [in] |
| 27 | + /// @param ntype number of atom types [in] |
| 28 | + /// @return vector of atom counts, one per type |
| 29 | + std::vector<int> get_atomCounts(const Atom* atoms, const int ntype); |
| 30 | + |
| 31 | + /// @brief Get lnchi counts (number of chi functions per L) for each atom type. |
| 32 | + /// @param atoms atom pointer [in] |
| 33 | + /// @param ntype number of atom types [in] |
| 34 | + /// @return vector of lnchi counts, one vector per type |
| 35 | + std::vector<std::vector<int>> get_lnchiCounts(const Atom* atoms, const int ntype); |
| 36 | + |
| 37 | + /// @brief Get target magnetic moment for each atom (used by deltaspin). |
| 38 | + /// @param atoms atom pointer [in] |
| 39 | + /// @param ntype number of atom types [in] |
| 40 | + /// @param nat total number of atoms [in] |
| 41 | + /// @return vector of target magnetic moments, one per atom |
| 42 | + std::vector<ModuleBase::Vector3<double>> get_target_mag(const Atom* atoms, |
| 43 | + const int ntype, |
| 44 | + const int nat); |
| 45 | + |
| 46 | + /// @brief Get Lagrange multiplier for each atom (used by deltaspin). |
| 47 | + /// @param atoms atom pointer [in] |
| 48 | + /// @param ntype number of atom types [in] |
| 49 | + /// @param nat total number of atoms [in] |
| 50 | + /// @return vector of Lagrange multipliers, one per atom |
| 51 | + std::vector<ModuleBase::Vector3<double>> get_lambda(const Atom* atoms, |
| 52 | + const int ntype, |
| 53 | + const int nat); |
| 54 | + |
| 55 | + /// @brief Get constrain flag for each atom (used by deltaspin). |
| 56 | + /// @param atoms atom pointer [in] |
| 57 | + /// @param ntype number of atom types [in] |
| 58 | + /// @param nat total number of atoms [in] |
| 59 | + /// @return vector of constrain flags, one per atom |
| 60 | + std::vector<ModuleBase::Vector3<int>> get_constrain(const Atom* atoms, |
| 61 | + const int ntype, |
| 62 | + const int nat); |
| 63 | + |
| 64 | + /// @brief Judge if any atom can move (any mbl component is non-zero). |
| 65 | + /// @param atoms atom pointer [in] |
| 66 | + /// @param ntype number of atom types [in] |
| 67 | + /// @return true if at least one atom is allowed to move |
| 68 | + bool if_atoms_can_move(const Atom* atoms, const int ntype); |
| 69 | + |
| 70 | + /// @brief Judge if any lattice vector can change. |
| 71 | + /// @param lat_axis_free lattice-axis freedom flags (size 3) [in] |
| 72 | + /// @return true if at least one lattice axis is free to change |
| 73 | + bool if_cell_can_change(const std::vector<int>& lat_axis_free); |
| 74 | +} |
| 75 | + |
| 76 | +#endif // CELL_TOOLS_H |
0 commit comments