Skip to content

Commit 3b99988

Browse files
authored
Fix: title of force output (#3093)
1 parent b1ac4a4 commit 3b99988

File tree

9 files changed

+16
-20
lines changed

9 files changed

+16
-20
lines changed

source/module_esolver/esolver_dp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ namespace ModuleESolver
130130
void ESolver_DP::cal_Force(ModuleBase::matrix& force)
131131
{
132132
force = dp_force;
133-
ModuleIO::print_force(GlobalV::ofs_running, *ucell_, " TOTAL-FORCE (eV/Angstrom)", force, false);
133+
ModuleIO::print_force(GlobalV::ofs_running, *ucell_, "TOTAL-FORCE (eV/Angstrom)", force, false);
134134
}
135135

136136
void ESolver_DP::cal_Stress(ModuleBase::matrix& stress)

source/module_esolver/esolver_lj.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ namespace ModuleESolver
101101
void ESolver_LJ::cal_Force(ModuleBase::matrix& force)
102102
{
103103
force = lj_force;
104-
ModuleIO::print_force(GlobalV::ofs_running, *ucell_, " TOTAL-FORCE (eV/Angstrom)", force, false);
104+
ModuleIO::print_force(GlobalV::ofs_running, *ucell_, "TOTAL-FORCE (eV/Angstrom)", force, false);
105105
}
106106

107107
void ESolver_LJ::cal_Stress(ModuleBase::matrix& stress)

source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ void Force_Stress_LCAO<T>::getForceStress(const bool isforce,
481481
GlobalV::ofs_running << std::setiosflags(std::ios::left);
482482

483483
// this->printforce_total(ry, istestf, fcs);
484-
ModuleIO::print_force(GlobalV::ofs_running, GlobalC::ucell, " TOTAL-FORCE (eV/Angstrom)", fcs, 0);
484+
ModuleIO::print_force(GlobalV::ofs_running, GlobalC::ucell, "TOTAL-FORCE (eV/Angstrom)", fcs, 0);
485485
if (istestf)
486486
{
487487
GlobalV::ofs_running << "\n FORCE INVALID TABLE." << std::endl;

source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ class Force_Stress_LCAO
5353
Stress_Func<double> sc_pw;
5454
Forces<double> f_pw;
5555

56-
void print_force(const std::string& name, ModuleBase::matrix& f, const bool screen, bool ry) const;
57-
void printforce_total(const bool ry, const bool istestf, ModuleBase::matrix& fcs);
58-
5956
void forceSymmetry(ModuleBase::matrix& fcs, ModuleSymmetry::Symmetry* symm);
6057

6158
void calForcePwPart(ModuleBase::matrix& fvl_dvl,

source/module_hamilt_pw/hamilt_pwdft/forces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ void Forces<FPTYPE, Device>::cal_force(ModuleBase::matrix& force,
259259
if (GlobalV::imp_sol)
260260
ModuleIO::print_force(GlobalV::ofs_running, GlobalC::ucell, "IMP_SOL FORCE (eV/Angstrom)", forcesol, 0);
261261
}
262-
ModuleIO::print_force(GlobalV::ofs_running, GlobalC::ucell, " TOTAL-FORCE (eV/Angstrom)", force, 0);
262+
ModuleIO::print_force(GlobalV::ofs_running, GlobalC::ucell, "TOTAL-FORCE (eV/Angstrom)", force, 0);
263263

264264
return;
265265
}

source/module_hamilt_pw/hamilt_stodft/sto_forces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void Sto_Forces::cal_stoforce(ModuleBase::matrix& force,
164164
force_gate,
165165
0);
166166
}
167-
ModuleIO::print_force(GlobalV::ofs_running, GlobalC::ucell, " TOTAL-FORCE (eV/Angstrom)", force, 0);
167+
ModuleIO::print_force(GlobalV::ofs_running, GlobalC::ucell, "TOTAL-FORCE (eV/Angstrom)", force, 0);
168168
ModuleBase::timer::tick("Sto_Force", "cal_force");
169169
return;
170170
}

source/module_io/output_log.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void print_force(std::ofstream& ofs_running,
4747
std::vector<double> force_y;
4848
std::vector<double> force_z;
4949
std::string table;
50-
context.set_context({"title", "force", "force", "force"});
50+
context.set_context({"short_title", "force", "force", "force"});
5151
int iat = 0;
5252
for (int it = 0; it < cell.ntype; it++)
5353
{
@@ -67,9 +67,8 @@ void print_force(std::ofstream& ofs_running,
6767
}
6868

6969
context.enable_title();
70-
context << "atom" << atom_label << "x" << force_x << "y" << force_y << "z" << force_z;
70+
context << name.c_str() << atom_label << "" << force_x << "" << force_y << "" << force_z;
7171
context.center_title();
72-
context.set_overall_title("TOTAL-FORCE (eV/Angstrom)");
7372
table = context.str();
7473
ofs_running << table << std::endl;
7574
if (GlobalV::TEST_FORCE)

source/module_io/test/outputlog_test.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,22 @@ TEST(PrintForce, PrintForce)
180180
std::ifstream ifs("test.txt");
181181
std::string output_str;
182182
getline(ifs, output_str);
183-
EXPECT_THAT(output_str, testing::HasSubstr("TOTAL-FORCE (eV/Angstrom)"));
184-
getline(ifs, output_str);
185183
EXPECT_THAT(output_str,
186-
testing::HasSubstr("---------------------------------------------------------------------"));
184+
testing::HasSubstr("---------------------------------------------------------------------------"));
187185
getline(ifs, output_str);
188-
EXPECT_THAT(output_str, testing::HasSubstr("atom x y z "));
186+
EXPECT_THAT(output_str, testing::HasSubstr("test"));
189187
getline(ifs, output_str);
190188
EXPECT_THAT(output_str,
191-
testing::HasSubstr("---------------------------------------------------------------------"));
189+
testing::HasSubstr("---------------------------------------------------------------------------"));
192190
getline(ifs, output_str);
193-
EXPECT_THAT(output_str, testing::HasSubstr(" Al1 25.7110532015 51.4221064030 77.1331596044"));
191+
EXPECT_THAT(output_str,
192+
testing::HasSubstr("Al1 25.7110532015 51.4221064030 77.1331596044"));
194193
getline(ifs, output_str);
195-
EXPECT_THAT(output_str, testing::HasSubstr(" Al2 0.0000000000 0.0000000000 0.0000000000"));
194+
EXPECT_THAT(output_str,
195+
testing::HasSubstr("Al2 0.0000000000 0.0000000000 0.0000000000"));
196196
getline(ifs, output_str);
197197
EXPECT_THAT(output_str,
198-
testing::HasSubstr("---------------------------------------------------------------------"));
198+
testing::HasSubstr("---------------------------------------------------------------------------"));
199199
ifs.close();
200200
std::remove("test.txt");
201201
}

tests/integrate/tools/catch_properties.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fi
7777
#echo $etot
7878
#echo "hasforce:"$has_force
7979
if ! test -z "$has_force" && [ $has_force == 1 ]; then
80-
nn3=`echo "$natom + 4" |bc`
80+
nn3=`echo "$natom + 1" |bc`
8181
#nn1=`echo "$natom + 1" |bc`
8282
#nn5=`echo "$natom + 6" |bc`
8383
#grep -A$nn3 "TOTAL-FORCE" $running_path|sed '1,5d'|sed ''$nn1','$nn5'd'|awk '{printf $2"\t"$3"\t"$4"\n"}' > force.txt

0 commit comments

Comments
 (0)