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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
use rest_tensors::BasicMatrix;
use tensors::{MatrixFullSlice, MatrixFull};
use super::DMatrix;
pub enum C2S {
L0(DMatrix1x1),
L1(DMatrix3x3),
L2(DMatrix6x5),
L3(DMatrix10x7),
L4(DMatrix15x9),
}
pub type DMatrix1x1 = DMatrix<1>;
pub type DMatrix3x3 = DMatrix<9>;
pub type DMatrix6x5 = DMatrix<30>;
pub type DMatrix10x7 = DMatrix<70>;
pub type DMatrix15x9 = DMatrix<135>;
//pub struct DMatrix1x1 {
// size: [usize;2],
// indicing: [usize;2],
// data: [f64;1]
//}
pub const C2S_L0: C2S = C2S::L0(DMatrix1x1{
size: [1,1],
indicing: [1,1],
data: [1.0]
});
//pub struct DMatrix3x3 {
// size: [usize;2],
// indicing: [usize;2],
// data: [f64;9]
//}
pub const C2S_L1: C2S = C2S::L1(DMatrix3x3{
size: [3,3],
indicing: [1,3],
data: [
// x y z
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
]});
//pub struct DMatrix6x5 {
// size: [usize;2],
// indicing: [usize;2],
// data: [f64;30]
//}
/// The transofrmation matrix from Cartesian to spheric for L=2
/// let a1 = 0.866025403784438647; //sqrt(3)/2
/// let a2 = -0.866025403784438647; //-sqrt(3)/2
/// let rel_max = [
/// // 0 1 2 3 4 5
/// // x^2, xy, xz, y^2, yz, z^2
/// 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, //(2,-2)
/// 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, //(2,-1)
/// -0.5, 0.0, 0.0,-0.5, 0.0, 1.0, //(2, 0)
/// 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, //(2, 1)
/// a1, 0.0, 0.0, a2, 0.0, 0.0, //(2, 2)
/// ].to_vec();
pub const C2S_L2: C2S = C2S::L2(DMatrix6x5 {
size: [6,5],
indicing: [1,6],
data: [
// 0 1 2 3 4 5
// x^2, xy, xz, y^2, yz, z^2
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, //(2,-2)
0.0, 0.0, 0.0, 0.0, 1.0, 0.0, //(2,-1)
-0.5, 0.0, 0.0, -0.5, 0.0, 1.0, //(2, 0)
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, //(2, 1)
0.866025403784438647, 0.0, 0.0,-0.8660254037844386472, 0.0, 0.0, //(2, 2)
]});
//pub struct DMatrix10x7 {
// size: [usize;2],
// indicing: [usize;2],
// data: [f64;70]
//}
/// The transofrmation matrix from Cartesian to spheric for L=3
/// let b1 = 1.060660171779821287; // 3/4*sqrt(2); a4
/// let b2 = -0.790569415042094833; // -sqrt(10)/4; -a5
/// let b3 = 0.790569415042094833; // sqrt(10)/4; a5
/// let b4 = -1.060660171779821287; // -3/4*sqrt(2); -a4
/// let b5 = 0.866025403784438647; // sqrt(3)/2; a6
/// let b6 = -0.866025403784438647; // -sqrt(3)/2; -a6
/// let b7 = -0.273861278752583057; // -sqrt(6/5)/4; -0.25*a7
/// let b8 = -0.612372435695794525; // -sqrt(6)/4; -0.25*s6
/// let b9 = 1.095445115010332227; // sqrt(6/5); a7
/// let b10 = -0.670820393249936909; // -3/sqrt(5)/2
/// let rel_max = [
/// // 0 1 2 3 4 5 6 7 8 9
/// // xxx, xxy, xxz, xyy, xyz, xzz, yyy, yyz, yzz, zzz
/// 0.0, b1, 0.0, 0.0, 0.0, 0.0, b2, 0.0, 0.0, 0.0, //(3,-3)
/// 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(3,-2)
/// 0.0, b7, 0.0, 0.0, 0.0, 0.0, b8, 0.0, b9, 0.0, //(3,-1)
/// 0.0, 0.0, b10, 0.0, 0.0, 0.0, 0.0, b10, 0.0, 1.0, //(3, 0)
/// b8, 0.0, 0.0, b7, 0.0, b9, 0.0, 0.0, 0.0, 0.0, //(3, 1)
/// 0.0, 0.0, b5, 0.0, 0.0, 0.0, 0.0, b6, 0.0, 0.0, //(3, 2)
/// b3, 0.0, 0.0, b4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(3, 3)
/// ].to_vec();
pub const C2S_L3: C2S = C2S::L3(DMatrix10x7 {
size: [10,7],
indicing: [1,10],
data: [
// 0 1 2 3 4 5 6 7 8 9
// xxx, xxy, xxz, xyy, xyz, xzz, yyy, yyz, yzz, zzz
0.0, 1.060660171779821287, 0.0, 0.0, 0.0, 0.0, -0.790569415042094833, 0.0, 0.0, 0.0, //(3,-3)
0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(3,-2)
0.0, -0.273861278752583057, 0.0, 0.0, 0.0, 0.0, -0.612372435695794525, 0.0, 1.095445115010332227, 0.0, //(3,-1)
0.0, 0.0, -0.670820393249936909, 0.0, 0.0, 0.0, 0.0, -0.670820393249936909, 0.0, 1.0, //(3, 0)
-0.612372435695794525, 0.0, 0.0, -0.273861278752583057, 0.0, 1.095445115010332227, 0.0, 0.0, 0.0, 0.0, //(3, 1)
0.0, 0.0, 0.866025403784438647, 0.0, 0.0, 0.0, 0.0, -0.866025403784438647, 0.0, 0.0, //(3, 2)
0.790569415042094833, 0.0, 0.0, -1.060660171779821287, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(3, 3)
]
});
//pub struct DMatrix15x9 {
// size: [usize;2],
// indicing: [usize;2],
// data: [f64;135]
//}
/// The transofrmation matrix from Cartesian to spheric for L=3
/// let c1 = -0.878310065653679861; // 3\sqrt(3)/\sqrt(35)
/// let c2 = 0.219577516413419965; // -a1/4
/// let c3 = 1.195228609334393640; // sqrt(10/7)
/// let c4 = -0.896421457000795230; // -3/4*sqrt(10/7)
/// let c5 = -0.400891862868636577; // -3/4*sqrt(2/7)
/// let c6 = 0.981980506061965716; //3/2*sqrt(3/7)
/// let c7 = -0.981980506061965716; //-3/2*sqrt(3/7)
/// let c8 = -0.559016994374947424; //-sqrt(5)/4
/// let c9 = 0.559016994374947424; // sqrt(5)/4
/// let c10 = 1.133893419027681682; // 3/sqrt(7)
/// let c11 = -0.422577127364258289; // -sqrt(5/7)/2
/// let c12 = 0.790569415042094833; // sqrt(10)/4
/// let c13 = -1.060660171779821287; // -3sqrt(2)/4
/// let c14 = -0.790569415042094833; // -sqrt(10)/4
/// let c15 = 1.060660171779821287; // 3sqrt(2)/4
/// let c16 = 0.739509972887452005; // sqrt(35)/8
/// let c17 = -1.299038105676657970; // -3sqrt(3)/4
/// let c18 = 1.118033988749894848; // sqrt(5)/2
/// let c19 = -1.118033988749894848; // -sqrt(5)/2
/// let rel_max = [
/// // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
/// // xxxx, xxxy, xxxz, xxyy, xxyz, xxzz, xyyy, xyyz, xyzz, xzzz yyyy yyyz yyzz yzzz zzzz
/// 0.0, c18, 0.0, 0.0, 0.0, 0.0, c19, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(4,-4)
/// 0.0, 0.0, 0.0, 0.0, c15, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, c14, 0.0, 0.0, 0.0, //(4,-3)
/// 0.0, c11, 0.0, 0.0, 0.0, 0.0, c11, 0.0, c10, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(4,-2)
/// 0.0, 0.0, 0.0, 0.0, c5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, c4, 0.0, c3, 0.0, //(4,-1)
/// 0.375, 0.0, 0.0, c2, 0.0, c1, 0.0, 0.0, 0.0, 0.0,0.375, 0.0, c1, 0.0, 1.0, //(4, 0)
/// 0.0, 0.0, c4, 0.0, 0.0, 0.0, 0.0, c5, 0.0, c3, 0.0, 0.0, 0.0, 0.0, 0.0, //(4, 1)
/// c8, 0.0, 0.0, 0.0, 0.0, c6, 0.0, 0.0, 0.0, 0.0, c9, 0.0, c7, 0.0, 0.0, //(4, 2)
/// 0.0, 0.0, c12, 0.0, 0.0, 0.0, 0.0, c13, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(4, 3)
/// c16, 0.0, 0.0, c17, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, c16, 0.0, 0.0, 0.0, 0.0, //(4, 4)
/// ].to_vec();
///
pub const C2S_L4: C2S = C2S::L4(DMatrix15x9 {
size: [15,9],
indicing: [1,15],
data: [
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// xxxx, xxxy, xxxz, xxyy, xxyz, xxzz, xyyy, xyyz, xyzz, xzzz yyyy yyyz yyzz yzzz zzzz
0.0, 1.118033988749894848, 0.0, 0.0, 0.0, 0.0, -1.118033988749894848, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(4,-4)
0.0, 0.0, 0.0, 0.0, 1.060660171779821287, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.790569415042094833, 0.0, 0.0, 0.0, //(4,-3)
0.0, -0.422577127364258289, 0.0, 0.0, 0.0, 0.0, -0.422577127364258289, 0.0, 1.133893419027681682, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(4,-2)
0.0, 0.0, 0.0, 0.0, -0.400891862868636577, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.896421457000795230, 0.0, 1.195228609334393640, 0.0, //(4,-1)
0.375, 0.0, 0.0, 0.219577516413419965, 0.0, -0.878310065653679861, 0.0, 0.0, 0.0, 0.0,0.375, 0.0, -0.878310065653679861, 0.0, 1.0, //(4, 0)
0.0, 0.0, -0.896421457000795230, 0.0, 0.0, 0.0, 0.0, -0.400891862868636577, 0.0, 1.195228609334393640, 0.0, 0.0, 0.0, 0.0, 0.0, //(4, 1)
-0.559016994374947424, 0.0, 0.0, 0.0, 0.0, 0.981980506061965716, 0.0, 0.0, 0.0, 0.0, 0.559016994374947424, 0.0, -0.981980506061965716, 0.0, 0.0, //(4, 2)
0.0, 0.0, 0.790569415042094833, 0.0, 0.0, 0.0, 0.0, -1.060660171779821287, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(4, 3)
0.739509972887452005, 0.0, 0.0, -1.299038105676657970, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.739509972887452005, 0.0, 0.0, 0.0, 0.0, //(4, 4)
]
});
impl C2S {
pub fn to_matrixfullslice(&self) -> MatrixFullSlice<f64> {
match &self {
C2S::L0(matr) => {
MatrixFullSlice {
size: &matr.size,
indicing: &matr.indicing,
data: &matr.data
}
},
C2S::L1(matr) => {
MatrixFullSlice {
size: &matr.size,
indicing: &matr.indicing,
data: &matr.data
}
},
C2S::L2(matr) => {
MatrixFullSlice {
size: &matr.size,
indicing: &matr.indicing,
data: &matr.data
}
},
C2S::L3(matr) => {
MatrixFullSlice {
size: &matr.size,
indicing: &matr.indicing,
data: &matr.data
}
},
C2S::L4(matr) => {
MatrixFullSlice {
size: &matr.size,
indicing: &matr.indicing,
data: &matr.data
}
},
}
}
}
pub fn c2s_matrix_const(l:usize) -> crate::constants::c2s::C2S {
if l == 0 {
C2S_L0
} else if l ==1 {
C2S_L1
} else if l== 2 {
C2S_L2
} else if l== 3 {
C2S_L3
} else if l== 4 {
C2S_L4
} else {
panic!("No C2S transformation implementation for l > 4")
}
}
pub fn c2s_matrix(l:usize) -> MatrixFull<f64> {
let len_c = (l+1)*(l+2)/2;
let len_s = 2*l+1;
if l==0 {
return MatrixFull::new([len_c,len_s],1.0)
} else if l==1 {
let rel_max = [
// x y z
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
].to_vec();
return unsafe{MatrixFull::from_vec_unchecked([len_c,len_s], rel_max)}
} else if l==2 {
let a1 = 0.866025403784438647; //sqrt(3)/2
let a2 = -0.866025403784438647; //-sqrt(3)/2
let rel_max = [
// 0 1 2 3 4 5
// x^2, xy, xz, y^2, yz, z^2
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, //(2,-2)
0.0, 0.0, 0.0, 0.0, 1.0, 0.0, //(2,-1)
-0.5, 0.0, 0.0,-0.5, 0.0, 1.0, //(2, 0)
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, //(2, 1)
a1, 0.0, 0.0, a2, 0.0, 0.0, //(2, 2)
].to_vec();
return unsafe{MatrixFull::from_vec_unchecked([len_c,len_s], rel_max)}
} else if l==3 {
//let s2 = (2.0f64).sqrt();
//let s3 = (3.0f64).sqrt();
//let s5 = (5.0f64).sqrt();
//let s6 = (6.0f64).sqrt();
//let a1 = 0.5*s5/s2; // 1/2\sqrt(5/2)
//let a2 = 0.5*s3/s2; // 1/2\sqrt(3/2)
//let a3 = 0.5*s3*s5; // 1/2\sqrt(15)
//let a4 = 0.75*s2;
//let a5 = 0.25*s2*s5;
//let a6 = 0.5*s3;
//let a7 = s6/s5;
//let rel_max = [
// // 0 1 2 3 4 5 6 7 8 9
// // xxx, xxy, xxz, xyy, xyz, xzz, yyy, yyz, yzz, zzz
// 0.0, a4, 0.0, 0.0, 0.0, 0.0, -a5, 0.0, 0.0, 0.0, //(3,-3)
// 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(3,-2)
// 0.0, -0.25*a7, 0.0, 0.0, 0.0, 0.0, -0.25*s6, 0.0, a7, 0.0, //(3,-1)
// 0.0, 0.0, -1.5/s5, 0.0, 0.0, 0.0, 0.0,-1.5/s5, 0.0, 1.0, //(3, 0)
//-0.25*s6, 0.0, 0.0, -0.25*a7, 0.0, a7, 0.0, 0.0, 0.0, 0.0, //(3, 1)
// 0.0, 0.0, a6, 0.0, 0.0, 0.0, 0.0, -a6, 0.0, 0.0, //(3, 2)
// a5, 0.0, 0.0, -a4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(3, 3)
//].to_vec();
let b1 = 1.060660171779821287; // 3/4*sqrt(2); a4
let b2 = -0.790569415042094833; // -sqrt(10)/4; -a5
let b3 = 0.790569415042094833; // sqrt(10)/4; a5
let b4 = -1.060660171779821287; // -3/4*sqrt(2); -a4
let b5 = 0.866025403784438647; // sqrt(3)/2; a6
let b6 = -0.866025403784438647; // -sqrt(3)/2; -a6
let b7 = -0.273861278752583057; // -sqrt(6/5)/4; -0.25*a7
let b8 = -0.612372435695794525; // -sqrt(6)/4; -0.25*s6
let b9 = 1.095445115010332227; // sqrt(6/5); a7
let b10 = -0.670820393249936909; // -3/sqrt(5)/2
let rel_max = [
// 0 1 2 3 4 5 6 7 8 9
// xxx, xxy, xxz, xyy, xyz, xzz, yyy, yyz, yzz, zzz
0.0, b1, 0.0, 0.0, 0.0, 0.0, b2, 0.0, 0.0, 0.0, //(3,-3)
0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(3,-2)
0.0, b7, 0.0, 0.0, 0.0, 0.0, b8, 0.0, b9, 0.0, //(3,-1)
0.0, 0.0, b10, 0.0, 0.0, 0.0, 0.0, b10, 0.0, 1.0, //(3, 0)
b8, 0.0, 0.0, b7, 0.0, b9, 0.0, 0.0, 0.0, 0.0, //(3, 1)
0.0, 0.0, b5, 0.0, 0.0, 0.0, 0.0, b6, 0.0, 0.0, //(3, 2)
b3, 0.0, 0.0, b4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(3, 3)
].to_vec();
return unsafe{MatrixFull::from_vec_unchecked([len_c,len_s], rel_max)}
} else if l==4 {
let a1 = -0.878310065653679861; // 3\sqrt(3)/\sqrt(35)
let a2 = 0.219577516413419965; // -a1/4
let a3 = 1.195228609334393640; // sqrt(10/7)
let a4 = -0.896421457000795230; // -3/4*sqrt(10/7)
let a5 = -0.400891862868636577; // -3/4*sqrt(2/7)
let a6 = 0.981980506061965716; //3/2*sqrt(3/7)
let a7 = -0.981980506061965716; //-3/2*sqrt(3/7)
let a8 = -0.559016994374947424; //-sqrt(5)/4
let a9 = 0.559016994374947424; // sqrt(5)/4
let a10 = 1.133893419027681682; // 3/sqrt(7)
let a11 = -0.422577127364258289; // -sqrt(5/7)/2
let a12 = 0.790569415042094833; // sqrt(10)/4
let a13 = -1.060660171779821287; // -3sqrt(2)/4
let a14 = -0.790569415042094833; // -sqrt(10)/4
let a15 = 1.060660171779821287; // 3sqrt(2)/4
let a16 = 0.739509972887452005; // sqrt(35)/8
let a17 = -1.299038105676657970; // -3sqrt(3)/4
let a18 = 1.118033988749894848; // sqrt(5)/2
let a19 = -1.118033988749894848; // -sqrt(5)/2
let rel_max = [
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
// xxxx, xxxy, xxxz, xxyy, xxyz, xxzz, xyyy, xyyz, xyzz, xzzz yyyy yyyz yyzz yzzz zzzz
0.0, a18, 0.0, 0.0, 0.0, 0.0, a19, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(4,-4)
0.0, 0.0, 0.0, 0.0, a15, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, a14, 0.0, 0.0, 0.0, //(4,-3)
0.0, a11, 0.0, 0.0, 0.0, 0.0, a11, 0.0, a10, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(4,-2)
0.0, 0.0, 0.0, 0.0, a5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, a4, 0.0, a3, 0.0, //(4,-1)
0.375, 0.0, 0.0, a2, 0.0, a1, 0.0, 0.0, 0.0, 0.0,0.375, 0.0, a1, 0.0, 1.0, //(4, 0)
0.0, 0.0, a4, 0.0, 0.0, 0.0, 0.0, a5, 0.0, a3, 0.0, 0.0, 0.0, 0.0, 0.0, //(4, 1)
a8, 0.0, 0.0, 0.0, 0.0, a6, 0.0, 0.0, 0.0, 0.0, a9, 0.0, a7, 0.0, 0.0, //(4, 2)
0.0, 0.0, a12, 0.0, 0.0, 0.0, 0.0, a13, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //(4, 3)
a16, 0.0, 0.0, a17, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, a16, 0.0, 0.0, 0.0, 0.0, //(4, 4)
].to_vec();
return unsafe{MatrixFull::from_vec_unchecked([len_c,len_s], rel_max)}
} else {
panic!("the angular momentum larger than 4 is not yet implemented for DFA");
return MatrixFull::empty()
}
}