Skip to content

Commit 7b568b6

Browse files
Minor adjustments to the interpolations
1 parent c072f14 commit 7b568b6

2 files changed

Lines changed: 30 additions & 37 deletions

File tree

‎neopdf/src/interpolator.rs‎

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,36 +35,36 @@ use super::subgrid::SubGrid;
3535
/// dimensions of the PDF grid data.
3636
#[derive(Debug, Clone, Copy)]
3737
pub enum InterpolationConfig {
38-
/// 2D interpolation, typically in `x` (momentum fraction) and `Q²` (energy scale).
38+
/// 2D interpolation, typically in `x` (momentum fraction) and `Q2` (energy scale).
3939
TwoD,
4040
/// 3D interpolation, including a dimension for varying nucleon numbers `A`,
41-
/// in addition to `x` and `Q²`.
41+
/// in addition to `x` and `Q2`.
4242
ThreeDNucleons,
4343
/// 3D interpolation, including a dimension for varying `alpha_s` values,
44-
/// in addition to `x` and `Q²`.
44+
/// in addition to `x` and `Q2`.
4545
ThreeDAlphas,
4646
/// 3D interpolation, including a dimension for varying `xi` values,
47-
/// in addition to `x` and `Q²`.
47+
/// in addition to `x` and `Q2`.
4848
ThreeDXi,
4949
/// 3D interpolation, including a dimension for varying `delta` values,
50-
/// in addition to `x` and `Q²`.
50+
/// in addition to `x` and `Q2`.
5151
ThreeDDelta,
5252
/// 3D interpolation, including a dimension for varying `kT` values,
53-
/// in addition to `x` and `Q²`.
53+
/// in addition to `x` and `Q2`.
5454
ThreeDKt,
55-
/// 4D interpolation, covering nucleon numbers `A`, `alpha_s`, `x`, and `Q²`.
55+
/// 4D interpolation, covering nucleon numbers `A`, `alpha_s`, `x`, and `Q2`.
5656
FourDNucleonsAlphas,
57-
/// 4D interpolation, covering nucleon numbers `A`, kT, `x`, and `Q²`.
57+
/// 4D interpolation, covering nucleon numbers `A`, kT, `x`, and `Q2`.
5858
FourDNucleonsKt,
59-
/// 4D interpolation, covering `alpha_s`, kT, `x`, and `Q²`.
59+
/// 4D interpolation, covering `alpha_s`, kT, `x`, and `Q2`.
6060
FourDAlphasKt,
61-
/// 4D interpolation, covering `xi`, `delta`, `x`, and `Q²`.
61+
/// 4D interpolation, covering `xi`, `delta`, `x`, and `Q2`.
6262
FourDXiDelta,
63-
/// 5D interpolation, covering nucleon numbers `A`, `alpha_s`, `kT`, `x`, and `Q²`.
63+
/// 5D interpolation, covering `kT`, `xi`, `delta`, `x`, and `Q2`.
6464
FiveD,
65-
/// 6D interpolation, covering `A`, `alpha_s`, `xi`, `delta`, `x`, and `Q²`.
65+
/// 6D interpolation, covering `A`, `kT`, `xi`, `delta`, `x`, and `Q2`.
6666
SixD,
67-
/// 7D interpolation, covering `A`, `alpha_s`, `xi`, `delta`, `kT`, `x`, and `Q²`.
67+
/// 7D interpolation, covering `A`, `alpha_s`, `xi`, `delta`, `kT`, `x`, and `Q2`.
6868
SevenD,
6969
}
7070

@@ -104,8 +104,8 @@ impl InterpolationConfig {
104104
(true, false, false, false, true) => Self::FourDNucleonsKt,
105105
(false, true, false, false, true) => Self::FourDAlphasKt,
106106
(false, false, true, true, false) => Self::FourDXiDelta,
107-
(true, true, false, false, true) => Self::FiveD,
108-
(true, true, true, true, false) => Self::SixD,
107+
(false, false, true, true, true) => Self::FiveD,
108+
(true, false, true, true, true) => Self::SixD,
109109
(true, true, true, true, true) => Self::SevenD,
110110
_ => panic!(
111111
"Unsupported dimension combination: nucleons={}, alphas={}, xis={}, deltas={}, kts={}",
@@ -412,7 +412,7 @@ impl InterpolatorFactory {
412412
pid_index: usize,
413413
) -> Box<dyn DynInterpolator> {
414414
let grid_view = subgrid.grid.view();
415-
// For 3D xi: slice out [xi, x, Q²] from 8D grid [A, alphas, xi, delta, kT, pids, x, Q²]
415+
// For 3D xi: slice out [xi, x, Q2] from 8D grid [A, alphas, xi, delta, kT, pids, x, Q2]
416416
let grid_data = grid_view
417417
.slice(s![0, 0, .., 0, 0, pid_index, .., ..])
418418
.to_owned();
@@ -453,7 +453,7 @@ impl InterpolatorFactory {
453453
pid_index: usize,
454454
) -> Box<dyn DynInterpolator> {
455455
let grid_view = subgrid.grid.view();
456-
// For 3D delta: slice out [delta, x, Q²] from 8D grid [A, alphas, xi, delta, kT, pids, x, Q²]
456+
// For 3D delta: slice out [delta, x, Q2] from 8D grid [A, alphas, xi, delta, kT, pids, x, Q2]
457457
let grid_data = grid_view
458458
.slice(s![0, 0, 0, .., 0, pid_index, .., ..])
459459
.to_owned();
@@ -587,7 +587,6 @@ impl InterpolatorFactory {
587587
pid_index: usize,
588588
) -> Box<dyn DynInterpolator> {
589589
let grid_view = subgrid.grid.view();
590-
// For 4D xi/delta: [xi, delta, x, Q²] from 8D grid [A, alphas, xi, delta, kT, pids, x, Q²]
591590
let grid_data = grid_view
592591
.slice(s![0, 0, .., .., 0, pid_index, .., ..])
593592
.to_owned();
@@ -631,20 +630,20 @@ impl InterpolatorFactory {
631630
) -> Box<dyn DynInterpolator> {
632631
let grid_view = subgrid.grid.view();
633632
let grid_data = grid_view
634-
.slice(s![.., .., pid_index, .., .., ..])
633+
.slice(s![0, 0, .., .., .., pid_index, .., ..])
635634
.to_owned();
636635
let coords = vec![
637-
subgrid.nucleons.mapv(f64::ln),
638-
subgrid.alphas.mapv(f64::ln),
639636
subgrid.kts.mapv(f64::ln),
637+
subgrid.xis.mapv(f64::ln),
638+
subgrid.deltas.mapv(f64::ln),
640639
subgrid.xs.mapv(f64::ln),
641640
subgrid.q2s.mapv(f64::ln),
642641
];
643642
let reshaped_data = grid_data
644643
.into_shape_with_order((
645-
subgrid.nucleons.len(),
646-
subgrid.alphas.len(),
647644
subgrid.kts.len(),
645+
subgrid.xis.len(),
646+
subgrid.deltas.len(),
648647
subgrid.xs.len(),
649648
subgrid.q2s.len(),
650649
))
@@ -679,14 +678,12 @@ impl InterpolatorFactory {
679678
pid_index: usize,
680679
) -> Box<dyn DynInterpolator> {
681680
let grid_view = subgrid.grid.view();
682-
// For 6D: [nucleons, alphas, xi, delta, x, Q²]
683-
// Grid layout: [nucleons, alphas, pids, kts, x, Q²] or [nucleons, alphas, xi, delta, kts, pids, x, Q²]
684681
let grid_data = grid_view
685-
.slice(s![.., .., .., .., 0, pid_index, .., ..])
682+
.slice(s![.., 0, .., .., .., pid_index, .., ..])
686683
.to_owned();
687684
let coords = vec![
688685
subgrid.nucleons.mapv(f64::ln),
689-
subgrid.alphas.mapv(f64::ln),
686+
subgrid.kts.mapv(f64::ln),
690687
subgrid.xis.mapv(f64::ln),
691688
subgrid.deltas.mapv(f64::ln),
692689
subgrid.xs.mapv(f64::ln),
@@ -695,7 +692,7 @@ impl InterpolatorFactory {
695692
let reshaped_data = grid_data
696693
.into_shape_with_order((
697694
subgrid.nucleons.len(),
698-
subgrid.alphas.len(),
695+
subgrid.kts.len(),
699696
subgrid.xis.len(),
700697
subgrid.deltas.len(),
701698
subgrid.xs.len(),
@@ -718,9 +715,6 @@ impl InterpolatorFactory {
718715
pid_index: usize,
719716
) -> Box<dyn DynInterpolator> {
720717
let grid_view = subgrid.grid.view();
721-
// For 7D interpolation: [nucleons, alphas, xi, delta, kT, x, Q²]
722-
// Grid layout is 8D: [nucleons, alphas, xi, delta, kts, pids, x, Q²]
723-
// We slice out the pid dimension to get 7D for interpolation
724718
let grid_data = grid_view
725719
.slice(s![.., .., .., .., .., pid_index, .., ..])
726720
.to_owned();
@@ -937,7 +931,7 @@ mod tests {
937931
InterpolationConfig::FourDAlphasKt
938932
));
939933
assert!(matches!(
940-
InterpolationConfig::from_dimensions(2, 2, 1, 1, 2),
934+
InterpolationConfig::from_dimensions(1, 1, 2, 2, 2),
941935
InterpolationConfig::FiveD
942936
));
943937
}

‎neopdf/src/subgrid.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,14 @@ impl SubGrid {
344344
InterpolationConfig::FourDNucleonsKt => (4, vec![&self.nucleons_range, &self.kt_range]),
345345
InterpolationConfig::FourDAlphasKt => (4, vec![&self.alphas_range, &self.kt_range]),
346346
InterpolationConfig::FourDXiDelta => (4, vec![&self.xi_range, &self.delta_range]),
347-
InterpolationConfig::FiveD => (
348-
5,
349-
vec![&self.nucleons_range, &self.alphas_range, &self.kt_range],
350-
),
347+
InterpolationConfig::FiveD => {
348+
(5, vec![&self.kt_range, &self.xi_range, &self.delta_range])
349+
}
351350
InterpolationConfig::SixD => (
352351
6,
353352
vec![
354353
&self.nucleons_range,
355-
&self.alphas_range,
354+
&self.kt_range,
356355
&self.xi_range,
357356
&self.delta_range,
358357
],

0 commit comments

Comments
 (0)