Skip to content

Commit 75fc7ca

Browse files
committed
refactor(potentials): Rename parameters for consistency in CosineHarmonic and CosineLinear implementations
1 parent 6779135 commit 75fc7ca

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

src/potentials/bonded/angle.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::types::EnergyDiff;
1313
///
1414
/// # Parameters
1515
///
16-
/// - `k_half`: Half force constant $C_{half} = C/2$.
16+
/// - `c_half`: Half force constant $C_{half} = C/2$.
1717
/// - `cos0`: Cosine of equilibrium angle $\cos_0$.
1818
///
1919
/// # Pre-computation
@@ -38,25 +38,25 @@ impl CosineHarmonic {
3838
///
3939
/// # Input
4040
///
41-
/// - `k`: Force constant $C$.
41+
/// - `c`: Force constant $C$.
4242
/// - `theta0_deg`: Equilibrium angle $\theta_0$ in degrees.
4343
///
4444
/// # Output
4545
///
46-
/// Returns `(k_half, cos0)`:
47-
/// - `k_half`: Half force constant $C/2$.
46+
/// Returns `(c_half, cos0)`:
47+
/// - `c_half`: Half force constant $C/2$.
4848
/// - `cos0`: Cosine of equilibrium angle $\cos_0$.
4949
///
5050
/// # Computation
5151
///
5252
/// $$ C_{half} = C / 2, \quad \cos_0 = \cos(\theta_0 \cdot \pi / 180) $$
5353
#[inline(always)]
54-
pub fn precompute<T: Real>(k: T, theta0_deg: T) -> (T, T) {
54+
pub fn precompute<T: Real>(c: T, theta0_deg: T) -> (T, T) {
5555
let deg_to_rad = T::pi() / T::from(180.0);
5656
let theta0 = theta0_deg * deg_to_rad;
57-
let k_half = k * T::from(0.5);
57+
let c_half = c * T::from(0.5);
5858
let cos0 = theta0.cos();
59-
(k_half, cos0)
59+
(c_half, cos0)
6060
}
6161
}
6262

@@ -69,9 +69,9 @@ impl<T: Real> AngleKernel<T> for CosineHarmonic {
6969
///
7070
/// $$ E = C_{half} (\Delta)^2, \quad \text{where } \Delta = \cos\theta - \cos_0 $$
7171
#[inline(always)]
72-
fn energy(cos_theta: T, (k_half, cos0): Self::Params) -> T {
72+
fn energy(cos_theta: T, (c_half, cos0): Self::Params) -> T {
7373
let delta = cos_theta - cos0;
74-
k_half * delta * delta
74+
c_half * delta * delta
7575
}
7676

7777
/// Computes only the derivative factor $\Gamma$.
@@ -83,21 +83,21 @@ impl<T: Real> AngleKernel<T> for CosineHarmonic {
8383
/// This factor allows computing forces via the chain rule:
8484
/// $$ \vec{F} = -\Gamma \cdot \nabla (\cos\theta) $$
8585
#[inline(always)]
86-
fn diff(cos_theta: T, (k_half, cos0): Self::Params) -> T {
87-
let c = k_half + k_half;
86+
fn diff(cos_theta: T, (c_half, cos0): Self::Params) -> T {
87+
let c = c_half + c_half;
8888
c * (cos_theta - cos0)
8989
}
9090

9191
/// Computes both energy and derivative factor efficiently.
9292
///
9393
/// This method reuses intermediate calculations to minimize operations.
9494
#[inline(always)]
95-
fn compute(cos_theta: T, (k_half, cos0): Self::Params) -> EnergyDiff<T> {
95+
fn compute(cos_theta: T, (c_half, cos0): Self::Params) -> EnergyDiff<T> {
9696
let delta = cos_theta - cos0;
9797

98-
let energy = k_half * delta * delta;
98+
let energy = c_half * delta * delta;
9999

100-
let c = k_half + k_half;
100+
let c = c_half + c_half;
101101
let diff = c * delta;
102102

103103
EnergyDiff { energy, diff }
@@ -111,12 +111,12 @@ impl<T: Real> AngleKernel<T> for CosineHarmonic {
111111
/// Models the angle bending energy for atoms with linear equilibrium geometry ($\theta_0 = 180°$),
112112
/// using a simple linear function of the cosine of the angle.
113113
///
114-
/// - **Formula**: $$ E = K (1 + \cos\theta) $$
115-
/// - **Derivative Factor (`diff`)**: $$ \Gamma = \frac{dE}{d(\cos\theta)} = K $$
114+
/// - **Formula**: $$ E = C (1 + \cos\theta) $$
115+
/// - **Derivative Factor (`diff`)**: $$ \Gamma = \frac{dE}{d(\cos\theta)} = C $$
116116
///
117117
/// # Parameters
118118
///
119-
/// - `k`: Force constant $K$.
119+
/// - `c`: Force constant $C$.
120120
///
121121
/// # Inputs
122122
///
@@ -137,34 +137,34 @@ impl<T: Real> AngleKernel<T> for CosineLinear {
137137
///
138138
/// # Formula
139139
///
140-
/// $$ E = K (1 + \cos\theta) $$
140+
/// $$ E = C (1 + \cos\theta) $$
141141
#[inline(always)]
142-
fn energy(cos_theta: T, k: Self::Params) -> T {
142+
fn energy(cos_theta: T, c: Self::Params) -> T {
143143
let one = T::from(1.0f32);
144-
k * (one + cos_theta)
144+
c * (one + cos_theta)
145145
}
146146

147147
/// Computes only the derivative factor $\Gamma$.
148148
///
149149
/// # Formula
150150
///
151-
/// $$ \Gamma = K $$
151+
/// $$ \Gamma = C $$
152152
///
153153
/// This factor allows computing forces via the chain rule:
154154
/// $$ \vec{F} = -\Gamma \cdot \nabla (\cos\theta) $$
155155
#[inline(always)]
156-
fn diff(_cos_theta: T, k: Self::Params) -> T {
157-
k
156+
fn diff(_cos_theta: T, c: Self::Params) -> T {
157+
c
158158
}
159159

160160
/// Computes both energy and derivative factor efficiently.
161161
///
162162
/// This method reuses intermediate calculations to minimize operations.
163163
#[inline(always)]
164-
fn compute(cos_theta: T, k: Self::Params) -> EnergyDiff<T> {
164+
fn compute(cos_theta: T, c: Self::Params) -> EnergyDiff<T> {
165165
let one = T::from(1.0f32);
166-
let energy = k * (one + cos_theta);
167-
let diff = k;
166+
let energy = c * (one + cos_theta);
167+
let diff = c;
168168

169169
EnergyDiff { energy, diff }
170170
}

0 commit comments

Comments
 (0)