Skip to content

Commit e754f5f

Browse files
authored
Merge branch 'develop' into rdmft_PR
2 parents 0dac83c + 5a6f494 commit e754f5f

File tree

127 files changed

+2128
-1729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+2128
-1729
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3960,6 +3960,13 @@ Currently supported: `RPA`, `LDA`, `PBE`, `HSE`, `HF`.
39603960
- **Description**: The number of 2-particle states to be solved
39613961
- **Default**: 0
39623962

3963+
### lr_unrestricted
3964+
- **Type**: Boolean
3965+
- **Description**: Whether to use unrestricted construction for LR-TDDFT (the matrix size will be doubled).
3966+
- True: Always use unrestricted LR-TDDFT.
3967+
- False: Use unrestricted LR-TDDFT only when the system is open-shell.
3968+
- **Default**: False
3969+
39633970
### abs_wavelen_range
39643971

39653972
- **Type**: Real Real

source/Makefile.Objects

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ OBJS_GINT=gint.o\
291291
init_orb.o\
292292

293293
OBJS_HAMILT=hamilt_pw.o\
294+
hamilt_sdft_pw.o\
294295
operator.o\
295296
operator_pw.o\
296297
ekinetic_pw.o\
@@ -648,7 +649,6 @@ OBJS_SRCPW=H_Ewald_pw.o\
648649
structure_factor_k.o\
649650
soc.o\
650651
sto_iter.o\
651-
sto_hchi.o\
652652
sto_che.o\
653653
sto_wf.o\
654654
sto_func.o\
@@ -728,7 +728,6 @@ OBJS_TENSOR=tensor.o\
728728
operator_lr_exx.o\
729729
kernel_xc.o\
730730
pot_hxc_lrtd.o\
731-
hsolver_lrtd.o\
732731
lr_spectrum.o\
733732
hamilt_casida.o\
734733
esolver_lrtd_lcao.o\

source/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ int main(int argc, char** argv)
2727
*/
2828
int nproc = 1;
2929
int my_rank = 0;
30-
Parallel_Global::read_mpi_parameters(argc, argv, nproc, my_rank);
30+
int nthread_per_proc = 1;
31+
Parallel_Global::read_pal_param(argc, argv, nproc, nthread_per_proc, my_rank);
3132
#ifdef _OPENMP
3233
// ref: https://www.fftw.org/fftw3_doc/Usage-of-Multi_002dthreaded-FFTW.html
3334
fftw_init_threads();
3435
fftw_plan_with_nthreads(omp_get_max_threads());
3536
#endif
36-
PARAM.set_rank_nproc(my_rank, nproc);
37+
PARAM.set_pal_param(my_rank, nproc, nthread_per_proc);
3738

3839
/*
3940
main program for doing electronic structure calculations.

source/module_base/math_chebyshev.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ bool Chebyshev<REAL>::checkconverge(
575575
std::function<void(std::complex<REAL>* in, std::complex<REAL>* out, const int)> funA,
576576
std::complex<REAL>* wavein,
577577
const int N,
578+
const int LDA,
578579
REAL& tmax,
579580
REAL& tmin,
580581
REAL stept)
@@ -584,9 +585,9 @@ bool Chebyshev<REAL>::checkconverge(
584585
std::complex<REAL>* arrayn;
585586
std::complex<REAL>* arrayn_1;
586587

587-
arraynp1 = new std::complex<REAL>[N];
588-
arrayn = new std::complex<REAL>[N];
589-
arrayn_1 = new std::complex<REAL>[N];
588+
arraynp1 = new std::complex<REAL>[LDA];
589+
arrayn = new std::complex<REAL>[LDA];
590+
arrayn_1 = new std::complex<REAL>[LDA];
590591

591592
ModuleBase::GlobalFunc::DCOPY(wavein, arrayn_1, N);
592593

source/module_base/math_chebyshev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ class Chebyshev
191191
bool checkconverge(std::function<void(std::complex<REAL>* in, std::complex<REAL>* out, const int)> funA,
192192
std::complex<REAL>* wavein,
193193
const int N,
194+
const int LDA,
194195
REAL& tmax, // trial number for upper bound
195196
REAL& tmin, // trial number for lower bound
196197
REAL stept); // tmax = max() + stept, tmin = min() - stept

source/module_base/parallel_global.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "module_base/global_function.h"
1515
#include "module_base/parallel_common.h"
1616
#include "module_base/parallel_reduce.h"
17+
#include "module_parameter/parameter.h"
18+
// #include "module_base/tool_quit.h"
1719
#include "version.h"
1820

1921
#include <iostream>
@@ -85,7 +87,12 @@ void Parallel_Global::split_grid_world(const int diag_np, const int& nproc, cons
8587
return;
8688
}
8789

88-
void Parallel_Global::read_mpi_parameters(int argc, char** argv, int& NPROC, int& MY_RANK)
90+
// changed from read_mpi_parameters in 2024-1018
91+
void Parallel_Global::read_pal_param(int argc,
92+
char** argv,
93+
int& NPROC,
94+
int& NTHREAD_PER_PROC,
95+
int& MY_RANK)
8996
{
9097
#ifdef __MPI
9198
#ifdef _OPENMP
@@ -150,6 +157,10 @@ void Parallel_Global::read_mpi_parameters(int argc, char** argv, int& NPROC, int
150157
// the user may take their own risk by set the OMP_NUM_THREADS env var.
151158
if (std::getenv("OMP_NUM_THREADS") == nullptr)
152159
{
160+
// usage of WARNING_QUIT need module_base/tool_quit.cpp
161+
// lead to undefined error in unit_test building
162+
// ModuleBase::WARNING_QUIT( "Parallel_Global::read_pal_param","OMP_NUM_THREADS setting is invalid. Please set it to a proper value.");
163+
std::cerr << "ERROR: OMP_NUM_THREADS setting is invalid. Please set it to a proper value." << std::endl;
153164
exit(1);
154165
}
155166
}
@@ -162,6 +173,8 @@ void Parallel_Global::read_mpi_parameters(int argc, char** argv, int& NPROC, int
162173
<< "Local thread limit: " << max_thread_num << std::endl;
163174
}
164175

176+
NTHREAD_PER_PROC = current_thread_num;
177+
165178
if (MY_RANK == 0)
166179
{
167180
#ifdef VERSION
@@ -192,7 +205,7 @@ void Parallel_Global::read_mpi_parameters(int argc, char** argv, int& NPROC, int
192205
<< std::endl
193206
<< " Commit: " << commit << std::endl
194207
<< std::endl;
195-
time_t time_now = time(NULL);
208+
time_t time_now = time(nullptr);
196209
std::cout << " " << ctime(&time_now);
197210
}
198211

source/module_base/parallel_global.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ extern int omp_number;
1818
//---------------------------
1919
// call at the very first.
2020
//---------------------------
21-
void read_mpi_parameters(int argc, char** argv, int& NPROC, int& MY_RANK);
21+
22+
// changed from read_mpi_parameters in 2024-1018
23+
void read_pal_param(int argc, char** argv, int& NPROC, int& NTHREAD_PER_PROC, int& MY_RANK);
2224
#ifdef __MPI
2325
void myProd(std::complex<double>* in, std::complex<double>* inout, int* len, MPI_Datatype* dptr);
2426
#endif

source/module_base/test/math_chebyshev_test.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,15 @@ TEST_F(MathChebyshevTest, checkconverge)
346346
double tmin = -1.1;
347347
double tmax = 1.1;
348348
bool converge;
349-
converge = p_chetest->checkconverge(fun_sigma_y, v, 2, tmax, tmin, 0.2);
349+
converge = p_chetest->checkconverge(fun_sigma_y, v, 2, 2, tmax, tmin, 0.2);
350350
EXPECT_TRUE(converge);
351-
converge = p_chetest->checkconverge(fun_sigma_y, v + 2, 2, tmax, tmin, 0.2);
351+
converge = p_chetest->checkconverge(fun_sigma_y, v + 2, 2, 2, tmax, tmin, 0.2);
352352
EXPECT_TRUE(converge);
353353
EXPECT_NEAR(tmin, -1.1, 1e-8);
354354
EXPECT_NEAR(tmax, 1.1, 1e-8);
355355

356356
tmax = -1.1;
357-
converge = p_chetest->checkconverge(fun_sigma_y, v, 2, tmax, tmin, 2.2);
357+
converge = p_chetest->checkconverge(fun_sigma_y, v, 2, 2, tmax, tmin, 2.2);
358358
EXPECT_TRUE(converge);
359359
EXPECT_NEAR(tmin, -1.1, 1e-8);
360360
EXPECT_NEAR(tmax, 1.1, 1e-8);
@@ -363,12 +363,12 @@ TEST_F(MathChebyshevTest, checkconverge)
363363
v[0] = std::complex<double>(0, 1), v[1] = 1;
364364
fun.factor = 1.5;
365365
tmin = -1.1, tmax = 1.1;
366-
converge = p_chetest->checkconverge(fun_sigma_y, v, 2, tmax, tmin, 0.2);
366+
converge = p_chetest->checkconverge(fun_sigma_y, v, 2, 2, tmax, tmin, 0.2);
367367
EXPECT_FALSE(converge);
368368

369369
fun.factor = -1.5;
370370
tmin = -1.1, tmax = 1.1;
371-
converge = p_chetest->checkconverge(fun_sigma_y, v, 2, tmax, tmin, 0.2);
371+
converge = p_chetest->checkconverge(fun_sigma_y, v, 2, 2, tmax, tmin, 0.2);
372372
EXPECT_FALSE(converge);
373373
fun.factor = 1;
374374

@@ -632,9 +632,9 @@ TEST_F(MathChebyshevTest, checkconverge_float)
632632

633633
auto fun_sigma_yf
634634
= [&](std::complex<float>* in, std::complex<float>* out, const int m = 1) { fun.sigma_y(in, out, m); };
635-
converge = p_fchetest->checkconverge(fun_sigma_yf, v, 2, tmax, tmin, 0.2);
635+
converge = p_fchetest->checkconverge(fun_sigma_yf, v, 2, 2, tmax, tmin, 0.2);
636636
EXPECT_TRUE(converge);
637-
converge = p_fchetest->checkconverge(fun_sigma_yf, v + 2, 2, tmax, tmin, 0.2);
637+
converge = p_fchetest->checkconverge(fun_sigma_yf, v + 2, 2, 2, tmax, tmin, 0.2);
638638
EXPECT_TRUE(converge);
639639
EXPECT_NEAR(tmin, -1.1, 1e-6);
640640
EXPECT_NEAR(tmax, 1.1, 1e-6);

source/module_basis/module_ao/parallel_2d.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Parallel_2D
1515
~Parallel_2D() = default;
1616

1717
Parallel_2D& operator=(Parallel_2D&& rhs) = default;
18+
Parallel_2D(Parallel_2D&& rhs) = default;
1819

1920
/// number of local rows
2021
int get_row_size() const

source/module_cell/module_symmetry/run_symmetry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main(int argc, char **argv)
1414
std::cout << "Hello, this is the 'symmetry' module of ABACUS." << std::endl;
1515

1616
std::cout << "The module does symmetry analysis for an input geometry." << std::endl;
17-
Parallel_Global::read_mpi_parameters(argc,argv);
17+
Parallel_Global::read_pal_param(argc,argv);
1818
//std::cout << "Right now, the module is still empty, soon we will have more tests." << std::endl;
1919

2020
calculate();

0 commit comments

Comments
 (0)