1#ifndef W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_HAMILT_LCAO_MODULE_TDDFT_EVOLVE_ELEC_H
2#define W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_HAMILT_LCAO_MODULE_TDDFT_EVOLVE_ELEC_H
20template <
typename TK,
typename TR>
22template <
typename TR,
typename Device>
39 for (
int i = 0; i < tensor.
shape().ndim(); ++i)
54 double clean_val = (std::abs(val) <
threshold) ? 0.0 :
static_cast<double>(val);
59 double re = (std::abs(val.real()) <
threshold) ? 0.0 : val.real();
60 double im = (std::abs(val.imag()) <
threshold) ? 0.0 : val.imag();
66 const std::vector<int64_t>& shape,
67 const std::vector<int64_t>& strides,
69 std::vector<int64_t>& indices,
70 const std::string& name,
73 if (dim == shape.size())
76 for (
size_t i = 0; i < indices.size(); ++i)
88 for (int64_t i = 0; i < shape[dim]; ++i)
104 p_tensor = &cpu_tensor_buffer;
107 const std::vector<int64_t>& shape = p_tensor->
shape().
dims();
108 const std::vector<int64_t>& strides = p_tensor->
shape().
strides();
110 const T* data = p_tensor->
data<
T>();
112 std::vector<int64_t> indices(shape.size(), 0);
125 p_tensor = &cpu_tensor_buffer;
128 const std::vector<int64_t>& shape = p_tensor->
shape().
dims();
129 const std::vector<int64_t>& strides = p_tensor->
shape().
strides();
131 const std::complex<double>* data = p_tensor->
data<std::complex<double>>();
133 std::vector<int64_t> indices(shape.size(), 0);
141template <
typename Device = base_device::DEVICE_CPU>
155 static void
solve_psi(const std::vector<EijOutputInfo>& eij_output,
159 hamilt::Hamilt<std::complex<double>>* phm,
160 const Parallel_Blkcyclic& matrix_layout,
161 const Parallel_Blkcyclic& wfc_layout,
162 const Parallel_Blkcyclic& mo_repr_layout,
163 psi::Psi<std::complex<double>>* psi,
164 psi::Psi<std::complex<double>>* psi_laststep,
165 ct::Tensor& Hk_laststep,
166 ct::Tensor& Sk_laststep,
167 ModuleBase::matrix& ekb,
168 std::ofstream& ofs_running,
169 const int propagator,
170 const bool use_tensor,
171 const bool use_lapack,
172 module_rt::TD_MovingGauge* td_mg,
173 const UnitCell* ucell,
174 const std::vector<ModuleBase::Vector3<double>>& kvec_d,
175 const bool use_td_moving_gauge);
compute band energy ekb This file originally belonged to file LCAO_evolve.cpp
Real-time TDDFT energy solver using the LCAO basis.
Definition esolver_ks_lcao_tddft.h:24
Kohn-Sham energy solver using the LCAO basis.
Definition esolver_ks_lcao.h:33
Parallel block-cyclic matrix distribution.
Definition parallel_blkcyc.h:25
int64_t dim_size(int dim) const
Get the size of a dimension in the tensor.
Definition tensor_shape.cpp:31
const std::vector< int64_t > & dims() const
Get all dimension sizes in the tensor.
Definition tensor_shape.cpp:36
unsigned int ndim() const
Get the ndim of the tensor.
Definition tensor_shape.cpp:46
const std::vector< int64_t > & strides() const
Definition tensor_shape.cpp:41
A multi-dimensional array of elements of a single data type.
Definition tensor.h:32
Tensor to_device() const
Method to transform data from a given tensor object to the output tensor with a given device type.
Definition tensor.h:231
void * data() const
Get a pointer to the data buffer of the tensor.
Definition tensor.cpp:73
DeviceType device_type() const
Get the data type of the tensor.
Definition tensor.cpp:64
const TensorShape & shape() const
Get the shape of the tensor.
Definition tensor.cpp:67
base_device::memory::synchronize_memory_op< double, base_device::DEVICE_CPU, Device > syncmem_double_d2h_op
Definition evolve_elec.h:184
static ct::DeviceType ct_device_type
Definition evolve_elec.h:178
typename ct::PsiToContainer< Device >::type ct_Device
Definition evolve_elec.h:180
base_device::memory::synchronize_memory_op< double, Device, base_device::DEVICE_CPU > syncmem_double_h2d_op
Definition evolve_elec.h:183
base_device::memory::synchronize_memory_op< std::complex< double >, Device, base_device::DEVICE_CPU > syncmem_complex_h2d_op
Definition evolve_elec.h:185
static void solve_psi(const std::vector< EijOutputInfo > &eij_output, const int nband, const int nlocal, const int &nks, hamilt::Hamilt< std::complex< double > > *phm, const Parallel_Blkcyclic &matrix_layout, const Parallel_Blkcyclic &wfc_layout, const Parallel_Blkcyclic &mo_repr_layout, psi::Psi< std::complex< double > > *psi, psi::Psi< std::complex< double > > *psi_laststep, ct::Tensor &Hk_laststep, ct::Tensor &Sk_laststep, ModuleBase::matrix &ekb, std::ofstream &ofs_running, const int propagator, const bool use_tensor, const bool use_lapack, module_rt::TD_MovingGauge *td_mg, const UnitCell *ucell, const std::vector< ModuleBase::Vector3< double > > &kvec_d, const bool use_td_moving_gauge)
Definition evolve_elec.cpp:20
Evolve_elec()
Definition evolve_elec.cpp:11
base_device::memory::synchronize_memory_op< std::complex< double >, base_device::DEVICE_CPU, Device > syncmem_complex_d2h_op
Definition evolve_elec.h:186
#define complex
Definition elpa_new.h:28
void print_tensor_shape(const ct::Tensor &tensor, const std::string &name)
Definition evolve_elec.h:36
void print_single_element(const T &val, double threshold)
Definition evolve_elec.h:52
void print_tensor_data(const ct::Tensor &tensor, const std::string &name)
Definition evolve_elec.h:96
void print_tensor_data_recursive(const T *data, const std::vector< int64_t > &shape, const std::vector< int64_t > &strides, int dim, std::vector< int64_t > &indices, const std::string &name, const double threshold=1e-10)
Definition evolve_elec.h:65
#define T
Definition exp.cpp:237
std::ofstream ofs_running
Definition global_variable.cpp:38
The First-Principles (FP) Energy Solver Class.
Definition opt_test_tools.cpp:93
DeviceType
Definition tensor_enums.h:28
@ CpuDevice
Definition tensor_enums.h:30
Definition band_energy.cpp:21
#define threshold
Definition sph_bessel_rec_test.cpp:4
Definition memory_op.h:61
Definition tensor_enums.h:25
Definition tensor_types.h:75