Skip to content

Commit

Permalink
Merge pull request #241 from toxa81/develop
Browse files Browse the repository at this point in the history
remove old utils.h  and some minor cleanup
  • Loading branch information
toxa81 authored Jul 18, 2018
2 parents 15fc140 + d9e9a71 commit c5f849b
Show file tree
Hide file tree
Showing 29 changed files with 177 additions and 741 deletions.
2 changes: 1 addition & 1 deletion src/Beta_projectors/beta_projectors.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Beta_projectors: public Beta_projectors_base<1>
/* vs = {r, theta, phi} */
auto vs = SHT::spherical_coordinates(gkvec_.gkvec_cart(igk));
/* compute real spherical harmonics for G+k vector */
std::vector<double> gkvec_rlm(Utils::lmmax(ctx_.unit_cell().lmax()));
std::vector<double> gkvec_rlm(utils::lmmax(ctx_.unit_cell().lmax()));
SHT::spherical_harmonics(ctx_.unit_cell().lmax(), vs[1], vs[2], &gkvec_rlm[0]);
for (int iat = 0; iat < ctx_.unit_cell().num_atom_types(); iat++) {
auto& atom_type = ctx_.unit_cell().atom_type(iat);
Expand Down
4 changes: 2 additions & 2 deletions src/Beta_projectors/beta_projectors_strain_deriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Beta_projectors_strain_deriv : public Beta_projectors_base<9>
auto& beta_ri1 = ctx_.beta_ri_djl();

int lmax = ctx_.unit_cell().lmax();
int lmmax = Utils::lmmax(lmax);
int lmmax = utils::lmmax(lmax);

mdarray<double, 2> rlm_g(lmmax, num_gkvec_loc());
mdarray<double, 3> rlm_dg(lmmax, 3, num_gkvec_loc());
Expand Down Expand Up @@ -142,7 +142,7 @@ class Beta_projectors_strain_deriv : public Beta_projectors_base<9>
// auto gvs = SHT::spherical_coordinates(gvc);

// /* compute real spherical harmonics for G+k vector */
// std::vector<double> gkvec_rlm(Utils::lmmax(lmax_beta_ + 2));
// std::vector<double> gkvec_rlm(utils::lmmax(lmax_beta_ + 2));
// SHT::spherical_harmonics(lmax_beta_ + 2, gvs[1], gvs[2], &gkvec_rlm[0]);

// mdarray<double, 3> tmp(ctx_.unit_cell().max_mt_radial_basis_size(), lmax_beta_ + 3, ctx_.unit_cell().num_atom_types());
Expand Down
8 changes: 4 additions & 4 deletions src/Density/density.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class Density : public Field4D
std::unique_ptr<Gaunt_coefficients<double_complex>> gaunt_coefs_{nullptr};

/// Fast mapping between composite lm index and corresponding orbital quantum number.
mdarray<int, 1> l_by_lm_;
std::vector<int> l_by_lm_;

/// High-frequency mixer for the pseudopotential density mixing.
std::unique_ptr<Mixer<double_complex>> hf_mixer_{nullptr};
Expand Down Expand Up @@ -231,9 +231,9 @@ class Density : public Field4D
int l1 = atom_type__.indexr(idxrf1).l;

int xi2 = atom_type__.indexb().index_by_idxrf(idxrf2);
for (int lm2 = Utils::lm_by_l_m(l2, -l2); lm2 <= Utils::lm_by_l_m(l2, l2); lm2++, xi2++) {
for (int lm2 = utils::lm(l2, -l2); lm2 <= utils::lm(l2, l2); lm2++, xi2++) {
int xi1 = atom_type__.indexb().index_by_idxrf(idxrf1);
for (int lm1 = Utils::lm_by_l_m(l1, -l1); lm1 <= Utils::lm_by_l_m(l1, l1); lm1++, xi1++) {
for (int lm1 = utils::lm(l1, -l1); lm1 <= utils::lm(l1, l1); lm1++, xi1++) {
for (int k = 0; k < gaunt_coeffs__.num_gaunt(lm1, lm2); k++) {
int lm3 = gaunt_coeffs__.gaunt(lm1, lm2, k).lm3;
auto gc = gaunt_coeffs__.gaunt(lm1, lm2, k).coef;
Expand Down Expand Up @@ -355,7 +355,7 @@ class Density : public Field4D
gaunt_coefs_ = std::unique_ptr<gc_z>(new gc_z(ctx_.lmax_apw(), ctx_.lmax_rho(), ctx_.lmax_apw(), SHT::gaunt_hybrid));
}

l_by_lm_ = Utils::l_by_lm(ctx_.lmax_rho());
l_by_lm_ = utils::l_by_lm(ctx_.lmax_rho());

density_matrix_ = mdarray<double_complex, 4>(unit_cell_.max_mt_basis_size(), unit_cell_.max_mt_basis_size(),
ctx_.num_mag_comp(), unit_cell_.num_atoms());
Expand Down
2 changes: 1 addition & 1 deletion src/Density/initial_density.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ inline void Density::initial_density_full_pot()
//}
//sba.approximate(gvec_len);

auto l_by_lm = Utils::l_by_lm(lmax);
auto l_by_lm = utils::l_by_lm(lmax);

std::vector<double_complex> zil(lmax + 1);
for (int l = 0; l <= lmax; l++) {
Expand Down
4 changes: 2 additions & 2 deletions src/Density/paw_density.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ inline void Density::init_paw()
auto& atom_type = atom.type();

int l_max = 2 * atom_type.indexr().lmax_lo();
int lm_max_rho = Utils::lmmax(l_max);
int lm_max_rho = utils::lmmax(l_max);

paw_density_data_t pdd;

Expand Down Expand Up @@ -88,7 +88,7 @@ inline void Density::generate_paw_atom_density(paw_density_data_t& pdd)

auto& atom_type = pdd.atom_->type();

auto l_by_lm = Utils::l_by_lm(2 * atom_type.indexr().lmax_lo());
auto l_by_lm = utils::l_by_lm(2 * atom_type.indexr().lmax_lo());

/* get gaunt coefficients */
Gaunt_coefficients<double> GC(atom_type.indexr().lmax_lo(), 2 * atom_type.indexr().lmax_lo(),
Expand Down
6 changes: 3 additions & 3 deletions src/Density/symmetrize_density_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ inline void Density::symmetrize_density_matrix()
dm.zero();

int lmax = unit_cell_.lmax();
int lmmax = Utils::lmmax(lmax);
int lmmax = utils::lmmax(lmax);

mdarray<double, 2> rotm(lmmax, lmmax);

Expand Down Expand Up @@ -42,10 +42,10 @@ inline void Density::symmetrize_density_matrix()

for (int j = 0; j < ndm; j++) {
for (int m3 = -l1; m3 <= l1; m3++) {
int lm3 = Utils::lm_by_l_m(l1, m3);
int lm3 = utils::lm(l1, m3);
int xi3 = atom_type.indexb().index_by_lm_order(lm3, o1);
for (int m4 = -l2; m4 <= l2; m4++) {
int lm4 = Utils::lm_by_l_m(l2, m4);
int lm4 = utils::lm(l2, m4);
int xi4 = atom_type.indexb().index_by_lm_order(lm4, o2);
dm_rot_spatial[j] += density_matrix_(xi3, xi4, j, ja) * rotm(lm1, lm3) * rotm(lm2, lm4) * alpha;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Hubbard/hubbard_generate_atomic_orbitals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void Hubbard_potential::generate_atomic_orbitals(K_point& kp, Q_operator<double_
// temporary wave functions
Wave_functions sphi(kp.gkvec_partition(), this->number_of_hubbard_orbitals(), num_sc);

kp.generate_atomic_centered_wavefunctions_(this->number_of_hubbard_orbitals(), sphi, this->offset, true);
kp.generate_atomic_centered_wavefunctions_aux(this->number_of_hubbard_orbitals(), sphi, this->offset, true);

// check if we have a norm conserving pseudo potential only
bool augment = false;
Expand Down
14 changes: 7 additions & 7 deletions src/Hubbard/hubbard_occupancies_derivatives.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ void Hubbard_potential::compute_occupancies_derivatives(K_point& kp,
// derivatives of the hubbard wave functions are needed.
auto &phi = kp.hubbard_wave_functions();

kp.generate_atomic_centered_wavefunctions_(this->number_of_hubbard_orbitals(),
phi,
this->offset,
true);
kp.generate_atomic_centered_wavefunctions_aux(this->number_of_hubbard_orbitals(),
phi,
this->offset,
true);

Beta_projectors_gradient bp_grad_(ctx_, kp.gkvec(), kp.igk_loc(), kp.beta_projectors());
kp.beta_projectors().prepare();
Expand Down Expand Up @@ -205,7 +205,7 @@ void Hubbard_potential::compute_occupancies_stress_derivatives(K_point& kp,
bool augment = false;

const int lmax = ctx_.unit_cell().lmax();
const int lmmax = Utils::lmmax(lmax);
const int lmmax = utils::lmmax(lmax);

mdarray<double, 2> rlm_g(lmmax, kp.num_gkvec_loc());
mdarray<double, 3> rlm_dg(lmmax, 3, kp.num_gkvec_loc());
Expand All @@ -225,7 +225,7 @@ void Hubbard_potential::compute_occupancies_stress_derivatives(K_point& kp,
bp_strain_deriv.prepare();

// compute the hubbard orbitals
kp.generate_atomic_centered_wavefunctions_(this->number_of_hubbard_orbitals(), phi, this->offset, true);
kp.generate_atomic_centered_wavefunctions_aux(this->number_of_hubbard_orbitals(), phi, this->offset, true);

#ifdef __GPU
if (ctx_.processing_unit() == GPU) {
Expand Down Expand Up @@ -403,7 +403,7 @@ void Hubbard_potential::compute_gradient_strain_wavefunctions(K_point& kp__,
}
} else {
for (int m = -l; m <= l; m++) {
int lm = Utils::lm_by_l_m(l, m);
int lm = utils::lm(l, m);
auto d1 = ri_values[atom_type.id()][i] * (gvc[mu] * rlm_dg(lm, nu, igkloc) +
p * rlm_g(lm, igkloc));
auto d2 = ridjl_values[atom_type.id()][i] * rlm_g(lm, igkloc) * gvc[mu] * gvc[nu] / gvs[0];
Expand Down
20 changes: 10 additions & 10 deletions src/Hubbard/hubbard_occupancy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ inline void Hubbard_potential::symmetrize_occupancy_matrix_noncolinear_case()
// check if we have some symmetries
if (sym.num_mag_sym()) {
int lmax = unit_cell_.lmax();
int lmmax = Utils::lmmax(lmax);
int lmmax = utils::lmmax(lmax);

mdarray<double_complex, 2> rotm(lmmax, lmmax);
mdarray<double_complex, 4> rotated_oc(lmmax, lmmax, ctx_.num_spins() * ctx_.num_spins(), unit_cell_.num_atoms());
Expand All @@ -400,9 +400,9 @@ inline void Hubbard_potential::symmetrize_occupancy_matrix_noncolinear_case()
const int lmax_at = 2 * atom.type().hubbard_l() + 1;
if (atom.type().hubbard_correction()) {
for (int ii = 0; ii < lmax_at; ii++) {
int l1 = Utils::lm_by_l_m(atom.type().hubbard_l(), ii - atom.type().hubbard_l());
int l1 = utils::lm(atom.type().hubbard_l(), ii - atom.type().hubbard_l());
for (int ll = 0; ll < lmax_at; ll++) {
int l2 = Utils::lm_by_l_m(atom.type().hubbard_l(), ll - atom.type().hubbard_l());
int l2 = utils::lm(atom.type().hubbard_l(), ll - atom.type().hubbard_l());
mdarray<double_complex, 1> rot_spa(ctx_.num_spins() * ctx_.num_spins());
rot_spa.zero();
for (int s1 = 0; s1 < ctx_.num_spins(); s1++) {
Expand All @@ -411,9 +411,9 @@ inline void Hubbard_potential::symmetrize_occupancy_matrix_noncolinear_case()
// A_ij B_jk C_kl

for (int jj = 0; jj < lmax_at; jj++) {
int l3 = Utils::lm_by_l_m(atom.type().hubbard_l(), jj - atom.type().hubbard_l());
int l3 = utils::lm(atom.type().hubbard_l(), jj - atom.type().hubbard_l());
for (int kk = 0; kk < lmax_at; kk++) {
int l4 = Utils::lm_by_l_m(atom.type().hubbard_l(), kk - atom.type().hubbard_l());
int l4 = utils::lm(atom.type().hubbard_l(), kk - atom.type().hubbard_l());
rot_spa(2 * s1 + s2) +=
std::conj(rotm(l1, l3)) *
occupancy_number_(jj, kk, (s1 == s2) * s1 + (s1 != s2) * (1 + 2 * s1 + s2), ia, 0) *
Expand Down Expand Up @@ -469,7 +469,7 @@ inline void Hubbard_potential::symmetrize_occupancy_matrix()
// check if we have some symmetries
if (sym.num_mag_sym()) {
int lmax = unit_cell_.lmax();
int lmmax = Utils::lmmax(lmax);
int lmmax = utils::lmmax(lmax);

mdarray<double_complex, 2> rotm(lmmax, lmmax);
mdarray<double_complex, 4> rotated_oc(lmmax, lmmax, ctx_.num_spins() * ctx_.num_spins(), unit_cell_.num_atoms());
Expand All @@ -493,15 +493,15 @@ inline void Hubbard_potential::symmetrize_occupancy_matrix()
rot_spa.zero();
for (int ispn = 0; ispn < ctx_.num_spins(); ispn++) {
for (int ii = 0; ii < lmax_at; ii++) {
int l1 = Utils::lm_by_l_m(atom.type().hubbard_l(), ii - atom.type().hubbard_l());
int l1 = utils::lm(atom.type().hubbard_l(), ii - atom.type().hubbard_l());
for (int ll = 0; ll < lmax_at; ll++) {
int l2 = Utils::lm_by_l_m(atom.type().hubbard_l(), ll - atom.type().hubbard_l());
int l2 = utils::lm(atom.type().hubbard_l(), ll - atom.type().hubbard_l());
// symmetrization procedure
// A_ij B_jk C_kl
for (int kk = 0; kk < lmax_at; kk++) {
int l4 = Utils::lm_by_l_m(atom.type().hubbard_l(), kk - atom.type().hubbard_l());
int l4 = utils::lm(atom.type().hubbard_l(), kk - atom.type().hubbard_l());
for (int jj = 0; jj < lmax_at; jj++) {
int l3 = Utils::lm_by_l_m(atom.type().hubbard_l(), jj - atom.type().hubbard_l());
int l3 = utils::lm(atom.type().hubbard_l(), jj - atom.type().hubbard_l());
rot_spa(ii, kk) +=
std::conj(rotm(l1, l3)) * occupancy_number_(jj, kk, ispn, ia, 0) * rotm(l2, l4) * alpha;
}
Expand Down
Loading

0 comments on commit c5f849b

Please sign in to comment.