| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#ifndef AVOGADRO_CORE_AVO_SPGLIB_H |
| 7 |
#define AVOGADRO_CORE_AVO_SPGLIB_H |
| 8 |
|
| 9 |
#include "avogadrocoreexport.h" |
| 10 |
|
| 11 |
#include "molecule.h" |
| 12 |
|
| 13 |
namespace Avogadro::Core { |
| 14 |
|
| 15 |
/** |
| 16 |
* @class AvoSpglib avospglib.h <avogadro/core/avospglib.h> |
| 17 |
* @brief The AvoSpglib class provides an interface between Avogadro and Spglib. |
| 18 |
*/ |
| 19 |
|
| 20 |
class AVOGADROCORE_EXPORT AvoSpglib |
| 21 |
{ |
| 22 |
public: |
| 23 |
AvoSpglib(); |
| 24 |
~AvoSpglib(); |
| 25 |
|
| 26 |
/** |
| 27 |
* Use spglib to find the Hall number for a crystal. If the unit cell does not |
| 28 |
* exist or if the algorithm fails, 0 will be returned. |
| 29 |
* |
| 30 |
* If the algorithm succeeds, the hall number will be set in the molecule. |
| 31 |
* |
| 32 |
* @param mol The molecule to be handled. |
| 33 |
* @param cartTol The cartesian tolerance for spglib. |
| 34 |
* @return The Hall number for the crystal. |
| 35 |
*/ |
| 36 |
static unsigned short getHallNumber(Molecule& mol, double cartTol = 1e-5); |
| 37 |
|
| 38 |
/** |
| 39 |
* Use spglib to reduce the crystal to a primitive cell. Unless the molecule |
| 40 |
* is missing its unit cell, it will be edited by spglib. Positions are |
| 41 |
* not idealized. |
| 42 |
* |
| 43 |
* If the algorithm succeeds, the hall number will be set in the molecule. |
| 44 |
* |
| 45 |
* @param mol The molecule to be reduced to its primitive cell. |
| 46 |
* @param cartTol The cartesian tolerance for spglib. |
| 47 |
* @return False if the molecule has no unit cell or if the |
| 48 |
spglib algorithm failed. True otherwise. |
| 49 |
*/ |
| 50 |
static bool reduceToPrimitive(Molecule& mol, double cartTol = 1e-5); |
| 51 |
|
| 52 |
/** |
| 53 |
* Use spglib to refine the crystal to its conventional cell. Unless the |
| 54 |
* molecule is missing its unit cell, it will be edited by spglib. Positions |
| 55 |
* are idealized. |
| 56 |
* |
| 57 |
* If the algorithm succeeds, the hall number will be set in the molecule. |
| 58 |
* |
| 59 |
* @param mol The molecule to be conventionalized. |
| 60 |
* @param cartTol The cartesian tolerance for spglib. |
| 61 |
* @return False if the molecule has no unit cell or if the |
| 62 |
* spglib algorithm failed. True otherwise. |
| 63 |
*/ |
| 64 |
static bool conventionalizeCell(Molecule& mol, double cartTol = 1e-5); |
| 65 |
|
| 66 |
/** |
| 67 |
* Use spglib to symmetrize the crystal. Unless the molecule is missing |
| 68 |
* its unit cell, it will be edited by spglib. It will be reduced |
| 69 |
* to its primitive form, and positions will be idealized. |
| 70 |
* |
| 71 |
* If the algorithm succeeds, the hall number will be set in the molecule. |
| 72 |
* |
| 73 |
* @param mol The molecule to be conventionalized. |
| 74 |
* @param cartTol The cartesian tolerance for spglib. |
| 75 |
* @return False if the molecule has no unit cell or if the |
| 76 |
* spglib algorithm failed. True otherwise. |
| 77 |
*/ |
| 78 |
static bool symmetrize(Molecule& mol, double cartTol = 1e-5); |
| 79 |
|
| 80 |
private: |
| 81 |
// Called by reduceToPrimitive(), conventionalizeCell(), and symmetrize() |
| 82 |
// Calls spg_standardize_cell() |
| 83 |
static bool standardizeCell(Molecule& mol, double cartTol, bool toPrimitive, |
| 84 |
bool idealize); |
| 85 |
}; |
| 86 |
|
| 87 |
} // namespace Avogadro::Core |
| 88 |
|
| 89 |
#endif // AVOGADRO_CORE_AVO_SPGLIB_H |