use super::*;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct WeightedStructure {
pub configuration: Configuration,
pub weight: f64,
pub movable_atoms: Option<Vec<usize>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct RmcDataset {
pub exafs: ExafsDataset,
pub objective: Objective,
pub refeff: Option<RefeffOptions>,
pub absorbers_by_structure: Vec<Vec<usize>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub source: Option<Box<RmcSpectrumSource>>,
}
impl From<ExafsDataset> for RmcDataset {
fn from(exafs: ExafsDataset) -> Self {
Self {
exafs,
objective: Objective::K,
refeff: None,
absorbers_by_structure: Vec::new(),
source: None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct EnsembleProblem {
pub structures: Vec<WeightedStructure>,
pub datasets: Vec<RmcDataset>,
}
impl EnsembleProblem {
pub fn single(configuration: Configuration, dataset: RmcDataset) -> Self {
Self {
structures: vec![WeightedStructure {
configuration,
weight: 1.,
movable_atoms: None,
}],
datasets: vec![dataset],
}
}
}
impl From<RmcProblem> for EnsembleProblem {
fn from(problem: RmcProblem) -> Self {
Self {
structures: vec![WeightedStructure {
configuration: problem.configuration,
weight: 1.,
movable_atoms: None,
}],
datasets: problem.datasets.into_iter().map(Into::into).collect(),
}
}
}
#[derive(Clone, Copy)]
pub struct CalculationRequest<'a> {
pub structure: usize,
pub configuration: &'a Configuration,
pub absorber: usize,
pub edge: crate::structure::Edge,
pub k: &'a [f64],
pub options: Option<&'a RefeffOptions>,
pub paths: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct PathContribution {
pub index: usize,
pub legs: usize,
pub degeneracy: f64,
pub half_length: f64,
pub chi: Vec<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct CalculatedSpectrum {
pub chi: Vec<f64>,
pub paths: Vec<PathContribution>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct AbsorberPaths {
pub dataset: usize,
pub structure: usize,
pub absorber: usize,
pub paths: Vec<PathContribution>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct EnsembleState {
pub structures: Vec<WeightedStructure>,
pub evaluation: Evaluation,
pub penalty: f64,
pub component_chi: Vec<Vec<Vec<f64>>>,
pub paths: Vec<AbsorberPaths>,
}