IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
corsika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Air Shower Physics
corsika
Commits
5d3fd53c
Commit
5d3fd53c
authored
4 years ago
by
Nikos Karastathis
Browse files
Options
Downloads
Patches
Plain Diff
put formulas to CoREAS & improve ZHS & .writeOutput()
parent
e750611f
No related branches found
No related tags found
1 merge request
!329
Radio interface
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
corsika/modules/radio/CoREAS.hpp
+36
-34
36 additions, 34 deletions
corsika/modules/radio/CoREAS.hpp
corsika/modules/radio/RadioProcess.hpp
+24
-21
24 additions, 21 deletions
corsika/modules/radio/RadioProcess.hpp
corsika/modules/radio/ZHS.hpp
+27
-20
27 additions, 20 deletions
corsika/modules/radio/ZHS.hpp
with
87 additions
and
75 deletions
corsika/modules/radio/CoREAS.hpp
+
36
−
34
View file @
5d3fd53c
...
@@ -50,63 +50,64 @@ namespace corsika {
...
@@ -50,63 +50,64 @@ namespace corsika {
ProcessReturn
simulate
(
Particle
&
particle
,
Track
const
&
track
)
const
{
ProcessReturn
simulate
(
Particle
&
particle
,
Track
const
&
track
)
const
{
//get global simulation time for that track. (This is my best guess for now)
//get global simulation time for that track. (This is my best guess for now)
auto
startTime_
{
particle
.
getTime
()};
// time at start point of track.
auto
startTime_
{
particle
.
getTime
()
auto
endTime_
{
particle
.
getTime
()
-
track
.
getDuration
()};
// time at end point of track.
-
track
.
getDuration
()};
// time at start point of track.
auto
endTime_
{
particle
.
getTime
()};
// time at end point of track.
// an alternative is the following which shouldn't work I think
// auto startTime_ {particle.getTime()};
// auto endTime_ {startTime_ + track.getDuration()};
// beta is defined as velocity / speed of light
// beta is defined as velocity / speed of light
auto
startBeta_
{
track
.
getVelocity
(
0
)
/
constants
::
c
};
auto
startBeta_
{
track
.
getVelocity
(
0
)
/
constants
::
c
};
auto
endBeta_
{
track
.
getVelocity
(
1
)
/
constants
::
c
};
auto
endBeta_
{
track
.
getVelocity
(
1
)
/
constants
::
c
};
// calculate gamma factor using beta (the proper way would be with energy over mass
but not yet :(
)
// calculate gamma factor using beta (the proper way would be with energy over mass)
auto
startGamma_
{
1.
/
sqrt
(
1.
-
(
startBeta_
*
startBeta_
))};
auto
startGamma_
{
1.
/
sqrt
(
1.
-
(
startBeta_
*
startBeta_
))};
auto
endGamma_
{
1.
/
sqrt
(
1.
-
(
endBeta_
*
endBeta_
))};
auto
endGamma_
{
1.
/
sqrt
(
1.
-
(
endBeta_
*
endBeta_
))};
// get start and end position of the track
auto
startPoint_
{
track
.
getPosition
(
0
)};
auto
endPoint_
{
track
.
getPosition
(
1
)};
// get particle charge
auto
const
charge_
{
get_charge
(
particle
.
getPID
())};
// we loop over each antenna in the collection
// we loop over each antenna in the collection
for
(
auto
&
antenna
:
detector_
.
getAntennas
())
{
for
(
auto
&
antenna
:
detector_
.
getAntennas
())
{
// auto startPoint = /* TODO: get Point from Track */;
// get the Path (path1) from the start "endpoint" to the antenna.
auto
startPoint
=
track
.
getPosition
(
0
);
// this MIGHT work and also get it out of the for loop?
auto
endPoint
=
track
.
getPosition
(
1
);
// I think we should get these guys out of the for loop
// get the Path from the track to the antenna
// This is a SignalPathCollection
// This is a SignalPathCollection
auto
paths1
{
this
->
propagator_
.
propagate
(
startPoint
,
antenna
.
getLocation
())};
auto
paths1
{
this
->
propagator_
.
propagate
(
startPoint_
,
antenna
.
getLocation
())};
auto
R1_
{(
startPoint_
-
antenna
.
getLocation
()).
getNorm
()};
// now loop over the paths that we got above
// now loop over the paths that we got above
// Note: for the StraightPropagator, there will only be a single
// path but other propagators may return more than one.
for
(
auto
const
&
path
:
paths1
)
{
for
(
auto
const
&
path
:
paths1
)
{
// auto startPoint_ {path.total_time_ + startTime_};
auto
startPointReceiveTime_
{
path
.
total_time_
+
startTime_
};
// might do it on the fly
// path.average_refractivity_;
// path.emit_;
// path.receive_;
// combination along this path.
// global time + time delay
// and pass it to the antenna.
// CoREAS calculation -> get ElectricFieldVector1
// CoREAS calculation -> get ElectricFieldVector1
antenna
.
receive
(
/* startPoint_, receive vector, ElectricFieldVector1 */
);
ElectricFieldVector
EV1_
{(
charge_
/
constants
::
c
)
*
path
.
receive_
.
cross
(
path
.
receive_
.
cross
(
startBeta_
))
/
(
R1_
*
(
1
-
path
.
average_refractivity_
*
startBeta_
*
path
.
receive_
))};
// pass it to the antenna
antenna
.
receive
(
startPointReceiveTime_
,
path
.
receive_
,
EV1_
);
}
// END: loop over paths
}
// END: loop over paths
// get the Path from the
track
to the antenna
// get the Path
(path2)
from the
end "endpoint"
to the antenna
.
// This is a SignalPathCollection
// This is a SignalPathCollection
auto
paths2
{
this
->
propagator_
.
propagate
(
endPoint
,
antenna
.
getLocation
())};
auto
paths2
{
this
->
propagator_
.
propagate
(
endPoint_
,
antenna
.
getLocation
())};
auto
R2_
{(
endPoint_
-
antenna
.
getLocation
()).
getNorm
()};
for
(
auto
const
&
path
:
paths2
)
{
for
(
auto
const
&
path
:
paths2
)
{
// auto endPoint_ {path.total_time + endTime_};
auto
endPointReceiveTime_
{
path
.
total_time
+
endTime_
};
// might do it on the fly
// path.average_refractivity_;
// path.emit_;
// path.receive_;
// combination along this path.
// global time + time delay
// and pass it to the antenna.
//CoREAS calculation -> get ElectricFieldVector2
//CoREAS calculation -> get ElectricFieldVector2
antenna
.
receive
(
/* endPoint_, receive vector, ElectricFieldVector2 */
);
ElectricFieldVector
EV2_
{(
charge_
/
constants
::
c
)
*
path
.
receive_
.
cross
(
path
.
receive_
.
cross
(
endBeta_
))
/
(
R2_
*
(
1
-
path
.
average_refractivity_
*
endBeta_
*
path
.
receive_
))};
// pass it to the antenna
antenna
.
receive
(
endPointReceiveTime_
,
path
.
receive_
,
EV2_
);
}
// END: loop over paths
}
// END: loop over paths
...
@@ -134,6 +135,7 @@ namespace corsika {
...
@@ -134,6 +135,7 @@ namespace corsika {
// This is part of the ZHS / CoReas formalisms and can
// This is part of the ZHS / CoReas formalisms and can
// be related from the magnetic field / acceleration, charge,
// be related from the magnetic field / acceleration, charge,
// etc. of the particle.
// etc. of the particle.
return
1000000000000
;
}
}
};
// END: class RadioProcess
};
// END: class RadioProcess
...
...
This diff is collapsed.
Click to expand it.
corsika/modules/radio/RadioProcess.hpp
+
24
−
21
View file @
5d3fd53c
...
@@ -31,13 +31,13 @@ namespace corsika {
...
@@ -31,13 +31,13 @@ namespace corsika {
class
RadioProcess
:
public
ContinuousProcess
<
class
RadioProcess
:
public
ContinuousProcess
<
RadioProcess
<
TRadioDetector
,
TRadioImpl
,
TPropagator
>>
{
RadioProcess
<
TRadioDetector
,
TRadioImpl
,
TPropagator
>>
{
using
ParticleType
=
corsika
::
setup
::
Stack
::
particle_type
;
//
using ParticleType = corsika::setup::Stack::particle_type;
using
TrackType
=
corsika
::
LeapFrogTrajectory
;
//
using TrackType = corsika::LeapFrogTrajectory;
/**
/**
* A collection of filter objects for deciding on valid particles and tracks.
* A collection of filter objects for deciding on valid particles and tracks.
*/
*/
std
::
vector
<
std
::
function
<
bool
(
ParticleType
&
,
TrackType
const
&
)
>>
filters_
;
//
std::vector<std::function<bool(ParticleType&, TrackType const&)>> filters_;
/**
/**
* Get a reference to the underlying radio implementation.
* Get a reference to the underlying radio implementation.
...
@@ -82,29 +82,29 @@ namespace corsika {
...
@@ -82,29 +82,29 @@ namespace corsika {
// filtering or thinning for calculation of the radio emission. This is
// filtering or thinning for calculation of the radio emission. This is
// important for controlling the runtime of radio (by ignoring particles
// important for controlling the runtime of radio (by ignoring particles
// that aren't going to contribute i.e. heavy hadrons)
// that aren't going to contribute i.e. heavy hadrons)
if
(
valid
(
particle
,
track
))
{
//
if (valid(particle, track))
{
return
this
->
implementation
().
simulate
(
particle
,
track
);
return
this
->
implementation
().
simulate
(
particle
,
track
);
}
//
}
}
}
/**
/**
* Decide whether this particle and track is valid for radio emission.
* Decide whether this particle and track is valid for radio emission.
*/
*/
template
<
typename
Particle
,
typename
Track
>
//
template <typename Particle, typename Track>
auto
valid
(
Particle
&
particle
,
Track
const
&
track
)
const
{
//
auto valid(Particle& particle, Track const& track) const {
//
// loop over the filters in the our collection
//
// loop over the filters in the our collection
for
(
auto
&
filter
:
filters_
)
{
//
for (auto& filter : filters_) {
// evaluate the filter. If the filter returns false,
//
// evaluate the filter. If the filter returns false,
// then this track is not valid for radio emission.
//
// then this track is not valid for radio emission.
if
(
!
filter
(
particle
,
track
))
return
false
;
//
if (!filter(particle, track)) return false;
}
//
}
}
//
}
template
<
typename
Particle
,
typename
Track
>
//
template <typename Particle, typename Track>
void
addFilter
(
const
std
::
function
<
bool
(
Particle
&
,
Track
const
&
)
>
filter
)
{
//
void addFilter(const std::function<bool(Particle&, Track const&)> filter) {
filters_
.
push_back
(
filter
);
//
filters_.push_back(filter);
}
//
}
/**
/**
* TODO: This is placeholder so we can use text output while
* TODO: This is placeholder so we can use text output while
...
@@ -114,10 +114,13 @@ namespace corsika {
...
@@ -114,10 +114,13 @@ namespace corsika {
int
i
=
1
;
int
i
=
1
;
for
(
auto
&
antenna
:
detector_
.
getAntennas
())
{
for
(
auto
&
antenna
:
detector_
.
getAntennas
())
{
auto
[
t
,
E
]
=
antenna
.
getWaveform
();
std
::
ofstream
out_file
(
"antenna"
+
to_string
(
i
)
+
"_output.csv"
);
std
::
ofstream
out_file
(
"antenna"
+
to_string
(
i
)
+
"_output.csv"
);
xt
::
dump_csv
(
out_file
,
antenna
.
getWaveform
()
);
xt
::
dump_csv
(
out_file
,
t
,
E
);
out_file
.
close
();
out_file
.
close
();
++
i
;
++
i
;
}
}
// how this method should work:
// how this method should work:
// 1. Loop over the antennas in the collection
// 1. Loop over the antennas in the collection
...
...
This diff is collapsed.
Click to expand it.
corsika/modules/radio/ZHS.hpp
+
27
−
20
View file @
5d3fd53c
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include
<corsika/modules/radio/propagators/StraightPropagator.hpp>
#include
<corsika/modules/radio/propagators/StraightPropagator.hpp>
#include
<corsika/framework/geometry/QuantityVector.hpp>
#include
<corsika/framework/geometry/QuantityVector.hpp>
#include
<corsika/framework/core/PhysicalUnits.hpp>
#include
<corsika/framework/core/PhysicalUnits.hpp>
#include
<bits/stdc++.h>
namespace
corsika
{
namespace
corsika
{
...
@@ -49,41 +50,46 @@ namespace corsika {
...
@@ -49,41 +50,46 @@ namespace corsika {
template
<
typename
Particle
,
typename
Track
>
template
<
typename
Particle
,
typename
Track
>
ProcessReturn
simulate
(
Particle
&
particle
,
Track
const
&
track
)
const
{
ProcessReturn
simulate
(
Particle
&
particle
,
Track
const
&
track
)
const
{
auto
globalTime_
=
particle
.
getTime
();
// this is very shady at the moment...
//get global simulation time for that track. (This is my best guess for now)
auto
startTime_
{
particle
.
getTime
()
-
track
.
getDuration
()};
// time at start point of track.
auto
endTime_
{
particle
.
getTime
()};
// time at end point of track.
auto
midTime_
{(
startTime_
+
endTime_
)
/
2
};
//get global time for that track
auto
startPoint_
=
track
.
getPosition
(
0
);
// auto startTime_ = track.getDuration(0); // time at start point of track.
// auto endTime_ = track.getDuration(1); // time at end point of track.
// track velocity
auto
trackVelocity_
{(
track
.
getVelocity
(
0
)
+
track
.
getVelocity
(
1
))
/
2
};
// beta is defined as velocity / speed of light
auto
beta_
{
trackVelocity_
/
constants
::
c
};
// get particle charge
auto
const
charge_
{
get_charge
(
particle
.
getPID
())};
// we loop over each antenna in the collection
// we loop over each antenna in the collection
for
(
auto
&
antenna
:
detector_
.
getAntennas
())
{
for
(
auto
&
antenna
:
detector_
.
getAntennas
())
{
// auto start = /* TODO: get Point from Track */;
auto
startPoint
=
track
.
getPosition
(
0
);
// this MIGHT work and also get it out of the for loop?
// get the Path from the track to the antenna
// get the Path from the track to the antenna
// This is a SignalPathCollection
// This is a SignalPathCollection
auto
paths
{
this
->
propagator_
.
propagate
(
startPoint
,
antenna
.
getLocation
())};
auto
paths
{
this
->
propagator_
.
propagate
(
startPoint_
,
antenna
.
getLocation
())};
auto
R_
{(
startPoint_
-
antenna
.
getLocation
()).
getNorm
()};
// now loop over the paths that we got above
// now loop over the paths that we got above
// Note: for the StraightPropagator, there will only be a single
// Note: for the StraightPropagator, there will only be a single
// path but other propagators may return more than one.
// path but other propagators may return more than one.
for
(
auto
const
&
path
:
paths
)
{
for
(
auto
const
&
path
:
paths
)
{
// path.total_time_ + globalTime_;
// path.average_refractivity_;
// path.emit_;
// path.receive_;
// calculate the ZHS formalism for this particle-antenna
// calculate the ZHS formalism for this particle-antenna
// combination along this path.
ElectricFieldVector
EV_
=
((
-
constants
)
*
trackVelocity_
.
dot
(
path
.
emit
))
*
// global time + time delay
((
midTime_
+
path
.
total_time_
-
(
1
-
path
.
average_refractivity_
*
beta_
*
// and pass it to the antenna.
acos
(
track
.
getDirection
(
0
).
dot
(
path
.
emit_
)))
*
startTime_
)
-
(
midTime_
+
path
.
total_time_
-
(
1
-
path
.
average_refractivity_
*
beta_
*
acos
(
track
.
getDirection
(
0
).
dot
(
path
.
emit_
)))
*
endTime_
))
/
(
1
-
path
.
average_refractivity_
*
beta_
*
acos
(
track
.
getDirection
(
0
).
dot
(
path
.
emit_
)));
// ElectricFieldVector EV_ = -(constants)*(V_perpendicular)*
// pass it to the antenna
// (delta(global time + time delay - (1 - average_refractivity*beta*costheta)t1)
antenna
.
receive
(
midTime_
+
path
.
total_time_
,
path
.
receive_
,
EV_
);
// - delta(global time + time delay- (1 - average_refractivity*beta*costheta)t1))
// /(1 - average_refractivity*beta*costheta);
antenna
.
receive
(
/* global time + time delay, receive vector, ElectricFieldVector */
);
}
// END: loop over paths
}
// END: loop over paths
...
@@ -111,6 +117,7 @@ namespace corsika {
...
@@ -111,6 +117,7 @@ namespace corsika {
// This is part of the ZHS / CoReas formalisms and can
// This is part of the ZHS / CoReas formalisms and can
// be related from the magnetic field / acceleration, charge,
// be related from the magnetic field / acceleration, charge,
// etc. of the particle.
// etc. of the particle.
return
1000000000
_m
;
}
}
};
// END: class RadioProcess
};
// END: class RadioProcess
...
...
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