lorenzo-rovigatti / oxDNA

A new version of the code to simulate the oxDNA/oxRNA models, now equipped with Python bindings
https://dna.physics.ox.ac.uk/
GNU General Public License v3.0
38 stars 26 forks source link

Shift harmonic force pos the same way as NT pos #73

Closed RodenLuo closed 5 months ago

RodenLuo commented 8 months ago

Fix #71.

Hi Lorenzo, Thanks for the guidance on the issue. I believe this PR fixes it. Below is a short description of what's happening.

https://github.com/lorenzo-rovigatti/oxDNA/blob/a6214b99b64806d322e110c3d84fce4bbe9815f2/src/Backends/SimBackend.cpp#L535-L542

The above code snippet is executed if fix_diffusion = true even at step == 0. It means the positions of NTs might be shifted at the very beginning. This makes it hard to set the pos0 parameter for harmonic traps. This PR solves the issue by shifting the pos0 of the external forces of an NT using its recorded p->_pos_shift and the box sides. The attached files in #71 can be used to test the issue and the fix.

I believe the "rotating harmonic trap" will suffer from the same issue. But I do not have a use case to test. So, I have only fixed the "harmonic trap". If this PR is accepted, the same fix might need to be applied to the "rotating harmonic trap".

lorenzo-rovigatti commented 8 months ago

Thanks for the PR Roden. This may fix it it, but also changes the default behaviour of the trap (and therefore breaks backward compatibility), which is something I don't like too much. I think this should be controlled by a key in the input. I'm pretty busy with teaching these days, but I'll try to come up with a solution.