QMCPACK
OrbitalImages.h
Go to the documentation of this file.
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: Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
8 // Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory
9 //
10 // File created by: Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #ifndef QMCPLUSPLUS_ORBITAL_IMAGES_H
15 #define QMCPLUSPLUS_ORBITAL_IMAGES_H
16 
19 
20 namespace qmcplusplus
21 {
22 /** "Estimator" to produce files for orbital plotting.
23  * Orbitals are evaluated on a uniform grid and written to ascii files.
24  * Only format currently supported is xsf (XCrySDen).
25  * Can print real, imag, abs, and abs^2 of each orbital.
26  * This class should work with any SPOSet.
27  * All work is performed by omp thread 0 of mpi task 0.
28  *
29  * TO USE THIS YOU NEED TO KNOW THE NAME OF THE SPOSET(S)!!!
30  * For example, using sposet_builder the names are prominently displayed:
31  *
32  * <sposet_builder type="bspline" href="pwscf.h5" tilematrix="1 0 0 0 1 0 0 0 1" twistnum="0" source="ion0" version="0.10">
33  * <sposet type="bspline" name="spo_ud" size="2" spindataset="0"/>
34  * </sposet_builder>
35  *
36  * In this case a single sposet named "spo_ud" exists.
37  *
38  * If you are using Slater-Jastrow w/o sposet_builder
39  * the sposets should be named updet and downdet.
40  *
41  *
42  * To make xsf files, add xml similar to the following to <hamiltonian/>:
43  *
44  * minimal working example: single sposet named spo_ud on a 20x20x20 grid
45  *
46  * <estimator name="OrbitalImages" type="orbitalimages" ions="ion0">
47  * <parameter name="sposets"> spo_ud </parameter>
48  * <parameter name="grid"> 20 20 20 </parameter>
49  * </estimator>
50  *
51  * as above, but print real, imag, abs, and abs^2 of orbitals (default real)
52  *
53  * <estimator name="OrbitalImages" type="orbitalimages" ions="ion0">
54  * <parameter name="sposets"> spo_ud </parameter>
55  * <parameter name="grid"> 20 20 20 </parameter>
56  * <parameter name="value"> real imag abs abs2 </parameter>
57  * </estimator>
58  *
59  * up and down sposets named spo_u and spo_d w/ individual orbitals selected
60  *
61  * <estimator name="OrbitalImages" type="orbitalimages" ions="ion0">
62  * <parameter name="sposets"> spo_u spo_d </parameter>
63  * <parameter name="spo_u"> 13 24 37 </parameter>
64  * <parameter name="spo_d"> 10 18 29 41 </parameter>
65  * <parameter name="grid"> 20 20 20 </parameter>
66  * <parameter name="value"> real imag abs abs2 </parameter>
67  * </estimator>
68  *
69  * user defined cell by cell center and axes (openbc's, subset of pbc cell)
70  *
71  * <estimator name="OrbitalImages" type="orbitalimages" ions="ion0">
72  * <parameter name="sposets"> spo_ud </parameter>
73  * <parameter name="grid"> 20 20 20 </parameter>
74  * <parameter name="center"> 2.5 2.5 2.5 </parameter>
75  * <parameter name="cell">
76  * 5.0 0.0 0.0
77  * 0.0 5.0 0.0
78  * 0.0 0.0 5.0
79  * </parameter>
80  * </estimator>
81  *
82  * user defined cell by cell corner and axes (default corner is 0 0 0)
83  *
84  * <estimator name="OrbitalImages" type="orbitalimages" ions="ion0">
85  * <parameter name="sposets"> spo_ud </parameter>
86  * <parameter name="grid"> 20 20 20 </parameter>
87  * <parameter name="corner"> 0.0 0.0 0.0 </parameter>
88  * <parameter name="cell">
89  * 5.0 0.0 0.0
90  * 0.0 5.0 0.0
91  * 0.0 0.0 5.0
92  * </parameter>
93  * </estimator>
94  *
95  * store only a batch of orbital values in memory
96  * this can save on memory for very large grids
97  * but will evaluate all orbitals #orbitals/batch_size times
98  *
99  * <estimator name="OrbitalImages" type="orbitalimages" ions="ion0">
100  * <parameter name="sposets"> spo_ud </parameter>
101  * <parameter name="grid"> 200 200 200 </parameter>
102  * <parameter name="batch_size"> 10 </parameter>
103  * </estimator>
104  *
105  */
107 {
108 public:
109  enum
110  {
112  };
113 
117  using PSPool = std::map<std::string, const std::unique_ptr<ParticleSet>>;
118 
119  ///derivative types
121  {
122  value_d = 0,
125  };
126 
127 
128  ///options for orbital value to write
130  {
131  real_val = 0,
135  };
136 
137  ///options for orbital output file format
139  {
140  xsf = 0
141  };
142 
143  ///at put() ion particleset is obtained from ParticleSetPool
144  const PSPool& psetpool;
145 
146  ///electron particleset
148 
149  ///ion particleset
151 
152  ///mpi communicator
154 
155 
156  ///file format selection
158 
159  ///orbital value selections
160  std::vector<value_types_enum> value_types;
161 
162  ///write out derivatives in addition to values
164 
165  ///names of sposets to evaluate
166  std::vector<std::string> sposet_names;
167 
168  ///indices of orbitals within each sposet to evaluate
169  const std::shared_ptr<std::vector<std::vector<int>>> sposet_indices;
170 
171  ///sposets obtained by name from SPOMap
172  std::vector<std::unique_ptr<SPOSet>> sposets;
173 
174  ///evaluate points at grid cell centers instead of edges
176 
177  ///cell bounding the evaluation grid, default is simulation cell
179 
180  ///location of cell corner, positions in the cell are corner+uvec*cell
182 
183  ///number of grid points in each direction (cell axis)
185 
186  ///stride to generate grid in arbitrary dimensions
188 
189  ///total number of grid points
190  int npoints;
191 
192  ///number of orbitals to store in memory at a time (batch_size*npoints)
194 
195  ///temporary vector to hold values of all orbitals at a single point
197 
198  ///temporary vector to hold gradients of all orbitals at a single point
200 
201  ///temporary vector to hold laplacians of all orbitals at a single point
203 
204  ///temporary array to hold values of a batch of orbitals at all grid points
206 
207  ///temporary array to hold gradients of a batch of orbitals at all grid points
209 
210  ///temporary array to hold laplacians of a batch of orbitals at all grid points
212 
213  ///temporary array to hold values of a single orbital at all grid points
214  std::vector<ValueType> orbital;
215 
216  //constructors
217  OrbitalImages(ParticleSet& P, const PSPool& PSP, Communicate* mpicomm, const SPOMap& spomap);
218  OrbitalImages(const OrbitalImages& other);
219 
220  std::string getClassName() const override { return "OrbitalImages"; }
221 
222  //standard interface
223  std::unique_ptr<OperatorBase> makeClone(ParticleSet& P, TrialWaveFunction& psi) final;
224 
225  ///read xml input
226  bool put(xmlNodePtr cur) override;
227 
228  ///hijack estimator evaluate to evaluate and write all orbitals
229  Return_t evaluate(ParticleSet& P) override;
230 
231  //optional standard interface
232  //void getRequiredTraces(TraceManager& tm);
233 
234  //required for Collectables interface
235  void addObservables(PropertySetType& plist, BufferType& olist) override {}
236  void registerCollectables(std::vector<ObservableHelper>& h5desc, hdf_archive& file) const override {}
237 
238  //should be empty for Collectables interface
239  void resetTargetParticleSet(ParticleSet& P) override {}
240  void setObservables(PropertySetType& plist) override {}
241  void setParticlePropertyList(PropertySetType& plist, int offset) override {}
242 #if !defined(REMOVE_TRACEMANAGER)
246 #endif
247 
248  //obsolete?
249  bool get(std::ostream& os) const override { return false; }
250 
251  //local functions
252  ///write brief report of configuration data
253  void report(const std::string& pad);
254 
255  ///write a single orbital to file
256  void write_orbital(const std::string& sponame,
257  int index,
258  std::vector<ValueType>& orb,
260  derivative_types_enum derivative_type = value_d,
261  int dimension = 0);
262 
263  ///write a single orbital to an xsf file
264  void write_orbital_xsf(const std::string& sponame,
265  int index,
266  std::vector<ValueType>& orb,
268  derivative_types_enum derivative_type = value_d,
269  int dimension = 0);
270 
271 private:
272  /// reference to the sposet_builder_factory
273  const SPOMap& spomap_;
274 };
275 
276 } // namespace qmcplusplus
277 
278 #endif
a class that defines a supercell in D-dimensional Euclean space.
OrbitalImages(ParticleSet &P, const PSPool &PSP, Communicate *mpicomm, const SPOMap &spomap)
formats_enum format
file format selection
Array< GradType, 2 > batch_gradients
temporary array to hold gradients of a batch of orbitals at all grid points
bool center_grid
evaluate points at grid cell centers instead of edges
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TinyVector< int, DIM > grid
number of grid points in each direction (cell axis)
Array< ValueType, 2 > batch_values
temporary array to hold values of a batch of orbitals at all grid points
derivative_types_enum
derivative types
const PSPool & psetpool
at put() ion particleset is obtained from ParticleSetPool
CrystalLattice< OHMMS_PRECISION, OHMMS_DIM > ParticleLayout
Definition: Configuration.h:79
void setObservables(PropertySetType &plist) override
Set the values evaluated by this object to plist Default implementation is to assign Value which is u...
Declaration of OperatorBase.
std::vector< std::string > sposet_names
names of sposets to evaluate
std::vector< std::unique_ptr< SPOSet > > sposets
sposets obtained by name from SPOMap
class to handle hdf file
Definition: hdf_archive.h:51
Vectorized record engine for scalar properties.
void setParticlePropertyList(PropertySetType &plist, int offset) override
#define OHMMS_DIM
Definition: config.h:64
SPOSet::ValueVector ValueVector
std::map< std::string, const std::unique_ptr< ParticleSet > > PSPool
Array< ValueType, 2 > batch_laplacians
temporary array to hold laplacians of a batch of orbitals at all grid points
Wrapping information on parallelism.
Definition: Communicate.h:68
void write_orbital(const std::string &sponame, int index, std::vector< ValueType > &orb, value_types_enum value_type, derivative_types_enum derivative_type=value_d, int dimension=0)
write a single orbital to file
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
ParticleSet * Pion
ion particleset
PosType corner
location of cell corner, positions in the cell are corner+uvec*cell
void write_orbital_xsf(const std::string &sponame, int index, std::vector< ValueType > &orb, value_types_enum value_type, derivative_types_enum derivative_type=value_d, int dimension=0)
write a single orbital to an xsf file
ValueVector spo_ltmp
temporary vector to hold laplacians of all orbitals at a single point
Lattice_t cell
cell bounding the evaluation grid, default is simulation cell
void report(const std::string &pad)
write brief report of configuration data
std::vector< ValueType > orbital
temporary array to hold values of a single orbital at all grid points
GradVector spo_gtmp
temporary vector to hold gradients of all orbitals at a single point
OrbitalSetTraits< ValueType >::ValueVector ValueVector
Definition: SPOSet.h:49
const std::shared_ptr< std::vector< std::vector< int > > > sposet_indices
indices of orbitals within each sposet to evaluate
std::vector< value_types_enum > value_types
orbital value selections
int batch_size
number of orbitals to store in memory at a time (batch_size*npoints)
"Estimator" to produce files for orbital plotting.
formats_enum
options for orbital output file format
void addObservables(PropertySetType &plist, BufferType &olist) override
named values to the property list Default implementaton uses addValue(plist_)
std::string getClassName() const override
return class name
int npoints
total number of grid points
An abstract class for Local Energy operators.
Definition: OperatorBase.h:59
void resetTargetParticleSet(ParticleSet &P) override
Reset the data with the target ParticleSet.
SPOSet::SPOMap SPOMap
const SPOMap & spomap_
reference to the sposet_builder_factory
OrbitalSetTraits< ValueType >::GradVector GradVector
Definition: SPOSet.h:51
Class to represent a many-body trial wave function.
Communicate * comm
mpi communicator
SPOSet::GradVector GradVector
ParticleSet * Peln
electron particleset
ValueVector spo_vtmp
temporary vector to hold values of all orbitals at a single point
TinyVector< int, DIM > gdims
stride to generate grid in arbitrary dimensions
void checkout_scalar_arrays(TraceManager &tm)
std::unique_ptr< OperatorBase > makeClone(ParticleSet &P, TrialWaveFunction &psi) final
QMCTraits::FullPrecRealType value_type
BareKineticEnergy::Return_t Return_t
value_types_enum
options for orbital value to write
Return_t evaluate(ParticleSet &P) override
hijack estimator evaluate to evaluate and write all orbitals
bool derivatives
write out derivatives in addition to values
void registerCollectables(std::vector< ObservableHelper > &h5desc, hdf_archive &file) const override
bool put(xmlNodePtr cur) override
read xml input