delphi_cb
 All Classes Namespaces Files Functions Variables Macros
site.h
1 /*
2  * site.h
3  *
4  * Created on: Feb 17, 2014
5  * Author: chuan
6  */
7 
8 #ifndef SITE_H_
9 #define SITE_H_
10 
11 #include <iostream>
12 #include <iomanip>
13 #include <fstream>
14 #include <memory>
15 #include <cstdio>
16 
17 #include "../interface/interface_datacontainer.h"
18 #include "../misc/misc_timer.h"
19 #include "../misc/misc_interpl.h"
20 #include "../delphi/delphi_constants.h"
21 #include "../io/io.h"
22 #include "site_exceptions.h"
23 
24 using namespace std;
25 
26 class CSite:public CIO
27 {
28  private:
29  /*********************************************************************************************
30  * *
31  * references to the variables obtained from the data container *
32  * *
33  ********************************************************************************************/
34  shared_ptr<CTimer> pTimer;
35  //----- set by statements
36  const delphi_integer& iGrid; // igrid
37  const delphi_real& fPercentageFill; // perfil
38  const delphi_real& fExDielec; // repsout
39  const delphi_real& fIonRadius; // exrad
40  const vector<delphi_real>& rgfProbeRadius; // radprb
41  const int& iLinIterateNum; // nlit
42  const int& iNonIterateNum; // nnit
43  const int& iBndyType; // ibctyp
44  const delphi_real& fPotentialUpperBond; // atompotdist
45  const bool& bOutCrgDensity; // iconc
46  //----- io file names
47  const string& strFrciFile; // frcinam
48  const string& strFrcFile; // frcnam
49  const string& strPhiFile; // phinam
50  //----- set by functions
51  const bool& bAtomInSite; // isita
52  const bool& bSaltInSite; // isiti
53  const bool& bMDInSite; // isitmd
54  const bool& bPotentialInSite; // isitpot
55  const int& iPhiFormatOut; // phifrm
56  const bool& bBiosystemOut; // ibios
57  //----- set by DelPhi
58  const delphi_real& fIonStrength; // rionst
59  const SGrid<delphi_real>& fgBoxCenter; // oldmid
60  const vector< SGrid<delphi_real> >& prgfgAtomCoordA; // xn1(natom)
61  const delphi_real& fTaylorCoeff1; // chi1
62  const delphi_real& fTaylorCoeff2; // chi2
63  const delphi_real& fTaylorCoeff3; // chi3
64  const delphi_real& fTaylorCoeff4; // chi4
65  const delphi_real& fTaylorCoeff5; // chi5
66  //----- set by Surface class
67  const delphi_integer& iBndyGridNum; // ibnum
68  const delphi_integer& iCrgGridNum; // nqass
69  const vector< SGridValue<delphi_real> >& prggvAtomicCrg; // atmcrg(nqass)
70  const vector< SGrid<delphi_real> >& prgfgCrgPoseA; // chgpos(ibnum)
71  const vector< SGrid<delphi_real> >& prgfgSurfCrgA; // scspos(ibnum)
72  const vector<delphi_integer>& prgiCrgAt; // crgatn(nqass)
73  const vector<delphi_integer>& prgiAtSurf; // atsurf(ibnum)
74  const vector< SGrid<delphi_real> >& prgfgSurfCrgE; // scsnor(ibnum)
75  const vector<bool>& prgbDielecMap; // idebmap(igrid,igrid,igrid)
76  const vector< SGrid<delphi_integer> >& prgigBndyGrid; // ibgrd(ibnum)
77  const vector<delphi_real>& prgfAtomEps; // atmeps(nqass)
78  const vector<delphi_integer>& prgiAtNdx; // atndx(ibnum)
79  //----- set by Solver class
80  const delphi_integer& iDielecBndySum; // icount2b
81  //----- set by Energy class
82  const vector<delphi_real>& prgfSurfCrgE; // schrg(ibnum)
83  //++++++++++++++++ reference to read-and-write variables from data container +++++++++++++++//
84  bool& bAtomCoordInSite; // isitx
85  bool& bCrgInSite; // isitq
86  bool& bFieldInSite; // isitf
87  bool& bGridPotentialInSite; // isitp
88  bool& bReactPotentialInSite; // isitr
89  bool& bCoulombPotentialInSite; // isitc
90  bool& bAtomPotentialInSite; // isitap
91  bool& bDebyeFractionInSite; // isitdeb
92  bool& bSurfCrgInSite; // isitsf
93  bool& bTotalForceInSite; // isittf
94  bool& bReactForceInSite; // isitrf
95  bool& bTotalPotentialInSite; // isitt
96  bool& bCoulombForceInSite; // isitcf
97  bool& bPDB2FRCInSite; // iself
98  int& iFrcFormatOut; // frcfrm
99  delphi_real& fScale; // scale
100  vector<delphi_real>& prgfPhiMap; // phimap
101  /*********************************************************************************************
102  * *
103  * variables defined in this class *
104  * *
105  ********************************************************************************************/
106  delphi_real *** phimap;
107 
108  vector< SGrid<delphi_real> > rforceeps1();
109 
110  vector< SGrid<delphi_real> > rforce();
111 
112  //delphi_real debinterpl(const SGrid<delphi_real> & gPoint);
113 
114  delphi_real tops(const SGrid<delphi_real>& xxo,const SGrid<delphi_real>& xxu,const delphi_real& crg,const delphi_real& eps,const int& flag);
115 
116  void phicon();
117 
118  void writePotential_insight(vector<delphi_real>& phimapIn);
119 
120  void writePotential_grasp(vector<delphi_real>& phimapIn);
121 
122  void writePotential_ccp4(vector<delphi_real>& phimapIn);
123 
124  void writePotential_fromPrevious(vector<delphi_real>& phimapIn);
125 
126  void writePotential_cube();
127 
128  void writePotential_delphi();
129 
130  void writePhiMap(const int& formatflag,vector<delphi_real>& phimap4,ofstream& ofFileStream);
131 
132  void expand(const int& mgrid, vector<delphi_real>& phimapIn);
133 
134  public:
135 #ifdef MCCE
136  vector<delphi_real> mcce_phiv; // to save phiv produced in site_writeSite()
137 #endif
138 
139  CSite(shared_ptr<IDataContainer> pdc,shared_ptr<CTimer> pt):
140  CIO(pdc->getKey_Val<delphi_real>("repsin"),pdc->getKey_Val<delphi_real>("epkt")),
141  pTimer(pt),
142  //----- set by statements
143  iGrid(pdc->getKey_constRef<delphi_integer>("igrid")), // modified in setFocusBndy
144  fPercentageFill(pdc->getKey_constRef<delphi_real>("perfil")),
145  fExDielec(pdc->getKey_constRef<delphi_real>("repsout")),
146  fIonRadius(pdc->getKey_constRef<delphi_real>("exrad")),
147  rgfProbeRadius(pdc->getKey_constRef< vector<delphi_real> >("radprb")),
148  iLinIterateNum(pdc->getKey_constRef<int>("nlit")),
149  iNonIterateNum(pdc->getKey_constRef<int>("nnit")),
150  iBndyType(pdc->getKey_constRef<int>("ibctyp")),
151  fPotentialUpperBond(pdc->getKey_constRef<delphi_real>("atompotdist")),
152  bOutCrgDensity(pdc->getKey_constRef<bool>("iconc")),
153  //----- io file names
154  strFrciFile(pdc->getKey_constRef<string>("frcinam")),
155  strFrcFile(pdc->getKey_constRef<string>("frcnam")),
156  strPhiFile(pdc->getKey_constRef<string>("phinam")),
157  //----- set by functions
158  bAtomInSite(pdc->getKey_constRef<bool>("isita")),
159  bSaltInSite(pdc->getKey_constRef<bool>("isiti")),
160  bMDInSite(pdc->getKey_constRef<bool>("isitmd")),
161  bPotentialInSite(pdc->getKey_constRef<bool>("isitpot")),
162  iPhiFormatOut(pdc->getKey_constRef<int>("phifrm")),
163  bBiosystemOut(pdc->getKey_constRef<bool>("ibios")),
164  //----- set by DelPhi
165  fIonStrength(pdc->getKey_constRef<delphi_real>("rionst")),
166  fgBoxCenter(pdc->getKey_constRef< SGrid<delphi_real> >("oldmid")),
167  prgfgAtomCoordA(pdc->getKey_constRef< vector< SGrid<delphi_real> > >("xn1")),
168  fTaylorCoeff1(pdc->getKey_constRef<delphi_real>("chi1")),
169  fTaylorCoeff2(pdc->getKey_constRef<delphi_real>("chi2")),
170  fTaylorCoeff3(pdc->getKey_constRef<delphi_real>("chi3")),
171  fTaylorCoeff4(pdc->getKey_constRef<delphi_real>("chi4")),
172  fTaylorCoeff5(pdc->getKey_constRef<delphi_real>("chi5")),
173  //----- set by Surface class
174  iBndyGridNum(pdc->getKey_constRef<delphi_integer>("ibnum")),
175  iCrgGridNum(pdc->getKey_constRef<delphi_integer>("nqass")),
176  prggvAtomicCrg(pdc->getKey_constRef< vector< SGridValue<delphi_real> > >("atmcrg")),
177  prgfgCrgPoseA(pdc->getKey_constRef< vector< SGrid<delphi_real> > >("chgpos")),
178  prgfgSurfCrgA(pdc->getKey_constRef< vector< SGrid<delphi_real> > >("scspos")),
179  prgiCrgAt(pdc->getKey_constRef< vector<delphi_integer> >("crgatn")),
180  prgiAtSurf(pdc->getKey_constRef< vector<delphi_integer> >("atsurf")),
181  prgfgSurfCrgE(pdc->getKey_constRef< vector< SGrid<delphi_real> > >("scsnor")),
182  prgbDielecMap(pdc->getKey_constRef< vector<bool> >("idebmap")),
183  prgigBndyGrid(pdc->getKey_constRef< vector< SGrid<delphi_integer> > >("ibgrd")),
184  prgfAtomEps(pdc->getKey_constRef< vector<delphi_real> >("atmeps")),
185  prgiAtNdx(pdc->getKey_constRef< vector<delphi_integer> >("atndx")),
186  //----- set by Solver class
187  iDielecBndySum(pdc->getKey_constRef<delphi_integer>("icount2b")),
188  //----- set by Energy class
189  prgfSurfCrgE(pdc->getKey_constRef< vector<delphi_real> >("schrg")),
190  //++++++++++++++ reference to read-and-write variables from data container ++++++++++++++//
191  bAtomCoordInSite(pdc->getKey_Ref<bool>("isitx")),
192  bCrgInSite(pdc->getKey_Ref<bool>("isitq")),
193  bFieldInSite(pdc->getKey_Ref<bool>("isitf")),
194  bGridPotentialInSite(pdc->getKey_Ref<bool>("isitp")),
195  bReactPotentialInSite(pdc->getKey_Ref<bool>("isitr")),
196  bCoulombPotentialInSite(pdc->getKey_Ref<bool>("isitc")),
197  bAtomPotentialInSite(pdc->getKey_Ref<bool>("isitap")),
198  bDebyeFractionInSite(pdc->getKey_Ref<bool>("isitdeb")),
199  bSurfCrgInSite(pdc->getKey_Ref<bool>("isitsf")),
200  bTotalForceInSite(pdc->getKey_Ref<bool>("isittf")),
201  bReactForceInSite(pdc->getKey_Ref<bool>("isitrf")),
202  bTotalPotentialInSite(pdc->getKey_Ref<bool>("isitt")),
203  bCoulombForceInSite(pdc->getKey_Ref<bool>("isitcf")),
204  bPDB2FRCInSite(pdc->getKey_Ref<bool>("iself")),
205  iFrcFormatOut(pdc->getKey_Ref<int>("frcfrm")),
206  fScale(pdc->getKey_Ref<delphi_real>("scale")),
207  prgfPhiMap(pdc->getKey_Ref< vector<delphi_real> >("phimap"))
208  {
209 #ifdef DEBUG_OBJECT
210  cout << endl;
211  cout << "****************************************************************\n";
212  cout << "* CSite is constructed *\n";
213  cout << "****************************************************************\n";
214 #endif
215 
216  //----- variables inherited from CIO class
217  iResidueNum = pdc->getKey_Val<delphi_integer>("resnummax");
218  vctfMediaEps = pdc->getKey_Val< vector<delphi_real> >("medeps");
219  iMediaNum = pdc->getKey_Val<delphi_integer>("nmedia");
220  iAtomNum = pdc->getKey_Val<delphi_integer>("natom");
221  vctapAtomPdb = pdc->getKey_Val< vector<CAtomPdb> >("delphipdb");
222 
223  //----- local variables
224  phimap = pdc->getKey_Ptr<delphi_real>("phimap",iGrid,iGrid,iGrid); // pointer to 3D phimap
225 
226  //cout << "fDielec = " << fDielec << endl;
227  };
228 
233  {
234  /*
235  * delete delphi_real *** phimap without deleting underneath prgfPhiMap in data container
236  */
237  for(int i = 0; i != iGrid; ++i)
238  {
239  //for(int j = 0; j != iGrid; ++j)
240  //{
241  // delete[] phimap[i][j];
242  //}
243  delete[] phimap[i];
244  }
245  delete[] phimap;
246 
247 #ifdef DEBUG_OBJECT
248  cout << endl;
249  cout << "****************************************************************\n";
250  cout << "* CSite is destroyed *\n";
251  cout << "****************************************************************\n";
252 #endif
253  };
254 
255  void writeSite(const int& iisitsf);
256 
257  void writePhi();
258 
259 };
260 
261 
262 
263 #endif /* SITE_H_ */
~CSite()
Definition: site.h:232
Definition: site.h:26
Definition: io.h:36