ERKALE
ERKALE - DFT from Hel
 All Classes Functions Variables Friends Pages
spherical_expansion.h
1 /*
2  * This source code is part of
3  *
4  * E R K A L E
5  * -
6  * DFT from Hel
7  *
8  * Written by Susi Lehtola, 2010-2011
9  * Copyright (c) 2010-2011, Susi Lehtola
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  */
16 
17 
18 
19 #ifndef ERKALE_SPHEXP
20 #define ERKALE_SPHEXP
21 
22 #include <complex>
23 #include <vector>
24 
25 // Need to include for max_am
26 #include "../basis.h"
27 
29 typedef struct {
31  int l;
33  int m;
35  std::complex<double> c;
36 } ylmcoeff_t;
37 
39 bool operator<(const ylmcoeff_t & lhs, const ylmcoeff_t & rhs);
41 bool operator==(const ylmcoeff_t & lhs, const ylmcoeff_t & rhs);
42 
43 // Forward declaration
45 
61  std::vector<ylmcoeff_t> comb;
62 
63  public:
68 
70  void add(const ylmcoeff_t & c);
72  void addylm(int l, int m, std::complex<double> c);
74  void addylm(int l, int m, double c);
75 
77  void clean();
79  void clear();
83  void print() const;
85  void sort();
86 
88  size_t getN() const;
90  ylmcoeff_t getcoeff(size_t i) const;
92  std::vector<ylmcoeff_t> getcoeffs() const;
94  int getmaxl() const;
95 
100 
103 
108 
114  SphericalExpansion & operator*=(std::complex<double> fac);
116  SphericalExpansion & operator*=(double fac);
117 
118  friend SphericalExpansion operator*(std::complex<double> fac, const SphericalExpansion & func);
119  friend SphericalExpansion operator*(double fac, const SphericalExpansion & func);
121 };
122 
124 SphericalExpansion operator*(std::complex<double> fac, const SphericalExpansion & func);
126 SphericalExpansion operator*(double fac, const SphericalExpansion & func);
127 
142  std::vector<SphericalExpansion> table;
144  int maxam;
145  public:
150 
152  void print() const;
153 
155  SphericalExpansion mult(const SphericalExpansion & lhs, const SphericalExpansion & rhs) const;
156 };
157 
160  // Expansions of shells, table[l+m+n][ind(l,m,n)]
161  std::vector< std::vector<SphericalExpansion> > table;
162 
164  size_t ind(int l, int m, int n) const;
165 
166  public:
167  CartesianExpansion(int max=2*max_am);
169 
171  SphericalExpansion get(int l, int m, int n) const;
172 };
173 
174 #endif
int m
Angular number m of term in expansion.
Definition: spherical_expansion.h:33
SphericalExpansion & operator+=(const SphericalExpansion &rhs)
Increment operator.
Definition: spherical_expansion.cpp:190
int maxam
Maximum angular momentum supported.
Definition: spherical_expansion.h:144
SphericalExpansion & operator*=(const SphericalExpansion &rhs)
Multiplication operator.
Definition: spherical_expansion.cpp:281
void add(const ylmcoeff_t &c)
Add new Ylm with coefficient c to the linear combination.
Definition: spherical_expansion.cpp:60
ylmcoeff_t getcoeff(size_t i) const
Get i:th expansion coefficient.
Definition: spherical_expansion.cpp:166
void print() const
Print multiplication table.
Definition: spherical_expansion.cpp:341
size_t getN() const
Get amount of terms in the expansion.
Definition: spherical_expansion.cpp:162
SphericalExpansion operator+(const SphericalExpansion &rhs) const
Addition operator.
Definition: spherical_expansion.cpp:182
std::vector< ylmcoeff_t > getcoeffs() const
Get expansion coefficients.
Definition: spherical_expansion.cpp:170
std::vector< ylmcoeff_t > comb
Linear combination of spherical harmonics.
Definition: spherical_expansion.h:61
SphericalExpansion()
Constructor.
Definition: spherical_expansion.cpp:54
std::vector< SphericalExpansion > table
Multiplication table of spherical harmonics.
Definition: spherical_expansion.h:142
int getmaxl() const
Get maximum value of l in expansion.
Definition: spherical_expansion.cpp:174
std::complex< double > c
Expansion coefficient.
Definition: spherical_expansion.h:35
SphericalExpansion mult(const SphericalExpansion &lhs, const SphericalExpansion &rhs) const
Multiplication operator.
Definition: spherical_expansion.cpp:351
Spherical expansion of px^l py^m pz^n.
Definition: spherical_expansion.h:159
SphericalExpansion operator*(const SphericalExpansion &rhs) const
Multiplication operator.
Definition: spherical_expansion.cpp:221
SphericalExpansion & operator-=(const SphericalExpansion &rhs)
Decrement operator.
Definition: spherical_expansion.cpp:213
SphericalExpansion operator-() const
Get negative of expansion.
Definition: spherical_expansion.cpp:197
Multiplication table of spherical harmonics.
Definition: spherical_expansion.h:140
Coefficient of expansion in spherical harmonics .
Definition: spherical_expansion.h:29
SphericalExpansion conjugate() const
Complex conjugate the expansion.
Definition: spherical_expansion.cpp:117
void clean()
Clean out the expansion by removing any entries with zero coefficient.
Definition: spherical_expansion.cpp:93
~SphericalExpansion()
Destructor.
Definition: spherical_expansion.cpp:57
void print() const
Print out the expansion.
Definition: spherical_expansion.cpp:134
void clear()
Clear out everything.
Definition: spherical_expansion.cpp:111
void addylm(int l, int m, std::complex< double > c)
Add new Ylm with coefficient c to the linear combination.
Definition: spherical_expansion.cpp:80
int l
Angular number l of term in expansion.
Definition: spherical_expansion.h:31
Class for working with spherical harmonics expansions.
Definition: spherical_expansion.h:59
void sort()
Sort the combination in increasing l, increasing m.
Definition: spherical_expansion.cpp:141
SphericalExpansionMultiplicationTable(int maxam=max_am)
Construct multiplication table that supports spherical harmonics up to maxam.
Definition: spherical_expansion.cpp:318
~SphericalExpansionMultiplicationTable()
Destructor.
Definition: spherical_expansion.cpp:338
size_t ind(int l, int m, int n) const
Get index of element at (l,m,n)