Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3dad13

Browse files
committed
Generalized photoproduction specializations for pseudoscalars & vectors
- Refactored XchBase from xch_base into base (and specialized the pseudoscalar & vector version under ::kind module); - Extracted the spin-average | M |^2 calculation for pseudoscalar and vector particles.
1 parent 82bfa34 commit c3dad13

File tree

6 files changed

+131
-29
lines changed

6 files changed

+131
-29
lines changed

src/scattering/photo22.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
use super::*;
44

55
pub mod base;
6+
pub mod kind;
67
pub mod rx_data;
78
pub mod cross_section;
8-
pub mod xch_base;
99

1010
pub use base::*;
11+
pub use kind::*;
1112
pub use rx_data::*;
12-
pub use cross_section::*;
13-
pub use xch_base::*;
13+
pub use cross_section::*;

src/scattering/photo22/base.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,10 @@ pub trait PhotoproductionBase {
55
fn get_reaction_data(&self) -> &ReactionData;
66

77
fn calc_amplitude_avgsq(&self) -> Real;
8+
}
9+
10+
pub trait XchBase {
11+
fn get_xch_mass(&self, rx: &ReactionData) -> Real;
12+
13+
fn calc_form_factor(&self, rx: &ReactionData) -> Real;
814
}

src/scattering/photo22/kind.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
use super::*;
2+
3+
pub mod pseudoscalar;
4+
pub mod vector;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
use super::*;
2+
use crate::math::number::*;
3+
use crate::quantum::{*, relativistic::*};
4+
5+
6+
pub trait XchBasePseudoscalar : XchBase {
7+
fn calc_invariant_amplitude(
8+
&self,
9+
rx: &ReactionData,
10+
h_photon: Helicity,
11+
) -> StateMatrix;
12+
}
13+
14+
pub struct QuantumStatesIters {
15+
h_photon: Vec<Helicity>,
16+
sp_inc_b: Vec<Spin>,
17+
sp_out_d: Vec<Spin>,
18+
}
19+
20+
pub fn calc_ampl_avgsq(
21+
rx: &ReactionData,
22+
xchs: &Vec<Box<dyn XchBasePseudoscalar>>,
23+
iter_states: QuantumStatesIters,
24+
spin_avg: Real
25+
) -> Real {
26+
if rx.energy == 0. { return 0. }
27+
28+
let ampl_sq = |h1: Helicity, s1: Spin, s2: Spin| -> Real {
29+
let mut sum = Complex::zero();
30+
31+
let u: &StateVector = &dirac_spinor(&rx.particles.inc_b, s1);
32+
let u_bar: &StateVector = &dirac_adjoint(&dirac_spinor(&rx.particles.out_d, s2));
33+
34+
for xch in xchs {
35+
let m = xch.calc_invariant_amplitude(rx, h1);
36+
37+
// < f | M | i >
38+
sum += u_bar * m * u;
39+
}
40+
41+
return sum.norm_sq();
42+
};
43+
44+
let mut sum = 0.;
45+
46+
// TODO: Parallelization and iter zip.
47+
for h_photon in &iter_states.h_photon {
48+
for s_inc_b in &iter_states.sp_inc_b {
49+
for s_out_d in &iter_states.sp_out_d {
50+
sum += ampl_sq(*h_photon, *s_inc_b, *s_out_d);
51+
}
52+
}
53+
}
54+
55+
return sum / spin_avg;
56+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
use super::*;
2+
use crate::math::number::*;
3+
use crate::quantum::{*, relativistic::*};
4+
5+
6+
pub trait XchBaseVector : XchBase {
7+
fn calc_invariant_amplitude(
8+
&self,
9+
rx: &ReactionData,
10+
h_photon: Helicity,
11+
h_vector: Helicity,
12+
) -> StateMatrix;
13+
}
14+
15+
pub struct QuantumStatesIters {
16+
h_photon: Vec<Helicity>,
17+
h_out_c: Vec<Helicity>,
18+
sp_inc_b: Vec<Spin>,
19+
sp_out_d: Vec<Spin>,
20+
}
21+
22+
pub fn calc_ampl_avgsq(
23+
rx: &ReactionData,
24+
xchs: &Vec<Box<dyn XchBaseVector>>,
25+
iter_states: QuantumStatesIters,
26+
spin_avg: Real
27+
) -> Real {
28+
29+
if rx.energy == 0. { return 0. }
30+
31+
let ampl_sq = |h1: Helicity, s1: Spin, h2: Helicity, s2: Spin| -> Real {
32+
let mut sum = Complex::zero();
33+
34+
let u: &StateVector = &dirac_spinor(&rx.particles.inc_b, s1);
35+
let u_bar: &StateVector = &dirac_adjoint(&dirac_spinor(&rx.particles.out_d, s2));
36+
37+
for xch in xchs {
38+
let m = xch.calc_invariant_amplitude(rx, h1, h2);
39+
40+
// < f | M | i >
41+
sum += u_bar * m * u;
42+
}
43+
44+
// | < f | M | i >_1 + < f | M | i >_2 + ... < f | M | i >_n |^2
45+
return sum.norm_sq();
46+
};
47+
48+
let mut sum = 0.;
49+
50+
// TODO: Parallelization and iter zip.
51+
for h_photon in &iter_states.h_photon {
52+
for s_inc_b in &iter_states.sp_inc_b {
53+
for h_out_c in &iter_states.h_out_c {
54+
for s_out_d in &iter_states.sp_out_d {
55+
sum += ampl_sq(*h_photon, *s_inc_b, *h_out_c, *s_out_d);
56+
}
57+
}
58+
}
59+
}
60+
61+
return sum / spin_avg;
62+
}

src/scattering/photo22/xch_base.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)