Skip to content

Commit

Permalink
start unit tests on as2
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiani committed Sep 11, 2024
1 parent 429206a commit 2d9b7ca
Showing 1 changed file with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use num::complex::Complex;
use num::traits::Pow;
use num::Zero;

use crate::cmplx;
use crate::constants::{CA, CF, TR, ZETA2, ZETA3};
use crate::harmonics::cache::{Cache, K};

Expand Down Expand Up @@ -281,3 +280,54 @@ pub fn A_ns(c: &mut Cache, _nf: u8, L: f64) -> [[Complex<f64>; 2]; 2] {
[Complex::<f64>::zero(), Complex::<f64>::zero()],
]
}

#[cfg(test)]
mod test {
use crate::cmplx;
use crate::{
harmonics::cache::Cache, operator_matrix_elements::unpolarized::spacelike::as2::*,
};
use float_cmp::assert_approx_eq;
use num::complex::Complex;
const NF: u8 = 5;

#[test]
fn test_quark_number_conservation() {
let logs = [0., 100.];
for L in logs {
let N = cmplx![1., 0.];
let mut c = Cache::new(N);
let aNSqq2 = A_qq_ns(&mut c, NF, L);
assert_approx_eq!(f64, aNSqq2.re, 0.0, epsilon = 2e-11);
assert_approx_eq!(f64, aNSqq2.im, 0.0, epsilon = 2e-11);
}
}

#[test]
fn test_momentum_conservation() {
let logs = [0., 100.];
for L in logs {
let N = cmplx![2., 0.];
let mut c = Cache::new(N);
let aS2 = A_singlet(&mut c, NF, L, false);

// gluon momenum conservation
assert_approx_eq!(
f64,
(aS2[0][0] + aS2[1][0] + aS2[2][0]).re,
0.0,
epsilon = 2e-6
);
assert_approx_eq!(
f64,
(aS2[0][0] + aS2[1][0] + aS2[2][0]).im,
0.0,
epsilon = 2e-6
);

// quark momentum conservation
// assert_approx_eq!(f64, (aS2[0][1] + aS2[1][1] + aS2[2][1]).re, 0.0, epsilon = 1e-11);
// assert_approx_eq!(f64, (aS2[0][1] + aS2[1][1] + aS2[2][1]).im, 0.0, epsilon = 1e-11);
}
}
}

0 comments on commit 2d9b7ca

Please sign in to comment.