1 /* PFFT headers include FFTW-MPI, and FFTW-MPI headers include FFTW and MPI. 2 No matter what, we only need to include one file. 3 4 This header is internal. We do not bother to have a serial and parallel version. 5 */ 6 7 #ifndef VDW_CORE_H 8 #define VDW_CORE_H 9 10 #include "vdwxc.h" 11 #include "vdw_kernel.h" 12 13 #if defined HAVE_CONFIG_H 14 #include "config.h" 15 #endif 16 17 #ifdef HAVE_PFFT 18 #include <pfft.h> 19 #else 20 #ifdef HAVE_MPI 21 #include <fftw3-mpi.h> 22 #else 23 #include <fftw3.h> 24 #endif 25 #endif 26 27 #define VDWXC_PI 3.14159265358979323846 28 29 void vdwxc_writefile(char* name, int N, double *array); 30 31 32 struct vdwxc_unit_cell 33 { 34 double vec[9]; 35 int Nglobal[3]; 36 int Nlocal[3]; 37 int offset[3]; 38 double dV; 39 }; 40 41 42 struct vdwxc_data_obj 43 { 44 int initialized; 45 int functional; 46 int nspin; 47 double Z_ab; 48 double q_cut; 49 struct vdwxc_unit_cell cell; 50 struct vdwxc_unit_cell icell; 51 struct vdwxc_kernel kernel; 52 53 int fft_type; 54 #ifdef HAVE_MPI 55 MPI_Comm mpi_comm; 56 #endif 57 58 int mpi_rank; 59 int mpi_size; 60 61 int Ng; // Number of local real space points 62 int Nglobal; // Number of global real space points 63 int gLDA; 64 65 int pfft_grid[2]; 66 67 double* q0_g; 68 double complex* work_ka; // theta_ga (padded), theta_ka, and F_ka. 69 70 //int Nk; // Number of local reciprocal space points 71 int kLDA; // Shortest dimension of k stored in reduced r2c-format. 72 73 double* rho_dq0drho_sg; 74 double* rho_dq0dsigma_sg; 75 76 fftw_plan plan_r2c; 77 fftw_plan plan_c2r; 78 //fftw_plan radial_plan_r2c; 79 //fftw_plan radial_plan_c2r; 80 81 // Now some non-allocated (convenience) pointers. 82 // These pointers will be used/set during a calculation, but do not 83 // involve (de)allocation of any arrays. They do save us from having 84 // to pass all those arrays as arguments though. 85 double *rho; 86 double *rho_up; 87 double *rho_dn; 88 double *sigma; 89 double *sigma_up; 90 double *sigma_dn; 91 double *dedn; 92 double *dedn_up; 93 double *dedn_dn; 94 double *dedsigma; 95 double *dedsigma_up; 96 double *dedsigma_dn; 97 // End of convenience pointers 98 99 #ifdef HAVE_PFFT 100 pfft_plan pfft_plan_r2c; 101 pfft_plan pfft_plan_c2r; 102 MPI_Comm mpi_cart_comm; 103 #endif 104 int errorcode; 105 }; 106 107 108 #define VDWXC_LDA_A 0.031091 109 #define VDWXC_LDA_a1 0.2137 110 #define VDWXC_LDA_b1 7.5957 111 #define VDWXC_LDA_b2 3.5876 112 #define VDWXC_LDA_b3 1.6382 113 #define VDWXC_LDA_b4 0.49294 114 115 #define VDWXC_KF_PREFACTOR 3.0936677262801355 // (3.0 * pi**2)**(1.0 / 3.0) 116 #define VDWXC_RS_PREFACTOR 0.6203504908994001 // (3.0 / (4.0 * pi))**(1.0 / 3.0) 117 118 #define VDWXC_ERROR_NOERROR 0 119 #define VDWXC_ERROR_UNINITIALIZED 1 120 #define VDWXC_ERROR_UNKNOWN_FUNCTIONAL 2 121 #define VDWXC_ERROR_UNIT_CELL_NOT_SET 3 122 #define VDWXC_ERROR_UNIT_CELL_ALREADY_SET 4 123 #define VDWXC_ERROR_RADIAL_GRID_NOT_SET 5 124 125 #define VDWXC_INITIALIZED (unsigned int) 0x76647778 // vdwx 126 #define VDWXC_UNINITIALIZED 0 127 128 //void vdwxc_q0_and_theta(vdwxc_data data); 129 //void vdwxc_fft_r2c(vdwxc_data data); 130 //void vdwxc_fft_c2r(vdwxc_data data); 131 //void vdwxc_potential(vdwxc_data data); 132 //void vdwxc_fatal(char* msg); 133 //void vdwxc_nullify_convenience_pointers(vdwxc_data data); 134 void vdwxc_allocate_buffers(vdwxc_data data); 135 136 //double vdwxc_calculate_anyspin(vdwxc_data data); 137 138 #ifdef HAVE_MPI 139 void vdwxc_set_communicator(vdwxc_data data, MPI_Comm mpi_comm); 140 #endif 141 142 #endif 143