WaveBlocksND
energy.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../types.hpp"
4 #include "../wavepackets/hawp_commons.hpp"
5 #include "../wavepackets/hawp_gradient_operator.hpp"
6 #include "../wavepackets/hawp_gradient_evaluator.hpp"
7 #include "../innerproducts/homogeneous_inner_product.hpp"
8 
9 
10 namespace waveblocks {
11  namespace observables {
16  using utilities::Squeeze;
17 
31  template<class Potential, int D, class MultiIndex, class TQR>
32  real_t potential_energy(const ScalarHaWp<D, MultiIndex>& packet,
33  const Potential& V) {
34  HomogeneousInnerProduct<D, MultiIndex, TQR> ip;
35  return ip.quadrature(packet,
36  [&V] (const CMatrix<D,Eigen::Dynamic>& nodes,
37  const RMatrix<D,1>& pos)
39  (void)pos; // Unused
40  const dim_t n_nodes = nodes.cols();
41  CMatrix<1,Eigen::Dynamic> result(1, n_nodes);
42  for(int i = 0; i < n_nodes; ++i) {
43  result(0,i) = V.evaluate_at(Squeeze<D,CMatrix<D,Eigen::Dynamic>>::apply(nodes,i));
44  }
45  return result;
46  }
47  ).real();
48  }
49 
59  template<int D, class MultiIndex>
60  real_t kinetic_energy(const ScalarHaWp<D, MultiIndex>& packet) {
61  HaWpGradientOperator<D,MultiIndex> nabla;
62  HaWpGradient<D,MultiIndex> gradwp = nabla(packet);
63  complex_t result(0,0);
64  for (size_t i = 0 ; i < gradwp.n_components(); ++i) {
65  result += gradwp.component(i).coefficients().dot(gradwp.component(i).coefficients());
66  }
67  return 0.5 * result.real();
68  }
69 
70  template<int D,class MultiIndex>
71  real_t norm(const ScalarHaWp<D,MultiIndex>& packet)
72  {
73  complex_t result(0,0);
74  result += packet.coefficients().dot(packet.coefficients());
75  return std::sqrt(result.real());
76  }
77  }
78 }
Definition: coefficients_file_parser.cpp:10
real_t norm(const ScalarHaWp< D, MultiIndex > &packet)
Definition: energy.hpp:71
Eigen::Matrix< real_t, R, C > RMatrix
Definition: types.hpp:22
real_t kinetic_energy(const ScalarHaWp< D, MultiIndex > &packet)
Computes kinetic energy of a Hagedorn Wavepacket.
Definition: energy.hpp:60
std::complex< real_t > complex_t
Definition: types.hpp:15
double real_t
Definition: types.hpp:14
Class providing homogeneous inner product calculation of scalar wavepackets.
Definition: homogeneous_inner_product.hpp:30
This class represents the gradient of a (scalar) Hagedorn wavepacket .
Definition: hawp_gradient_operator.hpp:29
Concrete implementation of a scalar Hagedorn wavepacket.
Definition: hawp_commons.hpp:209
Eigen::Matrix< complex_t, R, C > CMatrix
Definition: types.hpp:19
real_t potential_energy(const ScalarHaWp< D, MultiIndex > &packet, const Potential &V)
Computes potential energy of a Hagedorn Wavepacket.
Definition: energy.hpp:32
Definition: squeeze.hpp:7
int dim_t
Definition: types.hpp:16
This class applies the gradient operator to an arbitrary scalar wavepacket .
Definition: hawp_gradient_operator.hpp:286