3
3
using FastGaussQuadrature
4
4
5
5
# Bring in the prefactors
6
- include (" Legendre/Precompute .jl" )
6
+ include (" Legendre/PrecomputeLegendre .jl" )
7
7
8
8
# Bring in the integration tools
9
9
include (" Legendre/Legendre.jl" )
10
10
11
11
12
+ """ compute_aLegendre
12
13
14
+ for all values of u:
15
+ compute a_k(u) by looping over Legendre weights w(u), P_k(u) values, and G(u) values.
16
+
17
+ parallel or non-parallel options
18
+ """
13
19
function compute_aLegendre (tabwGLquad:: Vector{Float64} ,
14
20
tabG:: Vector{Float64} ,
15
21
tabPGLquad:: Matrix{Float64} ,
16
22
tabINVcGLquad:: Vector{Float64} ,
17
- PARALLEL:: Bool )
18
- #=
19
- Function that pre-computes the coefficients a
20
- using the G-L quadrature
21
- =#
23
+ PARALLEL:: Bool = true )
24
+
22
25
K_u = size (tabwGLquad, 1 )
23
26
24
27
taba = zeros (Float64,K_u)
25
28
29
+ if (PARALLEL) # If the calculation is made in parallel
26
30
27
- if (PARALLEL) # The calculation is made in parallel
28
31
Threads. @threads for k= 0 : (K_u- 1 ) # Loop over the Legendre functions
29
32
res = 0.0 # Initialisation of the result
30
33
for i= 1 : K_u # Loop over the G-L nodes
@@ -34,10 +37,12 @@ function compute_aLegendre(tabwGLquad::Vector{Float64},
34
37
res += w* G* P # Update of the sum
35
38
end
36
39
res *= tabINVcGLquad[k+ 1 ] # Multiplying by the prefactor. ATTENTION, to the shift of the array
37
- # ####
40
+
38
41
taba[k+ 1 ] = res # Filling in taba. ATTENTION, to the shift of the array
39
42
end
40
- else # The calculation is not made in parallel
43
+
44
+ else # If the calculation is not made in parallel...
45
+
41
46
for k= 0 : (K_u- 1 ) # Loop over the Legendre functions
42
47
res = 0.0 # Initialisation of the result
43
48
for i= 1 : K_u # Loop over the G-L nodes
@@ -47,17 +52,22 @@ function compute_aLegendre(tabwGLquad::Vector{Float64},
47
52
res += w* G* P # Update of the sum
48
53
end
49
54
res *= tabINVcGLquad[k+ 1 ] # Multiplying by the prefactor. ATTENTION, to the shift of the array
50
- # ####
55
+
51
56
taba[k+ 1 ] = res # Filling in taba. ATTENTION, to the shift of the array
52
57
end
58
+
53
59
end
54
60
55
61
return taba
56
62
57
63
end
58
64
59
65
66
+ """ get_Legendre_IminusXi
67
+
68
+ perform the loop calculation a_k*D_k, after computing D_k
60
69
70
+ """
61
71
function get_Legendre_IminusXi (omg:: Complex{Float64} ,
62
72
taba:: Vector{Float64} ,
63
73
xmax:: Float64 ,
@@ -75,47 +85,24 @@ function get_Legendre_IminusXi(omg::Complex{Float64},
75
85
76
86
# Computing the Hilbert-transformed Legendre functions
77
87
get_tabLeg! (varpi,K_u,struct_tabLeg,LINEAR)
78
- tabDLeg = struct_tabLeg. tabDLeg # Name of the array where the D_k(w) are stored
79
- # ####
80
- xi = 0.0 + 0.0 * im # Initialisation of the xi
88
+ # tabDLeg = struct_tabLeg.tabDLeg # Name of the array where the D_k(w) are stored
81
89
# ####
90
+
91
+ xi = 0.0 + 0.0 * im # Initialise xi
82
92
for k= 0 : (K_u- 1 ) # Loop over the Legendre functions
83
- xi += taba[k+ 1 ]* tabDLeg[k+ 1 ] # Adding a contribution. ATTENTION, to the shift of the array.
93
+ xi += taba[k+ 1 ]* struct_tabLeg . tabDLeg[k+ 1 ] # Adding a contribution. ATTENTION, to the shift of the array.
84
94
end
85
- # ####
86
- IminusXi = 1.0 - xi # Computing the value of 1.0 - xi
95
+
96
+ IminusXi = 1.0 - xi # Compute 1.0 - xi
87
97
return IminusXi # Output
88
98
end
89
99
90
- function test_ninepointsL (taba:: Vector{Float64} ,
91
- xmax:: Float64 ,
92
- struct_tabLeg:: struct_tabLeg_type ,
93
- digits:: Int64 = 4 )
94
- #= function to test nine unique points for values of D_k
95
100
96
- =#
97
- upperleft = - 1.5 + 1.5im
98
- uppercen = 0.0 + 1.5im
99
- upperright = 1.5 + 1.5im
100
- midleft = - 1.5 + 0.0im
101
- midcen = 0.0 + 0.0im
102
- midright = 1.5 + 0.0im
103
- lowerleft = - 1.5 - 1.5im
104
- lowercen = 0.0 - 1.5im
105
- lowerright = 1.5 - 1.5im
106
-
107
- println (round (get_Legendre_IminusXi (upperleft,taba,xmax,struct_tabLeg," unstable" ),digits= digits)," || " ,
108
- round (get_Legendre_IminusXi (uppercen,taba,xmax,struct_tabLeg," unstable" ),digits= digits)," || " ,
109
- round (get_Legendre_IminusXi (upperright,taba,xmax,struct_tabLeg," unstable" ),digits= digits))
110
- println (round (get_Legendre_IminusXi (midleft,taba,xmax,struct_tabLeg," neutral" ),digits= digits)," || " ,
111
- round (get_Legendre_IminusXi (midcen,taba,xmax,struct_tabLeg," neutral" ),digits= digits)," || " ,
112
- round (get_Legendre_IminusXi (midright,taba,xmax,struct_tabLeg," neutral" ),digits= digits))
113
- println (round (get_Legendre_IminusXi (lowerleft,taba,xmax,struct_tabLeg," damped" ),digits= digits)," || " ,
114
- round (get_Legendre_IminusXi (lowercen,taba,xmax,struct_tabLeg," damped" ),digits= digits)," || " ,
115
- round (get_Legendre_IminusXi (lowerright,taba,xmax,struct_tabLeg," damped" ),digits= digits))
116
- end
101
+ """ compute_tabIminusXi
117
102
103
+ wrapper to parallelise calculations of I-Xi
118
104
105
+ """
119
106
function compute_tabIminusXi (tabomega:: Vector{Complex{Float64}} ,
120
107
taba:: Vector{Float64} ,
121
108
xmax:: Float64 ,
@@ -145,7 +132,11 @@ function compute_tabIminusXi(tabomega::Vector{Complex{Float64}},
145
132
146
133
end
147
134
135
+ """ setup_legendre_integration
148
136
137
+ build various tables for integrating the plasma problem with Legendre
138
+
139
+ """
149
140
function setup_legendre_integration (K_u:: Int64 ,qself:: Float64 ,xmax:: Float64 ,PARALLEL:: Bool = false )
150
141
151
142
# Filling in the arrays used in the G-L quadrature (src/Precompute.jl)
@@ -163,3 +154,38 @@ function setup_legendre_integration(K_u::Int64,qself::Float64,xmax::Float64,PARA
163
154
return taba,struct_tabLeg
164
155
165
156
end
157
+
158
+
159
+
160
+ """
161
+
162
+ routine to test the different integration regimes for the plasma case
163
+
164
+ """
165
+ function test_ninepointsL (taba:: Vector{Float64} ,
166
+ xmax:: Float64 ,
167
+ struct_tabLeg:: struct_tabLeg_type ,
168
+ digits:: Int64 = 4 )
169
+ #= function to test nine unique points for values of D_k
170
+
171
+ =#
172
+ upperleft = - 1.5 + 1.5im
173
+ uppercen = 0.0 + 1.5im
174
+ upperright = 1.5 + 1.5im
175
+ midleft = - 1.5 + 0.0im
176
+ midcen = 0.0 + 0.0im
177
+ midright = 1.5 + 0.0im
178
+ lowerleft = - 1.5 - 1.5im
179
+ lowercen = 0.0 - 1.5im
180
+ lowerright = 1.5 - 1.5im
181
+
182
+ println (round (get_Legendre_IminusXi (upperleft,taba,xmax,struct_tabLeg," unstable" ),digits= digits)," || " ,
183
+ round (get_Legendre_IminusXi (uppercen,taba,xmax,struct_tabLeg," unstable" ),digits= digits)," || " ,
184
+ round (get_Legendre_IminusXi (upperright,taba,xmax,struct_tabLeg," unstable" ),digits= digits))
185
+ println (round (get_Legendre_IminusXi (midleft,taba,xmax,struct_tabLeg," neutral" ),digits= digits)," || " ,
186
+ round (get_Legendre_IminusXi (midcen,taba,xmax,struct_tabLeg," neutral" ),digits= digits)," || " ,
187
+ round (get_Legendre_IminusXi (midright,taba,xmax,struct_tabLeg," neutral" ),digits= digits))
188
+ println (round (get_Legendre_IminusXi (lowerleft,taba,xmax,struct_tabLeg," damped" ),digits= digits)," || " ,
189
+ round (get_Legendre_IminusXi (lowercen,taba,xmax,struct_tabLeg," damped" ),digits= digits)," || " ,
190
+ round (get_Legendre_IminusXi (lowerright,taba,xmax,struct_tabLeg," damped" ),digits= digits))
191
+ end
0 commit comments