Skip to content

Commit

Permalink
Clean up codes (mainly kpoint.cpp)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttadano committed Feb 23, 2018
1 parent dbe10dc commit 97307c2
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 240 deletions.
28 changes: 14 additions & 14 deletions anphon/conductivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void Conductivity::setup_kappa()
Temperature[i] = system->Tmin + static_cast<double>(i) * system->dT;
}

nks_total = kpoint->nk_reduced * ns;
nks_total = kpoint->nk_irred * ns;
nks_each_thread = nks_total / mympi->nprocs;
nrem = nks_total - nks_each_thread * mympi->nprocs;

Expand All @@ -83,7 +83,7 @@ void Conductivity::setup_kappa()

vks_job.clear();

for (i = 0; i < kpoint->nk_reduced; ++i) {
for (i = 0; i < kpoint->nk_irred; ++i) {
for (j = 0; j < ns; ++j) {
vks_job.insert(i * ns + j);
}
Expand Down Expand Up @@ -115,7 +115,7 @@ void Conductivity::prepare_restart()
writes->fs_result << "##Phonon Frequency" << std::endl;
writes->fs_result << "#K-point (irreducible), Branch, Omega (cm^-1)" << std::endl;

for (i = 0; i < kpoint->nk_reduced; ++i) {
for (i = 0; i < kpoint->nk_irred; ++i) {
ik = kpoint->kpoint_irred_all[i][0].knum;
for (is = 0; is < dynamical->neval; ++is) {
writes->fs_result << std::setw(6) << i + 1 << std::setw(6) << is + 1;
Expand Down Expand Up @@ -312,7 +312,7 @@ void Conductivity::write_result_gamma(const unsigned int ik, const unsigned int

iks_g = ik * np + j + nshift;

if (iks_g >= kpoint->nk_reduced * ns) break;
if (iks_g >= kpoint->nk_irred * ns) break;

writes->fs_result << "#GAMMA_EACH" << std::endl;
writes->fs_result << iks_g / ns + 1 << " " << iks_g % ns + 1 << std::endl;
Expand Down Expand Up @@ -358,13 +358,13 @@ void Conductivity::compute_kappa()
double **lifetime;
double ****kappa_mode;

memory->allocate(lifetime, kpoint->nk_reduced * ns, ntemp);
memory->allocate(kappa_mode, ntemp, 9, ns, kpoint->nk_reduced);
memory->allocate(lifetime, kpoint->nk_irred * ns, ntemp);
memory->allocate(kappa_mode, ntemp, 9, ns, kpoint->nk_irred);

average_self_energy_at_degenerate_point(kpoint->nk_reduced * ns, ntemp, damping3);
average_self_energy_at_degenerate_point(kpoint->nk_irred * ns, ntemp, damping3);

if (isotope->include_isotope) {
for (iks = 0; iks < kpoint->nk_reduced * ns; ++iks) {
for (iks = 0; iks < kpoint->nk_irred * ns; ++iks) {
snum = iks % ns;
if (relaxation->is_imaginary[iks / ns][snum]) {
for (i = 0; i < ntemp; ++i) {
Expand All @@ -382,7 +382,7 @@ void Conductivity::compute_kappa()
}
}
} else {
for (iks = 0; iks < kpoint->nk_reduced * ns; ++iks) {
for (iks = 0; iks < kpoint->nk_irred * ns; ++iks) {

if (relaxation->is_imaginary[iks / ns][iks % ns]) {
for (i = 0; i < ntemp; ++i) {
Expand Down Expand Up @@ -410,13 +410,13 @@ void Conductivity::compute_kappa()
if (Temperature[i] < eps) {
// Set kappa as zero when T = 0.
for (is = 0; is < ns; ++is) {
for (ik = 0; ik < kpoint->nk_reduced; ++ik) {
for (ik = 0; ik < kpoint->nk_irred; ++ik) {
kappa_mode[i][3 * j + k][is][ik] = 0.0;
}
}
} else {
for (is = 0; is < ns; ++is) {
for (ik = 0; ik < kpoint->nk_reduced; ++ik) {
for (ik = 0; ik < kpoint->nk_irred; ++ik) {
knum = kpoint->kpoint_irred_all[ik][0].knum;
omega = dynamical->eval_phonon[knum][is];
vv_tmp = 0.0;
Expand Down Expand Up @@ -448,7 +448,7 @@ void Conductivity::compute_kappa()
kappa[i][j][k] = 0.0;

for (is = 0; is < ns; ++is) {
for (ik = 0; ik < kpoint->nk_reduced; ++ik) {
for (ik = 0; ik < kpoint->nk_irred; ++ik) {
kappa[i][j][k] += kappa_mode[i][3 * j + k][is][ik];
}
}
Expand All @@ -472,7 +472,7 @@ void Conductivity::average_self_energy_at_degenerate_point(const int n,
double **damping)
{
int i, j, k, l;
int nkr = kpoint->nk_reduced;
int nkr = kpoint->nk_irred;
int ik;

double *eval_tmp;
Expand Down Expand Up @@ -595,7 +595,7 @@ void Conductivity::compute_frequency_resolved_kappa(const int ntemp,

for (j = 0; j < ntemp; ++j) {
for (k = 0; k < 3; ++k) {
for (ik = 0; ik < kpoint->nk_reduced; ++ik) {
for (ik = 0; ik < kpoint->nk_irred; ++ik) {
knum = kpoint->kpoint_irred_all[ik][0].knum;
kappa_spec[i][j][k] += kappa_mode[j][3 * k + k][is][ik] * weight[knum];
}
Expand Down
13 changes: 8 additions & 5 deletions anphon/ewald.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "constants.h"
#include <iostream>
#include <fstream>
#include <cmath>
#include <boost/math/special_functions/erf.hpp>
#include <vector>
#include <iomanip>
Expand Down Expand Up @@ -49,7 +48,6 @@ void Ewald::init()
MPI_Bcast(&rate_ab, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);

if (is_longrange) {
int i, j, k;
int nsize[3] = {1, 1, 1};

memory->allocate(multiplicity, system->nat, system->nat);
Expand All @@ -58,9 +56,9 @@ void Ewald::init()

get_pairs_of_minimum_distance(system->nat, nsize, system->xr_s);

for (i = 0; i < system->natmin; ++i) {
for (j = 0; j < 3; ++j) {
for (k = 0; k < 3; ++k) {
for (int i = 0; i < system->natmin; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
Born_charge[i][j][k] = dynamical->borncharge[i][j][k];
}
}
Expand Down Expand Up @@ -489,6 +487,11 @@ void Ewald::compute_ewald_fcs2()
std::cout << " Calculating long-range (dipole-dipole) FCs in the supercell ...";
}

std::vector<std::vector<double>> k_commensurate;
kpoint->get_commensurate_kpoints(system->lavec_s,
system->lavec_p,
k_commensurate);

memory->allocate(fcs_ewald, 3 * natmin, 3 * nat);
memory->allocate(fc_ewald_short, 3, 3);
memory->allocate(fc_ewald_long, 3, 3);
Expand Down
5 changes: 2 additions & 3 deletions anphon/gruneisen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ or http://opensource.org/licenses/mit-license.php for information.
*/

#include "mpi_common.h"
#include "gruneisen.h"
#include "constants.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include "dynamical.h"
#include "error.h"
#include "fcs_phonon.h"
#include "gruneisen.h"
#include "pointers.h"
#include "kpoint.h"
#include "memory.h"
#include "system.h"
#include "parsephon.h"
#include "write_phonons.h"
#include "mathfunctions.h"
#include "relaxation.h"
#include "version.h"
Expand Down
6 changes: 3 additions & 3 deletions anphon/isotope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void Isotope::setup_isotope_scattering()
std::cout << std::endl;
}

memory->allocate(gamma_isotope, kpoint->nk_reduced, dynamical->neval);
memory->allocate(gamma_isotope, kpoint->nk_irred, dynamical->neval);
}
}

Expand Down Expand Up @@ -177,7 +177,7 @@ void Isotope::calc_isotope_selfenergy_all()
int i, j;
int nk = kpoint->nk;
int ns = dynamical->neval;
int nks = kpoint->nk_reduced * ns;
int nks = kpoint->nk_irred * ns;
int knum, snum;
double tmp, omega;
double *gamma_tmp, *gamma_loc;
Expand Down Expand Up @@ -208,7 +208,7 @@ void Isotope::calc_isotope_selfenergy_all()
MPI_Reduce(&gamma_loc[0], &gamma_tmp[0], nks,
MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);

for (i = 0; i < kpoint->nk_reduced; ++i) {
for (i = 0; i < kpoint->nk_irred; ++i) {
for (j = 0; j < ns; ++j) {
gamma_isotope[i][j] = gamma_tmp[ns * i + j];
}
Expand Down

0 comments on commit 97307c2

Please sign in to comment.