Pages

Notes on Molecular Dynamics simulation (MD)

"The molecular dynamics problem is generally treated as a coupled set of differential equations. The system of differential equation  is discretized by choosing a discrete time step. Given the position and velocity of each particle at one time step, molecular dynamics simulation algorithms estimate these values at the next time step."

"The Time step is a crucial parameter in MD simulations as it determines the accuracy and efficiency of the numerical integration scheme. By default, the time step is typically set to 1 fs or less (in Q-Chem, 1 a.u. which is 0.0242 fs)  in a number of codes.

"The central point is that a larger time step, although it may at first glance improve the efficiency of the simulation, increases the error in the numerical integration scheme of the equations of motion. The underlying assumption that the atomic forces are approximately constant during one integration step is not valid any more. Essentially, the chosen time step should be small enough to resolve the highest vibrational frequencies of the atoms (i.e. it should be much smaller than the smallest vibrational period), so if you have light atoms (e.g. hydrogen), you will generally be required to use a smaller time step than if you have only heavy atoms (such as gold). A smaller time step size may also be necessary if you have different elements in your calculation, if the temperature is high, or if the atoms are far away from their equilibrium configuration, i.e if large forces act on the particles. For most systems a safe choice to start, if you do not know what time step to use, is 1 fs. Larger timestep values can then be assessed by monitoring the conservation of the total energy in an NVE simulation under the conditions of interest."

To read more:
Molecular Dynamics: Basics (from quantumwise.com) 
MD Molecular dynamics (a C program to do molecular dynamics

Install and Use ASE (Atomic Simulation Environment) in Ubuntu Linux

To install, I tried,

pip install --upgrade --user ase

/home/user/...../pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
Collecting ase
  Downloading https://files.pythonhosted.org/packages/b4/52/df21f492fbd/ase-3.18.0.tar.gz (1.8MB)
    100% |████████████████████████████████| 1.8MB 21.2MB/s 
    Complete output from command python setup.py egg_info:
    Python 3.5 or later is required!
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-tSeI9W/ase/
You are using pip version 18.0, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Then, I tried since "Python 3.5 or later is required!" is given.

pip3 install --upgrade --user ase

Now, I get

Installing collected packages: ase
  Found existing installation: ase 3.17.0
    Uninstalling ase-3.17.0:
      Successfully uninstalled ase-3.17.0
Successfully installed ase-3.18.0

(Earlier I have installed ase 3.17.0. Now it is updated to 3.18.0)


Then I tested the installation using

ase test

========== Summary ==========
Number of tests   317
Passes:           229
Failures:           0
Errors:             0
Skipped:           88
=============================
Test suite passed!
Time elapsed: 167.4 s

Now, ase is successfully installed.


Now, how to use for calculations? Lets try.

Now I tested ase in real calculation.

I checked the example given in this page https://wiki.fysik.dtu.dk/ase/tutorials/surface.html

Saved following script in a file (ase_example.py)

from ase import Atoms
from ase.calculators.emt import EMT
from ase.constraints import FixAtoms
from ase.optimize import QuasiNewton
from ase.build import fcc111, add_adsorbate

h = 1.85
d = 1.10

slab = fcc111('Cu', size=(4, 4, 2), vacuum=10.0)

slab.set_calculator(EMT())
e_slab = slab.get_potential_energy()

molecule = Atoms('2N', positions=[(0., 0., 0.), (0., 0., d)])
molecule.set_calculator(EMT())
e_N2 = molecule.get_potential_energy()

add_adsorbate(slab, molecule, h, 'ontop')
constraint = FixAtoms(mask=[a.symbol != 'N' for a in slab])
slab.set_constraint(constraint)
dyn = QuasiNewton(slab, trajectory='N2Cu.traj')
dyn.run(fmax=0.05)

print('Adsorption energy:', e_slab + e_N2 - slab.get_potential_energy())
Then, I run the python script (ase_example.py) as follow.
python3 ase_example.py
Now, I got following output.
                Step[ FC]     Time          Energy          fmax
*Force-consistent energies used in optimization.
BFGSLineSearch:    0[  0] 12:55:55       11.689927*       1.0797
BFGSLineSearch:    1[  2] 12:55:55       11.670814*       0.4090
BFGSLineSearch:    2[  4] 12:55:55       11.625880*       0.0409
Adsorption energy: 0.32351942231809083
This means that, the installation is successful and ready for calculations.
Hope this post is useful. Comment below if this is useful to you. Subscribe to this blog if you want to receive similar posts.











Running multiple jobs with qsub with uniqe names.

I have a PBS script to run jobs. The name is specified by #PBS -N tag.

But, if you want to run a number of files (100s, 1000s), it may be tedious to edit submit-jobs file for each file. Instead one can use this onliner to assign name to each jobs.

For example,

#For foo_bar_abc_1_01_geh_file.in, the Job Name should be test01, 
#For foo_bar_abc_1_02_geh_file.in, the Job Name should be test02, 
#For foo_bar_abc_1_100_geh_file.in, the Job Name should be test100,
   etc.

for f in foo*.in; do qsub -N test$(echo $f|cut -d_ -f5) -v infile=$f run.pbs; done

Removing permanent marker from Whiteboard

Recently, I used permanent marker mistakenly instead of white-board marker. How to remove this writing?

1. If the writing is a few words or letters, you can use whiteboard marker (of any color) to write on the letters written by permanent marker. Then you can use clean cloth the remove. Now all will be gone.

2. If you have written the whole white board and you can use the first method, you can use fallowing procedure.
You can use pencil eraser to remove the writing.

3. Use Acetone. Acetone (250 ml) can be bought for about 2 USD. Use a pure cotton cloth and dip in acetone so that the cloth become wet. Then, gently rub on the board where the marker is written. This will clean the board completely. Make sure that acetone bottle is closed tight. Otherwise, it will evaporate quickly. You can use tissue papers too instead of a cloth.

4. You can use any alcohol and use method 3 by using a clean cloth.

For more ideas, visit lifehack stack exchange.






Copy multiple files with different names (res to unres)

Change directory to where you have the original files.

Then test with the following command line,

for i in *_original.*;do echo cp -p "$i" "${i/_original./_copy.}";done
and if it looks good, remove echo and do the copying,

for i in *_original.*;do cp -p "$i" "${i/_original./_copy.}";done


Reference
https://askubuntu.com/a/1045000/465828



Using for loop to save outcome in in different file using np.savetxt

I wrote a script to do following task.

For each number that is created using range(0,100), I created xyz coordinates to generate guess structures for my calculations. The structure of the script is as follow.


for numPoints in range(0, 101):
     #do something to create x0, y0 and cons0 (xyz coordinates for a molecule)
     np.savetxt(fname_template.format(i=numPoints), np.c_[x0,y0,cons0],delimiter=' ',fmt='%10f')

This solved my problem.

I got this idea from following post in stack overflow.

fname_template = "Subarray.{i}.txt"
for i, sarr in enumerate(sub_arr):
    np.savetxt(fname_template.format(i=i), sarr, fmt='%s')
To create the file name I've used the new string formatting. Otherwise you can concatenate strings with + as "Subarray."+str(i)+".txt", but you have to make sure that all the elements that you concatenate are strings.

awk, sed, pipe, grep, etc like functions in python

I would like to translate from bash to python script.

The bash contains awk, sed, pipes, cat commands.

How to write commands in python?




Ubuntu update error: Unable to lock directory /var/lib/apt/lists/

When I update using

sudo apt-get update
or
sudo apt update

I get following error.

E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/

I tried updating through Software Updater and Restarted the machine.

Now its fine.




Trignometric formula

Trig functions

sin(A + B) = sin A cos B  +  cos A sin B
cos(A + B) = cos A cos B  −  sin A sin B

cos(A − B) = cos A cos B + sin A sin B
sin(A − B) = sin A cos B − cos A sin B

Useful sites
https://brownmath.com

Installing VESTA

Check whether curl has been installed or not.

which curl

if curl is installed, it will give you the path. 

If not installed, 

sudo apt-get install curl 


Now, use 


This will download the installer to the current directory.

Now, 

sudo bash vestacp.sh

This will install vesta. First it will ask for e-mail ID. Enter a valid e-mail ID. 
Then, it will ask for host. If want to use default, presee ENTER.

Then, vesta will be installed.

It may take 15 minutes to 30 minutes.






Tetrahedral site



What is tetrahedral site?

Here is a good explanation with clear sketch.
Following description and figures are taken from

https://www.tf.uni-kiel.de/matwis/amat/def_en/kap_1/illustr/t1_3_4.html

"In a tetrahedral site the interstitial is in the center of a tetrahedra forms by four lattice atoms. Three atoms, touching each other, are in plane; the fourth atom sits in the symmetrical position on top. Again, the tetrahedral site has a defined geometry and offers space for an interstitial atom."

 "The configuration on top is the tetrahedral position in the fcc lattice. The black circles denote lattice points, the red circle marks one of the 8 the tetrahedral position."

"The picture on the bottom shows the tetrahedral configuration for the bcc lattice. We have (6 · 4)/2 = 12 positions per unit cell."


Figure: The tetrahedral site in FCC (above) and BCC (below) crystal structures

References
https://www.tf.uni-kiel.de/matwis/amat/def_en/kap_1/illustr/t1_3_4.html

SI Prefixes


Factor
Name
Symbol
Multiplying Factor
1024
yotta
Y
1 000 000 000 000 000 000 000 000
1021
zetta
Z
1 000 000 000 000 000 000 000
1018
exa
E
1 000 000 000 000 000 000
1015
peta
P
1 000 000 000 000 000
1012
tera
T
1 000 000 000 000
109
giga
G
1 000 000 000
106
mega
M
1 000 000
103
kilo
k
1 000
102
hecto
h
100
101
deca
da
10
10–1
deci
d
0.1
10–2
centi
c
0.01
10–3
milli
m
0.001
10–6
micro
µ
0.000 001
10–9
nano
n
0.000 000 001
10–12
pico
p
0.000 000 000 001
10–15
femto
f
0.000 000 000 000 001
10–18
atto
a
0.000 000 000 000 000 001
10–21
zepto
z
0.000 000 000 000 000 000 001
10–24
yocto
y
0.000 000 000 000 000 000 000 001


Source: https://www.bipm.org/en/measurement-units/prefixes.html

Teaching philosophy

Universities ask for statement of teaching interest or teaching philosophy

Important components in the statement

first one: internal honesty with myself
take the time, to think thorough and think fundamentally what it
attitude
take you put into

- statement should be completely personal.
- should use "I" instead of speaking globally
- don't explain others how to teach
- because it is going to be read by already who is teaching (they will get irritated by reading your statement if you teach them how to teach)




You may be interested in these posts

Error in image file conversion: convert-im6.q16: not authorized `test.eps' @ error/constitute.c/WriteImage/1037.

This error is because of the vulnerability. This allows remote execution of code using image formats. So, some Linux distributions by defaul...