fips_md/parser/
interaction.rs

1//! Structures representing interaction primary blocks
2
3use super::{CompileTimeConstant, Expression, Identifier, Statement};
4
5/// Interaction between particle types
6#[derive(Clone,PartialEq,Debug)]
7pub struct Interaction {
8    pub name: String,
9    pub name_a: Identifier,
10    pub type_a: String,
11    pub name_b: Identifier,
12    pub type_b: String,
13    pub distance: Identifier,
14    pub distance_vec: Option<String>,
15    pub cutoff: CompileTimeConstant<f64>,
16    pub common_block: Option<Vec<Statement>>,
17    pub quantities: Vec<InteractionQuantity>
18}
19
20/// Specific quantity determined by the interaction of two particle types
21#[derive(Clone,PartialEq,Debug)]
22pub struct InteractionQuantity {
23    pub name: String,
24    pub reduction_method: ReductionMethod,
25    pub target_a: String,
26    pub target_b: String,
27    pub symmetry: InteractionSymmetry,
28    // pub negated_b: bool,
29    pub expression: Expression
30}
31
32#[derive(Clone,Eq,PartialEq,Debug)]
33pub enum ReductionMethod {
34    Sum
35}
36
37#[derive(Clone,Copy,Eq,PartialEq,Debug)]
38pub enum InteractionSymmetry {
39    Symmetric,
40    Antisymmetric,
41    Asymmetric
42}
43
44mod tests {
45    #[allow(unused_imports)] // Rust analyzer bug
46    use super::super::*;
47
48    #[test]
49    fn coulomb_potential() {
50        let string = r#"interaction myinteraction (p1: PointLike, p2: PointLike) for r < CUTOFF {
51            quantity myforce -[sum]-> (F, F) {
52                4.0*EPSILON*((SIGMA/r))
53            }
54        }"#;
55        fips_parser::interaction(string).expect("Cannot parse string");
56    }
57}