Skip to content

Commit 0e458b9

Browse files
committed
Did nothing, just formatting esolver.cpp
1 parent 7f94b4d commit 0e458b9

File tree

1 file changed

+86
-78
lines changed

1 file changed

+86
-78
lines changed

source/module_esolver/esolver.cpp

Lines changed: 86 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern "C"
1919
#include "esolver_lj.h"
2020
#include "esolver_of.h"
2121
#include "module_parameter/md_parameter.h"
22+
2223
#include <stdexcept>
2324

2425
namespace ModuleESolver
@@ -45,16 +46,16 @@ std::string determine_type()
4546
else if (PARAM.inp.basis_type == "lcao_in_pw")
4647
{
4748
#ifdef __LCAO
48-
if(PARAM.inp.esolver_type == "sdft")
49-
{
50-
esolver_type = "sdft_pw";
51-
}
52-
else if(PARAM.inp.esolver_type == "ksdft")
53-
{
49+
if (PARAM.inp.esolver_type == "sdft")
50+
{
51+
esolver_type = "sdft_pw";
52+
}
53+
else if (PARAM.inp.esolver_type == "ksdft")
54+
{
5455
esolver_type = "ksdft_lip";
55-
}
56+
}
5657
#else
57-
ModuleBase::WARNING_QUIT("ESolver", "Calculation involving numerical orbitals must be compiled with __LCAO");
58+
ModuleBase::WARNING_QUIT("ESolver", "Calculation involving numerical orbitals must be compiled with __LCAO");
5859
#endif
5960
}
6061
else if (PARAM.inp.basis_type == "lcao")
@@ -67,7 +68,7 @@ std::string determine_type()
6768
else if (PARAM.inp.esolver_type == "ksdft")
6869
{
6970
esolver_type = "ksdft_lcao";
70-
}
71+
}
7172
else if (PARAM.inp.esolver_type == "ks-lr")
7273
{
7374
esolver_type = "ksdft_lr_lcao";
@@ -77,7 +78,7 @@ std::string determine_type()
7778
esolver_type = "lr_lcao";
7879
}
7980
#else
80-
ModuleBase::WARNING_QUIT("ESolver", "Calculation involving numerical orbitals must be compiled with __LCAO");
81+
ModuleBase::WARNING_QUIT("ESolver", "Calculation involving numerical orbitals must be compiled with __LCAO");
8182
#endif
8283
}
8384

@@ -98,59 +99,58 @@ std::string determine_type()
9899

99100
auto device_info = PARAM.inp.device;
100101

101-
for (char &c : device_info)
102-
{
103-
if (std::islower(c))
104-
{
105-
c = std::toupper(c);
106-
}
107-
}
108-
if (GlobalV::MY_RANK == 0)
109-
{
110-
std::cout << " RUNNING WITH DEVICE : " << device_info << " / "
111-
<< base_device::information::get_device_info(PARAM.inp.device) << std::endl;
112-
}
102+
for (char& c: device_info)
103+
{
104+
if (std::islower(c))
105+
{
106+
c = std::toupper(c);
107+
}
108+
}
109+
if (GlobalV::MY_RANK == 0)
110+
{
111+
std::cout << " RUNNING WITH DEVICE : " << device_info << " / "
112+
<< base_device::information::get_device_info(PARAM.inp.device) << std::endl;
113+
}
113114

114115
GlobalV::ofs_running << "\n RUNNING WITH DEVICE : " << device_info << " / "
115116
<< base_device::information::get_device_info(PARAM.inp.device) << std::endl;
116117

117118
return esolver_type;
118119
}
119120

120-
121-
//Some API to operate E_Solver
121+
// Some API to operate E_Solver
122122
ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
123123
{
124-
//determine type of esolver based on INPUT information
125-
const std::string esolver_type = determine_type();
124+
// determine type of esolver based on INPUT information
125+
const std::string esolver_type = determine_type();
126126

127127
// initialize the corresponding Esolver child class
128128
if (esolver_type == "ksdft_pw")
129129
{
130130
#if ((defined __CUDA) || (defined __ROCM))
131-
if (PARAM.inp.device == "gpu")
132-
{
133-
if (PARAM.inp.precision == "single")
134-
{
135-
return new ESolver_KS_PW<std::complex<float>, base_device::DEVICE_GPU>();
136-
}
137-
else
138-
{
139-
return new ESolver_KS_PW<std::complex<double>, base_device::DEVICE_GPU>();
140-
}
141-
}
131+
if (PARAM.inp.device == "gpu")
132+
{
133+
if (PARAM.inp.precision == "single")
134+
{
135+
return new ESolver_KS_PW<std::complex<float>, base_device::DEVICE_GPU>();
136+
}
137+
else
138+
{
139+
return new ESolver_KS_PW<std::complex<double>, base_device::DEVICE_GPU>();
140+
}
141+
}
142142
#endif
143-
if (PARAM.inp.precision == "single")
144-
{
145-
return new ESolver_KS_PW<std::complex<float>, base_device::DEVICE_CPU>();
146-
}
147-
else
148-
{
149-
return new ESolver_KS_PW<std::complex<double>, base_device::DEVICE_CPU>();
150-
}
151-
}
143+
if (PARAM.inp.precision == "single")
144+
{
145+
return new ESolver_KS_PW<std::complex<float>, base_device::DEVICE_CPU>();
146+
}
147+
else
148+
{
149+
return new ESolver_KS_PW<std::complex<double>, base_device::DEVICE_CPU>();
150+
}
151+
}
152152
else if (esolver_type == "sdft_pw")
153-
{
153+
{
154154
#if ((defined __CUDA) || (defined __ROCM))
155155
if (PARAM.inp.device == "gpu")
156156
{
@@ -160,19 +160,19 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
160160
// }
161161
// else
162162
// {
163-
return new ESolver_SDFT_PW<std::complex<double>, base_device::DEVICE_GPU>();
163+
return new ESolver_SDFT_PW<std::complex<double>, base_device::DEVICE_GPU>();
164164
// }
165165
}
166166
#endif
167167
// if (PARAM.inp.precision == "single")
168-
// {
169-
// return new ESolver_SDFT_PW<std::complex<float>, base_device::DEVICE_CPU>();
170-
// }
171-
// else
172-
// {
173-
return new ESolver_SDFT_PW<std::complex<double>, base_device::DEVICE_CPU>();
174-
// }
175-
}
168+
// {
169+
// return new ESolver_SDFT_PW<std::complex<float>, base_device::DEVICE_CPU>();
170+
// }
171+
// else
172+
// {
173+
return new ESolver_SDFT_PW<std::complex<double>, base_device::DEVICE_CPU>();
174+
// }
175+
}
176176
#ifdef __LCAO
177177
else if (esolver_type == "ksdft_lip")
178178
{
@@ -212,14 +212,20 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
212212
}
213213
}
214214
else if (esolver_type == "ksdft_lcao_tddft")
215-
{
216-
return new ESolver_KS_LCAO_TDDFT();
215+
{
216+
return new ESolver_KS_LCAO_TDDFT();
217217
}
218218
else if (esolver_type == "lr_lcao")
219219
{
220220
// use constructor rather than Init function to initialize reference (instead of pointers) to ucell
221-
if (PARAM.globalv.gamma_only_local) { return new LR::ESolver_LR<double, double>(inp, ucell); }
222-
else { return new LR::ESolver_LR<std::complex<double>, double>(inp, ucell); }
221+
if (PARAM.globalv.gamma_only_local)
222+
{
223+
return new LR::ESolver_LR<double, double>(inp, ucell);
224+
}
225+
else
226+
{
227+
return new LR::ESolver_LR<std::complex<double>, double>(inp, ucell);
228+
}
223229
}
224230
else if (esolver_type == "ksdft_lr_lcao")
225231
{
@@ -261,34 +267,36 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
261267
return p_esolver_lr;
262268
}
263269
#endif
264-
else if(esolver_type == "ofdft")
265-
{
266-
return new ESolver_OF();
267-
}
268-
else if (esolver_type == "lj_pot")
269-
{
270-
return new ESolver_LJ();
271-
}
272-
else if (esolver_type == "dp_pot")
273-
{
274-
return new ESolver_DP(PARAM.mdp.pot_file);
275-
}
276-
throw std::invalid_argument("esolver_type = "+std::string(esolver_type)+". Wrong in "+std::string(__FILE__)+" line "+std::to_string(__LINE__));
270+
else if (esolver_type == "ofdft")
271+
{
272+
return new ESolver_OF();
273+
}
274+
else if (esolver_type == "lj_pot")
275+
{
276+
return new ESolver_LJ();
277+
}
278+
else if (esolver_type == "dp_pot")
279+
{
280+
return new ESolver_DP(PARAM.mdp.pot_file);
281+
}
282+
throw std::invalid_argument("esolver_type = " + std::string(esolver_type) + ". Wrong in " + std::string(__FILE__)
283+
+ " line " + std::to_string(__LINE__));
277284
}
278285

279-
void clean_esolver(ESolver * &pesolver, const bool lcao_cblacs_exit)
286+
void clean_esolver(ESolver*& pesolver, const bool lcao_cblacs_exit)
280287
{
281288
// Zhang Xiaoyang modified in 2024/7/6:
282289
// Note: because of the init method of serial lcao hsolver
283290
// it needs no release step for it, or this [delete] will cause Segmentation Fault
284291
// Probably it will be modified later.
285292
#ifdef __MPI
286-
delete pesolver;
293+
delete pesolver;
287294
#ifdef __LCAO
288-
if (lcao_cblacs_exit) {
295+
if (lcao_cblacs_exit)
296+
{
289297
Cblacs_exit(1);
290-
}
298+
}
291299
#endif
292300
#endif
293301
}
294-
}
302+
} // namespace ModuleESolver

0 commit comments

Comments
 (0)