4
#include <libmints/molecule.h>
13
natoms_(0), nirreps_(0)
23
void Molecule::clear()
30
void Molecule::add_atom(int Z, double x, double y, double z,
31
const char *label, double mass,
32
int have_charge, double charge)
45
atoms_.push_back(info);
48
double Molecule::mass(int atom) const
50
if (atoms_[atom].mass != 0.0)
51
return atoms_[atom].mass;
53
return an2masses[atoms_[atom].Z];
56
const std::string Molecule::label(int atom) const
58
return atoms_[atom].label;
61
int Molecule::atom_at_position(double *xyz, double tol) const
64
for (int i=0; i < natom(); ++i) {
65
Vector3 a(atoms_[i].x, atoms_[i].y, atoms_[i].z);
66
if (b.distance(a) < tol)
72
Vector3 Molecule::center_of_mass() const
80
for (int i=0; i<natom(); ++i) {
91
double Molecule::nuclear_repulsion_energy()
95
for (int i=1; i<natom(); ++i) {
96
for (int j=0; j<i; ++j) {
97
e += Z(i) * Z(j) / (xyz(i).distance(xyz(j)));
104
double* Molecule::nuclear_repulsion_energy_deriv1()
106
double *de = new double[3*natom()];
108
memset(de, 0, sizeof(double)*3*natom());
109
for (int i=1; i<natom(); ++i) {
110
for (int j=0; j<natom(); ++j) {
112
double temp = pow((xyz(i).distance(xyz(j))), 3.0);
113
de[3*i+0] -= (x(i) - x(j)) * Z(i) * Z(j) / temp;
114
de[3*i+1] -= (y(i) - y(j)) * Z(i) * Z(j) / temp;
115
de[3*i+2] -= (z(i) - z(j)) * Z(i) * Z(j) / temp;
123
void Molecule::translate(const Vector3& r)
125
for (int i=0; i<natom(); ++i) {
132
void Molecule::move_to_com()
134
Vector3 com = -center_of_mass();
138
void Molecule::init_with_chkpt(Ref<PSIO> &psio)
140
// User sent a psio object. Create a chkpt object based on it.
141
Ref<Chkpt> chkpt(new Chkpt(psio.pointer(), PSIO_OPEN_OLD));
142
init_with_chkpt(chkpt);
145
void Molecule::init_with_chkpt(Ref<Chkpt> &chkpt)
147
int atoms = chkpt->rd_natom();
148
double *zvals = chkpt->rd_zvals();
149
double **geom = chkpt->rd_geom();
151
for (int i=0; i<atoms; ++i) {
152
add_atom((int)zvals[i], geom[i][0], geom[i][1], geom[i][2], atomic_labels[(int)zvals[i]], an2masses[(int)zvals[i]]);
155
nirreps_ = chkpt->rd_nirreps();
161
void Molecule::print(FILE *out)
164
fprintf(out," Center X Y Z\n");
165
fprintf(out," ------------ ----------------- ----------------- -----------------\n");
167
for(int i = 0; i < natom(); ++i){
168
Vector3 geom = xyz(i);
169
fprintf(out, " %12s ",label(i).c_str()); fflush(out);
170
for(int j = 0; j < 3; j++)
171
fprintf(out, " %17.12f", geom[j]);
179
SimpleVector Molecule::nuclear_dipole_contribution()
183
for(int i=0; i<natom(); ++i) {
184
Vector3 geom = xyz(i);
185
ret[0] += Z(i) * geom[0];
186
ret[1] += Z(i) * geom[1];
187
ret[2] += Z(i) * geom[2];
193
SimpleVector Molecule::nuclear_quadrupole_contribution()
196
double xx, xy, xz, yy, yz, zz;
198
xx = xy = xz = yy = yz = zz = 0.0;
200
for (int i=0; i<natom(); ++i) {
201
Vector3 geom = xyz(i);
202
ret[0] += Z(i) * geom[0] * geom[0]; // xx
203
ret[1] += Z(i) * geom[0] * geom[1]; // xy
204
ret[2] += Z(i) * geom[0] * geom[2]; // xz
205
ret[3] += Z(i) * geom[1] * geom[1]; // yy
206
ret[4] += Z(i) * geom[1] * geom[2]; // yz
207
ret[5] += Z(i) * geom[2] * geom[2]; // zz