pyMBE-dev / pyMBE

pyMBE provides tools to facilitate building up molecules with complex architectures in the Molecular Dynamics software ESPResSo. For an up-to-date API documention please check our website:
https://pymbe-dev.github.io/pyMBE/pyMBE.html
GNU General Public License v3.0
6 stars 8 forks source link

Fixing perpendicular vector #26

Closed mariusaarsten closed 6 months ago

mariusaarsten commented 6 months ago

Fixes #25

pm-blanco commented 6 months ago

@mariusaarsten could you also provide your test to check that the vectors that are created are perpendicular? please upload it to testsuite and we will integrate it into the CI

pm-blanco commented 6 months ago

@mariusaarsten I tested your implementation and I think that for the same backbone vector, it creates consistently very similar perpendicular vectors, see (first row: backbone vector; second row: output perpendicular vector):

[ 0.49593437  0.81029915 -0.31219286] [0.46366211 0.05688033 0.88418441]
[ 0.49593437  0.81029915 -0.31219286] [0.45919242 0.06042315 0.88627951]
[ 0.49593437  0.81029915 -0.31219286] [0.45964479 0.0600653  0.88606931]
[ 0.49593437  0.81029915 -0.31219286] [0.45888877 0.06066327 0.88642037]
[ 0.49593437  0.81029915 -0.31219286] [0.45704807 0.06211729 0.88727025]
[ 0.49593437  0.81029915 -0.31219286] [0.45519462 0.06357873 0.88811914]
[ 0.49593437  0.81029915 -0.31219286] [0.45527088 0.06351866 0.88808435]
[ 0.49593437  0.81029915 -0.31219286] [0.47804817 0.04536955 0.87716108]
[ 0.49593437  0.81029915 -0.31219286] [0.45725371 0.06195499 0.88717565]
[ 0.49593437  0.81029915 -0.31219286] [0.47451969 0.04820825 0.87892379]
[ 0.49593437  0.81029915 -0.31219286] [0.47115676 0.05090436 0.88057938]
[ 0.49593437  0.81029915 -0.31219286] [0.45513231 0.06362782 0.88814756]
[ 0.49593437  0.81029915 -0.31219286] [0.45752065 0.06174424 0.88705271]
[ 0.49593437  0.81029915 -0.31219286] [0.47578505 0.04719142 0.87829468]
[ 0.49593437  0.81029915 -0.31219286] [0.47064041 0.05131752 0.88083149]
pm-blanco commented 6 months ago

@mariusaarsten I think I solved the issue in the last commit, can you please check it? Once you add the test to this branch we can merge it and solve this bug!

mariusaarsten commented 6 months ago

@pm-blanco Yes, I think you solved it too, it look very good now! Later, one could try to implement that it knows the vector of the previous sidechain and then make the current sidechain have the opposite direction? I think it works very well for now, though.

Will upload the testing script to testsuite. I just have to adjust it and use np.assert_equal and np.assert_raisers. It should check:

Do you agree or am I missing something?

pm-blanco commented 6 months ago

@mariusaarsten Yes, we could have such a feature in future developments if we consider that is necessary to have a more refined inicialization :smile:

The test you suggest sounds reasonable to me, but I think that it should rather check that the output perpendicular vector has a magnitude equal to the provided input magnitude.

mariusaarsten commented 6 months ago

@pm-blanco Sorry for the long wait, I have uploaded the script in test_suite now in the branch fixing_perpendicular_vector. Please check if it looks good, it seems reasonable to me at least!

pm-blanco commented 6 months ago

@mariusaarsten no worries for the delay! While reviewing your test, I realized that there was a problem when generating perpendicular vectors with a different origin. After playing around a while I came up with the following solution:

Could you please check if the current implementation still works correctly for your peptide simulations? If yes, I think that we are ready to merge this PR :smile:

mariusaarsten commented 6 months ago

@pm-blanco Peptide simulations works very well now. The side chains are initialized perpendicular to the backbone vector in different directions!