Skip to content

Commit 3ebc74e

Browse files
committed
clang-format change.
1 parent ed63b35 commit 3ebc74e

File tree

5 files changed

+86
-78
lines changed

5 files changed

+86
-78
lines changed

source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.cpp

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
#include "LCAO_deepks_interface.h"
33

44
#include "LCAO_deepks_io.h" // mohan add 2024-07-22
5-
#include "source_base/global_variable.h"
6-
#include "source_base/tool_title.h"
75
#include "module_elecstate/cal_dm.h"
86
#include "module_hamilt_lcao/module_hcontainer/hcontainer.h"
97
#include "module_hamilt_lcao/module_hcontainer/output_hcontainer.h"
108
#include "module_parameter/parameter.h"
9+
#include "source_base/global_variable.h"
10+
#include "source_base/tool_title.h"
1111

1212
template <typename TK, typename TR>
1313
LCAO_Deepks_Interface<TK, TR>::LCAO_Deepks_Interface(std::shared_ptr<LCAO_Deepks<TK>> ld_in) : ld(ld_in)
@@ -359,7 +359,9 @@ void LCAO_Deepks_Interface<TK, TR>::out_deepks_labels(const double& etot,
359359
// set the output
360360
const double sparse_threshold = 1e-10;
361361
const int precision = 8;
362-
const std::string file_hrtot = PARAM.globalv.global_out_dir + (PARAM.inp.deepks_out_labels == 1 ? "deepks_hrtot.csr" : "deepks_hamiltonian_r.csr");
362+
const std::string file_hrtot
363+
= PARAM.globalv.global_out_dir
364+
+ (PARAM.inp.deepks_out_labels == 1 ? "deepks_hrtot.csr" : "deepks_hamiltonian_r.csr");
363365
hamilt::HContainer<TR>* hR_tot = (p_ham->getHR());
364366

365367
if (rank == 0)
@@ -394,21 +396,21 @@ void LCAO_Deepks_Interface<TK, TR>::out_deepks_labels(const double& etot,
394396
int R_size = DeePKS_domain::get_R_size(*h_deltaR);
395397
torch::Tensor vdr_precalc;
396398
DeePKS_domain::cal_vdr_precalc(nlocal,
397-
lmaxd,
398-
inlmax,
399-
nat,
400-
nks,
401-
R_size,
402-
inl2l,
403-
kvec_d,
404-
phialpha,
405-
gevdm,
406-
inl_index,
407-
ucell,
408-
orb,
409-
*ParaV,
410-
GridD,
411-
vdr_precalc);
399+
lmaxd,
400+
inlmax,
401+
nat,
402+
nks,
403+
R_size,
404+
inl2l,
405+
kvec_d,
406+
phialpha,
407+
gevdm,
408+
inl_index,
409+
ucell,
410+
orb,
411+
*ParaV,
412+
GridD,
413+
vdr_precalc);
412414

413415
const std::string file_vdrpre = PARAM.globalv.global_out_dir + "deepks_vdrpre.npy";
414416
LCAO_deepks_io::save_tensor2npy<double>(file_vdrpre, vdr_precalc, rank);
@@ -418,16 +420,16 @@ void LCAO_Deepks_Interface<TK, TR>::out_deepks_labels(const double& etot,
418420
int R_size = DeePKS_domain::get_R_size(*h_deltaR);
419421
torch::Tensor phialpha_r_out;
420422
DeePKS_domain::prepare_phialpha_r(nlocal,
421-
lmaxd,
422-
inlmax,
423-
nat,
424-
R_size,
425-
phialpha,
426-
ucell,
427-
orb,
428-
*ParaV,
429-
GridD,
430-
phialpha_r_out);
423+
lmaxd,
424+
inlmax,
425+
nat,
426+
R_size,
427+
phialpha,
428+
ucell,
429+
orb,
430+
*ParaV,
431+
GridD,
432+
phialpha_r_out);
431433
const std::string file_phialpha_r = PARAM.globalv.global_out_dir + "deepks_phialpha_r.npy";
432434
LCAO_deepks_io::save_tensor2npy<double>(file_phialpha_r, phialpha_r_out, rank);
433435

@@ -571,7 +573,7 @@ void LCAO_Deepks_Interface<TK, TR>::out_deepks_labels(const double& etot,
571573
<< " = " << std::setprecision(8) << e_delta_band * ModuleBase::Ry_to_eV << " eV" << std::endl;
572574
ofs_running << " E_delta_NN = " << std::setprecision(8) << E_delta << " Ry"
573575
<< " = " << std::setprecision(8) << E_delta * ModuleBase::Ry_to_eV << " eV" << std::endl;
574-
ofs_running << " -----------------------------------------------" << std::endl;
576+
ofs_running << " -----------------------------------------------" << std::endl;
575577
}
576578
if (PARAM.inp.deepks_out_unittest)
577579
{

source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
#ifdef __MLALGO
55
#include "LCAO_deepks.h"
6+
#include "module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h"
67
#include "source_base/complexmatrix.h"
78
#include "source_base/matrix.h"
8-
#include "module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h"
99

1010
#include <memory>
1111

source/module_hamilt_lcao/module_deepks/deepks_check.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ void DeePKS_domain::check_tensor(const torch::Tensor& tensor, const std::string&
99
{
1010
return;
1111
}
12-
using T_tensor = typename std::conditional<std::is_same<T, std::complex<double>>::value, c10::complex<double>, T>::type;
12+
using T_tensor =
13+
typename std::conditional<std::is_same<T, std::complex<double>>::value, c10::complex<double>, T>::type;
1314

1415
std::ofstream ofs(filename.c_str());
1516
ofs << std::setprecision(10);
@@ -21,15 +22,18 @@ void DeePKS_domain::check_tensor(const torch::Tensor& tensor, const std::string&
2122

2223
// stride for each dimension
2324
std::vector<int64_t> strides(ndim, 1);
24-
for (int i = ndim - 2; i >= 0; --i) {
25+
for (int i = ndim - 2; i >= 0; --i)
26+
{
2527
strides[i] = strides[i + 1] * sizes[i + 1];
2628
}
2729

28-
for (int64_t idx = 0; idx < numel; ++idx) {
30+
for (int64_t idx = 0; idx < numel; ++idx)
31+
{
2932
// index to multi-dimensional indices
3033
std::vector<int64_t> indices(ndim);
3134
int64_t tmp = idx;
32-
for (int d = 0; d < ndim; ++d) {
35+
for (int d = 0; d < ndim; ++d)
36+
{
3337
indices[d] = tmp / strides[d];
3438
tmp = tmp % strides[d];
3539
}
@@ -39,17 +43,24 @@ void DeePKS_domain::check_tensor(const torch::Tensor& tensor, const std::string&
3943
ofs << *tmp_ptr;
4044

4145
// print space or newline
42-
if ( ( (idx+1) % sizes[ndim-1] ) == 0 ) {
46+
if (((idx + 1) % sizes[ndim - 1]) == 0)
47+
{
4348
ofs << std::endl;
44-
} else {
49+
}
50+
else
51+
{
4552
ofs << " ";
4653
}
4754
}
4855

4956
ofs.close();
5057
}
5158

52-
template void DeePKS_domain::check_tensor<double>(const torch::Tensor& tensor, const std::string& filename, const int rank);
53-
template void DeePKS_domain::check_tensor<std::complex<double>>(const torch::Tensor& tensor, const std::string& filename, const int rank);
59+
template void DeePKS_domain::check_tensor<double>(const torch::Tensor& tensor,
60+
const std::string& filename,
61+
const int rank);
62+
template void DeePKS_domain::check_tensor<std::complex<double>>(const torch::Tensor& tensor,
63+
const std::string& filename,
64+
const int rank);
5465

5566
#endif

source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.cpp

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,20 @@ void test_deepks<T>::check_orbpre()
250250
torch::Tensor orbpre;
251251
DeePKS_domain::cal_gevdm(ucell.nat, this->ld.inlmax, this->ld.inl2l, this->ld.pdm, gevdm);
252252
DeePKS_domain::cal_orbital_precalc<T, TH>(dm,
253-
this->ld.lmaxd,
254-
this->ld.inlmax,
255-
ucell.nat,
256-
kv.nkstot,
257-
this->ld.inl2l,
258-
kv.kvec_d,
259-
this->ld.phialpha,
260-
gevdm,
261-
this->ld.inl_index,
262-
ucell,
263-
ORB,
264-
ParaO,
265-
Test_Deepks::GridD,
266-
orbpre);
253+
this->ld.lmaxd,
254+
this->ld.inlmax,
255+
ucell.nat,
256+
kv.nkstot,
257+
this->ld.inl2l,
258+
kv.kvec_d,
259+
this->ld.phialpha,
260+
gevdm,
261+
this->ld.inl_index,
262+
ucell,
263+
ORB,
264+
ParaO,
265+
Test_Deepks::GridD,
266+
orbpre);
267267
DeePKS_domain::check_tensor<double>(orbpre, "orbital_precalc.dat", 0); // 0 for rank
268268
this->compare_with_ref("orbital_precalc.dat", "orbpre_ref.dat");
269269
}
@@ -300,23 +300,23 @@ void test_deepks<T>::check_vdrpre()
300300
torch::Tensor vdrpre;
301301
DeePKS_domain::cal_gevdm(ucell.nat, this->ld.inlmax, this->ld.inl2l, this->ld.pdm, gevdm);
302302
// normally use hR to get R_size, here use phialpha[0] only for test case
303-
int R_size = DeePKS_domain::get_R_size<double>(*(this->ld.phialpha[0]));
303+
int R_size = DeePKS_domain::get_R_size<double>(*(this->ld.phialpha[0]));
304304
DeePKS_domain::cal_vdr_precalc(PARAM.sys.nlocal,
305-
this->ld.lmaxd,
306-
this->ld.inlmax,
307-
ucell.nat,
308-
kv.nkstot,
309-
R_size,
310-
this->ld.inl2l,
311-
kv.kvec_d,
312-
this->ld.phialpha,
313-
gevdm,
314-
this->ld.inl_index,
315-
ucell,
316-
ORB,
317-
ParaO,
318-
Test_Deepks::GridD,
319-
vdrpre);
305+
this->ld.lmaxd,
306+
this->ld.inlmax,
307+
ucell.nat,
308+
kv.nkstot,
309+
R_size,
310+
this->ld.inl2l,
311+
kv.kvec_d,
312+
this->ld.phialpha,
313+
gevdm,
314+
this->ld.inl_index,
315+
ucell,
316+
ORB,
317+
ParaO,
318+
Test_Deepks::GridD,
319+
vdrpre);
320320
// vdrpre is large, we only check the main element in Bravo lattice vector (0, 0, 0)
321321
torch::Tensor vdrpre_sliced = vdrpre.slice(0, 0, 1, 1).slice(1, 0, 1, 1).slice(2, 0, 1, 1);
322322
DeePKS_domain::check_tensor<double>(vdrpre_sliced, "vdr_precalc.dat", 0); // 0 for rank
@@ -439,12 +439,7 @@ void test_deepks<T>::check_o_delta()
439439
const int nks = kv.nkstot;
440440
ModuleBase::matrix o_delta;
441441
o_delta.create(nks, 1);
442-
DeePKS_domain::cal_o_delta<T>(dm,
443-
ld.V_delta,
444-
o_delta,
445-
ParaO,
446-
nks,
447-
nspin);
442+
DeePKS_domain::cal_o_delta<T>(dm, ld.V_delta, o_delta, ParaO, nks, nspin);
448443
std::ofstream ofs("o_delta.dat");
449444
ofs << std::setprecision(10);
450445
o_delta.print(ofs);
@@ -476,8 +471,8 @@ void test_deepks<T>::compare_with_ref(const std::string f1, const std::string f2
476471
return;
477472
}
478473
}
479-
else if (word1[0] == '(' && word1[word1.size() - 1] == ')' &&
480-
word2[0] == '(' && word2[word2.size() - 1] == ')') // complex number
474+
else if (word1[0] == '(' && word1[word1.size() - 1] == ')' && word2[0] == '('
475+
&& word2[word2.size() - 1] == ')') // complex number
481476
{
482477
std::string word1_str = word1.substr(1, word1.size() - 2);
483478
std::string word2_str = word2.substr(1, word2.size() - 2);

source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "klist.h"
2-
#include "source_base/global_function.h"
3-
#include "source_base/global_variable.h"
42
#include "module_basis/module_ao/ORB_read.h"
53
#include "module_cell/module_neighbor/sltk_atom_arrange.h"
64
#include "module_cell/module_neighbor/sltk_grid_driver.h"
75
#include "module_cell/unitcell.h"
6+
#include "source_base/global_function.h"
7+
#include "source_base/global_variable.h"
88
//#include "parallel_orbitals.h"
99

1010
#include "../LCAO_deepks.h"

0 commit comments

Comments
 (0)