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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 //                    Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 //                    Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 //
11 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
15 #ifndef QMCPLUSPLUS_BAREPRESSURE_H
16 #define QMCPLUSPLUS_BAREPRESSURE_H
17 #include "Particle/ParticleSet.h"
18 #include "Particle/WalkerSetRef.h"
19 #include "QMCDrivers/WalkerProperties.h"
20 #include "QMCHamiltonians/OperatorBase.h"
21 #include "ParticleBase/ParticleAttribOps.h"
22 #include "OhmmsData/ParameterSet.h"
23 
24 
25 namespace qmcplusplus
26 {
27 /** @ingroup hamiltonian
28  @brief Evaluate the Bare Pressure.
29  P=/frac{2T+V}{d* /Omega}
30  where d is the dimension of space and /Omega is the volume.
31 **/
32 
33 struct Pressure : public OperatorBase
34 {
35   using WP = WalkerProperties::Indexes;
36   double pNorm;
37   //     bool ZV;
38   //     bool ZB;
39 
40   /** constructor
41    *
42    * Pressure operators need to be re-evaluated during optimization.
43    */
PressurePressure44   Pressure(ParticleSet& P)
45   {
46     UpdateMode.set(OPTIMIZABLE, 1);
47     pNorm = 1.0 / (P.Lattice.DIM * P.Lattice.Volume);
48   }
49   ///destructor
~PressurePressure50   ~Pressure() {}
51 
resetTargetParticleSetPressure52   void resetTargetParticleSet(ParticleSet& P) { pNorm = 1.0 / (P.Lattice.DIM * P.Lattice.Volume); }
53 
evaluatePressure54   inline Return_t evaluate(ParticleSet& P)
55   {
56     Value = 2.0 * P.PropertyList[WP::LOCALENERGY] - P.PropertyList[WP::LOCALPOTENTIAL];
57     Value *= pNorm;
58     return 0.0;
59   }
60 
61   /** implements the virtual function.
62    *
63    * Nothing is done but should check the mass
64    */
65 
putPressure66   bool put(xmlNodePtr cur) { return true; }
67 
68   //     bool put(xmlNodePtr cur, ParticleSet& P, QMCHamiltonian* H) {
69   //       xmlNodePtr tcur = cur->children;
70   //
71   //       double RPAKCut= -1.0;
72   //       std::string RPAPCorr("ZB");
73   //       std::string RPAPfunc("RPA_LR");
74   //       ParameterSet nattrib;
75   //       OhmmsAttributeSet attrib;
76   //       attrib.add(RPAPCorr,"etype" );
77   //       attrib.add(RPAPfunc,"functor" );
78   //       attrib.put(cur);
79   //       nattrib.add(RPAKCut,"kc");
80   //       nattrib.put(cur);
81 
82   //       if (RPAPCorr=="ZB"){
83   //         ZB=true;
84   //         ZV=false;
85   //         bpcorr = new RPAPressureCorrection(P);
86   //         bpcorr-> put(cur, P);
87   //         H->addOperator(bpcorr,"ZVterm");
88   //       }
89   //       else if (RPAPCorr=="ZVZB"){
90   //         ZB=true;
91   //         ZV=true;
92   //         bpcorr = new RPAPressureCorrection(P);
93   //         wfderivE = new RPADerivEnergy(P);
94   //         wfderivE2 = new RPADerivEnergy2(P);
95   //         wfEP = new RPAEnergyPressure(P);
96   //         bpcorr-> put(cur, P);
97   //         wfderiv = new RPADeriv(P);
98   //         wfderiv -> put(cur, bpcorr);
99   //         wfderivE -> put(cur, bpcorr, H);
100   //         wfderivE2 -> put(cur, bpcorr, H);
101   //         wfEP -> put(cur, bpcorr, H);
102   //         potkin = new RPAPotKin(P);
103   //         H->addOperator(potkin,"PotKin");
104   //         H->addOperator(wfEP,"EPterm");
105   //         H->addOperator(bpcorr,"ZVterm");
106   //         H->addOperator(wfderiv,"dpsi");
107   //         H->addOperator(wfderivE,"Edpsi");
108   //         H->addOperator(wfderivE2,"Tdpsi");
109   //       }
110   //       else if (RPAPCorr=="ZV"){
111   //         ZV=true;
112   //         ZB=false;
113   //         bpcorr = new RPAPressureCorrection(P);
114   //         bpcorr-> put(cur, P);
115   //         H->addOperator(bpcorr,"ZVterm");
116   //       }
117   //       else if (RPAPCorr=="none"){
118   //         ZV=false;
119   //         ZB=false;
120   //         app_log() <<" using bare estimator "<< std::endl;;
121   //       }
122 
123   //       return true;
124   //     }
125 
getPressure126   bool get(std::ostream& os) const
127   {
128     os << "Pressure";
129     return true;
130   }
131 
makeClonePressure132   OperatorBase* makeClone(ParticleSet& qp, TrialWaveFunction& psi) { return new Pressure(qp); }
133 };
134 } // namespace qmcplusplus
135 #endif
136