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
28 std::cout <<
"Shape of " << name <<
": [";
29 for (
int i = 0; i < tensor.
shape().ndim(); ++i)
37 std::cout <<
"]" << std::endl;
43 const std::vector<int64_t>& shape,
44 const std::vector<int64_t>& strides,
46 std::vector<int64_t>& indices,
47 const std::string& name)
49 if (dim == shape.size())
53 for (
size_t i = 0; i < indices.size(); ++i)
55 std::cout <<
"[" << indices[i] <<
"]";
57 std::cout <<
" = " << *data << std::endl;
61 for (int64_t i = 0; i < shape[dim]; ++i)
72 const std::vector<int64_t>& shape = tensor.
shape().
dims();
73 const std::vector<int64_t>& strides = tensor.
shape().
strides();
74 const T* data = tensor.
data<
T>();
75 std::vector<int64_t> indices(shape.size(), 0);
81inline void print_tensor_data<std::complex<double>>(
const ct::Tensor& tensor,
const std::string& name)
83 const std::vector<int64_t>& shape = tensor.shape().dims();
84 const std::vector<int64_t>& strides = tensor.shape().strides();
85 const std::complex<double>* data = tensor.data<std::complex<double>>();
86 std::vector<int64_t> indices(shape.size(), 0);
103 const int* desc_psi = para_orb.
desc_wfc;
104 int ctxt = desc_psi[1];
105 int nrows = desc_psi[2];
106 int ncols = desc_psi[3];
108 if (myid == root_proc)
110 psi_g.
p.reset(
new T[nrows * ncols]);
114 psi_g.
p.reset(
new T[nrows * ncols]);
118 psi_g.
desc.reset(
new int[9]{1, ctxt, nrows, ncols, nrows, ncols, 0, 0, nrows});
123 Cpxgemr2d(nrows, ncols, psi_l, 1, 1,
const_cast<int*
>(desc_psi), psi_g.
p.get(), 1, 1, psi_g.
desc.get(), ctxt);
129 const int* desc_psi = para_orb.
desc_wfc;
130 int ctxt = desc_psi[1];
131 int nrows = desc_psi[2];
132 int ncols = desc_psi[3];
135 Cpxgemr2d(nrows, ncols, psi_g.
p.get(), 1, 1, psi_g.
desc.get(), psi_l, 1, 1,
const_cast<int*
>(desc_psi), ctxt);
140template <
typename Device = base_device::DEVICE_CPU>
158 hamilt::Hamilt<std::complex<double>>* phm,
159 Parallel_Orbitals& para_orb,
160 psi::Psi<std::complex<double>>* psi,
161 psi::Psi<std::complex<double>>* psi_laststep,
162 std::complex<double>** Hk_laststep,
163 std::complex<double>** Sk_laststep,
164 ModuleBase::matrix& ekb,
165 std::ofstream& ofs_running,
167 const int propagator,
168 const bool use_tensor,
169 const bool use_lapack);
Definition esolver_ks_lcao_tddft.h:54
Definition esolver_ks_lcao.h:50
Definition parallel_orbitals.h:9
int desc_wfc[9]
Definition parallel_orbitals.h:37
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
void * data() const
Get a pointer to the data buffer of the tensor.
Definition tensor.cpp:73
const TensorShape & shape() const
Get the shape of the tensor.
Definition tensor.cpp:67
Definition evolve_elec.h:142
static ct::DeviceType ct_device_type
Definition evolve_elec.h:172
typename ct::PsiToContainer< Device >::type ct_Device
Definition evolve_elec.h:174
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, std::complex< double > **Hk_laststep, std::complex< double > **Sk_laststep, ModuleBase::matrix &ekb, std::ofstream &ofs_running, const int htype, const int propagator, const bool use_tensor, const bool use_lapack)
Definition evolve_elec.cpp:23
std::complex< double > complex
Definition diago_cusolver.cpp:13
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)
Definition evolve_elec.h:42
void print_tensor_shape(const ct::Tensor &tensor, const std::string &name)
Definition evolve_elec.h:26
void print_tensor_data(const ct::Tensor &tensor, const std::string &name)
Definition evolve_elec.h:70
#define T
Definition exp.cpp:237
DeviceType
The type of memory used by an allocator.
Definition tensor_types.h:73
Definition band_energy.cpp:11
void distributePsi(const Parallel_Orbitals ¶_orb, T *psi_l, const ModuleESolver::Matrix_g< T > &psi_g)
Definition evolve_elec.h:127
void gatherPsi(const int myid, const int root_proc, T *psi_l, const Parallel_Orbitals ¶_orb, ModuleESolver::Matrix_g< T > &psi_g)
Definition evolve_elec.h:97
std::enable_if< block2d_data_type< T >::value, void >::type Cpxgemr2d(int M, int N, T *A, int IA, int JA, int *DESCA, T *B, int IB, int JB, int *DESCB, int ICTXT)
Definition scalapack_connector.h:186
Definition esolver_ks_lcao_tddft.h:17
std::shared_ptr< T > p
Definition esolver_ks_lcao_tddft.h:18
size_t row
Definition esolver_ks_lcao_tddft.h:19
size_t col
Definition esolver_ks_lcao_tddft.h:20
std::shared_ptr< int > desc
Definition esolver_ks_lcao_tddft.h:21
Definition memory_op.h:45
Definition tensor_types.h:113