Module gosh_elastic::elastic
source · Expand description
elastic energy and force
For computing the energy and force of a center node for elastic connections with its immediate neighbors.
Example
ⓘ
// build connections
let mut connections = vec![];
let pi: Vector3f = positions[i].into();
for j in 0..n {
let pj: Vector3f = positions[j].into();
let displace = pj - pi;
let rij = displace.norm();
let spring = Spring::new(rij.powi(-2)).with_length(rij);
let connect = Connection::new(spring, displace);
connections.push(connect);
}
// compute energy and force for center node i
let (e, f) = compute_elastic_contribution(connections);
Functions
Compute elastic energy and force contribution of a center node from its
elastic connections with its neighbors
Compute elastic energy/force between image 1 in
position1
and
image 2 in positions2