COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
starlord.py
1 """
2 STARLORD (SeT of Algorithms foR mOdified stRucture function computation)
3 Set of functions for structure function computation
4 """
5 
6 import numpy as np
7 from scipy.special import jv # Bessel function
8 
9 
10 def dphi_highpass(r, x0, tabx, taby):
11  """
12  Fonction de structure de phase "haute frequence"
13  A renormalise en fonction du r0
14  :params:
15  r : distance [m]
16  x0 : distance interactionneur [m]
17  tabx, taby : integrale tabulee obtenue avec la fonction tabulateIj0
18  """
19  return (r**
20  (5. / 3.)) * (1.1183343328701949 - Ij0t83(r * (np.pi / x0), tabx, taby)) * (
21  2 * (2 * np.pi)**(8 / 3.) * 0.0228956)
22 
23 
24 def dphi_lowpass(r, x0, L0, tabx, taby):
25  """
26  Fonction de structure de phase "basse frequence"
27  A renormalise en fonction du r0
28  :params:
29  r : distance [m]
30  x0 : distance interactionneur [m]
31  tabx, taby : integrale tabulee obtenue avec la fonction tabulateIj0
32  """
33  return rodconan(r, L0) - dphi_highpass(r, x0, tabx, taby)
34 
35 
36 def Ij0t83(x, tabx, taby):
37  """
38  Calcul de l'integrale tabulee
39  x
40  $ t^(-8/3) (1-bessel_j(0,t)) dt
41  0
42 
43  Pres de 0, le resultat s'approxime par (3/4.)*x^(1./3)*(1-x^2/112.+...)
44  """
45  res = x.copy()
46  ismall = np.where(res < np.exp(-3.0))
47  ilarge = np.where(res >= np.exp(-3.0))
48  if (ismall[0].size > 0):
49  res[ismall] = 0.75 * x[ismall]**(1. / 3) * (1 - x[ismall]**2 / 112.)
50  if (ilarge[0].size > 0):
51  res[ilarge] = np.interp(x[ilarge], tabx, taby)
52 
53  return res
54 
55 
56 def tabulateIj0():
57  """
58  Tabulation de l'intesgrale
59  Necessaire avant utilisation des fonction dphi_lowpass et dphi_highpass
60  """
61  n = 10000
62  t = np.linspace(-4, 10, n)
63  dt = (t[-1] - t[0]) / (n - 1)
64  smallx = np.exp(-4.0)
65  A = 0.75 * smallx**(1. / 3) * (1 - smallx**2 / 112.)
66  X = np.exp(t)
67  Y = np.exp(-t * (5. / 3.)) * (1 - jv(0, X))
68  Y[1:] = np.cumsum(Y[:-1] + np.diff(Y) / 2.)
69  Y[0] = 0.
70  Y = Y * dt + A
71 
72  return X, Y
73 
74 
75 def asymp_macdo(x):
76  k2 = 1.00563491799858928388289314170833
77  k3 = 1.25331413731550012081
78  a1 = 0.22222222222222222222
79  a2 = -0.08641975308641974829
80  a3 = 0.08001828989483310284
81 
82  x_1 = 1. / x
83  res = k2 - k3 * np.exp(-x) * x**(1. / 3.) * (1.0 + x_1 * (a1 + x_1 *
84  (a2 + x_1 * a3)))
85  return res
86 
87 
88 def macdo(x):
89  a = 5. / 6.
90  x2a = x**(2. * a)
91  x22 = x * x / 4.
92  s = 0.0
93 
94  Ga = [
95  0, 12.067619015983075, 5.17183672113560444, 0.795667187867016068,
96  0.0628158306210802181, 0.00301515986981185091, 9.72632216068338833e-05,
97  2.25320204494595251e-06, 3.93000356676612095e-08, 5.34694362825451923e-10,
98  5.83302941264329804e-12
99  ]
100 
101  Gma = [
102  -3.74878707653729304, -2.04479295083852408, -0.360845814853857083,
103  -0.0313778969438136685, -0.001622994669507603, -5.56455315259749673e-05,
104  -1.35720808599938951e-06, -2.47515152461894642e-08, -3.50257291219662472e-10,
105  -3.95770950530691961e-12, -3.65327031259100284e-14
106  ]
107 
108  x2n = 0.5
109 
110  s = Gma[0] * x2a
111  s *= x2n
112 
113  x2n *= x22
114 
115  for n in np.arange(10) + 1:
116 
117  s += (Gma[n] * x2a + Ga[n]) * x2n
118  x2n *= x22
119 
120  return s
121 
122 
123 def rodconan(r, L0):
124  """
125  Fonction de structure de phase avec prise en compte de l'echelle externe
126  A renormalise en fonction du r0
127  """
128  res = r * 0.
129  k1 = 0.1716613621245709486
130  dprf0 = (2 * np.pi / L0) * r
131  ilarge = np.where(dprf0 > 4.71239)
132  ismall = np.where(dprf0 <= 4.71239)
133  if (ilarge[0].size > 0):
134  res[ilarge] = asymp_macdo(dprf0[ilarge])
135  if (ismall[0].size > 0):
136  res[ismall] = -macdo(dprf0[ismall])
137 
138  res *= k1 * L0**(5. / 3.)
139 
140  return res
guardians.starlord.dphi_highpass
def dphi_highpass(r, x0, tabx, taby)
Definition: starlord.py:18
guardians.starlord.Ij0t83
def Ij0t83(x, tabx, taby)
Definition: starlord.py:44
guardians.starlord.rodconan
def rodconan(r, L0)
Definition: starlord.py:127
guardians.starlord.tabulateIj0
def tabulateIj0()
Definition: starlord.py:60
guardians.starlord.macdo
def macdo(x)
Definition: starlord.py:88
guardians.starlord.dphi_lowpass
def dphi_lowpass(r, x0, L0, tabx, taby)
Definition: starlord.py:32
guardians.starlord.asymp_macdo
def asymp_macdo(x)
Definition: starlord.py:75