/usr/include/libint2/atom.h is in libint2-dev 2.1.0~beta2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | /*
* This file is a part of Libint.
* Copyright (C) 2004-2014 Edward F. Valeev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License, version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/
#ifndef _libint2_src_lib_libint_atom_h_
#define _libint2_src_lib_libint_atom_h_
#if __cplusplus <= 199711L
# error "The simple Libint API requires C++11 support"
#endif
#include <iostream>
#include <sstream>
#include <vector>
#include <libint2.h>
namespace libint2 {
struct Atom {
int atomic_number;
double x, y, z;
};
namespace {
bool strcaseequal(const std::string& a, const std::string& b) {
return a.size() == b.size() && std::equal(a.begin(), a.end(), b.begin(),
[](char a, char b) {return ::tolower(a) == ::tolower(b);}
);
}
}
/// reads the list of atoms from a file in the standard XYZ format supported by most chemistry software
inline std::vector<Atom> read_dotxyz(std::istream& is) {
// first line = # of atoms
size_t natom;
is >> natom;
// read off the rest of first line and discard
std::string rest_of_line;
std::getline(is, rest_of_line);
// second line = comment
std::string comment;
std::getline(is, comment);
// rest of lines are atoms
std::vector<Atom> atoms(natom);
for (auto i = 0; i < natom; i++) {
// read line
std::string line;
std::getline(is, line);
std::istringstream iss(line);
// then parse ... this handles "extended" XYZ formats
std::string element_symbol;
double x, y, z;
iss >> element_symbol >> x >> y >> z;
// .xyz files report element labels, hence convert to atomic numbers
int Z = -1;
using libint2::chemistry::element_info;
for(const auto& e: element_info) {
if (strcaseequal(e.symbol, element_symbol)) {
Z = e.Z;
break;
}
}
if (Z == -1) {
std::cerr << "read_dotxyz: element symbol \"" << element_symbol << "\" is not recognized" << std::endl;
throw "Did not recognize element symbol in .xyz file";
}
atoms[i].atomic_number = Z;
// .xyz files report Cartesian coordinates in angstroms; convert to bohr
const auto angstrom_to_bohr = 1 / 0.52917721092; // 2010 CODATA value
//const auto angstrom_to_bohr = 1 / 0.529177249; // 1986 CODATA value, used by MPQC
atoms[i].x = x * angstrom_to_bohr;
atoms[i].y = y * angstrom_to_bohr;
atoms[i].z = z * angstrom_to_bohr;
}
return atoms;
}
} // namespace libint2
#endif /* _libint2_src_lib_libint_atom_h_ */
|