IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 52e3e25f authored by Ralf Ulrich's avatar Ralf Ulrich
Browse files

Merge branch '61_tested_example' into 'master'

61 tested example

Closes #61

See merge request AirShowerPhysics/corsika!25
parents 0f38ed57 1c1e193f
No related branches found
No related tags found
No related merge requests found
add_executable (helix_example helix_example.cc) add_executable (helix_example helix_example.cc)
target_compile_options(helix_example PRIVATE -g) # do not skip asserts
target_link_libraries(helix_example CORSIKAgeometry CORSIKAunits) target_link_libraries(helix_example CORSIKAgeometry CORSIKAunits)
install (TARGETS helix_example DESTINATION share/examples) install (TARGETS helix_example DESTINATION share/examples)
add_test(helix_example helix_example)
add_executable (geometry_example geometry_example.cc) add_executable (geometry_example geometry_example.cc)
target_compile_options(geometry_example PRIVATE -g) # do not skip asserts
target_link_libraries (geometry_example CORSIKAgeometry CORSIKAunits) target_link_libraries (geometry_example CORSIKAgeometry CORSIKAunits)
install (TARGETS geometry_example DESTINATION share/examples) #install (TARGETS geometry_example DESTINATION share/examples)
add_test(geometry_example geometry_example)
add_executable (logger_example logger_example.cc) add_executable (logger_example logger_example.cc)
target_compile_options(logger_example PRIVATE -g) # do not skip asserts
target_link_libraries (logger_example CORSIKAunits CORSIKAlogging) target_link_libraries (logger_example CORSIKAunits CORSIKAlogging)
install (TARGETS logger_example DESTINATION share/examples) #install (TARGETS logger_example DESTINATION share/examples)
add_test(logger_example logger_example)
add_executable (stack_example stack_example.cc) add_executable (stack_example stack_example.cc)
target_compile_options(stack_example PRIVATE -g) # do not skip asserts
target_link_libraries (stack_example SuperStupidStack CORSIKAunits CORSIKAlogging) target_link_libraries (stack_example SuperStupidStack CORSIKAunits CORSIKAlogging)
install (TARGETS stack_example DESTINATION share/examples) add_test(stack_example stack_example)
add_executable (cascade_example cascade_example.cc) add_executable (cascade_example cascade_example.cc)
target_compile_options(cascade_example PRIVATE -g) # do not skip asserts
target_link_libraries (cascade_example SuperStupidStack CORSIKAunits CORSIKAlogging target_link_libraries (cascade_example SuperStupidStack CORSIKAunits CORSIKAlogging
CORSIKArandom CORSIKArandom
CORSIKAsibyll CORSIKAsibyll
...@@ -25,13 +33,15 @@ target_link_libraries (cascade_example SuperStupidStack CORSIKAunits CORSIKAlogg ...@@ -25,13 +33,15 @@ target_link_libraries (cascade_example SuperStupidStack CORSIKAunits CORSIKAlogg
CORSIKAgeometry CORSIKAgeometry
CORSIKAprocesssequence CORSIKAprocesssequence
) )
install (TARGETS cascade_example DESTINATION share/examples) #install (TARGETS cascade_example DESTINATION share/examples)
add_test(cascade_example cascade_example)
add_executable (staticsequence_example staticsequence_example.cc) add_executable (staticsequence_example staticsequence_example.cc)
target_compile_options(staticsequence_example PRIVATE -g) # do not skip asserts
target_link_libraries (staticsequence_example target_link_libraries (staticsequence_example
CORSIKAprocesssequence CORSIKAprocesssequence
CORSIKAunits CORSIKAunits
CORSIKAgeometry CORSIKAgeometry
CORSIKAlogging) CORSIKAlogging)
install (TARGETS staticsequence_example DESTINATION share/examples) #install (TARGETS staticsequence_example DESTINATION share/examples)
add_test(staticsequence_example staticsequence_example)
...@@ -50,12 +50,15 @@ int main() { ...@@ -50,12 +50,15 @@ int main() {
std::cout << "p2-p1 components in cs3: " << diff.GetComponents(cs3) std::cout << "p2-p1 components in cs3: " << diff.GetComponents(cs3)
<< std::endl; // but not under rotations << std::endl; // but not under rotations
std::cout << "p2-p1 norm^2: " << norm << std::endl; std::cout << "p2-p1 norm^2: " << norm << std::endl;
assert(norm == 1 * meter*meter);
Sphere s(p1, 10_m); // define a sphere around a point with a radius Sphere s(p1, 10_m); // define a sphere around a point with a radius
std::cout << "p1 inside s: " << s.Contains(p2) << std::endl; std::cout << "p1 inside s: " << s.Contains(p2) << std::endl;
assert(s.Contains(p2) == 1);
Sphere s2(p1, 3_um); // another sphere Sphere s2(p1, 3_um); // another sphere
std::cout << "p1 inside s2: " << s2.Contains(p2) << std::endl; std::cout << "p1 inside s2: " << s2.Contains(p2) << std::endl;
assert(s2.Contains(p2) == 0);
// let's try parallel projections: // let's try parallel projections:
auto const v1 = Vector<length_d>(root, {1_m, 1_m, 0_m}); auto const v1 = Vector<length_d>(root, {1_m, 1_m, 0_m});
......
...@@ -35,7 +35,7 @@ int main() { ...@@ -35,7 +35,7 @@ int main() {
auto constexpr t0 = 0_s; auto constexpr t0 = 0_s;
auto constexpr t1 = 1_s; auto constexpr t1 = 1_s;
auto constexpr dt = 1_us; auto constexpr dt = 1_ms;
auto constexpr n = long((t1 - t0) / dt) + 1; auto constexpr n = long((t1 - t0) / dt) + 1;
auto arr = std::make_unique<std::array<std::array<double, 4>, n>>(); auto arr = std::make_unique<std::array<std::array<double, 4>, n>>();
......
...@@ -35,7 +35,7 @@ int main() { ...@@ -35,7 +35,7 @@ int main() {
std::any std::any
*/ */
for (int i = 0; i < 100000; ++i) { for (int i = 0; i < 10000; ++i) {
LOG(info, "irgendwas", " ", string("and more"), " ", LOG(info, "irgendwas", " ", string("and more"), " ",
boost::format("error: %i message: %s. done."), i, "stupido"); boost::format("error: %i message: %s. done."), i, "stupido");
LOG(err, "Fehler"); LOG(err, "Fehler");
...@@ -46,7 +46,7 @@ int main() { ...@@ -46,7 +46,7 @@ int main() {
sink::NoSink off; sink::NoSink off;
Logger<MessageOff> info("", "", off); Logger<MessageOff> info("", "", off);
for (int i = 0; i < 100000; ++i) { for (int i = 0; i < 10000; ++i) {
LOG(info, "irgendwas", string("and more"), LOG(info, "irgendwas", string("and more"),
boost::format("error: %i message: %s. done."), i, "stupido", "a-number:", 8.99, boost::format("error: %i message: %s. done."), i, "stupido", "a-number:", 8.99,
"ENDE"); "ENDE");
......
...@@ -13,13 +13,11 @@ ...@@ -13,13 +13,11 @@
#include <corsika/stack/super_stupid/SuperStupidStack.h> #include <corsika/stack/super_stupid/SuperStupidStack.h>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <cassert>
using namespace std;
// using namespace corsika::literals;
// using namespace corsika::io;
using namespace corsika::units::si; using namespace corsika::units::si;
using namespace corsika::stack; using namespace corsika::stack;
using namespace std;
void fill(corsika::stack::super_stupid::SuperStupidStack& s) { void fill(corsika::stack::super_stupid::SuperStupidStack& s) {
for (int i = 0; i < 11; ++i) { for (int i = 0; i < 11; ++i) {
...@@ -30,14 +28,17 @@ void fill(corsika::stack::super_stupid::SuperStupidStack& s) { ...@@ -30,14 +28,17 @@ void fill(corsika::stack::super_stupid::SuperStupidStack& s) {
} }
void read(corsika::stack::super_stupid::SuperStupidStack& s) { void read(corsika::stack::super_stupid::SuperStupidStack& s) {
cout << "found Stack with " << s.GetSize() << " particles. " << endl; assert(s.GetSize() == 11); // stack has 11 particles
EnergyType Etot;
EnergyType total_energy;
int i = 0;
for (auto& p : s) { for (auto& p : s) {
Etot += p.GetEnergy(); total_energy += p.GetEnergy();
cout << "particle: " << p.GetPID() << " with " << p.GetEnergy() / 1_GeV << " GeV" // particles are electrons with 1.5 GeV energy times i
<< endl; assert(p.GetPID() == corsika::particles::Code::Electron);
assert(p.GetEnergy() == 1.5_GeV * (i++));
} }
cout << "Etot=" << Etot << " = " << Etot / 1_GeV << " GeV" << endl; //assert(total_energy == 82.5_GeV);
} }
int main() { int main() {
......
...@@ -38,8 +38,8 @@ public: ...@@ -38,8 +38,8 @@ public:
Process2() {} Process2() {}
template <typename D, typename T, typename S> template <typename D, typename T, typename S>
inline EProcessReturn DoContinuous(D&, T&, S&) const { inline EProcessReturn DoContinuous(D& d, T&, S&) const {
// for (int i=0; i<10; ++i) d.p[i] *= 2; for (int i=0; i<10; ++i) d.p[i] -= 0.1*i;
return EProcessReturn::eOk; return EProcessReturn::eOk;
} }
}; };
...@@ -74,7 +74,7 @@ private: ...@@ -74,7 +74,7 @@ private:
}; };
struct DummyData { struct DummyData {
double p[10]; double p[10] = {0,0,0,0,0,0,0,0,0,0};
}; };
struct DummyStack {}; struct DummyStack {};
...@@ -86,14 +86,19 @@ void modular() { ...@@ -86,14 +86,19 @@ void modular() {
Process4 m4; Process4 m4;
const auto sequence = m1 + m2 + m3 + m4; const auto sequence = m1 + m2 + m3 + m4;
DummyData p; DummyData p;
DummyStack s; DummyStack s;
Trajectory t; Trajectory t;
const int n = 100000000; const int n = 1000;
for (int i = 0; i < n; ++i) { sequence.DoContinuous(p, t, s); } for (int i = 0; i < n; ++i) { sequence.DoContinuous(p, t, s); }
for(int i=0; i<10; ++i) {
//cout << p.p[i] << endl;
//assert(p.p[i] == n-i*100);
}
cout << " done (nothing...) " << endl; cout << " done (nothing...) " << endl;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment