Skip to content

Commit

Permalink
Merge 85b2794 into 0a2a294
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmerten committed Jun 8, 2021
2 parents 0a2a294 + 85b2794 commit 12a5843
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Expand Up @@ -49,7 +49,7 @@ class TurbulenceSpectrum : public Referenced {
range
*/
TurbulenceSpectrum(double Brms, double lMin, double lMax,
double lBendover = 1, double sIndex = 5. / 3.,
double lBendover = 1, double sIndex = (5. / 3.),
double qIndex = 4)
: Brms(Brms), lMin(lMin), lMax(lMax), lBendover(lBendover),
sIndex(sIndex), qIndex(qIndex) {
Expand Down
10 changes: 10 additions & 0 deletions test/testPythonExtension.py
Expand Up @@ -204,6 +204,16 @@ def testGridPropertiesConstructor(self):

if hasattr(crp, 'GridTurbulence'):
class testTurbulentField(unittest.TestCase):
#check problems brought up in https://github.com/CRPropa/CRPropa3/issues/322
def testTurbulenceSpectrum(self):
spectrum = crp.TurbulenceSpectrum(1., 1., 10.)
self.assertEqual(spectrum.getBrms(), 1.)
self.assertEqual(spectrum.getLmin(), 1.)
self.assertEqual(spectrum.getLmax(), 10.)
self.assertEqual(spectrum.getLbendover(), 1.)
self.assertEqual(spectrum.getSindex(), 5./3.)
self.assertEqual(spectrum.getQindex(), 4.)

def testGridTurbulence(self):
N = 64
boxSize = 1*crp.Mpc
Expand Down
17 changes: 17 additions & 0 deletions test/testTurbulentField.cpp
Expand Up @@ -13,6 +13,23 @@

using namespace crpropa;

//check problems brought up in https://github.com/CRPropa/CRPropa3/issues/322
TEST(testTurbulenceSpectrum, constructor) {
double sIndex = 5./3.;
double qIndex = 4.;
double bendOver = 1.;
double lMin = 1.;
double lMax = 10.;
double brms = 1*muG;
auto spectrum = TurbulenceSpectrum(brms, lMin, lMax);
EXPECT_DOUBLE_EQ(spectrum.getBrms(), brms);
EXPECT_DOUBLE_EQ(spectrum.getLmin(), lMin);
EXPECT_DOUBLE_EQ(spectrum.getLmax(), lMax);
EXPECT_DOUBLE_EQ(spectrum.getLbendover(), bendOver); //default
EXPECT_DOUBLE_EQ(spectrum.getSindex(), sIndex); //default
EXPECT_DOUBLE_EQ(spectrum.getQindex(), qIndex); //default
}

TEST(testTurbulenceSpectrum, correlationLength) {
double lMin = 0.00001; // not used for Lc
double lMax = 9999999; // not used for Lc
Expand Down

0 comments on commit 12a5843

Please sign in to comment.