@@ -17,7 +17,8 @@ Output_Mulliken<TK>::Output_Mulliken(Output_Sk<TK>* output_sk,
1717 CellIndex* cell_index,
1818 const std::vector<int >& isk,
1919 int nspin)
20- : output_sk_(output_sk), output_dmk_(output_dmk), ParaV_(ParaV), cell_index_(cell_index), isk_(isk), nspin_(nspin)
20+ : output_sk_(output_sk), output_dmk_(output_dmk),
21+ ParaV_ (ParaV), cell_index_(cell_index), isk_(isk), nspin_(nspin)
2122{
2223 this ->set_nspin (nspin);
2324 this ->set_ParaV (ParaV);
@@ -69,20 +70,27 @@ void Output_Mulliken<TK>::write_mulliken_nspin1(int istep,
6970{
7071 os << std::setprecision (4 );
7172 // / step info
72- os << " STEP: " << istep << std::endl;
73- os << " CALCULATE THE MULLIkEN ANALYSIS FOR EACH ATOM" << std::endl;
74- os << " Total charge:\t " << tot_chg[0 ] << std::endl;
73+ os << " --- Ionic Step " << istep+1 << " ---" << std::endl;
74+ os << " Total charge " << tot_chg[0 ] << std::endl;
7575 // / orbital decomposed mulliken populations
76- FmtCore fmt_of_chg (" %20.4f" );
77- FmtCore fmt_of_label (" %-20s" );
78- FmtCore fmt_of_Z (" %20d" );
79- os << " Decomposed Mulliken populations" << std::endl;
76+ FmtCore fmt_of_chg (" %10.4f" );
77+ FmtCore fmt_of_label (" %12s" );
78+ FmtCore fmt_of_Z (" %2d" );
79+ FmtCore fmt_of_sum (" %14s" );
80+ os << " Decomposed Mulliken population analysis for each atom" << std::endl;
81+ os << " l and m from Ylm, z stands for zeta orbital" << std::endl;
82+ os << std::endl;
83+
8084 for (int iat = 0 ; iat < this ->cell_index_ ->get_nat (); ++iat)
8185 {
8286 // / header of the table
8387 std::string atom_label = this ->cell_index_ ->get_atom_label (iat);
84- os << FmtCore::format (" %-20d" , iat) << FmtCore::format (" %20s" , std::string (" Zeta of " ) + atom_label)
85- << FmtCore::format (" %20s" , std::string (" Spin 1" )) << std::endl;
88+ os << " ------------------" << std::endl;
89+ os << " Atom " << iat+1 << " is " << atom_label << std::endl;
90+ os << " ------------------" << std::endl;
91+ os << FmtCore::format (" %14s" , std::string (" zeta" ))
92+ << FmtCore::format (" %10s" , std::string (" spin1" )) << std::endl;
93+
8694 // / loop of L
8795 for (int L = 0 ; L <= this ->cell_index_ ->get_maxL (iat); L++)
8896 {
@@ -91,7 +99,8 @@ void Output_Mulliken<TK>::write_mulliken_nspin1(int istep,
9199 {
92100 for (int M = 0 ; M < (2 * L + 1 ); M++)
93101 {
94- os << fmt_of_label.format (ModuleBase::Name_Angular[L][M]) << fmt_of_Z.format (Z)
102+ os << fmt_of_label.format (ModuleBase::Name_Angular[L][M])
103+ << fmt_of_Z.format (Z+1 )
95104 << fmt_of_chg.format (orb_chg[std::vector<int >{iat, 0 , L, Z, M}]) << std::endl;
96105 }
97106 // sum over m
@@ -106,20 +115,20 @@ void Output_Mulliken<TK>::write_mulliken_nspin1(int istep,
106115 }
107116 if (L > 0 )
108117 {
109- os << fmt_of_label .format (std::string (" SUM OVER M " )) << std::setw ( 20 ) << " "
118+ os << fmt_of_sum .format (std::string (" sum m " ))
110119 << fmt_of_chg.format (sum_over_m[0 ]) << std::endl;
111120 }
112121 }
113- os << fmt_of_label .format (std::string (" SUM OVER M+Zeta " )) << std::setw ( 20 ) << " "
122+ os << fmt_of_sum .format (std::string (" sum mz " ))
114123 << fmt_of_chg.format (sum_over_m_and_z[0 ]) << std::endl;
115124 os << std::endl;
116125 }
117- os << fmt_of_label .format (std::string (" SUM OVER M+Zeta+L " )) << std::setw ( 20 ) << " "
126+ os << fmt_of_sum .format (std::string (" sum lmz " ))
118127 << fmt_of_chg.format (atom_chg[iat][0 ]) << std::endl;
119128 os << std::endl;
120- os << std::left << std::setw ( 30 ) << " Total Charge on atom: " << std::right << std::setw ( 10 ) << atom_label
129+ os << std::left << " total charge on atom " << iat+ 1 << " "
121130 << fmt_of_chg.format (atom_chg[iat][0 ]) << std::endl;
122- os << std::endl << std::endl ;
131+ os << std::endl;
123132 }
124133}
125134
@@ -132,23 +141,32 @@ void Output_Mulliken<TK>::write_mulliken_nspin2(int istep,
132141{
133142 os << std::setprecision (4 );
134143 // / step info
135- os << " STEP: " << istep << std::endl;
136- os << " CALCULATE THE MULLIkEN ANALYSIS FOR EACH ATOM" << std::endl;
137- os << " Total charge of spin " << 1 << " :\t " << tot_chg[0 ] << std::endl;
138- os << " Total charge of spin " << 2 << " :\t " << tot_chg[1 ] << std::endl;
139- os << " Total charge:\t " << tot_chg[0 ] + tot_chg[1 ] << std::endl;
144+ os << " --- Ionic Step " << istep+1 << " ---" << std::endl;
145+ os << " Total charge " << tot_chg[0 ] + tot_chg[1 ] << std::endl;
146+ os << " Total charge of spin1 " << tot_chg[0 ] << std::endl;
147+ os << " Total charge of spin2 " << tot_chg[1 ] << std::endl;
140148 // / orbital decomposed mulliken populations
141- FmtCore fmt_of_chg (" %20.4f" );
142- FmtCore fmt_of_label (" %-20s" );
143- FmtCore fmt_of_Z (" %20d" );
144- os << " Decomposed Mulliken populations" << std::endl;
149+ FmtCore fmt_of_chg (" %10.4f" );
150+ FmtCore fmt_of_label (" %12s" );
151+ FmtCore fmt_of_Z (" %2d" );
152+ FmtCore fmt_of_sum (" %14s" );
153+ os << " Decomposed Mulliken population analysis for each atom" << std::endl;
154+ os << " l and m from Ylm, z stands for zeta orbital" << std::endl;
155+ os << std::endl;
156+
145157 for (int iat = 0 ; iat < this ->cell_index_ ->get_nat (); ++iat)
146158 {
147159 // / header of the table
148160 std::string atom_label = this ->cell_index_ ->get_atom_label (iat);
149- os << FmtCore::format (" %-20d" , iat) << FmtCore::format (" %20s" , std::string (" Zeta of " ) + atom_label)
150- << FmtCore::format (" %20s" , std::string (" Spin 1" )) << FmtCore::format (" %20s" , std::string (" Spin 2" ))
151- << FmtCore::format (" %20s" , std::string (" Sum" )) << FmtCore::format (" %20s" , std::string (" Diff" )) << std::endl;
161+ os << " ------------------" << std::endl;
162+ os << " Atom " << iat+1 << " is " << atom_label << std::endl;
163+ os << " ------------------" << std::endl;
164+ os << FmtCore::format (" %14s" , std::string (" zeta" ))
165+ << FmtCore::format (" %10s" , std::string (" spin1" ))
166+ << FmtCore::format (" %10s" , std::string (" spin2" ))
167+ << FmtCore::format (" %10s" , std::string (" sum" ))
168+ << FmtCore::format (" %10s" , std::string (" diff" )) << std::endl;
169+
152170 // / loop of L
153171 for (int L = 0 ; L <= this ->cell_index_ ->get_maxL (iat); L++)
154172 {
@@ -157,7 +175,8 @@ void Output_Mulliken<TK>::write_mulliken_nspin2(int istep,
157175 {
158176 for (int M = 0 ; M < (2 * L + 1 ); M++)
159177 {
160- os << fmt_of_label.format (ModuleBase::Name_Angular[L][M]) << fmt_of_Z.format (Z)
178+ os << fmt_of_label.format (ModuleBase::Name_Angular[L][M])
179+ << fmt_of_Z.format (Z+1 ) // be careful, Z+1, modified by mohan 2026-02-21
161180 << fmt_of_chg.format (orb_chg[std::vector<int >{iat, 0 , L, Z, M}])
162181 << fmt_of_chg.format (orb_chg[std::vector<int >{iat, 1 , L, Z, M}])
163182 << fmt_of_chg.format (orb_chg[std::vector<int >{iat, 0 , L, Z, M}]
@@ -178,28 +197,31 @@ void Output_Mulliken<TK>::write_mulliken_nspin2(int istep,
178197 }
179198 if (L > 0 )
180199 {
181- os << fmt_of_label.format (std::string (" SUM OVER M" )) << std::setw (20 ) << " "
182- << fmt_of_chg.format (sum_over_m[0 ]) << fmt_of_chg.format (sum_over_m[1 ])
200+ os << fmt_of_sum.format (std::string (" sum m" ))
201+ << fmt_of_chg.format (sum_over_m[0 ])
202+ << fmt_of_chg.format (sum_over_m[1 ])
183203 << fmt_of_chg.format (sum_over_m[0 ] + sum_over_m[1 ])
184204 << fmt_of_chg.format (sum_over_m[0 ] - sum_over_m[1 ]) << std::endl;
185205 }
186206 }
187- os << fmt_of_label.format (std::string (" SUM OVER M+Zeta" )) << std::setw (20 ) << " "
188- << fmt_of_chg.format (sum_over_m_and_z[0 ]) << fmt_of_chg.format (sum_over_m_and_z[1 ])
207+ os << fmt_of_sum.format (std::string (" sum mz" ))
208+ << fmt_of_chg.format (sum_over_m_and_z[0 ])
209+ << fmt_of_chg.format (sum_over_m_and_z[1 ])
189210 << fmt_of_chg.format (sum_over_m_and_z[0 ] + sum_over_m_and_z[1 ])
190211 << fmt_of_chg.format (sum_over_m_and_z[0 ] - sum_over_m_and_z[1 ]) << std::endl;
191212 os << std::endl;
192213 }
193- os << fmt_of_label.format (std::string (" SUM OVER M+Zeta+L" )) << std::setw (20 ) << " "
194- << fmt_of_chg.format (atom_chg[iat][0 ]) << fmt_of_chg.format (atom_chg[iat][1 ])
214+ os << fmt_of_sum.format (std::string (" sum lmz" ))
215+ << fmt_of_chg.format (atom_chg[iat][0 ])
216+ << fmt_of_chg.format (atom_chg[iat][1 ])
195217 << fmt_of_chg.format (atom_chg[iat][0 ] + atom_chg[iat][1 ])
196218 << fmt_of_chg.format (atom_chg[iat][0 ] - atom_chg[iat][1 ]) << std::endl;
197219 os << std::endl;
198- os << std::left << std::setw ( 30 ) << " Total Charge on atom: " << std::right << std::setw ( 10 ) << atom_label
220+ os << std::left << " total charge on atom " << iat+ 1 << " "
199221 << fmt_of_chg.format (atom_chg[iat][0 ] + atom_chg[iat][1 ]) << std::endl;
200- os << std::left << std::setw ( 30 ) << " Total Magnetism on atom: " << std::right << std::setw ( 10 ) << atom_label
222+ os << std::left << " total magnetism on atom " << iat+ 1 << " "
201223 << fmt_of_chg.format (atom_chg[iat][0 ] - atom_chg[iat][1 ]) << std::endl;
202- os << std::endl << std::endl ;
224+ os << std::endl;
203225 }
204226}
205227
@@ -212,22 +234,30 @@ void Output_Mulliken<TK>::write_mulliken_nspin4(int istep,
212234{
213235 os << std::setprecision (4 );
214236 // / step info
215- os << " STEP: " << istep << std::endl;
216- os << " CALCULATE THE MULLIkEN ANALYSIS FOR EACH ATOM" << std::endl;
217- os << " Total charge:\t " << tot_chg[0 ] << std::endl;
237+ os << " --- Ionic Step " << istep+1 << " ---" << std::endl;
238+ os << " Total charge " << tot_chg[0 ] << std::endl;
218239 // / orbital decomposed mulliken populations
219- FmtCore fmt_of_chg (" %20.4f" );
220- FmtCore fmt_of_label (" %-20s" );
221- FmtCore fmt_of_Z (" %20d" );
222- os << " Decomposed Mulliken populations" << std::endl;
240+ FmtCore fmt_of_chg (" %10.4f" );
241+ FmtCore fmt_of_label (" %12s" );
242+ FmtCore fmt_of_Z (" %2d" );
243+ FmtCore fmt_of_sum (" %14s" );
244+ os << " Decomposed Mulliken population analysis for each atom" << std::endl;
245+ os << " l and m from Ylm, z stands for zeta orbital" << std::endl;
246+ os << std::endl;
247+
223248 for (int iat = 0 ; iat < this ->cell_index_ ->get_nat (); ++iat)
224249 {
225250 // / header of the table
226251 std::string atom_label = this ->cell_index_ ->get_atom_label (iat);
227- os << FmtCore::format (" %-20d" , iat) << FmtCore::format (" %20s" , std::string (" Zeta of " ) + atom_label)
228- << FmtCore::format (" %20s" , std::string (" Spin 1" )) << FmtCore::format (" %20s" , std::string (" Spin 2" ))
229- << FmtCore::format (" %20s" , std::string (" Spin 3" )) << FmtCore::format (" %20s" , std::string (" Spin 4" ))
230- << std::endl;
252+ os << " ------------------" << std::endl;
253+ os << " Atom " << iat+1 << " is " << atom_label << std::endl;
254+ os << " ------------------" << std::endl;
255+ os << FmtCore::format (" %14s" , std::string (" zeta" ))
256+ << FmtCore::format (" %10s" , std::string (" spin1" ))
257+ << FmtCore::format (" %10s" , std::string (" spin2" ))
258+ << FmtCore::format (" %10s" , std::string (" spin3" ))
259+ << FmtCore::format (" %10s" , std::string (" spin4" )) << std::endl;
260+
231261 // / loop of L
232262 for (int L = 0 ; L <= this ->cell_index_ ->get_maxL (iat); L++)
233263 {
@@ -236,7 +266,8 @@ void Output_Mulliken<TK>::write_mulliken_nspin4(int istep,
236266 {
237267 for (int M = 0 ; M < (2 * L + 1 ); M++)
238268 {
239- os << fmt_of_label.format (ModuleBase::Name_Angular[L][M]) << fmt_of_Z.format (Z)
269+ os << fmt_of_label.format (ModuleBase::Name_Angular[L][M])
270+ << fmt_of_Z.format (Z+1 )
240271 << fmt_of_chg.format (orb_chg[std::vector<int >{iat, 0 , L, Z, M}])
241272 << fmt_of_chg.format (orb_chg[std::vector<int >{iat, 1 , L, Z, M}])
242273 << fmt_of_chg.format (orb_chg[std::vector<int >{iat, 2 , L, Z, M}])
@@ -254,26 +285,33 @@ void Output_Mulliken<TK>::write_mulliken_nspin4(int istep,
254285 }
255286 if (L > 0 )
256287 {
257- os << fmt_of_label.format (std::string (" SUM OVER M" )) << std::setw (20 ) << " "
258- << fmt_of_chg.format (sum_over_m[0 ]) << fmt_of_chg.format (sum_over_m[1 ])
259- << fmt_of_chg.format (sum_over_m[2 ]) << fmt_of_chg.format (sum_over_m[3 ]) << std::endl;
288+ os << fmt_of_sum.format (std::string (" sum m" ))
289+ << fmt_of_chg.format (sum_over_m[0 ])
290+ << fmt_of_chg.format (sum_over_m[1 ])
291+ << fmt_of_chg.format (sum_over_m[2 ])
292+ << fmt_of_chg.format (sum_over_m[3 ]) << std::endl;
260293 }
261294 }
262- os << fmt_of_label.format (std::string (" SUM OVER M+Zeta" )) << std::setw (20 ) << " "
263- << fmt_of_chg.format (sum_over_m_and_z[0 ]) << fmt_of_chg.format (sum_over_m_and_z[1 ])
264- << fmt_of_chg.format (sum_over_m_and_z[2 ]) << fmt_of_chg.format (sum_over_m_and_z[3 ]) << std::endl;
295+ os << fmt_of_sum.format (std::string (" sum mz" ))
296+ << fmt_of_chg.format (sum_over_m_and_z[0 ])
297+ << fmt_of_chg.format (sum_over_m_and_z[1 ])
298+ << fmt_of_chg.format (sum_over_m_and_z[2 ])
299+ << fmt_of_chg.format (sum_over_m_and_z[3 ]) << std::endl;
265300 os << std::endl;
266301 }
267- os << fmt_of_label.format (std::string (" SUM OVER M+Zeta+L" )) << std::setw (20 ) << " "
268- << fmt_of_chg.format (atom_chg[iat][0 ]) << fmt_of_chg.format (atom_chg[iat][1 ])
269- << fmt_of_chg.format (atom_chg[iat][2 ]) << fmt_of_chg.format (atom_chg[iat][3 ]) << std::endl;
302+ os << fmt_of_sum.format (std::string (" sum lmz" ))
303+ << fmt_of_chg.format (atom_chg[iat][0 ])
304+ << fmt_of_chg.format (atom_chg[iat][1 ])
305+ << fmt_of_chg.format (atom_chg[iat][2 ])
306+ << fmt_of_chg.format (atom_chg[iat][3 ]) << std::endl;
270307 os << std::endl;
271- os << std::left << std::setw ( 30 ) << " Total Charge on atom: " << std::right << std::setw ( 10 ) << atom_label
308+ os << std::left << " total charge on atom " << iat+ 1 << " "
272309 << fmt_of_chg.format (atom_chg[iat][0 ]) << std::endl;
273- os << std::left << std::setw (30 ) << " Total Magnetism on atom: " << std::right << std::setw (10 ) << atom_label
274- << fmt_of_chg.format (atom_chg[iat][1 ]) << fmt_of_chg.format (atom_chg[iat][2 ])
310+ os << std::left << " total magnetism on atom " << iat+1 << " "
311+ << fmt_of_chg.format (atom_chg[iat][1 ]) << " "
312+ << fmt_of_chg.format (atom_chg[iat][2 ]) << " "
275313 << fmt_of_chg.format (atom_chg[iat][3 ]) << std::endl;
276- os << std::endl << std::endl ;
314+ os << std::endl;
277315 }
278316}
279317
0 commit comments