JuliaMolSim / Molly.jl

Molecular simulation in Julia
Other
371 stars 51 forks source link

`Mie` interaction gives `InexactError` due to the `convert` in constructor #94

Closed JaydevSR closed 1 year ago

JaydevSR commented 1 year ago

If we use some value for m and n such that (n / (n - m)) * (n / m) ^ (m / (n - m)) gives a floating point number then, https://github.com/JuliaMolSim/Molly.jl/blob/7d95bcc27217343cf0283e10dcc13da3ccf378fa/src/interactions/mie.jl#L37 leads to inexact error (if typeof(m) is Int). Maybe it is better to do something like:

m, n, mn_fac = promote(m, n, (n / (n - m)) * (n / m) ^ (m / (n - m)))
jgreener64 commented 1 year ago

Yes seems sensible, open a PR if you have time.