tnorthey / normal-mode-displacer

Displace atomic coordinates along molecular normal modes.
8 stars 5 forks source link

Use stepwise structure distortion rather than random #2

Closed prasanta13 closed 5 months ago

prasanta13 commented 5 months ago

I wanted to create a set of geometries (9) within the displacement range of -0.5 to +0.5 A along all the normal modes. Such that along each mode (as there are total of 3 modes) there will be 3 geometries (totalling 3*3 = 9 geometries). If I have understood correctly, I have changed the variable.py as,

# Number of geometries to generate
N = 9

# switch on (1) or off (0) random displacements
randm = 1

# if randm is on the random displacement will be in range [-a,a], if randm is off it will displace by exactly a
a = 0.5

# frequencies (cm-1) of selected modes
freqcm1 = [1722.4496, 3799.4476, 3925.0128]

# selected modes
Modes = [1,2,3]
#nmodes = 2
nmodes = len(Modes)
#Modes = list(range(1, nmodes + 1 ))  # all modes

Also, I have added a small print statement in the file, run.py as,

for j in range(N):  # loop N times
  print('Step ' + str(j+1))
  D=R0  # Starting coordinates
  for i in range(nmodes):  # Loop over modes
    print("i = ",i)
    if nmodes==1:

Now when I run python run.py I get this error,

Step 1
i =  0
Traceback (most recent call last):
  File "run.py", line 20, in <module>
    b=a[i]
TypeError: 'float' object is not subscriptable
tnorthey commented 5 months ago

Hi prasanta,

I think it will work if you put a = [0.5, 0.5, 0.5] in the variables.py. It's because there's a different value of a for each mode (and in this case you use 3 modes). It should be explained better in the readme, I'll update it soon! Let me know if that works.

Thanks, Thomas

prasanta13 commented 5 months ago

Hi @tnorthey , Thank you very much for your quick and prompt reply.

I was wondering what changes I need to make in the variables.py file if I need the following.

Say, I have a water dimer or trimer and I want 20 geometries along each normal modes within the range [-0.5, +0.5].

I can change the freqcm1 list as required and change normalmodes.txt file accordingly. I am confused about the variables.py file. If possible, could you please have a look into this?

tnorthey commented 5 months ago

This should work for variables.py for the water dimer, and you can modify for the trimer. Please change the 0.1 values I added to the correct frequencies (cm-1) that you want. Hope it helps!

# Number of geometries to generate
N = 20

# switch on (1) or off (0) random displacements
randm = 1

# if randm is on the random displacement will be in range [-a,a], if randm is off it will displace by exactly a
a = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
# I think this will work for water dimer because there are 12 modes and you want them all to move in the range [-0.5, 0.5]. For the trimer make it so there are 21.

# frequencies (cm-1) of selected modes
freqcm1 = [1722.4496, 3799.4476, 3925.0128, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] # change the 0.1 values to real frequencies values

# selected modes
natoms = 6 # water dimer
nmodes = 3 * natoms - 6
nmodes = len(Modes)
#Modes = [1,2,3]
Modes = list(range(1, nmodes + 1 ))  # all modes
prasanta13 commented 5 months ago

Just had a test with water monomer. Here is the variable.py

# Number of geometries to generate
N = 10

# switch on (1) or off (0) random displacements
randm = 1

# if randm is on the random displacement will be in range [-a,a], if randm is off it will displace by exactly a
a = [1,1,1]

# frequencies (cm-1) of selected modes
freqcm1 = [1722.4496, 3799.4476, 3925.0128]

# selected modes
natoms = 3
nmodes = 3 * natoms - 6
#Modes = [1,2]
#nmodes = 2
#nmodes = len(Modes)
Modes = list(range(1, nmodes + 1 ))  # all modes

AND IT WORKS. THANK YOU VERY MUCH. i am trying to tweak the code now in this part. I do not like the addition of random variables in run.py.

    if randm==1:
      v = random()  # random value between 0 and 1
      Factor = b*(2*v-1)  # random value in range [-a,a]

Let me try. Thank you very much. @tnorthey