|
1 | 1 | #include "paw_cell.h" |
2 | 2 | #include "module_base/tool_title.h" |
3 | 3 | #include "module_base/tool_quit.h" |
| 4 | +#ifdef __MPI |
| 5 | +#include "module_base/parallel_reduce.h" |
| 6 | +#endif |
| 7 | + |
| 8 | +namespace GlobalC |
| 9 | +{ |
| 10 | + Paw_Cell paw_cell; |
| 11 | +} |
4 | 12 |
|
5 | 13 | void Paw_Cell::init_paw_cell( |
6 | 14 | const double ecutwfc_in, const double cell_factor_in, |
7 | 15 | const double omega_in, |
8 | 16 | const int nat_in, const int ntyp_in, |
9 | 17 | const int * atom_type_in, const double ** atom_coord_in, |
10 | | - const std::vector<std::string> & filename_list_in, |
11 | | - const int nx_in, const int ny_in, const int nz_in, |
12 | | - const std::complex<double> * eigts1_in, const std::complex<double> * eigts2_in, const std::complex<double> * eigts3_in) |
| 18 | + const std::vector<std::string> & filename_list_in) |
13 | 19 | { |
14 | 20 | ModuleBase::TITLE("Paw_Element","init_paw_cell"); |
15 | 21 |
|
16 | 22 | this -> nat = nat_in; |
17 | 23 | this -> ntyp = ntyp_in; |
18 | | - this -> nx = nx_in; |
19 | | - this -> ny = ny_in; |
20 | | - this -> nz = nz_in; |
21 | 24 | this -> omega = omega_in; |
22 | 25 |
|
23 | 26 | atom_coord.resize(nat); |
@@ -71,6 +74,16 @@ void Paw_Cell::init_paw_cell( |
71 | 74 | int nproj = paw_element_list[it].get_mstates(); |
72 | 75 | paw_atom_list[iat].init_paw_atom(nproj); |
73 | 76 | } |
| 77 | +} |
| 78 | + |
| 79 | +void Paw_Cell::set_eigts(const int nx_in, const int ny_in, const int nz_in, |
| 80 | + const std::complex<double> * eigts1_in, |
| 81 | + const std::complex<double> * eigts2_in, |
| 82 | + const std::complex<double> * eigts3_in) |
| 83 | +{ |
| 84 | + this -> nx = nx_in; |
| 85 | + this -> ny = ny_in; |
| 86 | + this -> nz = nz_in; |
74 | 87 |
|
75 | 88 | eigts1.resize(nat); |
76 | 89 | eigts2.resize(nat); |
@@ -422,6 +435,14 @@ void Paw_Cell::get_vkb() |
422 | 435 | } |
423 | 436 | } |
424 | 437 |
|
| 438 | +void Paw_Cell::reset_rhoij() |
| 439 | +{ |
| 440 | + for(int iat = 0; iat < nat; iat ++) |
| 441 | + { |
| 442 | + paw_atom_list[iat].reset_rhoij(); |
| 443 | + } |
| 444 | +} |
| 445 | + |
425 | 446 | void Paw_Cell::accumulate_rhoij(const std::complex<double> * psi, const double weight) |
426 | 447 | { |
427 | 448 | ModuleBase::TITLE("Paw_Cell","accumulate_rhoij"); |
@@ -451,9 +472,9 @@ void Paw_Cell::accumulate_rhoij(const std::complex<double> * psi, const double w |
451 | 472 | } |
452 | 473 | } |
453 | 474 |
|
454 | | - // ca should be summed over MPI ranks since planewave basis is distributed |
455 | | - // but not for now (I'll make sure serial version works first) |
456 | | - // Parallel_Reduce::reduce_complex_double_pool(ca.data(), nproj); |
| 475 | +#ifdef __MPI |
| 476 | + Parallel_Reduce::reduce_complex_double_pool(ca.data(), nproj); |
| 477 | +#endif |
457 | 478 |
|
458 | 479 | paw_atom_list[iat].set_ca(ca, weight); |
459 | 480 | paw_atom_list[iat].accumulate_rhoij(); |
@@ -530,9 +551,9 @@ void Paw_Cell::paw_nl_psi(const int mode, const std::complex<double> * psi, std: |
530 | 551 | } |
531 | 552 | } |
532 | 553 |
|
533 | | - // ca should be summed over MPI ranks since planewave basis is distributed |
534 | | - // but not for now (I'll make sure serial version works first) |
535 | | - // Parallel_Reduce::reduce_complex_double_pool(ca.data(), nproj); |
| 554 | +#ifdef __MPI |
| 555 | + Parallel_Reduce::reduce_complex_double_pool(ca.data(), nproj); |
| 556 | +#endif |
536 | 557 |
|
537 | 558 | // sum_ij D_ij ca_j |
538 | 559 | std::vector<std::complex<double>> v_ca; |
|
0 commit comments