Skip to content

Commit

Permalink
Make xif parameter of Grid::evolve_with_slice_iter
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Mar 3, 2024
1 parent ded265b commit d2a4f3d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 36 deletions.
36 changes: 21 additions & 15 deletions pineappl/src/evolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ pub struct OperatorSliceInfo {
pub alphas: Vec<f64>,
/// Multiplicative factor for the central renormalization scale.
pub xir: f64,
/// Multiplicative factor for the central factorization scale.
pub xif: f64,
/// Identifier of the particle basis for the `FkTable`.
pub lumi_id_types: String,
}
Expand Down Expand Up @@ -276,10 +274,11 @@ fn ndarray_from_subgrid_orders_slice(
subgrids: &ArrayView1<SubgridEnum>,
orders: &[Order],
order_mask: &[bool],
xif: f64,
) -> Result<X1aX1bOp2Tuple, GridError> {
// TODO: skip empty subgrids

let fac1 = info.xif * info.xif * info.fac1;
let fac1 = xif * xif * info.fac1;
let mut x1_a: Vec<_> = subgrids
.iter()
.enumerate()
Expand Down Expand Up @@ -321,11 +320,11 @@ fn ndarray_from_subgrid_orders_slice(
}

if order.logxif > 0 {
if approx_eq!(f64, info.xif, 1.0, ulps = 4) {
if approx_eq!(f64, xif, 1.0, ulps = 4) {
continue;
}

logs *= (info.xif * info.xif).ln();
logs *= (xif * xif).ln();
}

// TODO: use `try_collect` once stabilized
Expand Down Expand Up @@ -355,12 +354,7 @@ fn ndarray_from_subgrid_orders_slice(
for ((ifac1, ix1, ix2), value) in subgrid.indexed_iter() {
let Mu2 { ren, fac } = subgrid.mu2_grid()[ifac1];

if !approx_eq!(
f64,
info.xif * info.xif * fac,
fac1,
ulps = EVOLUTION_TOL_ULPS
) {
if !approx_eq!(f64, xif * xif * fac, fac1, ulps = EVOLUTION_TOL_ULPS) {
continue;
}

Expand Down Expand Up @@ -395,6 +389,7 @@ pub(crate) fn evolve_slice_with_one(
operator: &ArrayView4<f64>,
info: &OperatorSliceInfo,
order_mask: &[bool],
xif: f64,
) -> Result<(Array3<SubgridEnum>, Vec<LumiEntry>), GridError> {
let gluon_has_pid_zero = gluon_has_pid_zero(grid);
let has_pdf1 = grid.has_pdf1();
Expand All @@ -417,8 +412,13 @@ pub(crate) fn evolve_slice_with_one(
let mut tables = vec![Array1::zeros(info.x0.len()); lumi0.len()];

for (subgrids_o, lumi1) in subgrids_ol.axis_iter(Axis(1)).zip(grid.lumi()) {
let (x1_a, x1_b, array) =
ndarray_from_subgrid_orders_slice(info, &subgrids_o, grid.orders(), order_mask)?;
let (x1_a, x1_b, array) = ndarray_from_subgrid_orders_slice(
info,
&subgrids_o,
grid.orders(),
order_mask,
xif,
)?;

let x1 = if has_pdf1 { x1_a } else { x1_b };

Expand Down Expand Up @@ -510,6 +510,7 @@ pub(crate) fn evolve_slice_with_two(
operator: &ArrayView4<f64>,
info: &OperatorSliceInfo,
order_mask: &[bool],
xif: f64,
) -> Result<(Array3<SubgridEnum>, Vec<LumiEntry>), GridError> {
let gluon_has_pid_zero = gluon_has_pid_zero(grid);

Expand Down Expand Up @@ -538,8 +539,13 @@ pub(crate) fn evolve_slice_with_two(
let mut tables = vec![Array2::zeros((info.x0.len(), info.x0.len())); lumi0.len()];

for (subgrids_o, lumi1) in subgrids_ol.axis_iter(Axis(1)).zip(grid.lumi()) {
let (x1_a, x1_b, array) =
ndarray_from_subgrid_orders_slice(info, &subgrids_o, grid.orders(), order_mask)?;
let (x1_a, x1_b, array) = ndarray_from_subgrid_orders_slice(
info,
&subgrids_o,
grid.orders(),
order_mask,
xif,
)?;

if (last_x1a.len() != x1_a.len())
|| last_x1a
Expand Down
7 changes: 4 additions & 3 deletions pineappl/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,13 +1927,13 @@ impl Grid {
ren1: info.ren1.clone(),
alphas: info.alphas.clone(),
xir: info.xir,
xif: info.xif,
lumi_id_types: info.lumi_id_types.clone(),
},
CowArray::from(op),
))
}),
order_mask,
info.xif,
)
}

Expand All @@ -1956,6 +1956,7 @@ impl Grid {
&self,
slices: impl IntoIterator<Item = Result<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>,
order_mask: &[bool],
xif: f64,
) -> Result<FkTable, GridError> {
use super::evolution::EVOLVE_INFO_TOL_ULPS;

Expand Down Expand Up @@ -1983,9 +1984,9 @@ impl Grid {
let view = operator.view();

let (subgrids, lumi) = if self.has_pdf1() && self.has_pdf2() {
evolution::evolve_slice_with_two(self, &view, &info, order_mask)
evolution::evolve_slice_with_two(self, &view, &info, order_mask, xif)
} else {
evolution::evolve_slice_with_one(self, &view, &info, order_mask)
evolution::evolve_slice_with_one(self, &view, &info, order_mask, xif)
}?;

let mut rhs = Self {
Expand Down
24 changes: 6 additions & 18 deletions pineappl_cli/src/evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,13 @@ mod eko {
Err(anyhow!("no file 'metadata.yaml' in EKO archive found"))
}

pub fn new(
eko_path: &Path,
ren1: &[f64],
alphas: &[f64],
xir: f64,
xif: f64,
) -> Result<Self> {
pub fn new(eko_path: &Path, ren1: &[f64], alphas: &[f64], xir: f64) -> Result<Self> {
let metadata = Self::read_metadata(eko_path)?;

match metadata {
Metadata::V0(v0) => Self::with_v0(v0, eko_path, ren1, alphas, xir, xif),
Metadata::V1(v1) => Self::with_v1(v1, eko_path, ren1, alphas, xir, xif),
Metadata::V2(v2) => Self::with_v2(v2, eko_path, ren1, alphas, xir, xif),
Metadata::V0(v0) => Self::with_v0(v0, eko_path, ren1, alphas, xir),
Metadata::V1(v1) => Self::with_v1(v1, eko_path, ren1, alphas, xir),
Metadata::V2(v2) => Self::with_v2(v2, eko_path, ren1, alphas, xir),
}
}

Expand All @@ -149,7 +143,6 @@ mod eko {
ren1: &[f64],
alphas: &[f64],
xir: f64,
xif: f64,
) -> Result<Self> {
let mut operator = None;

Expand Down Expand Up @@ -178,7 +171,6 @@ mod eko {
ren1: ren1.to_vec(),
alphas: alphas.to_vec(),
xir,
xif,
},
operator,
})
Expand All @@ -190,7 +182,6 @@ mod eko {
ren1: &[f64],
alphas: &[f64],
xir: f64,
xif: f64,
) -> Result<Self> {
let mut fac1 = HashMap::new();
let base64 = GeneralPurpose::new(&URL_SAFE, PAD);
Expand Down Expand Up @@ -265,7 +256,6 @@ mod eko {
ren1: ren1.to_vec(),
alphas: alphas.to_vec(),
xir,
xif,
},
archive: Archive::new(File::open(eko_path)?),
})
Expand All @@ -277,7 +267,6 @@ mod eko {
ren1: &[f64],
alphas: &[f64],
xir: f64,
xif: f64,
) -> Result<Self> {
let mut fac1 = HashMap::new();
let mut operator: Option<OperatorV1> = None;
Expand Down Expand Up @@ -344,7 +333,6 @@ mod eko {
ren1: ren1.to_vec(),
alphas: alphas.to_vec(),
xir,
xif,
},
archive: Archive::new(File::open(eko_path)?),
})
Expand Down Expand Up @@ -507,9 +495,9 @@ fn evolve_grid(
})
.collect();

let mut eko_slices = EkoSlices::new(eko, &ren1, &alphas, xir, xif)?;
let mut eko_slices = EkoSlices::new(eko, &ren1, &alphas, xir)?;

Ok(grid.evolve_with_slice_iter(&mut eko_slices, &order_mask)?)
Ok(grid.evolve_with_slice_iter(&mut eko_slices, &order_mask, xif)?)
}

#[cfg(not(feature = "evolve"))]
Expand Down

0 comments on commit d2a4f3d

Please sign in to comment.