AFLOW
 
Loading...
Searching...
No Matches
aflow_aconvasp.cpp
Go to the documentation of this file.
1// ***************************************************************************
2// * *
3// * Aflow STEFANO CURTAROLO - Duke University 2003-2024 *
4// * *
5// ***************************************************************************
6// Stefano Curtarolo and Dane Morgan
7
8#ifndef _AFLOW_PFLOW_CPP_
9#define _AFLOW_PFLOW_CPP_
10
11#include <algorithm>
12#include <cassert>
13#include <cmath>
14#include <cstddef>
15#include <cstdlib>
16#include <deque>
17#include <fstream>
18#include <ios>
19#include <iostream>
20#include <istream>
21#include <ostream>
22#include <sstream>
23#include <string>
24#include <vector>
25
26#include "AUROSTD/aurostd.h"
32
33#include "aflow.h"
34#include "flow/aflow_ivasp.h"
35#include "flow/aflow_pflow.h"
36#include "structure/aflow_xatom.h"
37#include "structure/aflow_xstructure.h"
38
39using std::deque;
40using std::endl;
41using std::ifstream;
42using std::istream;
43using std::ofstream;
44using std::ostream;
45using std::string;
46using std::stringstream;
47using std::vector;
48
51
52// ***************************************************************************
53// Simple interfaces
54// ***************************************************************************
55int SignNoZero(const double& x) {
56 return (int) aurostd::signnozero(x);
57}
58int Nint(const double& x) {
59 return (int) aurostd::nint(x);
60}
61int Sign(const double& x) {
62 return (int) aurostd::sign(x);
63}
64
65// ***************************************************************************
66// Function PutInCompact
67// ***************************************************************************
68// Make a structure where all the atoms are all the
69// atoms are mapped through the unit and neighbors cells
70// to minimixe the shortest possible bond with an adjacent atom. (SC 6 Aug 04)
71xstructure PutInCompact(const xstructure& a) {
72 xstructure sstr = a;
73 sstr.BringInCompact();
74 return sstr;
75}
76
77// ***************************************************************************
78// Function PutInCell - same as BringInCell
79// ***************************************************************************
80// Make a structure with all atoms mapped to their images within the
81// unit cell.
82xstructure PutInCell(const xstructure& a) {
83 xstructure sstr = a;
84 sstr.BringInCell();
85 return sstr;
86}
87
88// ***************************************************************************
89// Function WignerSeitz
90// ***************************************************************************
91// Make a structure where all the atoms are
92// mapped to their images in the Wigner-Seitz cell.(SC 10Jan04)
93xstructure WignerSeitz(const xstructure& a) {
94 xstructure sstr = a;
95 // zoology of vectors
96 xvector<double> rat(3);
97 xvector<double> xoo(3);
98 xvector<double> yoo(3);
99 xvector<double> zoo(3);
100 xvector<double> xyo(3);
101 xvector<double> xzo(3);
102 xvector<double> yzo(3);
103 xvector<double> xyz(3);
104 double axoo;
105 double ayoo;
106 double azoo;
107 double axyo;
108 double axzo;
109 double ayzo;
110 double axyz;
111 xoo = sstr.lattice(1);
112 axoo = modulus(xoo);
113 yoo = sstr.lattice(2);
114 ayoo = modulus(yoo);
115 zoo = sstr.lattice(3);
116 azoo = modulus(zoo);
117 xyo = sstr.lattice(1) + sstr.lattice(2);
118 axyo = modulus(xyo);
119 xzo = sstr.lattice(1) + sstr.lattice(3);
120 axzo = modulus(xzo);
121 yzo = sstr.lattice(2) + sstr.lattice(3);
122 ayzo = modulus(yzo);
123 xyz = sstr.lattice(1) + sstr.lattice(2) + sstr.lattice(3);
124 axyz = modulus(xyz);
125 double projxoo;
126 double projyoo;
127 double projzoo;
128 double projxyo;
129 double projxzo;
130 double projyzo;
131 double projxyz;
132
133 for (size_t iat = 0; iat < sstr.atoms.size(); iat++) {
134 for (int i = -1; i <= 1; i++) {
135 for (int j = -1; j <= 1; j++) {
136 for (int k = -1; k <= 1; k++) {
137 rat = sstr.atoms.at(iat).cpos + ((double) i) * sstr.lattice(1) + ((double) j) * sstr.lattice(2) + ((double) k) * sstr.lattice(3);
138 projxoo = scalar_product(rat, xoo) / axoo / axoo;
139 projyoo = scalar_product(rat, yoo) / ayoo / ayoo;
140 projzoo = scalar_product(rat, zoo) / azoo / azoo;
141 projxyo = scalar_product(rat, xyo) / axyo / axyo;
142 projxzo = scalar_product(rat, xzo) / axzo / axzo;
143 projyzo = scalar_product(rat, yzo) / ayzo / ayzo;
144 projxyz = scalar_product(rat, xyz) / axyz / axyz;
145 if ((projxoo > -0.5 && projxoo <= 0.5) && (projyoo > -0.5 && projyoo <= 0.5) && (projzoo > -0.5 && projzoo <= 0.5) && (projxyo > -0.5 && projxyo <= 0.5) && (projxzo > -0.5 && projxzo <= 0.5) &&
146 (projyzo > -0.5 && projyzo <= 0.5) && (projxyz > -0.5 && projxyz <= 0.5)) {
147 sstr.atoms.at(iat).cpos(1) = rat(1);
148 sstr.atoms.at(iat).cpos(2) = rat(2);
149 sstr.atoms.at(iat).cpos(3) = rat(3);
150 i = 10;
151 j = 10;
152 k = 10;
153 }
154 }
155 }
156 }
157 sstr.atoms.at(iat).fpos = C2F(sstr.lattice, sstr.atoms.at(iat).cpos);
158 }
159 return sstr;
160}
161
162// **************************************************************************
163// GetMom1
164// **************************************************************************
165// this function returns moment_1 position of the atoms in cartesians
166xvector<double> GetMom1(const xstructure& a) {
167 // Get's first moment in cartesian coordinates.
168 xvector<double> mom1(3);
169 for (size_t iat = 0; iat < a.atoms.size(); iat++) {
170 mom1 = mom1 + a.atoms[iat].cpos;
171 }
172 if (!a.atoms.empty()) {
173 mom1 = ((double) a.scale / ((double) a.atoms.size())) * mom1;
174 } else {
175 clear(mom1);
176 }
177 return mom1;
178}
179
180// **************************************************************************
181// SetMom1
182// **************************************************************************
183// this function sets moment_1 position of atoms
184xstructure SetMom1(const xstructure& a, const xvector<double>& mom1_new) {
185 xstructure sstr = a;
186 // Get old first moment in cart. coords.
187 xvector<double> mom1_old(3);
188 mom1_old = GetMom1(sstr);
189 // Get change in first moment in cart. coords.
190 xvector<double> dmom1(3);
191 dmom1 = mom1_new - mom1_old;
192 // Shift scaled cart. positions by dmom1.
193 for (size_t iat = 0; iat < sstr.atoms.size(); iat++) {
194 sstr.atoms[iat].cpos = sstr.scale * sstr.atoms[iat].cpos;
195 sstr.atoms[iat].cpos = sstr.atoms[iat].cpos + dmom1;
196 sstr.atoms[iat].cpos = sstr.atoms[iat].cpos / sstr.scale;
197 sstr.atoms[iat].fpos = C2F(sstr.lattice, sstr.atoms[iat].cpos);
198 }
199 return sstr;
200}
201
202// **************************************************************************
203// Function Function GetCDispFromOrigin
204// **************************************************************************
205// This function returns displacement from origin
207 xvector<double> diff(3);
208 diff = atom.cpos - atom.corigin;
209 return diff;
210}
211
212// **************************************************************************
213// Function GetDistFromOrigin
214// **************************************************************************
215// This function returns distance from origin
216double GetDistFromOrigin(const _atom& atom) {
217 return modulus(GetCDispFromOrigin(atom));
218}
219
220// **************************************************************************
221// Function ConvertAtomToLat
222// **************************************************************************
223// This function makes sure that an atoms fractional coords
224// and unit cell parameters are consistent with an input lattice.
225_atom ConvertAtomToLat(const _atom& in_at, const xmatrix<double>& lattice) {
226 xvector<double> cpos(3);
227 xvector<double> p_cell0(3);
228 xvector<int> ijk;
229 _atom out_at = in_at;
230 cpos = in_at.cpos;
231 GetUnitCellRep(cpos, p_cell0, ijk, lattice, true);
232 out_at.fpos = C2F(lattice, cpos);
233 out_at.ijk = ijk;
234 return out_at;
235}
236
237// **************************************************************************
238// Function GetXrayScattFactor
239// **************************************************************************
240double GetXrayScattFactor(const string& _name, double lambda, bool clean) {
241 string name = _name; // CO20190322
242 if (clean) {
243 name = KBIN::VASP_PseudoPotential_CleanName(name);
244 } // CO20190322
245 if (lambda) {
246 ;
247 } // phony just to keep lambda busy
248 // Does not use lambda for now.
249 double scatt_fact = 0.0;
250 for (size_t iat = 0; iat < vatom_name.size(); iat++) {
251 if (name == vatom_name[iat] || name == vatom_symbol[iat]) {
252 scatt_fact = vatom_xray_scatt[iat];
253 }
254 }
255 return scatt_fact;
256}
257
258// ***************************************************************************
259// Function GetVol
260// ***************************************************************************
261// This function returns the volume of the cell from the lattice parameters
262namespace pflow {
263 double GetVol(const xmatrix<double>& lat) {
265 }
266 double GetVol(const aurostd::matrix<double>& lat) { // CO20200404 pflow::matrix()->aurostd::matrix()
268 }
269} // namespace pflow
270
271// ***************************************************************************
272// Function GetSignedVol
273// ***************************************************************************
274// This function returns the volume of the cell from the lattice parameters
275namespace pflow {
276 double GetSignedVol(const xmatrix<double>& lat) {
277 double vol;
278 xvector<double> u(3);
279 u = aurostd::vector_product(lat(2), lat(3));
280 vol = aurostd::scalar_product(lat(1), u);
281 return vol;
282 }
283 double GetSignedVol(const aurostd::matrix<double>& lat) { // CO20200404 pflow::matrix()->aurostd::matrix()
284 return pflow::GetSignedVol(aurostd::matrix2xmatrix(lat)); // CO20200404 pflow::matrix()->aurostd::matrix()
285 }
286} // namespace pflow
287
288// ***************************************************************************
289// Function RecipLat xmatrix<double>
290// ***************************************************************************
291namespace pflow {
293 const xmatrix<double> rlat(3, 3);
294 xvector<double> rlat1(3);
295 xvector<double> rlat2(3);
296 xvector<double> rlat3(3);
297 const double vol = pflow::GetSignedVol(lat);
298 rlat1 = (2.0 * PI / vol) * aurostd::vector_product(lat(2), lat(3));
299 rlat2 = (2.0 * PI / vol) * aurostd::vector_product(lat(3), lat(1));
300 rlat3 = (2.0 * PI / vol) * aurostd::vector_product(lat(1), lat(2));
301 for (int i = 1; i <= 3; i++) {
302 rlat(1, i) = rlat1(i);
303 }
304 for (int i = 1; i <= 3; i++) {
305 rlat(2, i) = rlat2(i);
306 }
307 for (int i = 1; i <= 3; i++) {
308 rlat(3, i) = rlat3(i);
309 }
310 return rlat;
311 }
312} // namespace pflow
313
314// ***************************************************************************
315// Function RecipLat aurostd::matrix<double>
316// ***************************************************************************
317namespace pflow {
318 aurostd::matrix<double> RecipLat(const aurostd::matrix<double>& lat) { // CO20200404 pflow::matrix()->aurostd::matrix()
319 aurostd::matrix<double> rlat(3, 3); // CO20200404 pflow::matrix()->aurostd::matrix()
320 const double vol = pflow::GetSignedVol(lat);
321 rlat[0] = pflow::SVprod(2.0 * PI / vol, pflow::VVcross(lat[1], lat[2]));
322 rlat[1] = pflow::SVprod(2.0 * PI / vol, pflow::VVcross(lat[2], lat[0]));
323 rlat[2] = pflow::SVprod(2.0 * PI / vol, pflow::VVcross(lat[0], lat[1]));
324 return rlat;
325 }
326} // namespace pflow
327
328// ***************************************************************************
329// Function SetCpos
330// ***************************************************************************
331namespace pflow {
332 _atom SetCpos(const _atom& a, const vector<double>& in_cpos) {
333 assert(in_cpos.size() == 3);
334 _atom b;
335 b = a;
336 b.cpos(1) = in_cpos.at(0);
337 b.cpos(2) = in_cpos.at(1);
338 b.cpos(3) = in_cpos.at(2);
339 return b;
340 }
341} // namespace pflow
342
343// ***************************************************************************
344// Function SetFpos
345// ***************************************************************************
346namespace pflow {
347 _atom SetFpos(const _atom& a, const vector<double>& in_fpos) {
348 assert(in_fpos.size() == 3);
349 _atom b;
350 b = a;
351 b.fpos(1) = in_fpos.at(0);
352 b.fpos(2) = in_fpos.at(1);
353 b.fpos(3) = in_fpos.at(2);
354 return b;
355 }
356} // namespace pflow
357
358// ***************************************************************************
359// Function vecF2C
360// ***************************************************************************
361// This function converts a vector in direct to cartesian
362namespace pflow {
363 vector<double> vecF2C(const aurostd::matrix<double>& lat, const vector<double>& vf) { // CO20200404 pflow::matrix()->aurostd::matrix()
364 vector<double> vc(3, 0.0);
365 for (int ic = 0; ic < 3; ic++) {
366 for (int jc = 0; jc < 3; jc++) {
367 vc[ic] = vc[ic] + vf[jc] * lat[jc][ic];
368 }
369 }
370 return vc;
371 }
372} // namespace pflow
373
374// ***************************************************************************
375// Function vecC2F
376// ***************************************************************************
377// This function converts a vector in direct to cartesian
378namespace pflow {
379 vector<double> vecC2F(const aurostd::matrix<double>& lat, const vector<double>& vc) { // CO20200404 pflow::matrix()->aurostd::matrix()
380 vector<double> vf(3, 0.0);
381 vf = aurostd::xvector2vector(C2F(matrix2xmatrix(lat), aurostd::vector2xvector(vc)));
382 return vf;
383 }
384} // namespace pflow
385
386// ***************************************************************************
387// Function SetName
388// ***************************************************************************
389namespace pflow {
390 _atom SetName(const _atom& a, const string& in_name) {
391 _atom b;
392 b = a;
393 b.name = in_name;
394 return b;
395 }
396} // namespace pflow
397
398// ***************************************************************************
399// Function SetType
400// ***************************************************************************
401namespace pflow {
402 _atom SetType(const _atom& a, const int in_type) {
403 _atom b;
404 b = a;
405 b.type = in_type; // CONVASP_MODE
406 return b;
407 }
408} // namespace pflow
409
410// ***************************************************************************
411// Function SetNum
412// ***************************************************************************
413namespace pflow {
414 _atom SetNum(const _atom& a, const int in_num) {
415 _atom b;
416 b = a;
417 b.basis = in_num; //[CO20200130 - number->basis]b.number=in_num;
418 return b;
419 }
420} // namespace pflow
421
422// ***************************************************************************
423// Function GetFpos
424// ***************************************************************************
425namespace pflow {
426 aurostd::matrix<double> GetFpos(const xstructure& str) { // CO20200404 pflow::matrix()->aurostd::matrix()
427 const int num_atoms = str.atoms.size();
428 aurostd::matrix<double> fpos(num_atoms, 3);
429 pflow::VVset(fpos, 0.0); // CO20200404 pflow::matrix()->aurostd::matrix()
430 for (int i = 0; i < num_atoms; i++) {
431 for (int j = 0; j < 3; j++) {
432 fpos[i][j] = str.atoms.at(i).fpos(j + 1);
433 }
434 }
435 return fpos;
436 }
437} // namespace pflow
438
439// ***************************************************************************
440// Function GetCpos
441// ***************************************************************************
442namespace pflow {
443 aurostd::matrix<double> GetCpos(const xstructure& str) { // CO20200404 pflow::matrix()->aurostd::matrix()
444 const int num_atoms = str.atoms.size();
445 aurostd::matrix<double> cpos(num_atoms, 3);
446 pflow::VVset(cpos, 0.0); // CO20200404 pflow::matrix()->aurostd::matrix()
447 for (int i = 0; i < num_atoms; i++) {
448 for (int j = 0; j < 3; j++) {
449 cpos[i][j] = str.atoms.at(i).cpos(j + 1);
450 }
451 }
452 return cpos;
453 }
454} // namespace pflow
455
456// ***************************************************************************
457// Function SetLat
458// ***************************************************************************
459xstructure SetLat(const xstructure& a, const xmatrix<double>& in_lat) {
460 xstructure b(a);
461 b.lattice = in_lat;
462 return b;
463}
464namespace pflow {
465 xstructure SetLat(const xstructure& a, const aurostd::matrix<double>& in_lat) { // CO20200404 pflow::matrix()->aurostd::matrix()
466 xstructure b(a);
467 b.lattice = aurostd::matrix2xmatrix(in_lat); // CO20200404 pflow::matrix()->aurostd::matrix()
468 return b;
469 }
470} // namespace pflow
471
472// ***************************************************************************
473// Function GetLat
474// ***************************************************************************
475xmatrix<double> GetLat(const xstructure& a) {
476 return a.lattice;
477}
478namespace pflow {
479 aurostd::matrix<double> GetLat(const xstructure& a) { // CO20200404 pflow::matrix()->aurostd::matrix()
480 return aurostd::xmatrix2matrix(a.lattice); // CO20200404 pflow::matrix()->aurostd::matrix()
481 }
482} // namespace pflow
483
484// ***************************************************************************
485// Function GetScale
486// ***************************************************************************
487namespace pflow {
488 double GetScale(const xstructure& a) {
489 return a.scale;
490 }
491} // namespace pflow
492
493// ***************************************************************************
494// Function GetScaledLat
495// ***************************************************************************
496namespace pflow {
497 aurostd::matrix<double> GetScaledLat(const xstructure& a) { // CO20200404 pflow::matrix()->aurostd::matrix()
498 return aurostd::xmatrix2matrix(a.scale * a.lattice); // CO20200404 pflow::matrix()->aurostd::matrix()
499 }
500} // namespace pflow
501
502// ***************************************************************************
503// ***************************************************************************
504
505// ***************************************************************************
506// ***************************************************************************
507
508// ***************************************************************************
509// Function AddAllAtomPos
510// ***************************************************************************
511namespace pflow {
512 xstructure AddAllAtomPos(const xstructure& a,
513 const aurostd::matrix<double>& in_pos, // CO20200404 pflow::matrix()->aurostd::matrix()
514 const int in_coord_flag) {
515 assert(in_coord_flag == 0 || in_coord_flag == 1);
516 xstructure b(a);
517 b.atoms.clear();
518 _atom atom;
519 if (in_coord_flag == 0) {
520 for (size_t i = 0; i < in_pos.size(); i++) {
521 // atom=a.atoms.at(i); // start from scratch
522 for (int j = 1; j <= 3; j++) {
523 atom.fpos(j) = in_pos[i][j - 1];
524 }
525 atom.cpos = F2C(b.lattice, atom.fpos);
526 b.atoms.push_back(atom);
527 }
528 }
529 if (in_coord_flag == 1) {
530 for (size_t i = 0; i < in_pos.size(); i++) {
531 // atom=a.atoms.at(i); // start from scratch
532 for (int j = 1; j <= 3; j++) {
533 atom.cpos(j) = in_pos[i][j - 1];
534 }
535 atom.fpos = C2F(b.lattice, atom.cpos);
536 b.atoms.push_back(atom);
537 }
538 }
539 return b;
540 }
541} // namespace pflow
542
543// ***************************************************************************
544// Function SetAllAtomPos
545// ***************************************************************************
546namespace pflow {
547 xstructure SetAllAtomPos(const xstructure& a,
548 const aurostd::matrix<double>& in_pos, // CO20200404 pflow::matrix()->aurostd::matrix()
549 const int in_coord_flag) {
550 assert(in_coord_flag == 0 || in_coord_flag == 1);
551 xstructure b(a);
552 b.atoms.clear();
553 _atom atom;
554 if (in_coord_flag == 0) {
555 for (size_t i = 0; i < in_pos.size(); i++) {
556 atom = a.atoms.at(i);
557 for (int j = 1; j <= 3; j++) {
558 atom.fpos(j) = in_pos[i][j - 1];
559 }
560 atom.cpos = F2C(b.lattice, atom.fpos);
561 b.atoms.push_back(atom);
562 }
563 }
564 if (in_coord_flag == 1) {
565 for (size_t i = 0; i < in_pos.size(); i++) {
566 atom = a.atoms.at(i);
567 for (int j = 1; j <= 3; j++) {
568 atom.cpos(j) = in_pos[i][j - 1];
569 }
570 atom.fpos = C2F(b.lattice, atom.cpos);
571 b.atoms.push_back(atom);
572 }
573 }
574 return b;
575 }
576} // namespace pflow
577
578// ***************************************************************************
579// Function SetAllAtomNames
580// ***************************************************************************
581namespace pflow {
582 xstructure SetAllAtomNames(const xstructure& a, const vector<string>& in) {
583 xstructure b(a);
584 if (in.size() == a.num_each_type.size()) {
585 throw aurostd::xerror(__AFLOW_FILE__, __AFLOW_FUNC__, "this routine must be fixed, it does not work here", _RUNTIME_ERROR_);
586
587 for (size_t iat = 0; iat < b.num_each_type.size(); iat++) {
588 b.atoms.at(iat).name = in.at(b.atoms.at(iat).type); // CONVASP_MODE
589 if (!b.atoms.at(iat).name.empty()) {
590 b.atoms.at(iat).name_is_given = true;
591 b.atoms.at(iat).CleanName();
592 // DX20170921 - Need to keep spin info b.atoms.at(iat).CleanSpin();
593 }
594 }
595 return b;
596 }
597 if (in.size() == a.atoms.size()) {
598 for (size_t iat = 0; iat < b.atoms.size(); iat++) {
599 b.atoms[iat].name = in[iat];
600 b.atoms[iat].name_is_given = true;
601 b.atoms[iat].CleanName();
602 // DX20170921 - Need to keep spin info b.atoms.at(iat).CleanSpin();
603 }
604 return b;
605 }
606 stringstream message;
607 message << "Must specify as many names as types/bases: in.size()=" << in.size(); //[CO20200130 - number->basis]
608 message << " =a.num_each_type.size()=" << a.num_each_type.size();
609 message << " =a.atoms.size()=" << a.atoms.size();
611 }
612} // namespace pflow
613
614// ***************************************************************************
615// Function SetNamesWereGiven
616// ***************************************************************************
617namespace pflow {
618 xstructure SetNamesWereGiven(const xstructure& a, const vector<int>& in) {
619 xstructure b(a);
620 if (in.size() == a.num_each_type.size()) {
621 throw aurostd::xerror(__AFLOW_FILE__, __AFLOW_FUNC__, "this routine must be fixed... it does not work here", _RUNTIME_ERROR_);
622 for (size_t iat = 0; iat < b.num_each_type.size(); iat++) {
623 b.atoms.at(iat).name_is_given = in.at(b.atoms.at(iat).type); // CONVASP_MODE
624 }
625 return b;
626 }
627 if (in.size() == a.atoms.size()) {
628 for (size_t iat = 0; iat < b.atoms.size(); iat++) {
629 b.atoms[iat].name_is_given = in[iat];
630 }
631 return b;
632 }
633 stringstream message;
634 message << "Must specify as many names as types/bases: in.size()=" << in.size(); //[CO20200130 - number->basis]
635 message << " =a.num_each_type.size()=" << a.num_each_type.size();
636 message << " =a.atoms.size()=" << a.atoms.size();
638 }
639} // namespace pflow
640
641// ***************************************************************************
642// Function SetOrigin
643// ***************************************************************************
644namespace pflow {
645 xstructure SetOrigin(const xstructure& a, const vector<double>& in_origin) {
646 const xstructure b(a);
647 for (uint i = 1; i <= 3; i++) {
648 b.origin[i] = in_origin.at(i - 1);
649 }
650 return b;
651 }
652 xstructure SetOrigin(const xstructure& a, const xvector<double>& in_origin) {
653 const xstructure b(a);
654 for (uint i = 1; i <= 3; i++) {
655 b.origin[i] = in_origin[i];
656 }
657 return b;
658 }
659} // namespace pflow
660
661// ***************************************************************************
662// Function VVequal
663// ***************************************************************************
664// This function checks if two vectors are equal. double/int
665namespace pflow {
666 // vector
667 bool VVequal(const vector<double>& a, const vector<double>& b) {
668 const double tol = 1e-15;
669 const int size = std::min((int) a.size(), (int) b.size());
670 for (int i = 0; i < size; i++) {
671 if (aurostd::abs(a[i] - b[i]) > tol) {
672 return false;
673 }
674 }
675 return true;
676 }
677 bool VVequal(const vector<int>& a, const vector<int>& b) {
678 const double tol = 1e-15;
679 const int size = std::min((int) a.size(), (int) b.size());
680 for (int i = 0; i < size; i++) {
681 if (aurostd::abs((double) (a[i] - b[i])) > tol) {
682 return false;
683 }
684 }
685 return true;
686 }
687 // deque
688 bool VVequal(const deque<double>& a, const deque<double>& b) {
689 const double tol = 1e-15;
690 const int size = std::min((int) a.size(), (int) b.size());
691 for (int i = 0; i < size; i++) {
692 if (aurostd::abs(a[i] - b[i]) > tol) {
693 return false;
694 }
695 }
696 return true;
697 }
698 bool VVequal(const deque<int>& a, const deque<int>& b) {
699 const double tol = 1e-15;
700 const int size = std::min((int) a.size(), (int) b.size());
701 for (int i = 0; i < size; i++) {
702 if (aurostd::abs((double) (a[i] - b[i])) > tol) {
703 return false;
704 }
705 }
706 return true;
707 }
708
709} // namespace pflow
710// ***************************************************************************
711// Function SmoothFunc
712// ***************************************************************************
713// This function smooths an input functions.
714// Uses gaussian smoothing for now.
715// Assumes function argument is integer given by vector id.
716// Sigma is in units of function arguments (i.e., vector id).
717// Dane Morgan
718namespace pflow {
719 vector<double> SmoothFunc(const vector<double>& func, const double& sigma) {
720 if (sigma < 1e-10) {
721 return func;
722 }
723 const int nx = func.size();
724 const int range = (int) (5.0 * sigma);
725 // Get Gaussian weights
726 vector<double> norm(nx, 0.0);
727 aurostd::matrix<double> wt(nx, 2 * range + 1);
728 pflow::VVset(wt, 0.0); // CO20200404 pflow::matrix()->aurostd::matrix()
729
730 for (int ix = 0; ix < nx; ix++) {
731 for (int i = -range; i <= range; i++) {
732 if ((ix + i) >= 0 && (ix + i) < nx) {
733 wt[ix][i + range] = Normal((double) (ix + i), double(ix), sigma);
734 norm[ix] = norm[ix] + wt[ix][i + range];
735 }
736 }
737 }
738 // Normalize to one
739 for (int ix = 0; ix < nx; ix++) {
740 for (int i = -range; i <= range; i++) {
741 wt[ix][i + range] = wt[ix][i + range] / norm[ix];
742 }
743 }
744
745 vector<double> sfunc(nx, 0.0);
746 // Average in weighted nearby bins.
747 for (int ix = 0; ix < nx; ix++) {
748 double sf = 0;
749 for (int i = -range; i <= range; i++) {
750 if ((ix + i) > 0 && (ix + i) < nx) {
751 sf += wt[ix][i + range] * func[ix + i];
752 }
753 }
754 sfunc[ix] = sf;
755 }
756 return sfunc;
757 }
758} // namespace pflow
759// ***************************************************************************
760// Function Normal
761// ***************************************************************************
762// This function returns the value of a normal distribution.
763double Normal(const double& x, const double& mu, const double& sigma) {
764 const double tol = 1e-12;
765 // If sigma=0 return delta function
766 if (std::abs(sigma) < tol) {
767 if (std::abs(x - mu) < tol) {
768 return 1;
769 } else {
770 return 0;
771 }
772 }
773 const double arg = -(x - mu) * (x - mu) / (2 * sigma * sigma);
774 return exp(arg) / (sqrt(TWOPI) * sigma);
775}
776
777// ***************************************************************************
778// Function Set
779// ***************************************************************************
780// This function sets a vector of vector with the proper values
781namespace pflow {
782 void VVset(aurostd::matrix<double>& mat, const double& value) { // CO20200404 pflow::matrix()->aurostd::matrix()
783 for (size_t i = 0; i < mat.size(); i++) {
784 for (size_t j = 0; j < mat[i].size(); j++) {
785 mat[i][j] = (double) value;
786 }
787 }
788 }
789 void VVset(vector<vector<int>>& mat, const int& value) {
790 for (size_t i = 0; i < mat.size(); i++) {
791 for (size_t j = 0; j < mat[i].size(); j++) {
792 mat[i][j] = (int) value;
793 }
794 }
795 }
796} // namespace pflow
797
798// ***************************************************************************
799// Function norm
800// ***************************************************************************
801// This function finds the norm of a vector
802// Dane Morgan style
803namespace pflow {
804 // template<class utype>
805 double norm(const vector<double>& v) {
806 double sum = 0;
807 for (size_t i = 0; i < v.size(); i++) {
808 sum = sum + v[i] * v[i];
809 }
810 // sum=sqrt(aurostd::abs(sum));
811 sum = sqrt(aurostd::abs(sum));
812 return sum;
813 }
814} // namespace pflow
815
816// ***************************************************************************
817// Function getcos
818// ***************************************************************************
819// This function finds the cosine of the angle between
820// two vectors.
821// Dane Morgan style
822namespace pflow {
823 // template<class utype>
824 double getcos(const vector<double>& a, const vector<double>& b) {
825 double sum = 0.0;
826 const uint size = std::min((uint) a.size(), (uint) b.size());
827 for (uint i = 0; i < size; i++) {
828 sum = sum + a[i] * b[i];
829 }
830 const double na = pflow::norm(a);
831 const double nb = pflow::norm(b);
832 assert(na > 0.0 && nb > 0.0);
833 sum = sum / (na * nb);
834 return sum;
835 }
836} // namespace pflow
837
838// ***************************************************************************
839// Function Getabc_angles
840// ***************************************************************************
841// This function returns a,b,c,alpha,beta,gamma for the cell
842// given the lattice vectors.
843// Dane Morgan style
844namespace pflow {
845 // template<class utype>
846 vector<double> Getabc_angles(const aurostd::matrix<double>& lat) { // CO20200404 pflow::matrix()->aurostd::matrix()
847 // cerr << lat[0][0] << " " << lat[0][1] << " " << lat[0][2] << endl;
848 // cerr << lat[1][0] << " " << lat[1][1] << " " << lat[1][2] << endl;
849 // cerr << lat[2][0] << " " << lat[2][1] << " " << lat[2][2] << endl;
850 vector<double> data;
851 data.push_back(pflow::norm(lat[0])); // cerr << data.at(data.size()-1) << endl;
852 data.push_back(pflow::norm(lat[1])); // cerr << data.at(data.size()-1) << endl;
853 data.push_back(pflow::norm(lat[2])); // cerr << data.at(data.size()-1) << endl;
854 data.push_back(acos(pflow::getcos(lat[1], lat[2]))); // cerr << data.at(data.size()-1) << endl;
855 data.push_back(acos(pflow::getcos(lat[0], lat[2]))); // cerr << data.at(data.size()-1) << endl;
856 data.push_back(acos(pflow::getcos(lat[0], lat[1]))); // cerr << data.at(data.size()-1) << endl;
857 return data;
858 }
859} // namespace pflow
860
861// namespace pflow {
862// void dont_run_this(void) {
863// {
864// vector<float> d;pflow::norm(d);pflow::getcos(d,d);
865// aurostd::matrix<float> D;pflow::Getabc_angles(D); //CO20200404 pflow::matrix()->aurostd::matrix()
866// }
867// {
868// vector<double> d;pflow::norm(d);pflow::getcos(d,d);
869// aurostd::matrix<double> D;pflow::Getabc_angles(D); //CO20200404 pflow::matrix()->aurostd::matrix()
870// }
871// {
872// vector<long double> d;pflow::norm(d);pflow::getcos(d,d);
873// aurostd::matrix<long double> D;pflow::Getabc_angles(D); //CO20200404 pflow::matrix()->aurostd::matrix()
874// }
875// }
876// }
877
878// ***************************************************************************
879// Function Sort_abc_angles
880// ***************************************************************************
881// This fucntions sorts lattice vectors to a>=b>=c and
882// arranges angles equivalently.
883// Dane Morgan style
884namespace pflow {
885 vector<double> Sort_abc_angles(const vector<double>& abc_angles) {
886 vector<double> old = abc_angles;
887 vector<double> newv = abc_angles;
888 // if b>a then swap a/b: a=b,b=a,c=c,alpha=beta,beta=alpha,gamma=gamma.
889 if (old[1] > old[0]) {
890 newv[0] = old[1];
891 newv[1] = old[0];
892 newv[3] = old[4];
893 newv[4] = old[3];
894 old = newv;
895 }
896 // if c>a then swap a/c: a=c,b=b,c=a,alpha=gamma,beta=beta,gamma=alpha.
897 if (old[2] > old[0]) {
898 newv[0] = old[2];
899 newv[2] = old[0];
900 newv[3] = old[5];
901 newv[5] = old[3];
902 old = newv;
903 }
904 // if c>b then swap b/c: a=a,b=c,c=b,alpha=alpha,beta=gamma,gamma=beta.
905 if (old[2] > old[1]) {
906 newv[1] = old[2];
907 newv[2] = old[1];
908 newv[4] = old[5];
909 newv[5] = old[4];
910 old = newv;
911 }
912 return newv;
913 }
914} // namespace pflow
915
916// ***************************************************************************
917// Function Vout
918// ***************************************************************************
919// This function outputs a vector.
920// Dane Morgan style
921namespace pflow {
922 void Vout(const vector<double>& a, ostream& out) {
923 for (size_t i = 0; i < a.size(); i++) {
924 out << a[i] << " ";
925 }
926 out << endl;
927 }
928 void Vout(const vector<int>& a, ostream& out) {
929 for (size_t i = 0; i < a.size(); i++) {
930 out << a[i] << " ";
931 }
932 out << endl;
933 }
934 void Vout(const vector<string>& a, ostream& out) {
935 for (size_t i = 0; i < a.size(); i++) {
936 out << a[i] << " ";
937 }
938 out << endl;
939 }
940} // namespace pflow
941
942// ***************************************************************************
943// Function Mout
944// ***************************************************************************
945// This function outputs a matrix.
946// Dane Morgan style
947namespace pflow {
948 void Mout(const aurostd::matrix<double>& m, ostream& out) { // CO20200404 pflow::matrix()->aurostd::matrix()
949 for (size_t i = 0; i < m.size(); i++) {
950 for (size_t j = 0; j < m[i].size(); j++) {
951 out << m[i][j] << " ";
952 }
953 out << endl;
954 }
955 }
956 void Mout(const vector<vector<double>>& m, ostream& out) {
957 for (size_t i = 0; i < m.size(); i++) {
958 for (size_t j = 0; j < m[i].size(); j++) {
959 out << m[i][j] << " ";
960 }
961 out << endl;
962 }
963 }
964} // namespace pflow
965
966// **************************************************
967// Function SVprod
968// **************************************************
969// This function returns the product of a scalar and a vector.
970namespace pflow {
971 vector<double> SVprod(const double& s, const vector<double>& b) {
972 const int size = b.size();
973 vector<double> prod(size);
974 for (int i = 0; i < size; i++) {
975 prod[i] = s * b[i];
976 }
977 return prod;
978 }
979 vector<int> SVprod(const int& s, const vector<int>& b) {
980 const int size = b.size();
981 vector<int> prod(size);
982 for (int i = 0; i < size; i++) {
983 prod[i] = s * b[i];
984 }
985 return prod;
986 }
987} // namespace pflow
988
989// **************************************************
990// Function VVsum
991// **************************************************
992// This function returns the vector sum c=a+b.
993namespace pflow {
994 vector<double> VVsum(const vector<double>& a, const vector<double>& b) {
995 const int size = std::min(a.size(), b.size());
996 vector<double> c(size);
997 for (int i = 0; i < size; i++) {
998 c[i] = a[i] + b[i];
999 }
1000 return c;
1001 }
1002 vector<double> VVsum(const vector<double>& a, const vector<int>& b) {
1003 const int size = std::min(a.size(), b.size());
1004 vector<double> c(size);
1005 for (int i = 0; i < size; i++) {
1006 c[i] = a[i] + b[i];
1007 }
1008 return c;
1009 }
1010} // namespace pflow
1011
1012// **************************************************
1013// Function VVdiff
1014// **************************************************
1015// This function returns the vector c=a-b.
1016namespace pflow {
1017 vector<double> VVdiff(const vector<double>& a, const vector<double>& b) {
1018 const int size = std::min(a.size(), b.size());
1019 vector<double> c(size);
1020 for (int i = 0; i < size; i++) {
1021 c[i] = a[i] - b[i];
1022 }
1023 return c;
1024 }
1025} // namespace pflow
1026
1027// **************************************************
1028// Function VVprod
1029// **************************************************
1030// This function returns the scalar c=a*b.
1031// Dane Morgan style
1032namespace pflow {
1033 double VVprod(const vector<double>& a, const vector<double>& b) {
1034 const int size = std::min(a.size(), b.size());
1035 double c = 0;
1036 for (int i = 0; i < size; i++) {
1037 c = c + a[i] * b[i];
1038 }
1039 return c;
1040 }
1041 double VVprod(const vector<double>& a, const vector<int>& b) {
1042 const int size = std::min(a.size(), b.size());
1043 double c = 0;
1044 for (int i = 0; i < size; i++) {
1045 c = c + a[i] * b[i];
1046 }
1047 return c;
1048 }
1049} // namespace pflow
1050
1051// ***************************************************************************
1052// Function MMmult
1053// ***************************************************************************
1054// This function returns the product of two matrices.
1055// a=MxN, b=NxM.
1056// Dane Morgan style
1057namespace pflow {
1058 aurostd::matrix<double> MMmult(const aurostd::matrix<double>& a, const aurostd::matrix<double>& b) { // CO20200404 pflow::matrix()->aurostd::matrix()
1059 const uint M = std::min((uint) a.size(), (uint) b[0].size());
1060 const uint N = std::min((uint) a[0].size(), (uint) b.size());
1061 const vector<double> v(M, 0.0);
1062 aurostd::matrix<double> c(M, v); // CO20200404 pflow::matrix()->aurostd::matrix()
1063 for (uint i = 0; i < M; i++) {
1064 for (uint j = 0; j < M; j++) {
1065 double sum = 0.0;
1066 for (uint k = 0; k < N; k++) {
1067 sum = sum + a[i][k] * b[k][j];
1068 }
1069 c[i][j] = sum;
1070 }
1071 }
1072 return c;
1073 }
1074} // namespace pflow
1075
1076// ***************************************************************************
1077// Function MVmult
1078// ***************************************************************************
1079// This function returns the product of a matric and a vector A*v.
1080// A=MxN, v=Nx1.
1081// Dane Morgan style
1082namespace pflow {
1083 vector<double> MVmult(const aurostd::matrix<double>& A, const vector<double>& v) { // CO20200404 pflow::matrix()->aurostd::matrix()
1084 const uint M = A.size();
1085 const uint N = std::min((uint) A[0].size(), (uint) v.size());
1086 vector<double> u(M, 0.0);
1087 for (uint i = 0; i < M; i++) {
1088 double sum = 0;
1089 for (uint j = 0; j < N; j++) {
1090 sum = sum + A[i][j] * v[j];
1091 }
1092 u[i] = sum;
1093 }
1094 return u;
1095 }
1096} // namespace pflow
1097
1098// ***************************************************************************
1099// Function VMmult
1100// ***************************************************************************
1101// This function returns the product of a row vector and a matrix v*A.
1102// A=MxN, v=1xM. Return vector of length N.
1103// Dane Morgan style
1104namespace pflow {
1105 vector<double> VMmult(const vector<double>& v, const aurostd::matrix<double>& A) { // CO20200404 pflow::matrix()->aurostd::matrix()
1106 const uint M = A.size();
1107 const uint N = std::min((uint) A[0].size(), (uint) v.size());
1108 vector<double> u(M, 0.0);
1109 for (uint i = 0; i < N; i++) {
1110 double sum = 0;
1111 for (uint j = 0; j < M; j++) {
1112 sum = sum + v[j] * A[j][i];
1113 }
1114 u[i] = sum;
1115 }
1116 return u;
1117 }
1118 vector<double> VMmult(const vector<int>& v, const aurostd::matrix<double>& A) { // CO20200404 pflow::matrix()->aurostd::matrix()
1119 const uint M = A.size();
1120 const uint N = std::min((uint) A[0].size(), (uint) v.size());
1121 vector<double> u(M, 0.0);
1122 for (uint i = 0; i < N; i++) {
1123 double sum = 0;
1124 for (uint j = 0; j < M; j++) {
1125 sum = sum + v[j] * A[j][i];
1126 }
1127 u[i] = sum;
1128 }
1129 return u;
1130 }
1131} // namespace pflow
1132
1133// ***************************************************************************
1134// Function VVcross
1135// ***************************************************************************
1136// This function returns the cross product of two 3 dimensional vectors. */
1137// Dane Morgan style
1138namespace pflow {
1139 vector<double> VVcross(const vector<double>& a, const vector<double>& b) {
1140 if (a.size() != 3 || b.size() != 3) {
1141 return a;
1142 }
1143 vector<double> u(3);
1144 u[0] = a[1] * b[2] - a[2] * b[1];
1145 u[1] = -(a[0] * b[2] - a[2] * b[0]);
1146 u[2] = a[0] * b[1] - a[1] * b[0];
1147 return u;
1148 }
1149} // namespace pflow
1150
1151// ***************************************************************************
1152// Function VVdot
1153// ***************************************************************************
1154// This function returns the dot product of two vectors. */
1155// Dane Morgan style
1156namespace pflow {
1157 double VVdot(const vector<double>& a, const vector<double>& b) {
1158 double sum = 0;
1159 const int size = std::min(a.size(), b.size());
1160 for (int i = 0; i < size; i++) {
1161 sum = sum + a[i] * b[i];
1162 }
1163 return sum;
1164 }
1165} // namespace pflow
1166
1167// ***************************************************************************
1168// Function GetNumAtoms
1169// ***************************************************************************
1170// This function returns the number of atoms in a structure
1171namespace pflow {
1172 int GetNumAtoms(const xstructure& a) {
1173 return a.atoms.size();
1174 }
1175} // namespace pflow
1176
1177// ***************************************************************************
1178// Function SetSpline
1179// ***************************************************************************
1180// This function finds the second derivates so that
1181// spline interpolations can be evaluated quickly.
1182// I have shifted all indices to go from 0->(n-1).
1183namespace pflow {
1184 void SetSpline(const vector<double>& x, const vector<double>& y, const double& yp1, const double& ypn, vector<double>& y2) {
1185 int i;
1186 int k;
1187 double p;
1188 double qn;
1189 double sig;
1190 double un;
1191 const int n = x.size();
1192
1193 vector<double> u(n - 1);
1194 y2 = vector<double>(n, 0.0);
1195
1196 if (yp1 > 0.99e30) {
1197 y2[0] = u[0] = 0.0;
1198 } else {
1199 y2[0] = -0.5;
1200 u[0] = (3.0 / (x[2] - x[1])) * ((y[1] - y[0]) / (x[1] - x[0]) - yp1);
1201 }
1202 for (i = 1; i <= n - 2; i++) {
1203 sig = (x[i] - x[i - 1]) / (x[i + 1] - x[i - 1]);
1204 p = sig * y2[i - 1] + 2.0;
1205 y2[i] = (sig - 1.0) / p;
1206 u[i] = (y[i + 1] - y[i]) / (x[i + 1] - x[i]) - (y[i] - y[i - 1]) / (x[i] - x[i - 1]);
1207 u[i] = (6.0 * u[i] / (x[i + 1] - x[i - 1]) - sig * u[i - 1]) / p;
1208 }
1209 if (ypn > 0.99e30) {
1210 qn = un = 0.0;
1211 } else {
1212 qn = 0.5;
1213 un = (3.0 / (x[n - 1] - x[n - 2])) * (ypn - (y[n - 1] - y[n - 2]) / (x[n - 1] - x[n - 2]));
1214 }
1215 y2[n - 1] = (un - qn * u[n - 2]) / (qn * y2[n - 2] + 1.0);
1216 for (k = n - 2; k >= 0; k--) {
1217 y2[k] = y2[k] * y2[k + 1] + u[k];
1218 }
1219 }
1220} // namespace pflow
1221
1222// ***************************************************************************
1223// Function GetSplineInt
1224// ***************************************************************************
1225// This function finds the value of a function y at a
1226// point x from a spline interpolation. You must run
1227// SetSpline first.
1228// I have shifted all indices to go from 0->(n-1).
1229namespace pflow {
1230 void GetSplineInt(const vector<double>& xa, const vector<double>& ya, vector<double>& y2a, const double& x, double& y) {
1231 int klo;
1232 int khi;
1233 int k;
1234 double h;
1235 double b;
1236 double a;
1237 const int n = xa.size();
1238
1239 klo = 0;
1240 khi = n - 1;
1241 while (khi - klo > 1) {
1242 k = (khi + klo) >> 1;
1243 if (xa[k] > x) {
1244 khi = k;
1245 } else {
1246 klo = k;
1247 }
1248 }
1249 h = xa[khi] - xa[klo];
1250 if (h == 0.0) {
1251 throw aurostd::xerror(__AFLOW_FILE__, __AFLOW_FUNC__, "Bad xa input to routine splint", _INPUT_ERROR_);
1252 }
1253 a = (xa[khi] - x) / h;
1254 b = (x - xa[klo]) / h;
1255 y = a * ya[klo] + b * ya[khi] + ((a * a * a - a) * y2a[klo] + (b * b * b - b) * y2a[khi]) * (h * h) / 6.0;
1256 }
1257} // namespace pflow
1258
1259// ***************************************************************************
1260// Function PrintSpline
1261// ***************************************************************************
1262// This function prints out the original data and the
1263// spline interpolation with keywords for grep.
1264namespace pflow {
1265 void PrintSpline(const vector<double>& x, const vector<double>& y, const int& npts, ostream& outf) {
1266 outf.setf(std::ios::left, std::ios::adjustfield);
1267 outf.setf(std::ios::fixed, std::ios::floatfield);
1268 outf << "******************** Initial Data ********************" << endl;
1269 const int ndat = x.size();
1270 for (int id = 0; id < ndat; id++) {
1271 outf << x[id] << " " << y[id] << " " << "INPUT" << endl;
1272 }
1273 outf << "******************** Cubic Spline Interpolated Points ********************" << endl;
1274 if (npts == 1) {
1275 outf << x[0] << " " << y[0] << " " << "INTERPOLATED" << endl;
1276 } else {
1277 const double yp1 = 0.0;
1278 const double ypn = 0.0;
1279 vector<double> y2;
1280 SetSpline(x, y, yp1, ypn, y2);
1281 const double xrange = x[ndat - 1] - x[0];
1282 const double dx = xrange / (double) (npts - 1);
1283 for (int ip = 0; ip < npts; ip++) {
1284 const double xp = x[0] + (double) ip * dx;
1285 double yp;
1286 GetSplineInt(x, y, y2, xp, yp);
1287 outf << xp << " " << yp << " " << "INTERPOLATED" << endl;
1288 }
1289 }
1290 }
1291} // namespace pflow
1292
1293#endif
1294
1295// ***************************************************************************
1296// * *
1297// * Aflow STEFANO CURTAROLO - Duke University 2003-2024 *
1298// * *
1299// ***************************************************************************
vector< utype > clear(vector< utype > &v)
xvector< double > F2C(const double &scale, const xmatrix< double > &lattice, const xvector< double > &fpos)
xvector< double > C2F(const double &scale, const xmatrix< double > &lattice, const xvector< double > &cpos)
double Normal(const double &x, const double &mu, const double &sigma)
double GetXrayScattFactor(const string &_name, double lambda, bool clean)
xmatrix< double > GetLat(const xstructure &a)
int Nint(const double &x)
xstructure SetLat(const xstructure &a, const xmatrix< double > &in_lat)
xstructure WignerSeitz(const xstructure &a)
int SignNoZero(const double &x)
xvector< double > GetCDispFromOrigin(const _atom &atom)
xstructure SetMom1(const xstructure &a, const xvector< double > &mom1_new)
double GetDistFromOrigin(const _atom &atom)
int Sign(const double &x)
xvector< double > GetMom1(const xstructure &a)
_atom ConvertAtomToLat(const _atom &in_at, const xmatrix< double > &lattice)
xstructure PutInCell(const xstructure &a)
xstructure PutInCompact(const xstructure &a)
double Normal(const double &x, const double &mu, const double &sigma)
unsigned uint
Definition aurostd.h:39
#define __AFLOW_FILE__
Definition aurostd.h:44
#define __AFLOW_FUNC__
Definition aurostd.h:43
#define TWOPI
#define PI
#define _RUNTIME_ERROR_
#define _INPUT_NUMBER_
#define _INPUT_ERROR_
uint size() const
utype scalar_product(const xvector< utype > &a, const xvector< utype > &b)
xvector< utype > vector_product(const xvector< utype > &a, const xvector< utype > &b)
xmatrix< utype > sign(const xmatrix< utype > &a)
utype abs(const xcomplex< utype > &x)
xvector< utype > vector2xvector(const std::vector< utype > &, int lrows=1) __xprototype
xmatrix< utype > nint(const xmatrix< utype > &a)
vector< utype > xvector2vector(const xvector< utype > &xvec)
matrix< utype > xmatrix2matrix(const xmatrix< utype > &_xmatrix)
xmatrix< utype > matrix2xmatrix(const matrix< utype > &_matrix)
char signnozero(char x)
aurostd::matrix< double > GetFpos(const xstructure &str)
_atom SetName(const _atom &a, const string &in_name)
double VVprod(const vector< double > &a, const vector< double > &b)
xmatrix< double > RecipLat(const xmatrix< double > &lat)
double GetScale(const xstructure &a)
void GetSplineInt(const vector< double > &xa, const vector< double > &ya, vector< double > &y2a, const double &x, double &y)
void Vout(const vector< double > &a, ostream &out)
vector< double > SVprod(const double &s, const vector< double > &b)
double VVdot(const vector< double > &a, const vector< double > &b)
aurostd::matrix< double > MMmult(const aurostd::matrix< double > &a, const aurostd::matrix< double > &b)
void PrintSpline(const vector< double > &x, const vector< double > &y, const int &npts, ostream &outf)
void Mout(const aurostd::matrix< double > &m, ostream &out)
double getcos(const vector< double > &a, const vector< double > &b)
vector< double > VVdiff(const vector< double > &a, const vector< double > &b)
double norm(const vector< double > &v)
xstructure SetLat(const xstructure &a, const aurostd::matrix< double > &in_lat)
vector< double > vecC2F(const aurostd::matrix< double > &lat, const vector< double > &vc)
_atom SetNum(const _atom &a, const int in_num)
xstructure AddAllAtomPos(const xstructure &a, const aurostd::matrix< double > &in_pos, const int in_coord_flag)
xstructure SetAllAtomPos(const xstructure &a, const aurostd::matrix< double > &in_pos, const int in_coord_flag)
aurostd::matrix< double > GetScaledLat(const xstructure &a)
void SetSpline(const vector< double > &x, const vector< double > &y, const double &yp1, const double &ypn, vector< double > &y2)
_atom SetFpos(const _atom &a, const vector< double > &in_fpos)
xstructure SetAllAtomNames(const xstructure &a, const vector< string > &in_names)
_atom SetCpos(const _atom &a, const vector< double > &in_cpos)
void VVset(aurostd::matrix< double > &mat, const double &value)
vector< double > MVmult(const aurostd::matrix< double > &A, const vector< double > &v)
_atom SetType(const _atom &a, const int in_type)
vector< double > VVcross(const vector< double > &a, const vector< double > &b)
vector< double > SmoothFunc(const vector< double > &func, const double &sigma)
xstructure SetOrigin(const xstructure &a, const vector< double > &in_origin)
double GetSignedVol(const xmatrix< double > &lat)
vector< double > VVsum(const vector< double > &a, const vector< double > &b)
vector< double > vecF2C(const aurostd::matrix< double > &lat, const vector< double > &vf)
aurostd::matrix< double > GetLat(const xstructure &a)
vector< double > VMmult(const vector< double > &v, const aurostd::matrix< double > &A)
int GetNumAtoms(const xstructure &a)
vector< double > Getabc_angles(const aurostd::matrix< double > &lat)
double GetVol(const xmatrix< double > &lat)
vector< double > Sort_abc_angles(const vector< double > &abc_angles)
bool VVequal(const vector< double > &a, const vector< double > &b)
xstructure SetNamesWereGiven(const xstructure &a, const vector< int > &in_names_were_given)
aurostd::matrix< double > GetCpos(const xstructure &str)