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
30 for (
int i = 0;
i < tensor.
shape().ndim(); ++
i)
45 double clean_val = (std::abs(val) <
threshold) ? 0.0 :
static_cast<double>(val);
50 double re = (std::abs(val.real()) <
threshold) ? 0.0 : val.real();
51 double im = (std::abs(val.imag()) <
threshold) ? 0.0 : val.imag();
57 const std::vector<int64_t>& shape,
58 const std::vector<int64_t>& strides,
60 std::vector<int64_t>& indices,
61 const std::string& name,
64 if (dim == shape.size())
67 for (
size_t i = 0;
i < indices.size(); ++
i)
79 for (int64_t
i = 0;
i < shape[dim]; ++
i)
92 if (tensor.
device_type() != ct::DeviceType::CpuDevice)
95 p_tensor = &cpu_tensor_buffer;
98 const std::vector<int64_t>& shape = p_tensor->
shape().
dims();
99 const std::vector<int64_t>& strides = p_tensor->
shape().
strides();
101 const T* data = p_tensor->
data<
T>();
103 std::vector<int64_t> indices(shape.size(), 0);
108inline void print_tensor_data<std::complex<double>>(
const ct::Tensor& tensor,
const std::string& name)
113 if (tensor.device_type() != ct::DeviceType::CpuDevice)
116 p_tensor = &cpu_tensor_buffer;
119 const std::vector<int64_t>& shape = p_tensor->
shape().
dims();
120 const std::vector<int64_t>& strides = p_tensor->
shape().
strides();
122 const std::complex<double>* data = p_tensor->
data<std::complex<double>>();
124 std::vector<int64_t> indices(shape.size(), 0);
132template <
typename Device = base_device::DEVICE_CPU>
150 hamilt::Hamilt<std::complex<double>>* phm,
151 Parallel_Orbitals& para_orb,
152 psi::Psi<std::complex<double>>* psi,
153 psi::Psi<std::complex<double>>* psi_laststep,
154 ct::Tensor& Hk_laststep,
155 ct::Tensor& Sk_laststep,
156 ModuleBase::matrix& ekb,
157 std::ofstream& ofs_running,
158 const int propagator,
159 const bool use_tensor,
160 const bool use_lapack,
161 module_rt::TD_MovingGauge* td_mg,
162 const UnitCell* ucell,
163 const std::vector<ModuleBase::Vector3<double>>& kvec_d,
164 const bool use_td_moving_gauge);
const std::complex< double > i
Definition cal_pLpR.cpp:46
Definition esolver_ks_lcao_tddft.h:16
Definition esolver_ks_lcao.h:33
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
Definition evolve_elec.h:134
static ct::DeviceType ct_device_type
Definition evolve_elec.h:167
typename ct::PsiToContainer< Device >::type ct_Device
Definition evolve_elec.h:169
static void solve_psi(const int &istep, const int nband, const int nlocal, const int &nks, hamilt::Hamilt< std::complex< double > > *phm, Parallel_Orbitals ¶_orb, 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:22
std::complex< double > complex
Definition diago_cusolver.cpp:15
void print_tensor_shape(const ct::Tensor &tensor, const std::string &name)
Definition evolve_elec.h:27
void print_single_element(const T &val, double threshold)
Definition evolve_elec.h:43
void print_tensor_data(const ct::Tensor &tensor, const std::string &name)
Definition evolve_elec.h:87
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:56
#define T
Definition exp.cpp:237
std::ofstream ofs_running
Definition global_variable.cpp:38
DeviceType
The type of memory used by an allocator.
Definition tensor_types.h:73
Definition band_energy.cpp:15
#define threshold
Definition sph_bessel_recursive_test.cpp:4
Definition memory_op.h:61
A tag type for identifying CPU and GPU devices.
Definition tensor_types.h:68
Definition tensor_types.h:113