Sim.sd_norm_head: def of bend-prot@0.1.0.0 Import: import bend-prot@0.1.0.0/sim.bend as Sim Lines 218-225 of bend-prot@0.1.0.0/sim.bend: https://jend.leeeet.dev/read.txt?path=bend-prot@0.1.0.0/sim.bend&start_line=218&end_line=225 import Base import bend-prot@0.1.0.0/geom.bend as G # Steepest descent over state (fixed fuel; CLI reports convergedness). # Normalized steps (fixed distance along each force) relax clashes that # raw F*dt would overshoot; raw forces still feed MD and max-force. def sd_norm_head(h: DynAtom, +step: F32) -> DynAtom: match h: case DA{serial, elem, pos, vel, +frc, mass}: +n2 = G.Vec3.norm2(frc) DA{serial, elem, G.Vec3.add(pos, G.Vec3.scale(step, Bool.pick(G.Vec3, F32.is_eq(n2, 0.0), G.V3{0.0, 0.0, 0.0}, G.Vec3.scale((1.0 / F32.sqrt(n2) : F32), frc)))), vel, frc, mass} Uses (10): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.sqrt https://jend.leeeet.dev/definition.txt?path=bend-prot@0.1.0.0/geom.bend&name=Vec3 https://jend.leeeet.dev/definition.txt?path=bend-prot@0.1.0.0/geom.bend&name=Vec3.add https://jend.leeeet.dev/definition.txt?path=bend-prot@0.1.0.0/geom.bend&name=Vec3.norm2 https://jend.leeeet.dev/definition.txt?path=bend-prot@0.1.0.0/geom.bend&name=Vec3.scale https://jend.leeeet.dev/definition.txt?path=bend-prot@0.1.0.0/sim.bend&name=DynAtom