Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accommodate for two different EKOs in Evolution #289

Merged
merged 42 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1962fe2
implement some brute force skeleton
Radonirinaunimi May 30, 2024
95b3bc3
reflect changes to python interface
Radonirinaunimi May 30, 2024
a4bfa50
just makes things work for the time being
Radonirinaunimi May 31, 2024
2b58ae2
address changes in old evolve
Radonirinaunimi Jun 2, 2024
c11b388
propagate different info in places that should matter
Radonirinaunimi Jun 2, 2024
16244d2
propagate different info in places that should matter
Radonirinaunimi Jun 2, 2024
e2ab5a6
reflect changes from master
Radonirinaunimi Jun 2, 2024
97aa73e
fixes issues during merging
Radonirinaunimi Jun 2, 2024
d2e6e1f
fixed some ambiguities and clean up a bit
Radonirinaunimi Jun 3, 2024
4222163
apply some rewordings
Radonirinaunimi Jun 3, 2024
6549de8
add convolve_with_two method for py interface
Radonirinaunimi Jun 4, 2024
685303d
fix a typo in passing the info
Radonirinaunimi Jun 5, 2024
80d9739
working version: remove pending todos and add a few notes
Radonirinaunimi Jun 7, 2024
baca6c4
Merge branch 'master' into extend_eko_convolution
Radonirinaunimi Jun 12, 2024
5630f70
extend CLI and try tests
Radonirinaunimi Jun 12, 2024
b455328
move downloading of pPDF into rust-yml
Radonirinaunimi Jun 13, 2024
e236b3c
fix minor inconsistencies in tests
Radonirinaunimi Jun 13, 2024
76b6f8f
reflect parts of the changes
Radonirinaunimi Jul 1, 2024
9c66218
account for multi-pdfs convolution feature
Radonirinaunimi Jul 1, 2024
57a996f
remove external download of polarized set
Radonirinaunimi Jul 5, 2024
fed2a2b
Fix release workflow
cschwan Jul 5, 2024
d007dc6
Fix CIs
cschwan Jul 5, 2024
6978daa
Restore old methods and add new ones with different names
cschwan Jul 12, 2024
cc82f9e
Add missing documentation to `Grid::evolve2`
cschwan Jul 12, 2024
246cadb
Change `unimplemented` to an error
cschwan Jul 12, 2024
1fb7e81
Prepare evolvution for more than two EKOs
cschwan Jul 12, 2024
d0b8951
Fix warning and compilation error
cschwan Jul 12, 2024
b7d55f8
Fix panic message
cschwan Jul 12, 2024
8153abe
Undo whitespace changes
cschwan Jul 12, 2024
3bf44d0
Shorten CI job name
cschwan Jul 12, 2024
99dd18a
Merge branch 'master' into extend_eko_convolution
cschwan Jul 12, 2024
6081b97
Call the right evolution method
cschwan Jul 12, 2024
65a8bfb
Fix wrong assertion statement
cschwan Jul 12, 2024
4a8f7a4
Propagate new changes from master to `evolve_slice_with_two2`
cschwan Jul 12, 2024
6585ab6
Generalize `ndarray_from_subgrid_orders_slice` function
cschwan Jul 12, 2024
e8ecba7
Add Python bind for `Grid::evolve_with_slice_iter2`
cschwan Jul 12, 2024
a4395e2
Fix clippy warning
cschwan Jul 12, 2024
ad99bcc
Remove Node 20 workaround in CI
cschwan Jul 18, 2024
3361048
Add back accidentally removed environment variable in CI
cschwan Jul 18, 2024
bb6453c
Clarify wording of error message
cschwan Jul 18, 2024
744c417
Add changelog entry
cschwan Jul 18, 2024
c1ba7ab
remove Grid::evolve2 method and its python wrapper
Radonirinaunimi Jul 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions pineappl/src/evolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,21 +524,22 @@ pub(crate) fn evolve_slice_with_one(

pub(crate) fn evolve_slice_with_two(
grid: &Grid,
operator: &ArrayView4<f64>,
operator_a: &ArrayView4<f64>,
operator_b: &ArrayView4<f64>,
info: &OperatorSliceInfo,
order_mask: &[bool],
xi: (f64, f64),
alphas_table: &AlphasTable,
) -> Result<(Array3<SubgridEnum>, Vec<LumiEntry>), GridError> {
let gluon_has_pid_zero = gluon_has_pid_zero(grid);

let (pid_indices_a, pids_a) = pid_slices(operator, info, gluon_has_pid_zero, &|pid1| {
let (pid_indices_a, pids_a) = pid_slices(operator_a, info, gluon_has_pid_zero, &|pid1| {
grid.lumi()
.iter()
.flat_map(LumiEntry::entry)
.any(|&(a, _, _)| a == pid1)
})?;
let (pid_indices_b, pids_b) = pid_slices(operator, info, gluon_has_pid_zero, &|pid1| {
let (pid_indices_b, pids_b) = pid_slices(operator_b, info, gluon_has_pid_zero, &|pid1| {
grid.lumi()
.iter()
.flat_map(LumiEntry::entry)
Expand Down Expand Up @@ -572,7 +573,7 @@ pub(crate) fn evolve_slice_with_two(
.zip(x1_a.iter())
.any(|(&lhs, &rhs)| !approx_eq!(f64, lhs, rhs, ulps = EVOLUTION_TOL_ULPS))
{
operators_a = operator_slices(operator, info, &pid_indices_a, &x1_a)?;
operators_a = operator_slices(operator_a, info, &pid_indices_a, &x1_a)?;
last_x1a = x1_a;
}

Expand All @@ -582,7 +583,7 @@ pub(crate) fn evolve_slice_with_two(
.zip(x1_b.iter())
.any(|(&lhs, &rhs)| !approx_eq!(f64, lhs, rhs, ulps = EVOLUTION_TOL_ULPS))
{
operators_b = operator_slices(operator, info, &pid_indices_b, &x1_b)?;
operators_b = operator_slices(operator_b, info, &pid_indices_b, &x1_b)?;
last_x1b = x1_b;
}

Expand Down
62 changes: 58 additions & 4 deletions pineappl/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,8 @@ impl Grid {
}
}

/// TODO: Fix to account for the different EKOs
/// TODO: Does the info have to be different?
Radonirinaunimi marked this conversation as resolved.
Show resolved Hide resolved
/// Converts this `Grid` into an [`FkTable`] using an evolution kernel operator (EKO) given as
/// `operator`. The dimensions and properties of this operator must be described using `info`.
/// The parameter `order_mask` can be used to include or exclude orders from this operation,
Expand All @@ -1397,14 +1399,32 @@ impl Grid {
#[deprecated(since = "0.7.4", note = "use evolve_with_slice_iter instead")]
pub fn evolve(
cschwan marked this conversation as resolved.
Show resolved Hide resolved
&self,
operator: ArrayView5<f64>,
operator_a: ArrayView5<f64>,
operator_b: ArrayView5<f64>,
info: &OperatorInfo,
order_mask: &[bool],
) -> Result<FkTable, GridError> {
self.evolve_with_slice_iter(
info.fac1
.iter()
.zip(operator.axis_iter(Axis(0)))
.zip(operator_a.axis_iter(Axis(0)))
.map(|(&fac1, op)| {
Ok::<_, GridError>((
OperatorSliceInfo {
fac0: info.fac0,
pids0: info.pids0.clone(),
x0: info.x0.clone(),
fac1,
pids1: info.pids1.clone(),
x1: info.x1.clone(),
lumi_id_types: info.lumi_id_types.clone(),
},
CowArray::from(op),
))
}),
info.fac1
.iter()
.zip(operator_b.axis_iter(Axis(0)))
.map(|(&fac1, op)| {
Ok::<_, GridError>((
OperatorSliceInfo {
Expand Down Expand Up @@ -1446,16 +1466,21 @@ impl Grid {
pub fn evolve_with_slice_iter<'a, E: Into<anyhow::Error>>(
cschwan marked this conversation as resolved.
Show resolved Hide resolved
&self,
slices: impl IntoIterator<Item = Result<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>,
extra_slices: impl IntoIterator<Item = Result<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>,
order_mask: &[bool],
xi: (f64, f64),
alphas_table: &AlphasTable,
) -> Result<FkTable, GridError> {
use super::evolution::EVOLVE_INFO_TOL_ULPS;
use itertools::izip;

let mut lhs: Option<Self> = None;
let mut fac1 = Vec::new();

for result in slices {
// TODO: simplify the ugly repetition below
// TODO: what to do about the info? Shoulb they be the same?
for (result, extra_result) in izip!(slices, extra_slices) {
// Deal with the main EKO
let (info, operator) = result.map_err(|err| GridError::Other(err.into()))?;

let op_info_dim = (
Expand All @@ -1475,10 +1500,39 @@ impl Grid {

let view = operator.view();

// Deal with the additional EKO
let (extra_info, extra_operator) =
extra_result.map_err(|err| GridError::Other(err.into()))?;

let op_info_dim_extra = (
extra_info.pids1.len(),
extra_info.x1.len(),
extra_info.pids0.len(),
extra_info.x0.len(),
);

if extra_operator.dim() != op_info_dim_extra {
return Err(GridError::EvolutionFailure(format!(
"operator information {:?} does not match the operator's dimensions: {:?}",
op_info_dim_extra,
extra_operator.dim(),
)));
}

let extra_view = extra_operator.view();

let (subgrids, lumi) = if self.convolutions()[0] != Convolution::None
&& self.convolutions()[1] != Convolution::None
{
evolution::evolve_slice_with_two(self, &view, &info, order_mask, xi, alphas_table)
evolution::evolve_slice_with_two(
self,
&view,
&extra_view,
&info,
order_mask,
xi,
alphas_table,
)
} else {
evolution::evolve_slice_with_one(self, &view, &info, order_mask, xi, alphas_table)
}?;
Expand Down
14 changes: 13 additions & 1 deletion pineappl_cli/src/evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ mod eko {
fn evolve_grid(
grid: &Grid,
eko: &Path,
extra_eko: &Path,
cschwan marked this conversation as resolved.
Show resolved Hide resolved
pdf: &Pdf,
orders: &[(u32, u32)],
xir: f64,
Expand All @@ -446,8 +447,10 @@ fn evolve_grid(
.collect();

let mut eko_slices = EkoSlices::new(eko)?;
let mut extra_eko_slices = EkoSlices::new(extra_eko)?;
let alphas_table = AlphasTable::from_grid(grid, xir, &|q2| pdf.alphas_q2(q2));

// TODO: Take care of the old EKO behavior
if use_old_evolve {
if let EkoSlices::V0 {
fac1,
Expand Down Expand Up @@ -475,14 +478,21 @@ fn evolve_grid(
unimplemented!();
}
} else {
Ok(grid.evolve_with_slice_iter(&mut eko_slices, &order_mask, (xir, xif), &alphas_table)?)
Ok(grid.evolve_with_slice_iter(
&mut eko_slices,
extra_eko_slices,
&order_mask,
(xir, xif),
&alphas_table,
)?)
}
}

#[cfg(not(feature = "evolve"))]
fn evolve_grid(
_: &Grid,
_: &Path,
_: &Path,
_: &Pdf,
_: &[(u32, u32)],
_: f64,
Expand Down Expand Up @@ -554,9 +564,11 @@ impl Subcommand for Opts {
cfg,
);

// TODO: properly pass the additional EKO from input args
let fk_table = evolve_grid(
&grid,
&self.eko,
&self.eko,
&pdf,
&self.orders,
self.xir,
Expand Down
1 change: 1 addition & 0 deletions pineappl_py/pineappl/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ def evolve(
self.raw.evolve(
np.array(operator_grid),
operators["q2_ref"],
operators["q2_ref"], # TODO: Modify the input EKO
np.array(operators["inputpids"], dtype=np.int32),
np.array(operators["inputgrid"]),
np.array(q2grid, dtype=np.float64),
Expand Down
6 changes: 4 additions & 2 deletions pineappl_py/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ impl PyGrid {
/// produced FK table
pub fn evolve(
&self,
operator: PyReadonlyArray5<f64>,
operator_a: PyReadonlyArray5<f64>,
operator_b: PyReadonlyArray5<f64>,
fac0: f64,
pids0: PyReadonlyArray1<i32>,
x0: PyReadonlyArray1<f64>,
Expand Down Expand Up @@ -488,7 +489,8 @@ impl PyGrid {
let evolved_grid = self
.grid
.evolve(
operator.as_array(),
operator_a.as_array(),
operator_b.as_array(),
&op_info,
order_mask.as_slice().unwrap(),
)
Expand Down
Loading