1
1
#include " source_base/parallel_reduce.h"
2
2
#include " source_estate/module_charge/charge.h"
3
+ #include " source_io/dipole_io.h"
3
4
#include " source_lcao/module_rt/evolve_elec.h"
4
5
#include " source_pw/module_pwdft/global.h"
5
- #include " source_io/dipole_io.h"
6
6
7
7
// fuxiang add 2017-03-15
8
8
void ModuleIO::write_dipole (const UnitCell& ucell,
@@ -11,8 +11,7 @@ void ModuleIO::write_dipole(const UnitCell& ucell,
11
11
const int & is,
12
12
const int & istep,
13
13
const std::string& fn,
14
- const int & precision,
15
- const bool for_plot)
14
+ const int & precision)
16
15
{
17
16
ModuleBase::TITLE (" ModuleIO" , " write_dipole" );
18
17
@@ -51,9 +50,9 @@ void ModuleIO::write_dipole(const UnitCell& ucell,
51
50
int index = i * rhopw->ny * rhopw->nz + j * rhopw->nz + k;
52
51
double rho_val = rho_save[index];
53
52
54
- dipole_elec_x + = rho_val * i * lat_factor_x;
55
- dipole_elec_y + = rho_val * j * lat_factor_y;
56
- dipole_elec_z + = rho_val * k * lat_factor_z;
53
+ dipole_elec_x - = rho_val * i * lat_factor_x;
54
+ dipole_elec_y - = rho_val * j * lat_factor_y;
55
+ dipole_elec_z - = rho_val * k * lat_factor_z;
57
56
}
58
57
}
59
58
}
@@ -79,9 +78,9 @@ void ModuleIO::write_dipole(const UnitCell& ucell,
79
78
double y = (double )j / rhopw->ny ;
80
79
double z = (double )k / rhopw->nz ;
81
80
82
- dipole_elec[0 ] + = rho_save[ir] * x;
83
- dipole_elec[1 ] + = rho_save[ir] * y;
84
- dipole_elec[2 ] + = rho_save[ir] * z;
81
+ dipole_elec[0 ] - = rho_save[ir] * x;
82
+ dipole_elec[1 ] - = rho_save[ir] * y;
83
+ dipole_elec[2 ] - = rho_save[ir] * z;
85
84
}
86
85
87
86
Parallel_Reduce::reduce_pool (dipole_elec[0 ]);
@@ -92,12 +91,12 @@ void ModuleIO::write_dipole(const UnitCell& ucell,
92
91
dipole_elec[i] *= ucell.lat0 / bmod[i] * ucell.omega / rhopw->nxyz ;
93
92
}
94
93
95
- std::cout << std::setprecision ( 15 ) << " dipole_elec_x: " << dipole_elec[0 ] << std::endl ;
96
- std::cout << std::setprecision ( 15 ) << " dipole_elec_y: " << dipole_elec[1 ] << std::endl ;
97
- std::cout << std::setprecision ( 15 ) << " dipole_elec_z: " << dipole_elec[2 ] << std::endl ;
94
+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Electronic dipole moment P_elec_x(t) " , dipole_elec[0 ]) ;
95
+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Electronic dipole moment P_elec_y(t) " , dipole_elec[1 ]) ;
96
+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Electronic dipole moment P_elec_z(t) " , dipole_elec[2 ]) ;
98
97
99
- ofs << std::setprecision (8 ) << istep << " " << dipole_elec[0 ] << " " << dipole_elec[1 ] << " " << dipole_elec[ 2 ]
100
- << std::endl;
98
+ ofs << std::setprecision (precision ) << istep << " " << dipole_elec[0 ] << " " << dipole_elec[1 ] << " "
99
+ << dipole_elec[ 2 ] << std::endl;
101
100
102
101
double dipole_ion[3 ] = {0.0 };
103
102
double dipole_sum = 0.0 ;
@@ -116,20 +115,23 @@ void ModuleIO::write_dipole(const UnitCell& ucell,
116
115
dipole_ion[i] *= ucell.lat0 / bmod[i]; // * ModuleBase::FOUR_PI / ucell.omega;
117
116
}
118
117
119
- std::cout << std::setprecision ( 8 ) << " dipole_ion_x: " << dipole_ion[0 ] << std::endl ;
120
- std::cout << std::setprecision ( 8 ) << " dipole_ion_y: " << dipole_ion[1 ] << std::endl ;
121
- std::cout << std::setprecision ( 8 ) << " dipole_ion_z: " << dipole_ion[2 ] << std::endl ;
118
+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Ionic dipole moment P_ion_x(t) " , dipole_ion[0 ]) ;
119
+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Ionic dipole moment P_ion_y(t) " , dipole_ion[1 ]) ;
120
+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Ionic dipole moment P_ion_z(t) " , dipole_ion[2 ]) ;
122
121
123
122
double dipole[3 ] = {0.0 };
124
123
for (int i = 0 ; i < 3 ; ++i)
125
124
{
126
- dipole[i] = dipole_ion[i] - dipole_elec[i];
125
+ dipole[i] = dipole_ion[i] + dipole_elec[i];
127
126
}
128
- std::cout << std::setprecision (8 ) << " dipole_x: " << dipole[0 ] << std::endl;
129
- std::cout << std::setprecision (8 ) << " dipole_y: " << dipole[1 ] << std::endl;
130
- std::cout << std::setprecision (8 ) << " dipole_z: " << dipole[2 ] << std::endl;
127
+
128
+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Total dipole moment P_tot_x(t)" , dipole[0 ]);
129
+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Total dipole moment P_tot_y(t)" , dipole[1 ]);
130
+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Total dipole moment P_tot_z(t)" , dipole[2 ]);
131
+
131
132
dipole_sum = sqrt (dipole[0 ] * dipole[0 ] + dipole[1 ] * dipole[1 ] + dipole[2 ] * dipole[2 ]);
132
- std::cout << std::setprecision (8 ) << " dipole_sum: " << dipole_sum << std::endl;
133
+
134
+ ModuleBase::GlobalFunc::OUT (GlobalV::ofs_running, " Total dipole moment norm |P_tot(t)|" , dipole_sum);
133
135
134
136
#endif
135
137
0 commit comments