Hi all,
I try to change atom coordinates dynamically in Jmol 14.3.12_2015.03.01
(and other recent versions) but I got stuck with a strange assignement
problem/bug.
I am using three global arrays (xc,yc,zc) as intermediate coordinate
storage while calculating the changes.
When I try to assign the new coordinates, only the first assignment
works correctly. All others assign the coordinates of the first node
instead of the correct one.
Below is shown a minimal version (using only 'xc' and a simplified
change function) to ilustrate the problem.
The coordinate update function looks like this:
#-----------------------------
function updateCoordinates(atomSet) {
for (var i=1; i<=atomSet.size; i++) {
print "UPDATE: i=" + i + " oldXCord=" + atomSet[i].x + " x=" +
xc[i];
print atomSet[i];
atomSet[i].x = xc[i];
print "UPDATE2: i=" + i + " newXCoord=" + atomSet[i].x;
}
show xc;
show atomSet;
}
#------------------------------
The following function copies the current X coordinates to the 'xc' array:
#-----------------------------
function initialize(atomSet) {
xc = [];
for (var i=atomSet.size; i>=1; i--) {
xc[i] = atomSet[i].x;
print "INIT: i=" + i + " xCoord=" + atomSet[i].x + " x=" + xc[i]
}
}
#------------------------------
And this function changes the X coordinates by adding '1.0':
#-----------------------------
function changeCoordinates(atomSet) {
for (var i=atomSet.size; i>=1; i--) {
print "CHANGE: i=" + i + " oldX=" + xc[i];
xc[i] += 1.0;
print "CHANGE2: i=" + i + " newX=" + xc[i];
}
}
#------------------------------
Example run:
#------------------------------
load =1deh;
set1 = {atomno<5};
initialize(set1);
changeCoordinates(set1);
updateCoordinates(set1);
#------------------------------
The debug output of the example run is shown below. It demonstrates that
the 'xc' array as such seems to be intact but during replacing the X
coordinate it seems to be handled incorrectly:
----- DEBUG OUTPUT ------------------
INIT: i=4 xCoord=14.566 x=14.566
INIT: i=3 xCoord=15.426 x=15.426
INIT: i=2 xCoord=16.318 x=16.318
INIT: i=1 xCoord=15.489 x=15.489
CHANGE: i=4 oldX=14.566
CHANGE2: i=4 newX=15.566
CHANGE: i=3 oldX=15.426
CHANGE2: i=3 newX=16.425999
CHANGE: i=2 oldX=16.318
CHANGE2: i=2 newX=17.318
CHANGE: i=1 oldX=15.489
CHANGE2: i=1 newX=16.489
UPDATE: i=1 oldXCord=15.489 x=16.489
UPDATE2: i=1 newXCoord=16.489
UPDATE: i=2 oldXCord=16.318 x=17.318
UPDATE2: i=2 newXCoord=16.489
UPDATE: i=3 oldXCord=15.426 x=16.425999
UPDATE2: i=3 newXCoord=16.489
UPDATE: i=4 oldXCord=14.566 x=15.566
UPDATE2: i=4 newXCoord=16.489
xc = [ 16.489,17.318,16.425999,15.566 ]
atomSet = ({0:3})
-------------------------------------
The example does work as expected in Jmol version 14.0.5:
-----------------------------------------------
INIT: i=4 xCoord=14.566 x=14.566
INIT: i=3 xCoord=15.426 x=15.426
INIT: i=2 xCoord=16.318 x=16.318
INIT: i=1 xCoord=15.489 x=15.489
CHANGE: i=4 oldX=14.566
CHANGE2: i=4 newX=15.566
CHANGE: i=3 oldX=15.426
CHANGE2: i=3 newX=16.426000000000002
CHANGE: i=2 oldX=16.318
CHANGE2: i=2 newX=17.318
CHANGE: i=1 oldX=15.489
CHANGE2: i=1 newX=16.489
UPDATE: i=1 oldXCord=15.489 x=16.489
({0})
UPDATE2: i=1 newXCoord=16.489
UPDATE: i=2 oldXCord=16.318 x=17.318
({1})
UPDATE2: i=2 newXCoord=17.318
UPDATE: i=3 oldXCord=15.426 x=16.426000000000002
({2})
UPDATE2: i=3 newXCoord=16.426000000000002
UPDATE: i=4 oldXCord=14.566 x=15.566
({3})
UPDATE2: i=4 newXCoord=15.566
xc = [16.489,17.318,16.426000000000002,15.566]
atomset = ({0:3})
---------------------------
Regards,
Rolf
--
Rolf Huehne
Postdoc
Leibniz Institute for Age Research - Fritz Lipmann Institute (FLI)
Beutenbergstrasse 11
07745 Jena, Germany
Phone: +49 3641 65 6205
Fax: +49 3641 65 6210
E-Mail: [email protected]
Website: http://www.fli-leibniz.de
Scientific Director: Prof. Dr. K. Lenhard Rudolph
Head of Administration: Dr. Daniele Barthel
Chairman of Board of Trustees: Dennys Klein
VAT No: DE 153 925 464
Register of Associations: No. 230296, Amtsgericht Jena
Tax Number: 162/141/08228
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users