-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod_brem.f90
530 lines (422 loc) · 19.9 KB
/
mod_brem.f90
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
MODULE Mod_Brem
!############################################################################
!# This section contains the initialization subroutines for the bremsstrahlung object
!# as well as the subroutines related to the object itself.
!############################################################################
!### Modules to be Included###
USE Mod_Info
IMPLICIT NONE
PRIVATE :: Brem_phiH, Brem_phiHe
!### Defines Bremsstrahlung Type ###
TYPE :: Brem
!### Array to store the emissivity ###
REAL*8, ALLOCATABLE, DIMENSION(:) :: j
!### Pointer to the emission frequencies ###
REAL*8, POINTER :: nu(:)
!### Useful Integers ###
INTEGER :: nphbins
!### Flag to see if bremsstrahlung is on ###
LOGICAL :: bremsstrahlung=.FALSE.
END TYPE
CONTAINS
!### Initializes the Bremsstrahlung Object ###
SUBROUTINE Brem_Init(bremo,nu,nphbins)
TYPE(Brem), INTENT(INOUT) :: bremo
REAL*8, TARGET :: nu(nphbins)
INTEGER, INTENT(IN) :: nphbins
!### Allocate space for the emissivity ###
ALLOCATE(bremo%j(nphbins))
!### Store number of emission bins ###
bremo%nphbins=nphbins
!### Set up pointer to frequency ###
bremo%nu => nu
END SUBROUTINE Brem_Init
!### Clean up Bremsstrahlung Object ###
SUBROUTINE Brem_Destroy(bremo)
TYPE (Brem), INTENT(INOUT) :: bremo
!### Clean-up pointers ###
NULLIFY(bremo%nu)
!### De-Allocate Arrays ###
DEALLOCATE(bremo%j)
END SUBROUTINE Brem_Destroy
!### Does the Bremsstrahlung calculation ###
!### The formalism in "Cosmic Ray Astrophysics" by R. Schlickeiser (2002) is used the relativistic portion of this calculation (S02 from here on out). ###
!### Additionally for the non-relativistic end (Lorentz factor less than 2) the formalism in ###
!### "Classical Electrodynamics 3rd Ed." by J. D. Jackson 1999 was used for the cross-section (J99 from here on out) ###
!### Currently setup to handle an ambient medium containing ionized and neutral Hydrogen and Helium ###
SUBROUTINE Brem_Calc(bremo,cro,physo,ne,np,nalpha,nH,nHe)
TYPE(Brem), INTENT(INOUT) :: bremo
TYPE(CR), INTENT(IN) :: cro
TYPE(Phys), INTENT(IN) :: physo
REAL*8, INTENT(IN) :: ne, np, nalpha, nH, nHe
REAL*8 :: jl, ju, slope, nion, eph, ieph, sigma, phiu, phi1, phi2, delta
INTEGER :: i, j
!### Going to integrate it anyways so might as well zero it now. ###
bremo%j=0d0
!### We will deal with the ionized protons and electrons first as they contribute to the bremsstrahlung in the same way. ###
!### Total number of electron and protons
nion=ne+np
if (nion .NE. 0d0) then
!### Marches through emission frequencies ###
do j=1,bremo%nphbins
!### Current photon energy and it's inverse ###
eph=physo%h*bremo%nu(j)
ieph=1d0/eph
!### Calculate bremsstrahlung power for the first momentum for use later ###
!### Bremsstrahlung cross section in units of cm^3 ###
!### These are not the same units as S02 for the cross section ###
if (cro%g(1) .LT. 2d0) then
!### If the particle Lorentz factor is smaller than 2 we will consider it to be non-relativistic ###
!### Hence we will use the form from J99 (15.29) which requires being divided by (4*pi)**2 ###
if (cro%e(1) .GE. eph) then
sigma=16d0/3d0*(2d0*physo%pi)/(physo%h*(4d0*physo%pi)**2)*physo%q**2/physo%c*physo%r0**2 &
*1d0/(1d0-cro%ig2(1))*dlog((dsqrt(cro%e(1))+dsqrt(cro%e(1)-eph))**2*ieph)
else
sigma=0d0
endif
if (1d0/sigma .EQ. 0d0 .OR. ISNAN(sigma) .OR. (cro%e(1)-eph) .LT. 0d0 .OR. sigma .LT. 0d0) then
sigma=0d0
endif
else
!### Eq. 4.4.2 in S02 ###
if (cro%te(1) .GE. eph) then
phiu=4d0*(dlog(2d0*cro%g(1)*ieph*(cro%te(1)-eph))-0.5d0)
else
phiu=0d0
endif
!### Relativistic Cross section from S02 (4.4.1) ###
sigma=3d0/physo%pi*0.125d0*physo%alpha*physo%sigmat*((1d0+(1d0-cro%ite(1)*eph)**2)*phiu-2d0/3d0*(1d0-eph*cro%ite(1))*phiu)
endif
!### The cross section cannot be less than 0 ###
sigma=MAX(sigma,0d0)
!### Eq. 4.4.4 in S02 multiplied by dN/dE for this ambient species erg/s/Hz/cm^3/erg ###
!### Note that there appears to be a mistake in the units for S02. What he lists is in ergs/s not ergs/s/eV. ###
!### This includes the correction for if we are calculating bremsstrahlung for a CR species ###
!### That is not electrons. For a discussion see Dogiel et. al. A&A 382 (2002) 730 ###
jl=physo%c*physo%h*nion*sigma*cro%n(1)*(cro%q/physo%q)**4*physo%me/cro%m
!### Integrates the CR Spectrum ###
do i=1,cro%nbins-1
!### Bremsstrahlung cross section in units of cm^3 ###
!### These are not the same units as S02 for the cross section ###
if (cro%g(i+1) .LT. 2d0) then
!### If the particle Lorentz factor is smaller than 2 we will consider it to be non-relativistic ###
!### Hence we will use the form from J99 (15.29) which requires being divided by (4*pi)**2 ###
if (cro%e(i+1) .GE. eph) then
sigma=16d0/3d0*(2d0*physo%pi)/(physo%h*(4d0*physo%pi)**2)*physo%q**2/physo%c*physo%r0**2 &
*1d0/(1d0-cro%ig2(i+1))*dlog((dsqrt(cro%e(i+1))+dsqrt(cro%e(i+1)-eph))**2*ieph)
else
sigma=0d0
endif
if (1d0/sigma .EQ. 0d0 .OR. ISNAN(sigma) .OR. (cro%e(i+1)-eph) .LT. 0d0 .OR. sigma .LT. 0d0) then
sigma=0d0
endif
else
!### Eq. 4.4.2 in S02 ###
if (cro%te(i+1) .GE. eph) then
phiu=4d0*(dlog(2d0*cro%g(i+1)*ieph*(cro%te(i+1)-eph))-0.5d0)
else
phiu=0d0
endif
!### Relativistic Cross section from S02 (4.4.1) ###
sigma=3d0/physo%pi*0.125d0*physo%alpha*physo%sigmat*((1d0+(1d0-cro%ite(i+1)*eph)**2)*phiu-2d0/3d0*(1d0-eph*cro%ite(i+1))*phiu)
endif
!### The cross section cannot be less than 0 ###
sigma=MAX(sigma,0d0)
!### Eq. 4.4.4 in S02 multiplied by dN/dE for this species erg/s/Hz/cm^3/erg ###
!### Note that there appears to be a mistake in the units for S02. What he lists is in ergs/s not ergs/s/eV. ###
!### This includes the correction for if we are calculating bremsstrahlung for a CR species ###
!### That is not electrons. For a discussion see Dogiel et. al. A&A 382 (2002) 730 ###
ju=physo%c*physo%h*nion*sigma*cro%n(i+1)*(cro%q/physo%q)**4*physo%me/cro%m
!### Check to save time ###
if (jl .EQ. 0d0 .AND. ju .EQ. 0d0) then
jl=ju
CYCLE
endif
!### For this case it appears to work better if we use trapezoidal rule rather than a powerlaw assumption ###
bremo%j(j)=0.5d0*(cro%e(i+1)-cro%e(i))*(jl+ju)+bremo%j(j)
!### Store the upper value for the next update. ###
jl=ju
enddo
enddo
endif
!### Next we will deal with alpha particles ###
if (nalpha .NE. 0d0) then
!### Marches through emission frequencies ###
do j=1,bremo%nphbins
!### Current photon energy and it's inverse ###
eph=physo%h*bremo%nu(j)
ieph=1d0/eph
!### Calculate bremsstrahlung power for the first momentum for use later ###
!### Bremsstrahlung cross section in units of cm^3 ###
!### These are not the same units as S02 for the cross section ###
if (cro%g(1) .LT. 2d0) then
!### If the particle Lorentz factor is smaller than 2 we will consider it to be non-relativistic ###
!### Hence we will use the form from J99 (15.29) which requires being divided by (4*pi)**2 ###
if (cro%e(1) .GE. eph) then
sigma=16d0*16d0/3d0*(2d0*physo%pi)/(physo%h*(4d0*physo%pi)**2)*physo%q**2/physo%c*physo%r0**2 &
*1d0/(1d0-cro%ig2(1))*dlog((dsqrt(cro%e(1))+dsqrt(cro%e(1)-eph))**2*ieph)
else
sigma=0d0
endif
if (1d0/sigma .EQ. 0d0 .OR. ISNAN(sigma) .OR. (cro%e(1)-eph) .LT. 0d0 .OR. sigma .LT. 0d0) then
sigma=0d0
endif
else
!### Eq. 4.4.2 in S02 ###
if (cro%te(1) .GE. eph) then
phiu=16d0*4d0*(dlog(2d0*cro%g(1)*ieph*(cro%te(1)-eph))-0.5d0)
else
phiu=0d0
endif
!### Relativistic Cross section from S02 (4.4.1) ###
sigma=3d0/physo%pi*0.125d0*physo%alpha*physo%sigmat*((1d0+(1d0-cro%ite(1)*eph)**2)*phiu-2d0/3d0*(1d0-eph*cro%ite(1))*phiu)
endif
!### The cross section cannot be less than 0 ###
sigma=MAX(sigma,0d0)
!### Eq. 4.4.4 in S02 multiplied by dN/dE for this ambient species erg/s/Hz/cm^3/erg ###
!### This includes the correction for if we are calculating bremsstrahlung for a CR species ###
!### Note that there appears to be a mistake in the units for S02. What he lists is in ergs/s not ergs/s/eV. ###
!### That is not electrons. For a discussion see Dogiel et. al. A&A 382 (2002) 730 ###
jl=physo%c*physo%h*nalpha*sigma*cro%n(1)*(cro%q/physo%q)**4*physo%me/cro%m
!### Integrates the CR Spectrum ###
do i=1,cro%nbins-1
!### Bremsstrahlung cross section in units of cm^3 ###
!### These are not the same units as S02 for the cross section ###
if (cro%g(i+1) .LT. 2d0) then
!### If the particle Lorentz factor is smaller than 2 we will consider it to be non-relativistic ###
!### Hence we will use the form from J99 (15.29) which requires being divided by (4*pi)**2 ###
if (cro%e(i+1) .GE. eph) then
sigma=16d0*16d0/3d0*(2d0*physo%pi)/(physo%h*(4d0*physo%pi)**2)*physo%q**2/physo%c*physo%r0**2 &
*1d0/(1d0-cro%ig2(i+1))*dlog((dsqrt(cro%e(i+1))+dsqrt(cro%e(i+1)-eph))**2*ieph)
else
sigma=0d0
endif
if (1d0/sigma .EQ. 0d0 .OR. ISNAN(sigma) .OR. (cro%e(i+1)-eph) .LT. 0d0 .OR. sigma .LT. 0d0) then
sigma=0d0
endif
else
!### Eq. 4.4.2 in S02 ###
if (cro%te(i+1) .GE. eph) then
phiu=16d0*4d0*(dlog(2d0*cro%g(i+1)*ieph*(cro%te(i+1)-eph))-0.5d0)
else
phiu=0d0
endif
!### Relativistic Cross section from S02 (4.4.1) ###
sigma=3d0/physo%pi*0.125d0*physo%alpha*physo%sigmat*((1d0+(1d0-cro%ite(i+1)*eph)**2)*phiu-2d0/3d0*(1d0-eph*cro%ite(i+1))*phiu)
endif
!### The cross section cannot be less than 0 ###
sigma=MAX(sigma,0d0)
!### Eq. 4.4.4 in S02 multiplied by dN/dE for this species erg/s/Hz/cm^3/erg ###
!### This includes the correction for if we are calculating bremsstrahlung for a CR species ###
!### That is not electrons. For a discussion see Dogiel et. al. A&A 382 (2002) 730 ###
!### Note that there appears to be a mistake in the units for S02. What he lists is in ergs/s not ergs/s/eV. ###
ju=physo%c*physo%h*nalpha*sigma*cro%n(i+1)*(cro%q/physo%q)**4*physo%me/cro%m
!### Check to save time ###
if (jl .EQ. 0d0 .AND. ju .EQ. 0d0) then
jl=ju
CYCLE
endif
!### For this case it appears to work better if we use trapezoidal rule rather than a powerlaw assumption ###
bremo%j(j)=0.5d0*(cro%e(i+1)-cro%e(i))*(jl+ju)+bremo%j(j)
!### Store the upper value for the next update. ###
jl=ju
enddo
enddo
endif
!### Now we will handle the neutral Hydrogen ###
if (nH .NE. 0d0) then
!### Marches through emission frequencies ###
do j=1,bremo%nphbins
!### Current photon energy and it's inverse ###
eph=physo%h*bremo%nu(j)
ieph=1d0/eph
!### Calculate bremsstrahlung power for the first momentum for use later ###
!### Eq. 4.4.3 in S02 ###
delta=0.25d0*eph*cro%ig(1)/(physo%alpha*(cro%te(1)-eph))
!### Calculate phi_1 and phi_2 based on Delta ###
if (delta .GT. 2d0) then
!### If delta is greater than 2 then phi1 and phi1 reduce to phiu ###
!### Eq. 4.4.2 in S02 ###
phi1=4d0*(dlog(2d0*cro%g(1)*ieph*(cro%te(1)-eph))-0.5d0)
phi2=phi1
elseif (delta .GE. 0d0 .AND. delta .LE. 2d0) then
!### Calculates phi1 and phi2 ###
CALL Brem_phiH(delta,phi1,phi2)
else
phi1=0d0
phi2=0d0
endif
!### Bremsstrahlung cross section in units of cm^3 ###
!### These are not the same units as S02 for the cross section ###
!### Relativistic Cross section from S02 (4.4.1) ###
sigma=3d0/physo%pi*0.125d0*physo%alpha*physo%sigmat*((1d0+(1d0-cro%ite(1)*eph)**2)*phi1-2d0/3d0*(1d0-eph*cro%ite(1))*phi2)
!### The cross section cannot be less than 0 ###
sigma=MAX(sigma,0d0)
!### Eq. 4.4.4 in S02 multiplied by dN/dE for this ambient species erg/s/Hz/cm^3/erg ###
!### This includes the correction for if we are calculating bremsstrahlung for a CR species ###
!### That is not electrons. For a discussion see Dogiel et. al. A&A 382 (2002) 730 ###
!### Note that there appears to be a mistake in the units for S02. What he lists is in ergs/s not ergs/s/eV. ###
jl=physo%c*physo%h*nH*sigma*cro%n(1)*(cro%q/physo%q)**4*physo%me/cro%m
!### Integrates the CR Spectrum ###
do i=1,cro%nbins-1
!### Eq. 4.4.3 in S02 ###
delta=0.25d0*eph*cro%ig(i+1)/(physo%alpha*(cro%te(i+1)-eph))
!### Calculate phi_1 and phi_2 based on Delta ###
if (delta .GT. 2d0) then
!### If delta is greater than 2 then phi1 and phi1 reduce to phiu ###
!### Eq. 4.4.2 in S02 ###
phi1=4d0*(dlog(2d0*cro%g(i+1)*ieph*(cro%te(i+1)-eph))-0.5d0)
phi2=phi1
elseif (delta .GE. 0d0 .AND. delta .LE. 2d0) then
!### Calculates phi1 and phi2 ###
CALL Brem_phiH(delta,phi1,phi2)
else
phi1=0d0
phi2=0d0
endif
!### Bremsstrahlung cross section in units of cm^3 ###
!### These are not the same units as S02 for the cross section ###
!### Relativistic Cross section from S02 (4.4.1) ###
sigma=3d0/physo%pi*0.125d0*physo%alpha*physo%sigmat*((1d0+(1d0-cro%ite(i+1)*eph)**2)*phi1-2d0/3d0*(1d0-eph*cro%ite(i+1))*phi2)
!### The cross section cannot be less than 0 ###
sigma=MAX(sigma,0d0)
!### Eq. 4.4.4 in S02 multiplied by dN/dE for this species erg/s/Hz/cm^3/erg ###
!### This includes the correction for if we are calculating bremsstrahlung for a CR species ###
!### That is not electrons. For a discussion see Dogiel et. al. A&A 382 (2002) 730 ###
!### Note that there appears to be a mistake in the units for S02. What he lists is in ergs/s not ergs/s/eV. ###
ju=physo%c*physo%h*nH*sigma*cro%n(i+1)*(cro%q/physo%q)**4*physo%me/cro%m
!### Check to save time ###
if (jl .EQ. 0d0 .AND. ju .EQ. 0d0) then
jl=ju
CYCLE
endif
!### For this case it appears to work better if we use trapezoidal rule rather than a powerlaw assumption ###
bremo%j(j)=0.5d0*(cro%e(i+1)-cro%e(i))*(jl+ju)+bremo%j(j)
!### Store the upper value for the next update. ###
jl=ju
enddo
enddo
endif
!### Now we will handle the neutral Helium ###
if (nHe .NE. 0d0) then
!### Marches through emission frequencies ###
do j=1,bremo%nphbins
!### Current photon energy and it's inverse ###
eph=physo%h*bremo%nu(j)
ieph=1d0/eph
!### Calculate bremsstrahlung power for the first momentum for use later ###
!### Eq. 4.4.3 in S02 ###
delta=0.25d0*eph*cro%ig(1)/(physo%alpha*(cro%te(1)-eph))
!### Calculate phi_1 and phi_2 based on Delta ###
if (delta .GT. 2d0) then
!### If delta is greater than 2 then phi1 and phi1 reduce to phiu ###
!### Eq. 4.4.2 in S02 ###
phi1=16d0*4d0*(dlog(2d0*cro%g(1)*ieph*(cro%te(1)-eph))-0.5d0)
phi2=phi1
elseif (delta .GE. 0d0 .AND. delta .LE. 2d0) then
!### Calculates phi1 and phi2 ###
CALL Brem_phiHe(delta,phi1,phi2)
else
phi1=0d0
phi2=0d0
endif
!### Bremsstrahlung cross section in units of cm^3 ###
!### These are not the same units as S02 for the cross section ###
!### Relativistic Cross section from S02 (4.4.1) ###
sigma=3d0/physo%pi*0.125d0*physo%alpha*physo%sigmat*((1d0+(1d0-cro%ite(1)*eph)**2)*phi1-2d0/3d0*(1d0-eph*cro%ite(1))*phi2)
!### The cross section cannot be less than 0 ###
sigma=MAX(sigma,0d0)
!### Eq. 4.4.4 in S02 multiplied by dN/dE for this ambient species erg/s/Hz/cm^3/erg ###
!### This includes the correction for if we are calculating bremsstrahlung for a CR species ###
!### That is not electrons. For a discussion see Dogiel et. al. A&A 382 (2002) 730 ###
!### Note that there appears to be a mistake in the units for S02. What he lists is in ergs/s not ergs/s/eV. ###
jl=physo%c*physo%h*nHe*sigma*cro%n(1)*(cro%q/physo%q)**4*physo%me/cro%m
!### Integrates the CR Spectrum ###
do i=1,cro%nbins-1
!### Eq. 4.4.3 in S02 ###
delta=0.25d0*eph*cro%ig(i+1)/(physo%alpha*(cro%te(i+1)-eph))
!### Calculate phi_1 and phi_2 based on Delta ###
if (delta .GT. 2d0) then
!### If delta is greater than 2 then phi1 and phi1 reduce to phiu ###
!### Eq. 4.4.2 in S02 ###
phi1=16d0*4d0*(dlog(2d0*cro%g(i+1)*ieph*(cro%te(i+1)-eph))-0.5d0)
phi2=phi1
elseif (delta .GE. 0d0 .AND. delta .LE. 2d0) then
!### Calculates phi1 and phi2 ###
CALL Brem_phiHe(delta,phi1,phi2)
else
phi1=0d0
phi2=0d0
endif
!### Bremsstrahlung cross section in units of cm^3 ###
!### These are not the same units as S02 for the cross section ###
!### Relativistic Cross section from S02 (4.4.1) ###
sigma=3d0/physo%pi*0.125d0*physo%alpha*physo%sigmat*((1d0+(1d0-cro%ite(i+1)*eph)**2)*phi1-2d0/3d0*(1d0-eph*cro%ite(i+1))*phi2)
!### The cross section cannot be less than 0 ###
sigma=MAX(sigma,0d0)
!### Eq. 4.4.4 in S02 multiplied by dN/dE for this species erg/s/Hz/cm^3/erg ###
!### This includes the correction for if we are calculating bremsstrahlung for a CR species ###
!### That is not electrons. For a discussion see Dogiel et. al. A&A 382 (2002) 730 ###
!### Note that there appears to be a mistake in the units for S02. What he lists is in ergs/s not ergs/s/eV. ###
ju=physo%c*physo%h*nHe*sigma*cro%n(i+1)*(cro%q/physo%q)**4*physo%me/cro%m
!### Check to save time ###
if (jl .EQ. 0d0 .AND. ju .EQ. 0d0) then
jl=ju
CYCLE
endif
!### For this case it appears to work better if we use trapezoidal rule rather than a powerlaw assumption ###
bremo%j(j)=0.5d0*(cro%e(i+1)-cro%e(i))*(jl+ju)+bremo%j(j)
!### Store the upper value for the next update. ###
jl=ju
enddo
enddo
endif
!### S02 4.4.4 assumes the emission is isotropic and thus already folds in the factor 4*pi to take care of the angular component ###
!### However in this code we will be working in units where the /str remains, so we will be dividing by 4*pi ###
bremo%j=0.25d0/physo%pi*bremo%j
END SUBROUTINE Brem_Calc
!### Calculates phi1 and phi2 for Hydrogen based on Table 4.1 in S02 ###
SUBROUTINE Brem_phiH(delta,phi1,phi2)
REAL*8, INTENT(IN) :: delta
REAL*8, INTENT(OUT) :: phi1, phi2
REAL*8 :: d(9), p1(9), p2(9), slope
INTEGER :: i
!### Column 1, 2, 3 of Table 4.1 S02 ###
d = (/0d0, 0.01d0, 0.02d0, 0.05d0, 0.1d0, 0.2d0, 0.5d0, 1d0, 2d0/)
p1= (/45.79d0, 45.43d0, 45.09d0, 44.11d0, 42.64d0, 40.16d0, 34.97d0, 29.97d0, 24.73d0/)
p2= (/44.46d0, 44.38d0, 44.24d0, 43.65d0, 42.49d0, 40.19d0, 34.93d0, 29.78d0, 24.34d0/)
!### Now we will figure out in between which two bins delta lies. ###
do i=1,8
if (delta .GE. d(i) .AND. delta .LE. d(i+1)) EXIT
enddo
!### We will use simple linear interpolation for the inter bin values as the function is slowly varying. ###
!### phi_1 ###
slope=(p1(i+1)-p1(i))/(d(i+1)-d(i))
phi1=slope*(delta-d(i))+p1(i)
!### phi_2 ###
slope=(p2(i+1)-p2(i))/(d(i+1)-d(i))
phi2=slope*(delta-d(i))+p2(i)
END SUBROUTINE Brem_phiH
!### Calculates phi1 and phi2 for Helium based on Table 4.1 in S02 ###
SUBROUTINE Brem_phiHe(delta,phi1,phi2)
REAL*8, INTENT(IN) :: delta
REAL*8, INTENT(OUT) :: phi1, phi2
REAL*8 :: d(9), p1(9), p2(9), slope
INTEGER :: i
!### Column 1, 4, 5 of Table 4.1 S02 ###
d = (/0d0, 0.01d0, 0.02d0, 0.05d0, 0.1d0, 0.2d0, 0.5d0, 1d0, 2d0/)
p1= (/134.6d0, 133.85d0, 133.11d0, 130.86d0, 127.17d0, 120.35d0, 104.60d0, 89.94d0, 74.19d0/)
p2= (/131.4d0, 130.51d0, 130.33d0, 129.26d0, 126.76d0, 120.80d0, 105.21d0, 89.46d0, 73.03d0/)
!### Now we will figure out in between which two bins delta lies. ###
do i=1,8
if (delta .GE. d(i) .AND. delta .LE. d(i+1)) EXIT
enddo
!### We will use simple linear interpolation for the inter bin values as the function is slowly varying. ###
!### phi_1 ###
slope=(p1(i+1)-p1(i))/(d(i+1)-d(i))
phi1=slope*(delta-d(i))+p1(i)
!### phi_2 ###
slope=(p2(i+1)-p2(i))/(d(i+1)-d(i))
phi2=slope*(delta-d(i))+p2(i)
END SUBROUTINE Brem_phiHe
END MODULE Mod_Brem