Skip to main content

interatomic/twobody/
morse.rs

1// Copyright 2023-2024 Mikael Lund
2//
3// Licensed under the Apache license, version 2.0 (the "license");
4// you may not use this file except in compliance with the license.
5// You may obtain a copy of the license at
6//
7//     http://www.apache.org/licenses/license-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the license is distributed on an "as is" basis,
11// without warranties or conditions of any kind, either express or implied.
12// See the license for the specific language governing permissions and
13// limitations under the license.
14
15//! Implementation of the Morse potential (work in progress).
16
17#![allow(dead_code)]
18
19use super::IsotropicTwobodyEnergy;
20use crate::Cutoff;
21#[cfg(feature = "serde")]
22use serde::{Deserialize, Serialize};
23
24/// Morse potential.
25/// See <https://en.wikipedia.org/wiki/Morse_potential>.
26#[derive(Debug, Clone, PartialEq)]
27#[cfg_attr(
28    feature = "serde",
29    derive(Deserialize, Serialize),
30    serde(deny_unknown_fields)
31)]
32pub struct Morse {
33    #[cfg_attr(feature = "serde", serde(rename = "req"))]
34    equilibrium_distance: f64,
35    #[cfg_attr(feature = "serde", serde(rename = "d"))]
36    well_depth: f64,
37    #[cfg_attr(feature = "serde", serde(rename = "k"))]
38    force_constant: f64,
39    // shouldn't the parameter a, the 'width of the well' also be present?
40}
41
42impl Morse {
43    /// Create a new Morse potential with equilibrium distance, well depth, and force constant.
44    pub const fn new(equilibrium_distance: f64, well_depth: f64, force_constant: f64) -> Self {
45        Self {
46            equilibrium_distance,
47            well_depth,
48            force_constant,
49        }
50    }
51}
52
53impl IsotropicTwobodyEnergy for Morse {
54    #[inline(always)]
55    fn isotropic_twobody_energy(&self, _distance_squared: f64) -> f64 {
56        todo!("Morse potential is not yet implemented");
57    }
58}
59
60impl Cutoff for Morse {
61    fn cutoff(&self) -> f64 {
62        f64::INFINITY
63    }
64}