LCOV - code coverage report
Current view: top level - test - testAdiabaticCooling.cpp (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 100.0 % 23 23
Test Date: 2026-06-18 09:49:19 Functions: 100.0 % 2 2

            Line data    Source code
       1              : #include "crpropa/Candidate.h"
       2              : #include "crpropa/Units.h"
       3              : #include "crpropa/ParticleID.h"
       4              : #include "crpropa/advectionField/AdvectionField.h"
       5              : #include "crpropa/module/AdiabaticCooling.h"
       6              : #include "gtest/gtest.h"
       7              : 
       8              : //#include <fstream>
       9              : 
      10              : namespace crpropa {
      11              : 
      12              : // AdiabaticCooling ---------------------------------------------------------------
      13              : 
      14            1 : TEST (AdiabaticCooling, UniformField) {
      15              :         // Test in a uniform advection Field
      16              : 
      17            1 :         AdiabaticCooling AC(new UniformAdvectionField(Vector3d(1,0,0)));
      18            1 :         Candidate c(nucleusId(1,1), 1e13*eV);
      19            1 :         c.setCurrentStep(10*kpc);
      20            1 :         c.setNextStep(10*kpc);
      21            1 :         double E = c.current.getEnergy();
      22            1 :         AC.process(&c);
      23              : 
      24              :         // Energy is expected to be conserved
      25            1 :         EXPECT_DOUBLE_EQ(c.current.getEnergy(), E);
      26            1 :         EXPECT_DOUBLE_EQ(c.getNextStep(), 10*kpc);
      27              : 
      28              :         double limit = 0.2;
      29            2 :         AdiabaticCooling AC2(new UniformAdvectionField(Vector3d(1,0,0)), limit);
      30              :         
      31            1 :         EXPECT_DOUBLE_EQ(AC2.getLimit(), limit);
      32              : 
      33              :         //
      34              : 
      35            1 : }
      36              : 
      37            1 : TEST (AdiabaticCooling, ConstantSphericalField) {
      38              :         // Constant velocity vector
      39              :         
      40            1 :         AdiabaticCooling AC(new ConstantSphericalAdvectionField(Vector3d(0,0,0), 1));
      41            1 :         Candidate c(nucleusId(1,1), 10);
      42            1 :         c.current.setPosition(Vector3d(1,0,0));
      43            1 :         c.setCurrentStep(c_light);
      44            1 :         c.setNextStep(c_light);
      45            1 :         double E = c.current.getEnergy();
      46            1 :         AC.process(&c);
      47              : 
      48              :         // Check energy loss and step limitation
      49            1 :         EXPECT_DOUBLE_EQ(c.current.getEnergy(), E/3.);
      50            1 :         EXPECT_DOUBLE_EQ(c.getNextStep(), 0.15*c_light);
      51              : 
      52            1 : }
      53              : 
      54              : 
      55              : } // namespace crpropa
        

Generated by: LCOV version 2.0-1