-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasis.cpp
95 lines (63 loc) · 2.23 KB
/
basis.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "basis.h"
#include <iostream>
using namespace std;
Basis::Basis (int sh_number){
shell_number = sh_number;
for(int i = shell_number; i > 0; i--){
number_of_particles = number_of_particles + i*2;
}
}
void Basis::set_energy(){
energy = shell_number;
}
mat Basis::get_quantum_numbers(int shell){
/*
*Based on the equation E = (2n - |m| + 1) where E is known from the shell number.
*First we find all the n that can satisfy the equation, and then we find the
*corresponding m. We then add them into a 2 dimensional array.
*
*/
mat quantum_numbers(shell,2);
int counter = 0;
for (int value_n = 0; value_n < (shell + 1)/2 ; value_n++){
int value_m = shell - 1 - 2*value_n;
if(value_m == 0){
quantum_numbers(counter,0) = value_n;
quantum_numbers(counter,1) = value_m;
counter = counter + 1;
} //End if
if(value_m != 0 ){
quantum_numbers(counter,0) = value_n;
quantum_numbers(counter,1) = value_m;
quantum_numbers(counter + 1,0) = value_n;
quantum_numbers(counter + 1,1) = value_m * -1;
counter = counter + 2;
} // End if
} // End for loop
return quantum_numbers;
}
mat Basis::map_quantum_numbers(int number_of_particles){
/*
*We use the quantum numbers generated above, and
* make a mapping so that we have one mapping per state.
*/
mat mapping(number_of_particles,3);
int mapping_counter = 0;
for(int i = 1; i <= shell_number; i++){
mat quantum_numbers = Basis::get_quantum_numbers(i);
for(int j = 0; j < i; j++){
mapping(mapping_counter,0) = quantum_numbers(j,0);
mapping(mapping_counter,1) = quantum_numbers(j,1);
mapping(mapping_counter,2) = true;
mapping_counter++;
mapping(mapping_counter,0) = quantum_numbers(j,0);
mapping(mapping_counter,1) = quantum_numbers(j,1);
mapping(mapping_counter,2) = false;
mapping_counter ++;
} //end inner loop
} //end outer loop
for(int i = 0; i < number_of_particles; i++){
cout << mapping(i,0) << " " << mapping(i,1) << " "<< mapping(i,2) <<endl;
}
return mapping;
}