1 /* Copyright (c) 2015 Gerald Knizia 2 * 3 * This file is part of the IboView program (see: http://www.iboview.org) 4 * 5 * IboView is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, version 3. 8 * 9 * IboView is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with bfint (LICENSE). If not, see http://www.gnu.org/licenses/ 16 * 17 * Please see IboView documentation in README.txt for: 18 * -- A list of included external software and their licenses. The included 19 * external software's copyright is not touched by this agreement. 20 * -- Notes on re-distribution and contributions to/further development of 21 * the IboView software 22 */ 23 24 #ifndef _CT_DFTGRID_H 25 #define _CT_DFTGRID_H 26 27 #include <vector> 28 #include "CxVec3.h" 29 #include "CxPodArray.h" 30 #include "CxFortranInt.h" 31 #include "CtIo.h" 32 33 namespace ct { 34 35 typedef double 36 FScalar; 37 typedef TVector3<FScalar> 38 FVector3; 39 40 struct FDftGridParams 41 { 42 double nLevel; 43 bool AdjustByAtomicRadii; 44 uint iMinL; // minimum L which this grid should expand exactly. 45 46 explicit FDftGridParams( uint iLevel_ = 3, int iMinL_=0, bool AdjustByAtomicRadii_ = true ) nLevelFDftGridParams47 : nLevel(iLevel_), AdjustByAtomicRadii(AdjustByAtomicRadii_), iMinL(iMinL_) 48 {}; 49 50 double fTargetAccuracy() const; 51 void SetTargetAccuracy(double fAcc); 52 }; 53 54 struct FAtomSet; 55 56 // 3d DFT integration grid, based on atom positions 57 struct FDftGrid : public FIntrusivePtrDest 58 { 59 struct FPoint{ 60 FVector3 61 vPos; 62 FScalar 63 fWeight; 64 ptrdiff_t 65 iAtomicCenter; 66 }; 67 68 typedef std::vector<FPoint> 69 FPointList; 70 FPointList 71 // \sum_p p.fWeight integrates to total volume. 72 Points; 73 74 struct FGridBlock { 75 size_t 76 iFirst, iLast; // grid block spans points [iFirst,iLast). 77 FVector3 78 // average of spanned points 79 vCenter; 80 FScalar 81 // radius around vCenter such that all points spanned by 82 // the block lie inside the sphere of fRadius around vCenter. 83 fRadius, 84 // largest weight of any point within the block. 85 fLargestWeight; 86 ptrdiff_t 87 // atom with which the grid point moves. -1 if not moving with a center. 88 iAtomicCenter; nPtFDftGrid::FGridBlock89 size_t nPt() const { return iLast - iFirst; } 90 }; 91 typedef std::vector<FGridBlock> 92 FGridBlockList; 93 FGridBlockList 94 GridBlocks; 95 96 FDftGrid( FAtomSet const &Atoms, FDftGridParams const &Params, FLog *pLog = 0 ); 97 ~FDftGrid(); 98 99 // data in compatibility format -- DFTI-CXX expects positions and 100 // weights as separate entities. 101 TArray<double[3]> 102 Positions; 103 TArray<double> 104 Weights; 105 106 private: 107 // copy stuff from this->Points to this->Positions and this->Weights. 108 void MakeAdditionalRepresentations(); 109 }; 110 111 typedef boost::intrusive_ptr<FDftGrid> 112 FDftGridPtr; 113 114 115 } // namespace ct 116 117 #endif // CT_DFTGRID_H 118