# Bug with molecular variables

Hello, I am attempting to assign variables to the cartesian coordinates for a water dimer. One water molecular has fixed coordinates whilst the other is varied to get an interaction energy, nice and simple. However if I construct the dimer as

`molecule dimer {
O1 0.000000000 0.00000000 0.00000000
H1 -1.45365196 0.00000000 -1.12168732
H2 1.45365196 0.00000000 -1.12168732
O1 O_X O_Y O_Z

H1 -1.45365196 0.00000000 -1.12168732
H2 1.45365196 0.00000000 -1.12168732
O1 -4.03818248 0.00000000 -2.45198575
H1 -5.08151580 1.45365242 -2.04011599
H2 -5.08151828 -1.45365150 -2.04011904
}`

If I then set the variables as;-

molecularPositionsCartesian = [
-4.03818248, 0.00000000, -2.45198575
]

dimer.O_X = molecularPositionsCartesian[0]
print("1 dimer.O_X: " + str(dimer.O_X))
dimer.O_Y = molecularPositionsCartesian[1]
print("1 dimer.O_X: " + str(dimer.O_X))
dimer.O_Z = molecularPositionsCartesian[2]
print("1 dimer.O_X: " + str(dimer.O_X))

The output is then

[s.rayner@comanche water_dimer]\$ psi4
1 dimer.O_X: -4.03818248
1 dimer.O_X: -4.03818248
1 dimer.O_X: -1.45778350181

Notice the fact that I am printing out O_X in each instance but am assigning O_X, O_Y then O_Z. Upon setting O_Z the value of O_X changes, this is quite a problem… and if I switch the order and assign X,Z then Y the result is the same.

I also get the same problem without using the array.

`molecule dimer {
O1 0.000000000 0.00000000 0.00000000
H1 -1.45365196 0.00000000 -1.12168732
H2 1.45365196 0.00000000 -1.12168732
O1 O_X O_Y O_Z

H1 -1.45365196 0.00000000 -1.12168732
H2 1.45365196 0.00000000 -1.12168732
O1 -4.03818248 0.00000000 -2.45198575
H1 -5.08151580 1.45365242 -2.04011599
H2 -5.08151828 -1.45365150 -2.04011904
}

dimer.O_X = -4.0381824
dimer.O_Y = 0.00000000
dimer.O_Z = -2.45198575

print("1 dimer.O_X: " + str(dimer.O_X))
print("1 dimer.O_Y: " + str(dimer.O_Y))
print("1 dimer.O_Z: " + str(dimer.O_Z))`

Some help on this issue would be really appreciated.

Hello everyone I managed to figure this issue out. Turns out you need to ensure it doesn’t adjust the C.O.M or reorient the molecule. So adding;-

`no_reorient no_com`

Into the molecules definition as;-

`molecule dimer { units bohr no_reorient no_com O1 0.000000000 0.00000000 0.00000000 H1 -1.45365196 0.00000000 -1.12168732 H2 1.45365196 0.00000000 -1.12168732 O1 O_X O_Y O_Z H1 H1_X H1_Y H1_Z H2 H2_X H2_Y H2_Z }`

Note units bohr was left out before which was a mistake and should have been there but isn’t a significant problem as variables changing themselves.

Hope this help.