QMCPACK
OneSplineOrbData.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2023 QMCPACK developers.
6 //
7 // File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 // Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 // Jeongnim Kim, jeongnim.kim@inte.com, Intel Corp.
12 //
13 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
14 //////////////////////////////////////////////////////////////////////////////////////
15 
16 
17 #include "OneSplineOrbData.hpp"
18 #include <spline/einspline_engine.hpp>
19 #include "einspline_helper.hpp"
20 
21 namespace qmcplusplus
22 {
24 {
25  const int nx = mesh_size_[0];
26  const int ny = mesh_size_[1];
27  const int nz = mesh_size_[2];
28  //perform FFT using FFTW
29  FFTbox.resize(nx, ny, nz);
30  FFTplan = fftw_plan_dft_3d(nx, ny, nz, reinterpret_cast<fftw_complex*>(FFTbox.data()),
31  reinterpret_cast<fftw_complex*>(FFTbox.data()), +1, FFTW_ESTIMATE);
32  splineData_r.resize(nx, ny, nz);
33  if (isComplex_)
34  splineData_i.resize(nx, ny, nz);
35 
36  TinyVector<double, 3> start(0.0);
37  TinyVector<double, 3> end(1.0);
38  spline_r = einspline::create(spline_r, start, end, mesh_size_, halfG);
39  if (isComplex_)
40  spline_i = einspline::create(spline_i, start, end, mesh_size_, halfG);
41 }
42 
44  const TinyVector<int, 3>& halfG,
45  const bool isComplex)
46  : mesh_size_(mesh_size), isComplex_(isComplex)
47 {
48  create(halfG);
49 }
50 
52 
54 {
55  einspline::destroy(spline_r);
56  einspline::destroy(spline_i);
57  if (FFTplan != nullptr)
58  fftw_destroy_plan(FFTplan);
59  FFTplan = nullptr;
60 }
61 
62 /** fft and spline cG
63  * @param cG psi_g to be processed
64  * @param ti twist index
65  * @param iorb orbital index
66  *
67  * Perform FFT and spline to spline_r and spline_i
68  */
69 void OneSplineOrbData::fft_spline(const Vector<std::complex<double>>& cG,
70  const std::vector<TinyVector<int, 3>>& gvecs,
71  const TinyVector<double, 3>& primcell_kpoint,
72  const bool rotate)
73 {
74  unpack4fftw(cG, gvecs, mesh_size_, FFTbox);
75  fftw_execute(FFTplan);
76  if (isComplex_)
77  {
78  if (rotate)
80  else
81  {
83  rotate_phase_r = 1.0;
84  rotate_phase_i = 0.0;
85  }
86  einspline::set(spline_r, splineData_r.data());
87  einspline::set(spline_i, splineData_i.data());
88  }
89  else
90  {
92  einspline::set(spline_r, splineData_r.data());
93  }
94 }
95 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Type_t * data()
Definition: OhmmsArray.h:87
void fix_phase_rotate_c2c(const Array< std::complex< T >, 3 > &in, Array< std::complex< T1 >, 3 > &out, const TinyVector< T2, 3 > &twist)
void create(const TinyVector< int, 3 > &halfG)
void resize(const std::array< SIZET, D > &dims)
Resize the container.
Definition: OhmmsArray.h:65
Array< std::complex< double >, 3 > FFTbox
void fix_phase_rotate_c2r(Array< std::complex< T >, 3 > &in, Array< T1, 3 > &out, const TinyVector< T2, 3 > &twist, T &phase_r, T &phase_i)
rotate the state after 3dfft
void split_real_components_c2c(const Array< std::complex< T >, 3 > &in, Array< T1, 3 > &out_r, Array< T1, 3 > &out_i)
Split FFTs into real/imaginary components.
OneSplineOrbData(const TinyVector< int, 3 > &mesh_size, const TinyVector< int, 3 > &halfG, const bool isComplex)
hFile create(filename)
const TinyVector< int, 3 > & mesh_size_
void fft_spline(const Vector< std::complex< double >> &cG, const std::vector< TinyVector< int, 3 >> &gvecs, const TinyVector< double, 3 > &primcell_kpoint, const bool rotate)
fft and spline cG
void unpack4fftw(const Vector< std::complex< T >> &cG, const std::vector< TinyVector< int, 3 >> &gvecs, const TinyVector< int, 3 > &maxg, Array< std::complex< T >, 3 > &fftbox)
unpack packed cG to fftbox