-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindexing.qmd
127 lines (98 loc) · 3.68 KB
/
indexing.qmd
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
---
title: "Indexing conventions"
author: "baptiste"
date: today
---
```{r setup, warning=FALSE,echo=FALSE, message=FALSE}
suppressPackageStartupMessages(require(terms))
library(dplyr)
library(DT)
library(knitr)
library(dplyr)
library(ggplot2)
library(grid)
library(patchwork)
read_chunk('_fun.R')
source("_fun.R")
```
The convention is to use
- m: multipole order, -l:l
- l: multipole degree 1:lmax
- s: multipole polarisation type, 1 or 2
so for a T-matrix with $lmax=3$, we have
```{r tmat, warning=FALSE,echo=FALSE, message=FALSE}
indices <- function(lmax=3, part=1){
ul <- seq(1,lmax)
l = do.call(c, lapply(ul, function(.l)rep(.l, 2*.l+1)))
m = do.call(c, lapply(ul, function(.l)seq(-.l,.l)))
ll <- expand.grid(l = l, lp = l)
mm <- expand.grid(m = m, mp = m)
d <- rbind(cbind(ll, mm, s=1,sp=1),
cbind(ll, mm, s=1,sp=2),
cbind(ll, mm, s=2,sp=1),
cbind(ll, mm, s=2,sp=2))
dplyr::mutate(d,
p = l*(l+1)+m,
q = (s - 1)* max(p) + p,
pp = lp*(lp+1)+mp,
qp = (sp - 1)* max(pp) + pp)
}
tmat <- indices(3, 1)
cat(sprintf("l: %s\nm: %s\ns: %s\n%s elements",
paste(range(tmat$l), collapse = '..'),
paste(range(tmat$m), collapse = '..'),
paste(range(tmat$s), collapse = '..'),
nrow(tmat)))
d <- tmatrix_combinedindex(tmat)
lmax <- max(d$l)
breaks <- tmatrix_breaks(lmax)
p <- ggplot(d, aes(q, qp)) +
# geom_raster() +
coord_equal() +
scale_fill_viridis_c(option = 'A', direction = -1) +
annotate('segment',x=0.5,xend=max(breaks$breaks)+0.5,y=max(breaks$breaks)/2+0.5,
yend=max(breaks$breaks)/2+0.5,colour='white')+
annotate('segment',y=0.5,yend=max(breaks$breaks)+0.5,x=max(breaks$breaks)/2+0.5,
xend=max(breaks$breaks)/2+0.5,colour='white')+
scale_y_reverse(expand=c(0,0), breaks= breaks$breaks+0.5, minor_breaks=breaks$minor_breaks+0.5, labels=breaks$labels) +
scale_x_continuous(expand=c(0,0), breaks= breaks$breaks+0.5, minor_breaks=breaks$minor_breaks+0.5, labels=breaks$labels) +
theme_minimal() +
theme(panel.grid = element_line(colour = 'white'),
panel.background = element_rect(fill='grey90',colour='white'),
panel.border = element_rect(colour='black',fill=NA,linewidth = 0.2),
axis.text.x = element_text(hjust=1),
axis.text.y = element_text(vjust=0)) +
labs(x="p",y="p'",fill=expression(log~"|T|"))
print(p)
```
for each block we introduce a combined p-index such that,
$$
p(n,m) = n(n+1)+m
$$
which here varies as `r sprintf("p: %s", paste(range(tmat$p), collapse = '..'))`, as each block is of dimension `pmax = lmax(lmax+1)+lmax = 3(3+1)+3 = 15`.
The whole T-matrix is indexed with a combined q-index such that,
$$
q(s,p) = (s-1)p_{max} + p
$$
which here gives us,
`r sprintf("q: %s", paste(range(tmat$q), collapse = '..'))`. The total T-matrix dimension (along rows/columns) is thus $q_{max}=2\times(lmax(lmax+1)+lmax)=30$.
In summary, for a given $l_\text{max}$ the indices are given by:
- $l=1:l_\text{max}$
- $m=-l:l$ for each l
- $s=1:2$ for each pair of (l,m)
- $p(l,m) = l(l+1)+m$
- $q(s,p) = (s-1)p_{max} + p$
Given $q$ and $l_\text{max}$ we can invert these indices as follows,
- $p = q - (s-1)q_\text{max}/2$,
giving here, `r (p=1:30 - (rep(1:2, each=15)-1)*30/2)`
- $l = \lfloor\sqrt{p}\rfloor$,
giving here `r (l = floor(sqrt(p)))`
- $m = p - l(l+1)$,
giving here `r (m = p-l*(l+1))`
```{r summary, warning=FALSE,echo=FALSE, message=FALSE}
show_indices <- subset(tmat, lp==1 & mp==0 & sp==1)[c("q","p", "l","m","s")]
display <- t(show_indices[,-1])
colnames(display) <- show_indices$q
knitr::kable(display,
format = "markdown", padding = 2)
```