JuliaMolSim / Molly.jl

Molecular simulation in Julia
Other
372 stars 51 forks source link

Straight angle may produce NaNs in HarmonicAngle #58

Closed tverho closed 2 years ago

tverho commented 2 years ago

There is a special case when the calculation of angle force breaks down, namely when the cross product of the bond vectors vanishes. This may occur in initial configurations with completely straight polymer chains. The behavior is somewhat random due to floating point errors, making the identification of the cause for the NaN values a bit tricky for the user.

Perhaps the algorithm could be modified to work in all scenarios?

jgreener64 commented 2 years ago

You are correct - fixed in https://github.com/JuliaMolSim/Molly.jl/commit/f46e049ef97dd0e6e18d97b80ce1784b1369e5f5.