00001 /* Ergo, version 3.7, a program for linear scaling electronic structure 00002 * calculations. 00003 * Copyright (C) 2018 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, 00004 * and Anastasia Kruchinina. 00005 * 00006 * This program is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 * 00019 * Primary academic reference: 00020 * Ergo: An open-source program for linear-scaling electronic structure 00021 * calculations, 00022 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia 00023 * Kruchinina, 00024 * SoftwareX 7, 107 (2018), 00025 * <http://dx.doi.org/10.1016/j.softx.2018.03.005> 00026 * 00027 * For further information about Ergo, see <http://www.ergoscf.org>. 00028 */ 00029 00037 #ifndef BOYSFUNCTION_HEADER 00038 #define BOYSFUNCTION_HEADER 00039 00040 #include <vector> 00041 #include "realtype.h" 00042 #include "polydegree.h" 00043 00044 #include "config.h" // Needed to get the PRECISION_QUAD_FLT128 macro 00045 00046 /* We need Boys functions up to a degree 4 times the highest degree of basis functions. */ 00047 #define BOYS_N_MAX (BASIS_FUNC_POLY_MAX_DEGREE*4+1) 00048 00049 /* Tune things differently depending on required precision. */ 00050 #if defined(PRECISION_QUAD_FLT128) 00051 #define BOYS_X_MAX 120.0 00052 #define BOYS_TAB_DEGREE 12 00053 #define BOYS_NO_OF_INTERVALS 1600 00054 #elif defined(PRECISION_LONG_DOUBLE) 00055 #define BOYS_X_MAX 85.0 00056 #define BOYS_TAB_DEGREE 10 00057 #define BOYS_NO_OF_INTERVALS 300 00058 #else 00059 #define BOYS_X_MAX 75.0 00060 #define BOYS_TAB_DEGREE 10 00061 #define BOYS_NO_OF_INTERVALS 200 00062 #endif 00063 00064 typedef struct { 00065 ergo_real midx; 00066 ergo_real A[BOYS_TAB_DEGREE]; 00067 } BoysFuncIntervalStruct; 00068 00069 typedef struct { 00070 BoysFuncIntervalStruct list[BOYS_NO_OF_INTERVALS]; 00071 } BoysFuncIntervalSetStruct; 00072 00073 class BoysFunctionManager { 00074 private: 00075 std::vector<BoysFuncIntervalSetStruct> Boys_list; 00076 ergo_real SavedPrefactor_list[BOYS_N_MAX]; 00077 int Boys_init_flag; 00078 ergo_real BoysFunction_pretabulated(int n, ergo_real x) const; 00079 public: 00080 BoysFunctionManager(); 00081 void init(); 00082 ergo_real BoysFunction(int n, ergo_real x) const; 00083 ergo_real BoysFunction_expensive(int n, ergo_real x, int noOfIntegrationIntervals, int method = 0) const; 00084 // Stuff needed for Chunks&Tasks usage 00085 void write_to_buffer ( char * dataBuffer, size_t const bufferSize ) const; 00086 size_t get_size() const; 00087 void assign_from_buffer ( char const * dataBuffer, size_t const bufferSize); 00088 }; 00089 00090 #endif