atomicspectrum.hpp 3.85 KB
Newer Older
Carl Poelking's avatar
Carl Poelking committed
1
2
3
4
5
6
7
8
9
#ifndef _SOAP_ATOMICSPECTRUM_HPP
#define _SOAP_ATOMICSPECTRUM_HPP

#include <assert.h>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/complex.hpp>
#include <boost/serialization/base_object.hpp>

10
11
12
13
14
15
16
#include "soap/base/logger.hpp"
#include "soap/types.hpp"
#include "soap/globals.hpp"
#include "soap/options.hpp"
#include "soap/structure.hpp"
#include "soap/basis.hpp"
#include "soap/power.hpp"
Carl Poelking's avatar
Carl Poelking committed
17
18
19
20
21
22
23
24


namespace soap {


class AtomicSpectrum : public std::map<std::string, BasisExpansion*>
{
public:
Carl Poelking's avatar
Carl Poelking committed
25
    // EXPANSION TYPES
Carl Poelking's avatar
Carl Poelking committed
26
27
	typedef BasisExpansion qnlm_t;
	typedef PowerExpansion xnkl_t;
Carl Poelking's avatar
Carl Poelking committed
28
29
30
	typedef std::pair<std::string, std::string> type_pair_t;

	// CONTAINERS FOR STORING SCALAR FIELDS
Carl Poelking's avatar
Carl Poelking committed
31
32
	typedef std::map<std::string, qnlm_t*> map_qnlm_t; // <- key: center type, e.g. 'C'
	typedef std::map<std::pair<std::string, std::string>, xnkl_t*> map_xnkl_t; // <- key: type string pair, e.g. ('C','H')
Carl Poelking's avatar
Carl Poelking committed
33
34
35
36
37
38

	// CONTAINERS FOR STORING GRADIENTS
	typedef std::map<int, std::pair<std::string,qnlm_t*> > map_pid_qnlm_t; // <- id=>(type;qnlm)
	typedef std::map<int, map_xnkl_t> map_pid_xnkl_t; // <- id=>type=>xnkl
	typedef std::map<int, xnkl_t*> map_pid_xnkl_gc_t; // <- id=>xnkl_generic_coherent

39
40

	AtomicSpectrum(Particle *center, Basis *basis);
41
	AtomicSpectrum(Basis *basis);
42
43
44
	AtomicSpectrum() { this->null(); }
   ~AtomicSpectrum();
    void null();
Carl Poelking's avatar
Carl Poelking committed
45
46
47
    void write(std::ostream &ofs);
    void invert(map_xnkl_t &map_xnkl, xnkl_t *xnkl_generic_coherent, std::string type1, std::string type2);
    void invert(xnkl_t *xnkl, std::string type1, std::string type2);
Carl Poelking's avatar
Carl Poelking committed
48
49
50

    // CENTER & BASIS METHODS
    Particle *getCenter() { return _center; }
Carl Poelking's avatar
Carl Poelking committed
51
    int getCenterId() { return _center_id; }
Carl Poelking's avatar
Carl Poelking committed
52
53
54
55
	std::string &getCenterType() { return _center_type; }
	vec &getCenterPos() { return _center_pos; }
	Basis *getBasis() { return _basis; }
	// QNLM METHODS
56
    void addQnlm(std::string type, qnlm_t &nb_expansion);
Carl Poelking's avatar
Carl Poelking committed
57
    void addQnlmNeighbour(Particle *nb, qnlm_t *nb_expansion);
58
    qnlm_t *getQnlm(std::string type);
Carl Poelking's avatar
Carl Poelking committed
59
    qnlm_t *getQnlmGeneric() { return _qnlm_generic; }
60
61
    map_qnlm_t &getQnlmMap() { return _map_qnlm; }
    map_pid_qnlm_t &getPidQnlmMap() { return _map_pid_qnlm; }
Carl Poelking's avatar
Carl Poelking committed
62
    void mergeQnlm(AtomicSpectrum *other, double scale, bool gradients);
Carl Poelking's avatar
Carl Poelking committed
63
    // XNKL METHODS
64
    void computePower();
Carl Poelking's avatar
Carl Poelking committed
65
    void computePowerGradients();
Carl Poelking's avatar
Carl Poelking committed
66
    xnkl_t *getPower(std::string type1, std::string type2);
67
    xnkl_t *getPowerGradGeneric(int pid) { return _map_pid_xnkl_gc[pid]; }
68
    xnkl_t *getXnkl(type_pair_t &types);
Carl Poelking's avatar
Carl Poelking committed
69
    map_xnkl_t &getXnklMap() { return _map_xnkl; }
70
71
    xnkl_t *getXnklGenericCoherent() { return _xnkl_generic_coherent; }
    xnkl_t *getXnklGenericIncoherent() { return _xnkl_generic_incoherent; }
Carl Poelking's avatar
Carl Poelking committed
72

Carl Poelking's avatar
Carl Poelking committed
73
    boost::python::list getTypes();
74
    boost::python::list getNeighbourPids();
Carl Poelking's avatar
Carl Poelking committed
75
76
    static void registerPython();

Carl Poelking's avatar
Carl Poelking committed
77
78
79
80
    template<class Archive>
    void serialize(Archive &arch, const unsigned int version) {
    	// Center & basis
    	arch & _center;
81
    	arch & _center_id;
Carl Poelking's avatar
Carl Poelking committed
82
83
84
85
86
87
88
89
90
91
    	arch & _center_pos;
    	arch & _center_type;
    	arch & _basis;
    	// Qnlm's
    	arch & _map_qnlm;
    	arch & _qnlm_generic;
    	// Xnkl's
    	arch & _map_xnkl;
    	arch & _xnkl_generic_coherent;
    	arch & _xnkl_generic_incoherent;
Carl Poelking's avatar
Carl Poelking committed
92
93
94
95
    	// PID-resolved
    	arch & _map_pid_qnlm;
    	arch & _map_pid_xnkl;
    	arch & _map_pid_xnkl_gc;
Carl Poelking's avatar
Carl Poelking committed
96
97
98
99
100
    	return;
    }
protected:
    // CENTER & BASIS LINKS
	Particle *_center;
101
	int _center_id;
Carl Poelking's avatar
Carl Poelking committed
102
103
104
	vec _center_pos;
	std::string _center_type;
	Basis *_basis;
Carl Poelking's avatar
Carl Poelking committed
105

Carl Poelking's avatar
Carl Poelking committed
106
107
108
	// DENSITY EXPANSION
	map_qnlm_t _map_qnlm;
	qnlm_t *_qnlm_generic;
Carl Poelking's avatar
Carl Poelking committed
109

Carl Poelking's avatar
Carl Poelking committed
110
111
112
113
	// POWER DENSITY EXPANSION
	map_xnkl_t _map_xnkl;
	xnkl_t *_xnkl_generic_coherent;
	xnkl_t *_xnkl_generic_incoherent;
Carl Poelking's avatar
Carl Poelking committed
114
115
116
117
118

	// PID-RESOLVED (GRADIENTS)
	map_pid_qnlm_t _map_pid_qnlm; // <- for gradients wrt position of neighbour with global id
	map_pid_xnkl_t _map_pid_xnkl;
	map_pid_xnkl_gc_t _map_pid_xnkl_gc;
Carl Poelking's avatar
Carl Poelking committed
119
120
121
122
123
124
};


}

#endif /* _SOAP_ATOMICSPECTRUM_HPP_ */