Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mcray
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Horns, Prof. Dr. Dieter
mcray
Commits
f4aa6686
Commit
f4aa6686
authored
1 year ago
by
Oleg Kalashev
Browse files
Options
Downloads
Patches
Plain Diff
preparation for adding synchrotron losses
parent
b560ca43
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/tables/synchrotron/make_table.py
+41
-0
41 additions, 0 deletions
bin/tables/synchrotron/make_table.py
with
41 additions
and
0 deletions
bin/tables/synchrotron/make_table.py
0 → 100644
+
41
−
0
View file @
f4aa6686
import
numpy
as
np
from
sys
import
stderr
from
scipy.special
import
kv
from
scipy.integrate
import
quad
def
main
():
# printing dimensionless synchrotron power spectrum
# see e.g. formula (5.66) from https://www.cv.nrao.edu/~sransom/web/Ch5.html
def
integrand
(
x
):
return
kv
(
5
/
3
,
x
)
max_rel_error
=
1e-6
log_x_min
=
-
20
log_x_max
=
2
n_bins_per_decade
=
100
x
=
np
.
logspace
(
log_x_min
,
log_x_max
,
n_bins_per_decade
*
(
log_x_max
-
log_x_min
)
+
1
)
f
=
np
.
zeros_like
(
x
)
result
,
error
=
quad
(
integrand
,
x
[
-
1
],
np
.
inf
,
limit
=
200
,
epsabs
=
0
)
if
result
>
0
:
assert
error
/
result
<
max_rel_error
,
f
'
insufficient accuracy
{
error
/
result
}
for x =
{
x
[
-
1
]
}
'
f
[
-
1
]
=
result
for
i
in
range
(
len
(
f
)
-
1
,
0
,
-
1
):
result
,
error
=
quad
(
integrand
,
x
[
i
-
1
],
x
[
i
],
limit
=
1000
,
epsabs
=
0
)
if
result
>
0
:
assert
error
/
result
<
max_rel_error
,
f
'
insufficient accuracy
{
error
/
result
}
for x =
{
x
[
i
-
1
]
}
'
f
[
i
-
1
]
=
result
+
f
[
i
]
f
*=
x
# check that \Int_0^{x_max} f(x)dx = 1
checksum
=
np
.
sum
(
f
*
x
)
*
np
.
log
(
10
)
/
n_bins_per_decade
print
(
'
checksum =
'
,
checksum
,
file
=
stderr
)
checksum
=
np
.
sum
(
f
[
1
:]
*
(
x
[
1
:]
-
x
[:
-
1
]))
print
(
'
checksum2 =
'
,
checksum
,
file
=
stderr
)
X
=
np
.
vstack
((
x
,
f
)).
transpose
()
np
.
savetxt
(
'
sync_spec.dat
'
,
X
)
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment