Skip to content

Commit

Permalink
Cleanup codes
Browse files Browse the repository at this point in the history
  • Loading branch information
ttadano committed Jan 29, 2018
1 parent b07d8d3 commit 12e9e22
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 67 deletions.
2 changes: 1 addition & 1 deletion alm/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ void Constraint::rotational_invariance()
memory->allocate(interaction_tmp, order + 2);

if (order > 0) {
list_found_last = list_found;
list_found_last = list_found;
nxyz = static_cast<int>(pow(static_cast<double>(3), order));
memory->allocate(xyzcomponent, nxyz, order);
fcs->get_xyzcomponent(order, xyzcomponent);
Expand Down
3 changes: 1 addition & 2 deletions alm/constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ namespace ALM_NS

void remove_redundant_rows(const int, std::vector<ConstraintClass> &,
const double tolerance = eps12);
// void remove_redundant_rows_integer(const int, std::vector<std::vector<int>> &);
// void remove_redundant_rows_integer(const int, std::vector<std::vector<int>> &);

void rref(int, int, double **, int &, double tolerance = eps12);
void rref(std::vector<std::vector<double>> &, const double tolerance = eps12);
Expand All @@ -175,6 +175,5 @@ namespace ALM_NS
{
void dgetrf_(int *m, int *n, double *a, int *lda, int *ipiv, int *info);
void sgetrf_(int *m, int *n, float *a, int *lda, int *ipiv, int *info);

}
}
4 changes: 2 additions & 2 deletions alm/fcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace ALM_NS
a.elems.begin(), a.elems.end());
}

bool operator==(const FcProperty &a) const
bool operator==(const FcProperty &a) const
{
int n = elems.size();
int n_ = a.elems.size();
Expand Down Expand Up @@ -117,7 +117,7 @@ namespace std
template <>
struct hash<ALM_NS::FcProperty>
{
std::size_t operator () (ALM_NS::FcProperty const &obj) const
std::size_t operator ()(ALM_NS::FcProperty const &obj) const
{
hash<int> hasher;
size_t seed = 0;
Expand Down
5 changes: 2 additions & 3 deletions alm/fitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,10 +1098,10 @@ void Fitting::calc_matrix_elements_algebraic_constraint(const int M,
long ncycle;

std::cout << " Calculation of matrix elements for direct fitting started ... ";

ncycle = ndata_fit * nmulti;
long natmin3 = 3 * static_cast<long>(natmin);

#ifdef _OPENMP
#pragma omp parallel for private(j)
#endif
Expand Down Expand Up @@ -1236,7 +1236,6 @@ void Fitting::calc_matrix_elements_algebraic_constraint(const int M,
memory->deallocate(amat_orig);
memory->deallocate(amat_mod);
}

}


Expand Down
2 changes: 1 addition & 1 deletion alm/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ namespace ALM_NS

// memsize calculator


template <typename A>
unsigned long memsize_in_MB(const int size_of_one, const A n1)
{
Expand Down
116 changes: 58 additions & 58 deletions anphon/dynamical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,95 +906,95 @@ void Dynamical::load_born(const unsigned int flag_symmborn)

if (flag_symmborn) {

// Symmetrize Born effective charges. Necessary to avoid the violation of ASR
// particularly for NONANALYTIC=3 (Ewald summation).
// Symmetrize Born effective charges. Necessary to avoid the violation of ASR
// particularly for NONANALYTIC=3 (Ewald summation).

int isym, iat, iat_sym;
int m;
double ***born_sym;
double rot[3][3];
int isym, iat, iat_sym;
int m;
double ***born_sym;
double rot[3][3];

memory->allocate(born_sym, system->natmin, 3, 3);
memory->allocate(born_sym, system->natmin, 3, 3);

for (iat = 0; iat < system->natmin; ++iat) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
born_sym[iat][i][j] = 0.0;
for (iat = 0; iat < system->natmin; ++iat) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
born_sym[iat][i][j] = 0.0;
}
}
}
}

for (isym = 0; isym < symmetry->SymmListWithMap.size(); ++isym) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
rot[i][j] = symmetry->SymmListWithMap[isym].rot[3 * i + j];
for (isym = 0; isym < symmetry->SymmListWithMap.size(); ++isym) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
rot[i][j] = symmetry->SymmListWithMap[isym].rot[3 * i + j];
}
}
}

for (iat = 0; iat < system->natmin; ++iat) {
iat_sym = symmetry->SymmListWithMap[isym].mapping[iat];
for (iat = 0; iat < system->natmin; ++iat) {
iat_sym = symmetry->SymmListWithMap[isym].mapping[iat];

for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
for (k = 0; k < 3; ++k) {
for (m = 0; m < 3; ++m) {
born_sym[iat_sym][i][j] += rot[i][k] * rot[j][m] * borncharge[iat][k][m];
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
for (k = 0; k < 3; ++k) {
for (m = 0; m < 3; ++m) {
born_sym[iat_sym][i][j] += rot[i][k] * rot[j][m] * borncharge[iat][k][m];
}
}
}
}
}
}
}

for (iat = 0; iat < system->natmin; ++iat) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
born_sym[iat][i][j] /= static_cast<double>(symmetry->SymmListWithMap.size());
for (iat = 0; iat < system->natmin; ++iat) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
born_sym[iat][i][j] /= static_cast<double>(symmetry->SymmListWithMap.size());
}
}
}
}

// Check if the Born effective charges given by the users satisfy the symmetry.
// Check if the Born effective charges given by the users satisfy the symmetry.

double diff_sym = 0.0;
for (iat = 0; iat < system->natmin; ++iat) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
diff_sym = std::max<double>(diff_sym, std::abs(borncharge[iat][i][j] - born_sym[iat][i][j]));
double diff_sym = 0.0;
for (iat = 0; iat < system->natmin; ++iat) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
diff_sym = std::max<double>(diff_sym, std::abs(borncharge[iat][i][j] - born_sym[iat][i][j]));
}
}
}
}

if (diff_sym > 0.5) {
std::cout << std::endl;
std::cout << " WARNING: Born effective charges are inconsistent with the crystal symmetry." << std::endl;
}
if (diff_sym > 0.5) {
std::cout << std::endl;
std::cout << " WARNING: Born effective charges are inconsistent with the crystal symmetry." << std::endl;
}

for (iat = 0; iat < system->natmin; ++iat) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
borncharge[iat][i][j] = born_sym[iat][i][j];
for (iat = 0; iat < system->natmin; ++iat) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
borncharge[iat][i][j] = born_sym[iat][i][j];
}
}
}
}
memory->deallocate(born_sym);
memory->deallocate(born_sym);

if (diff_sym > eps8 || res > eps10) {
std::cout << std::endl;
std::cout << " Symmetrized Born effective charge tensor in Cartesian coordinate." << std::endl;
for (i = 0; i < system->natmin; ++i) {
std::cout << " Atom" << std::setw(5) << i + 1 << "("
<< std::setw(3) << system->symbol_kd[system->kd[system->map_p2s[i][0]]] << ") :" << std::endl;
if (diff_sym > eps8 || res > eps10) {
std::cout << std::endl;
std::cout << " Symmetrized Born effective charge tensor in Cartesian coordinate." << std::endl;
for (i = 0; i < system->natmin; ++i) {
std::cout << " Atom" << std::setw(5) << i + 1 << "("
<< std::setw(3) << system->symbol_kd[system->kd[system->map_p2s[i][0]]] << ") :" << std::endl;

for (j = 0; j < 3; ++j) {
for (k = 0; k < 3; ++k) {
std::cout << std::setw(15) << borncharge[i][j][k];
for (j = 0; j < 3; ++j) {
for (k = 0; k < 3; ++k) {
std::cout << std::setw(15) << borncharge[i][j][k];
}
std::cout << std::endl;
}
std::cout << std::endl;
}
}
}
}
std::cout << std::scientific;
}

Expand Down

0 comments on commit 12e9e22

Please sign in to comment.