Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
490fe9d
do not pass matrix in OperatorLRDiag
maki49 Oct 11, 2024
734f720
spin-up/down nocc, nvirt, npairs
maki49 Oct 12, 2024
0ef2410
spin up/down PotHxc
maki49 Oct 12, 2024
fb986fd
move the psi wrapper into LR_Util
maki49 Oct 12, 2024
03e06c8
refactor hsolver_lr
maki49 Oct 14, 2024
5714cd6
change X from Psi to pointer in dm_trans and AX
maki49 Oct 14, 2024
93af21a
refactor HSolverLR and remove the inheritance of HamiltLR
maki49 Oct 15, 2024
1bfaaf9
read/write value tool funcs
maki49 Oct 15, 2024
acd25f4
store X with ct::Tensor instead of Psi
maki49 Oct 15, 2024
fb9cafa
use const ref instead of pointer for Parallel_2D
maki49 Oct 16, 2024
0861ceb
key: ULR Hamilt & tear down HSolverLR
maki49 Oct 16, 2024
58b8575
pass spin-type to PotHxc
maki49 Oct 17, 2024
8ccfd68
rebase develop and update DM
maki49 Oct 17, 2024
ca4598b
traverse states outside of act()
maki49 Oct 18, 2024
879fc01
fix a fatal bug of AX index
maki49 Oct 18, 2024
f95da5f
remove nspin_solve
maki49 Oct 18, 2024
cfc6a80
openshell support for spectrum
maki49 Oct 19, 2024
00f6b96
add parameter lr_unrestricted
maki49 Oct 19, 2024
196fc4e
fix the parallel copy of eigenvectors
maki49 Oct 19, 2024
e295015
enable complex spin2 and fix a parameter bug
maki49 Oct 19, 2024
80e64b2
restrict DM size within orb_rcut
maki49 Oct 20, 2024
cda658e
remove band-traverse and recover RI-benchmark
maki49 Oct 20, 2024
8807912
update LR cases: cover spin2 and dav_subspace
maki49 Oct 20, 2024
fb2deb1
add a test case for open-shell solver
maki49 Oct 20, 2024
efbc072
fix compile error
maki49 Oct 20, 2024
c1eb129
minor fixes
maki49 Oct 21, 2024
b275f3b
Merge branch 'develop' into openshell
mohanchen Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -3957,6 +3957,13 @@ Currently supported: `RPA`, `LDA`, `PBE`, `HSE`, `HF`.
- **Description**: The number of 2-particle states to be solved
- **Default**: 0

### lr_unrestricted
- **Type**: Boolean
- **Description**: Whether to use unrestricted construction for LR-TDDFT (the matrix size will be doubled).
- True: Always use unrestricted LR-TDDFT.
- False: Use unrestricted LR-TDDFT only when the system is open-shell.
- **Default**: False

### abs_wavelen_range

- **Type**: Real Real
Expand Down
1 change: 0 additions & 1 deletion source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,6 @@ OBJS_TENSOR=tensor.o\
operator_lr_exx.o\
kernel_xc.o\
pot_hxc_lrtd.o\
hsolver_lrtd.o\
lr_spectrum.o\
hamilt_casida.o\
esolver_lrtd_lcao.o\
1 change: 1 addition & 0 deletions source/module_basis/module_ao/parallel_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Parallel_2D
~Parallel_2D() = default;

Parallel_2D& operator=(Parallel_2D&& rhs) = default;
Parallel_2D(Parallel_2D&& rhs) = default;

/// number of local rows
int get_row_size() const
Expand Down
9 changes: 2 additions & 7 deletions source/module_esolver/esolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,8 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
else if (esolver_type == "lr_lcao")
{
// use constructor rather than Init function to initialize reference (instead of pointers) to ucell
if (PARAM.globalv.gamma_only_local){
return new LR::ESolver_LR<double, double>(inp, ucell);
} else if (PARAM.inp.nspin < 2) {
return new LR::ESolver_LR<std::complex<double>, double>(inp, ucell);
} else {
throw std::runtime_error("LR-TDDFT is not implemented for spin polarized case");
}
if (PARAM.globalv.gamma_only_local) { return new LR::ESolver_LR<double, double>(inp, ucell); }
else { return new LR::ESolver_LR<std::complex<double>, double>(inp, ucell); }
}
else if (esolver_type == "ksdft_lr_lcao")
{
Expand Down
10 changes: 6 additions & 4 deletions source/module_io/read_input_item_tddft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ void ReadInput::item_lr_tddft()
read_sync_bool(input.out_wfc_lr);
this->add_item(item);
}
{
Input_Item item("lr_unrestricted");
item.annotation = "Whether to use unrestricted construction for LR-TDDFT";
read_sync_bool(input.lr_unrestricted);
this->add_item(item);
}
{
Input_Item item("abs_wavelen_range");
item.annotation = "the range of wavelength(nm) to output the absorption spectrum ";
Expand All @@ -337,10 +343,6 @@ void ReadInput::item_lr_tddft()
para.input.abs_wavelen_range.push_back(std::stod(item.str_values[i]));
}
};
item.check_value = [](const Input_Item& item, const Parameter& para) {
auto& awr = para.input.abs_wavelen_range;
if (awr.size() < 2) { ModuleBase::WARNING_QUIT("ReadInput", "abs_wavelen_range must have two values"); }
};
sync_doublevec(input.abs_wavelen_range, 2, 0.0);
this->add_item(item);
}
Expand Down
1 change: 1 addition & 0 deletions source/module_io/test/read_input_ptest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ TEST_F(InputParaTest, ParaRead)
EXPECT_EQ(param.inp.xc_kernel, "LDA");
EXPECT_EQ(param.inp.lr_solver, "dav");
EXPECT_DOUBLE_EQ(param.inp.lr_thr, 1e-2);
EXPECT_FALSE(param.inp.lr_unrestricted);
EXPECT_FALSE(param.inp.out_wfc_lr);
EXPECT_EQ(param.inp.abs_wavelen_range.size(), 2);
EXPECT_DOUBLE_EQ(param.inp.abs_wavelen_range[0], 0.0);
Expand Down
28 changes: 14 additions & 14 deletions source/module_lr/AX/AX.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ namespace LR
const psi::Psi<double>& c,
const int& nocc,
const int& nvirt,
psi::Psi<double>& AX_istate);
double* AX_istate);
void cal_AX_blas(
const std::vector<container::Tensor>& V_istate,
const psi::Psi<double>& c,
const int& nocc,
const int& nvirt,
psi::Psi<double>& AX_istate,
double* AX_istate,
const bool add_on = true);
#ifdef __MPI
void cal_AX_pblas(
const std::vector<container::Tensor>& V_istate,
const Parallel_2D& pmat,
const psi::Psi<double>& c,
const Parallel_2D& pc,
int naos,
int nocc,
int nvirt,
Parallel_2D& pX,
psi::Psi<double>& AX_istate,
const int& naos,
const int& nocc,
const int& nvirt,
const Parallel_2D& pX,
double* AX_istate,
const bool add_on=true);
#endif
// complex
Expand All @@ -40,13 +40,13 @@ namespace LR
const psi::Psi<std::complex<double>>& c,
const int& nocc,
const int& nvirt,
psi::Psi<std::complex<double>>& AX_istate);
std::complex<double>* AX_istate);
void cal_AX_blas(
const std::vector<container::Tensor>& V_istate,
const psi::Psi<std::complex<double>>& c,
const int& nocc,
const int& nvirt,
psi::Psi<std::complex<double>>& AX_istate,
std::complex<double>* AX_istate,
const bool add_on = true);

#ifdef __MPI
Expand All @@ -55,11 +55,11 @@ namespace LR
const Parallel_2D& pmat,
const psi::Psi<std::complex<double>>& c,
const Parallel_2D& pc,
int naos,
int nocc,
int nvirt,
Parallel_2D& pX,
psi::Psi<std::complex<double>>& AX_istate,
const int& naos,
const int& nocc,
const int& nvirt,
const Parallel_2D& pX,
std::complex<double>* AX_istate,
const bool add_on = true);
#endif
}
46 changes: 20 additions & 26 deletions source/module_lr/AX/AX_parallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,25 @@ namespace LR
const Parallel_2D& pmat,
const psi::Psi<double>& c,
const Parallel_2D& pc,
int naos,
int nocc,
int nvirt,
Parallel_2D& pX,
psi::Psi<double>& AX_istate,
const int& naos,
const int& nocc,
const int& nvirt,
const Parallel_2D& pX,
double* AX_istate,
const bool add_on)
{
ModuleBase::TITLE("hamilt_lrtd", "cal_AX_pblas");
assert(pmat.comm() == pc.comm());
assert(pmat.blacs_ctxt == pc.blacs_ctxt);

if (pX.comm() != pmat.comm() || pX.blacs_ctxt != pmat.blacs_ctxt)
LR_Util::setup_2d_division(pX, pmat.get_block_size(), nvirt, nocc, pmat.blacs_ctxt);
else assert(pX.get_local_size() > 0 && AX_istate.get_nbasis() == pX.get_local_size());
assert(pmat.comm() == pc.comm() && pmat.comm() == pX.comm());
assert(pmat.blacs_ctxt == pc.blacs_ctxt && pmat.blacs_ctxt == pX.blacs_ctxt);
assert(pX.get_local_size() > 0);

const int nks = V_istate.size();

Parallel_2D pVc; // for intermediate Vc
LR_Util::setup_2d_division(pVc, pmat.get_block_size(), naos, nocc, pmat.blacs_ctxt);
for (int isk = 0;isk < nks;++isk)
{
AX_istate.fix_k(isk);
const int ax_start = isk * pX.get_local_size();
c.fix_k(isk);

//Vc
Expand All @@ -60,7 +57,7 @@ namespace LR
pdgemm_(&transa, &transb, &nvirt, &nocc, &naos,
&alpha, c.get_pointer(), &i1, &ivirt, pc.desc,
Vc.data<double>(), &i1, &i1, pVc.desc,
&beta, AX_istate.get_pointer(), &i1, &i1, pX.desc);
&beta, AX_istate + ax_start, &i1, &i1, pX.desc);

}
}
Expand All @@ -70,28 +67,25 @@ namespace LR
const Parallel_2D& pmat,
const psi::Psi<std::complex<double>>& c,
const Parallel_2D& pc,
int naos,
int nocc,
int nvirt,
Parallel_2D& pX,
psi::Psi<std::complex<double>>& AX_istate,
const int& naos,
const int& nocc,
const int& nvirt,
const Parallel_2D& pX,
std::complex<double>* AX_istate,
const bool add_on)
{
ModuleBase::TITLE("hamilt_lrtd", "cal_AX_plas");
assert(pmat.comm() == pc.comm());
assert(pmat.blacs_ctxt == pc.blacs_ctxt);

if (pX.comm() != pmat.comm() || pX.blacs_ctxt != pmat.blacs_ctxt)
LR_Util::setup_2d_division(pX, pmat.get_block_size(), nvirt, nocc, pmat.blacs_ctxt);
else assert(pX.get_local_size() > 0 && AX_istate.get_nbasis() == pX.get_local_size());
assert(pmat.comm() == pc.comm() && pmat.comm() == pX.comm());
assert(pmat.blacs_ctxt == pc.blacs_ctxt && pmat.blacs_ctxt == pX.blacs_ctxt);
assert(pX.get_local_size() > 0);

const int nks = V_istate.size();

Parallel_2D pVc; // for intermediate Vc
LR_Util::setup_2d_division(pVc, pmat.get_block_size(), naos, nocc, pmat.blacs_ctxt);
for (int isk = 0;isk < nks;++isk)
{
AX_istate.fix_k(isk);
const int ax_start = isk * pX.get_local_size();
c.fix_k(isk);

//Vc
Expand All @@ -116,7 +110,7 @@ namespace LR
pzgemm_(&transa, &transb, &nvirt, &nocc, &naos,
&alpha, c.get_pointer(), &i1, &ivirt, pc.desc,
Vc.data<std::complex<double>>(), &i1, &i1, pVc.desc,
&beta, AX_istate.get_pointer(), &i1, &i1, pX.desc);
&beta, AX_istate + ax_start, &i1, &i1, pX.desc);
}
}
}
Expand Down
30 changes: 14 additions & 16 deletions source/module_lr/AX/AX_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ namespace LR
const psi::Psi<double>& c,
const int& nocc,
const int& nvirt,
psi::Psi<double>& AX_istate)
double* AX_istate)
{
ModuleBase::TITLE("hamilt_lrtd", "cal_AX_forloop");
const int nks = V_istate.size();
int naos = c.get_nbasis();
AX_istate.fix_k(0);
ModuleBase::GlobalFunc::ZEROS(AX_istate.get_pointer(), nks * nocc * nvirt);
ModuleBase::GlobalFunc::ZEROS(AX_istate, nks * nocc * nvirt);

for (int isk = 0;isk < nks;++isk)
{
c.fix_k(isk);
AX_istate.fix_k(isk);
const int ax_start = isk * nocc * nvirt;
for (int i = 0;i < nocc;++i)
{
for (int a = 0;a < nvirt;++a)
Expand All @@ -29,7 +28,7 @@ namespace LR
{
for (int mu = 0;mu < naos;++mu)
{
AX_istate(i * nvirt + a) += c(nocc + a, mu) * V_istate[isk].data<double>()[nu * naos + mu] * c(i, nu);
AX_istate[ax_start + i * nvirt + a] += c(nocc + a, mu) * V_istate[isk].data<double>()[nu * naos + mu] * c(i, nu);
}
}
}
Expand All @@ -41,18 +40,17 @@ namespace LR
const psi::Psi<std::complex<double>>& c,
const int& nocc,
const int& nvirt,
psi::Psi<std::complex<double>>& AX_istate)
std::complex<double>* AX_istate)
{
ModuleBase::TITLE("hamilt_lrtd", "cal_AX_forloop");
const int nks = V_istate.size();
int naos = c.get_nbasis();
AX_istate.fix_k(0);
ModuleBase::GlobalFunc::ZEROS(AX_istate.get_pointer(), nks * nocc * nvirt);
ModuleBase::GlobalFunc::ZEROS(AX_istate, nks * nocc * nvirt);

for (int isk = 0;isk < nks;++isk)
{
c.fix_k(isk);
AX_istate.fix_k(isk);
const int ax_start = isk * nocc * nvirt;
for (int i = 0;i < nocc;++i)
{
for (int a = 0;a < nvirt;++a)
Expand All @@ -61,7 +59,7 @@ namespace LR
{
for (int mu = 0;mu < naos;++mu)
{
AX_istate(i * nvirt + a) += std::conj(c(nocc + a, mu)) * V_istate[isk].data<std::complex<double>>()[nu * naos + mu] * c(i, nu);
AX_istate[ax_start + i * nvirt + a] += std::conj(c(nocc + a, mu)) * V_istate[isk].data<std::complex<double>>()[nu * naos + mu] * c(i, nu);
}
}
}
Expand All @@ -74,7 +72,7 @@ namespace LR
const psi::Psi<double>& c,
const int& nocc,
const int& nvirt,
psi::Psi<double>& AX_istate,
double* AX_istate,
const bool add_on)
{
ModuleBase::TITLE("hamilt_lrtd", "cal_AX_blas");
Expand All @@ -84,7 +82,7 @@ namespace LR
for (int isk = 0;isk < nks;++isk)
{
c.fix_k(isk);
AX_istate.fix_k(isk);
const int ax_start = isk * nocc * nvirt;

// Vc[naos*nocc]
container::Tensor Vc(DAT::DT_DOUBLE, DEV::CpuDevice, { nocc, naos });// (Vc)^T
Expand All @@ -101,15 +99,15 @@ namespace LR
//AX_istate=c^TVc (nvirt major)
dgemm_(&transa, &transb, &nvirt, &nocc, &naos, &alpha,
c.get_pointer(nocc), &naos, Vc.data<double>(), &naos, &beta,
AX_istate.get_pointer(), &nvirt);
AX_istate + ax_start, &nvirt);
}
}
void cal_AX_blas(
const std::vector<container::Tensor>& V_istate,
const psi::Psi<std::complex<double>>& c,
const int& nocc,
const int& nvirt,
psi::Psi<std::complex<double>>& AX_istate,
std::complex<double>* AX_istate,
const bool add_on)
{
ModuleBase::TITLE("hamilt_lrtd", "cal_AX_blas");
Expand All @@ -119,7 +117,7 @@ namespace LR
for (int isk = 0;isk < nks;++isk)
{
c.fix_k(isk);
AX_istate.fix_k(isk);
const int ax_start = isk * nocc * nvirt;

// Vc[naos*nocc] (V is hermitian)
container::Tensor Vc(DAT::DT_COMPLEX_DOUBLE, DEV::CpuDevice, { nocc, naos });// (Vc)^T
Expand All @@ -136,7 +134,7 @@ namespace LR
//AX_istate=c^\dagger Vc (nvirt major)
zgemm_(&transa, &transb, &nvirt, &nocc, &naos, &alpha,
c.get_pointer(nocc), &naos, Vc.data<std::complex<double>>(), &naos, &beta,
AX_istate.get_pointer(), &nvirt);
AX_istate + ax_start, &nvirt);
}
}
}
Loading
Loading