Main Page

From wiki
Revision as of 07:53, 13 April 2018 by Torres (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

BMCC Materials Research Project

Contents

Session 0: Orientation

Welcome aboard. Here we are going to discuss a few basic rules of conduct:

Rules

  • If we have an appointment you cannot be more than 15 mins late. If so, you need to tell me at least two hours in advance.
  • The research office is at N690. You could find the lab managers at N677 or N643 and they would be able to give you access to the office)
  • Your instructor will provide you with a USB key and a USB Wifi connector, is your responsibility to keep these devices safe (these are sensitive devices so be very careful with them)
  • the username for the USB is "user" and the password is "live". You need to have this info handy.
  • Every session is 4hours and the challenge (one per session) is one hour. You need to allocate 5 hours in total per session, sometimes It will take you more.
  • I will track your progress by means of a table in the shared folder, where the deadlines for all tasks will be written. I will also track your responsiveness (if you answer emails and communicate in a timely manner), your professionally (if you attend your meetings on time and act professional) and your time management skills (if you are able to accomplish the goals in the time you have). All this information in a very positive manner will be indicate in your reference letter after you finish the program.
  • You can reschedule a training session anytime. However, I wont be able to support you on that other time and you'll still have to come with the deliverable for that session.

Exercise 0: how to go over this training

This exercise will introduce you to this training. For every session, is there a few exercises to be done (like this one). In these exercises you will have to answer and work on problems and report the answers in a Worksheet. There is one work sheet per session. When you are done, you upload the worksheet to your shared GoogleDrive (GD) folder. For every session there is also a Challenge. You will have to work on the challenge and upload the results in GD as well. For example:

  • (a) How many sessions are there in this training? Write down the results in the Worksheet (WS)
  • (b) How many challenges you will have to overcome to finish this training? Write down the results in the Worksheet (WS)
  • (c) Knowing that you will need at least 4h to cover every session (if you are very focusses) and one hour for every challenge, how many hours will you need to finish the training and in how many days do you plan to do this? Write down the results in the Worksheet (WS)

Exercise 1: how to set up the WIFI at BMCC

To set up the wifi connection at BMCC you need to follow the next steps:

  • (a) click on the wifi menu (top of the screen right corner) and select BMCC Secured
  • (b) Select from the Authentication menu select Protected EAP
  • (c) click on the no CA certificate required
  • (d) put your username and pass
  • (e) More options by click on the WIFI menu and click edit connection
  • (e) Now in your phone, install the Google Hangout App

Results Worksheet

Write down all answers for the exercise questions in this worksheet. After you are done send the result by email to your instructor or upload the file to the shared Google Drive folder: document

Challenge

Try the challenge. After you are done send the result by email to your instructor or upload the challenge to the shared Google Drive folder: document

Learning Goals

The learning goals of the part of the training are: document

Session 1: CS Basics

The goal of this firsts session is to get you familiar with the basics of Linux. You will need to master all these commands to be able to carry any computer-based research project. In particular you will need to know how to make and remove folders, and how to enter and leave those folder. You will also need to be able to move in the linux file system.

Exercise 0: linux Desktop environment

this exercise will introduce you to Linux. Your instructor will give you access to a linux USB key.

  • (a) Take a good look a the visual environment. Explain how to access the internet browser.
  • (b) Make sure you can connect to the wifi
  • (c) Make a folder in your home directory named: test1.
  • (d) Make a folder in your Desktop directory named: test2.
  • (e) Find out how to shut down the computer and explain how to do it
  • (f) Find out (and explain) how to write a small MSWord Document (an essay)

Exercise 1: the power of linux

In this exercise you will learn why in Linux can be more convenient than windows sometimes. Get yourself familiar with the Linux visual environment. Check the start menu and the ‘explorer’ to enter folders. Take a look at the right-click mouse options. Does this look a alike Windows?

  • (a) Use the visual environment and create a set of folder in your home directory. Go to your home directory and right-click to create a set of new folders: 00, 01, 02, 03, 04, 05. Was that hard? Could you do the same with a windows computer?
  • (b) Why using Linux? Now create a set of 100 folders in the same way as in (a). Name them: 06, 07, ..., 150 . How long it took you to do this? Before you go on, remove all the folders created from (a) to (c).
  • (c) Open a terminal (a.k.a. Shell is the black screen in the Desktop Dock). Type
for i in $(seq 150 250); do mkdir $i ; done

What is the result of this command? How long it took you to do the task from (a) to (c) using this command? Why do you think Linux can be useful?

Exercise 2: linux commands

In this exercise you will get familiar with some basic ideas behind Linux:

  • (a) If you check the start menu, and look for the software installed in your linux ‘distro’, how many applications you have? Are these the only apps installed?
  • (b) Open a shell and press ‘c’ keys followed by the Tab key. What are all those names? Look up any of those names in the internet, for example the world 'cal' or the word 'clear'. What is the use of each of the commands?

Exercise 3: fun commands

Here you will learn how to use some fun Linux commands. The shell is not always dull and boring:

  • (a) Type the command 'fortune' and press enter. What is this command?
fortune
  • (b) Type the command 'toilet' and explain the use of the command:
toilet "welcome to BMCC"
  • (c) Now experiment with the command 'cowsay' and type:
cowsay "Hmm, I didn’t know that"
  • (d) You can also experiment with the command 'fortune' by typing:
fortune | cowsay

what is the use of the pipe?

  • (e) Type the following command and press enter. What is this command for? Use Control+C to cancel

aafire

  • (f) Type the following command and press enter. What is this command for? Use Control+C to cancel

oneko

  • (g) Type the following command and press enter. What is this command for? Use Control+C to cancel

cmatrix

  • (h) Type the following command and press enter. What is this command for? Use Control+C to cancel

xcowsay Hello

Exercise 4: Moving inside a terminal

This exercise will introduce you to the use of a terminal. In particular, you will leanr to enter and leave folders:

  • (a) Open a terminal and type
pwd

The result of this command is the 'path' and tell you where are you located inside the file system.

  • (b) Now type
cd /

followed by:

pwd
  • (c) then type
cd $HOME/Desktop
pwd 

What is the use of 'cd'? At this point you know how to access folder, by using the 'cd' command. What if you want to get out of a folder you got in?

  • (d) Close the shell (you can do this typing exit) and start a new shell. Type
ls

how do you get into the folder called Desktop? Type

cd Desktop

Now if you want to get out of Desktop and go back to your home directory, you can do this by typing:

cd ../

Exercise 5: Working with folders

This exercise will help you learn how to deal with folder.

  • (a) Create a folder with your first name by doing:
mkdir  yourname
  • (b) Using ls make sure you can actually see the folder you created
ls

make sure you see the folder you created with your name

  • (c) Now remove the folder you created by doing
rmdir  yourname
  • (d) Create another folder with a given name. Then go inside the folder and create another folder.
  • (e) Try removing both folders


Challenge

Try the challenge. After you are done send the result by email to your instructor or upload the challenge to the shared Google Drive folder: document

Learning Goals

The learning goals of the part of the training are: document

Session 2: Use of the VI editor

In this session you will learn how to use the VI editor. This is the most extended text editor in Linux. It would be the equivalent to MS word but is simpler and more powerful, besides the fact that is made to work remotely (in a far away computer). We will follow some conventions during this tutorial:

<ESC> means the Scape key
<Shift + : > means the Shift and Semicolon keys
<TAB> means the Tab key
< i > means the key i

Exercise 0: Hello world file

In this exercise we will learn how to create and save a simple file. We will create a file called 'myfile'. Is very important that you keep your hands out of the keyboard and only press the keys specified below:

  • (a)Go to your Desktop
cd Desktop
  • (b)Open Type in a shell
vi myfile
  • (c) Now, follow closely the next steps and press the following keys:

Now write: 'This is my first file'

  • (d)

<ESC> wq! <Shift + :>

  • (e) Lets edit your first file
vi myfile

Now, follow closely the next steps: <i> use the up/down keys to move in the file and use Del to remove the word ‘first’ and now type ‘second’. <ESC> q! <Shift + :> Go back to the file

vi myfile

What happened? Repeat the steps above but use wq! Instead of q!. What’s the difference between wq! And q!?

Exercise 1: VI

In this exercise we will learn how to use the VI editor:

  • (a)Open a shell
  • (b) go to your home directory and enter the folder called 'trainingVI'
cd $HOME
cd trainingVI
  • (c) Do the first exercise:
vi exercise-1

Exercise 2: VI

In this exercise we will learn how to use the VI editor:

  • (a)Open a shell
  • (b) go to your home directory and enter the folder called 'trainingVI'
cd $HOME
cd trainingVI
  • (c) Do the exercise:
vi exercise-2

Exercise 3: VI

In this exercise we will learn how to use the VI editor:

  • (a)Open a shell
  • (b) go to your home directory and enter the folder called 'trainingVI'
cd $HOME
cd trainingVI
  • (c) Do the exercise:
vi exercise-3

Exercise 4: VI

In this exercise we will learn how to use the VI editor:

  • (a)Open a shell
  • (b) go to your home directory and enter the folder called 'trainingVI'
cd $HOME
cd trainingVI
  • (c) Do the exercise:
vi exercise-4

Exercise 5: VI

In this exercise we will learn how to use the VI editor:

  • (a)Open a shell
  • (b) go to your home directory and enter the folder called 'trainingVI'
cd $HOME
cd trainingVI
  • (c) Do the exercise:
vi exercise-5

Exercise 6: VI

In this exercise we will learn how to use the VI editor:

  • (a)Open a shell
  • (b) go to your home directory and enter the folder called 'trainingVI'
cd $HOME
cd trainingVI
  • (c) Do the exercise:
vi exercise-6

Exercise 7: VI

In this exercise we will learn how to use the VI editor:

  • (a)Open a shell
  • (b) go to your home directory and enter the folder called 'trainingVI'
cd $HOME
cd trainingVI
  • (c) Do the exercise:
vi exercise-7

Exercise 8: VI

In this exercise we will learn how to use the VI editor:

  • (a)Open a shell
  • (b) go to your home directory and enter the folder called 'trainingVI'
cd $HOME
cd trainingVI
  • (c) Do the exercise:
vi exercise-8

Exercise 9: VI

In this exercise we will learn how to use the VI editor:

  • (a)Open a shell
  • (b) go to your home directory and enter the folder called 'trainingVI'
cd $HOME
cd trainingVI
  • (c) Do the exercise:
vi exercise-9

Challenge

Try the challenge. After you are done send the result by email to your instructor or upload the challenge to the shared Google Drive folder: document

Learning Goals

The learning goals of the part of the training are: document

Session 3: Data Processing

In this session you will learn how to process large amount of information quickly from text files. refresh your system by typing 'refresh' twice. Mind to do this twice.

Exercise 0: the end of a file

  • (a) In your home directory enter a folder called 'files' and open a file called 'file.txt'
  • (b) Go to the end of the file (that is the last line of the file). What does it say in the last line?
  • (c) was it hard for you to get to the last line?

Exercise 1: use of tail

This exercise will introduce you to the use of tail.

  • (a) In your home directory enter a folder called 'files'
  • (b) Type in the shell:
tail file.txt
  • (c) Type in the shell:
tail –n 5 file.txt

what does the –n 5 do.?


Exercise 2: use of head

This exercise will introduce you to the use of tail.

  • (a) In your home directory enter a folder called 'files'
  • (b) Type in the shell:

head file.txt

  • (c) Type in the shell:
head –n 5 file.txt

what does the –n 5 do.?


Exercise 3: use of Grep

This exercise will introduce you to the use of grep.

  • (a) In your home directory enter a folder called 'files'
  • (b) Look for the phase ‘Zero Kelvin’ in 'file.txt'. What is the first value of ‘Zero Kelvin’ you see in the file? And the last one? And the 15th value staring for the bottom of the file?
  • (c) Type in the shell:
grep 'Zero Kelvin' file.txt 

what happened?

Exercise 4: use of Awk

This exercise will introduce you to the use of grep.

  • (a) In your home directory enter a folder called 'files'
  • (b) Type in the shell:
grep 'Zero Kelvin' file.txt | awk '{print $1}'

what happened? Use $2 instead of $1. What changes?

  • (c) Type in the shell:
grep 'Zero Kelvin' file.txt | awk '{print $3}'

Use tail and head to print only the last and first value of ‘Zero Kelvin’, as well as the 15th value staring for the bottom of the file.

Exercise 5: Saving outputs

This exercise will introduce you to the use of grep.

  • (a) In your home directory enter a folder called 'files'. Is there any file called 'output'?
  • (b) Type in the shell:
grep 'Zero Kelvin' file.txt | awk '{print $1}'
  • (c) Type in the shell:
grep 'Zero Kelvin' file.txt | awk '{print $1}' >> output
  • (d) Is there any file called 'output'?
  • (e) Now open the file called 'output'. What's inside?

Challenge

Try the challenge. After you are done send the result by email to your instructor or upload the challenge to the shared Google Drive folder: document

Session 4: ASE

In this session you will learn how to code in python and use ASE to visualize molecules and materials. The Atomistic Simulation Environment (ASE) is a set of tools and Python modules for setting up, manipulating, running, visualizing and analyzing atomistic simulations. The code is freely available under the GNU LGPL license. You need to keep these headers all through the tutorial

  #!/usr/bin/env python
  from ase import *
  from ase.visualize import view
  from ase.calculators.emt import EMT
  from ase.optimize import *
  from ase.io import *
  from ase.build import *
  from gpaw import *
  from ase.lattice.surface import *
  from time import sleep
  from utilities import *

Remember to "sudo refresh" twice your system.

Exercise 0: Use the #Hashtag

In this exercise you will learn the basics of Python coding.

  • (a) Make a folder named E4-0. Enter the folder and edit with vi a file called test.py with the header above. Add the following line (remember to include always the heading above)
print "Hello!"
  • (b) Save the changes of the file (:wq!) and in the shell type and explain what happens (here you are executing the file gpaw.py).
submit

PS: mind a out file will be created every time you submit

  • (c) Now edit the test file and add a hastag before the print statement:
#print "Hello!"
  • (d) Save the changes of the file (:wq!) and in the shell type and explain what happens (here you are executing the file gpaw.py). What is the use of #?
submit

Exercise 1: Visualizing Molecules

In this exercise you will learn the basics of ASE.

  • (a) Make a folder with your name. Enter the folder and edit with vi a file called gpaw.py with the header above. Add the following line (remember to include always the heading above)
atoms = molecule("H2O")
view(atoms)
  • (b) Save the changes of the file (:wq!) and in the shell type and explain what happens (here you are executing the file gpaw.py)
submit

at this point a small window should pop up. You can use the right click of the mouse to move the molecule. IN order to do this just right click and then move the mouse. The molecule should move.

  • (c) Lets place the molecule in a box. Go back to gpaw.py and add these lines before view(atoms). After that execute gpaw.py again. (remember to include always the heading above)
atoms.center(vacuum=6)

does the molecule looks different?

  • (d) Now try other molecules such as for example NH3 or HCl instead of water. Remember after you change the file you need to execute it by typing submit

Exercise 2: Visualizing More Molecules

In this exercise you will learn more advanced features of ASE:

  • (a) Make a folder with your name. Enter the folder and edit with vi a file called gpaw.py with the header above. The goal is to visualize the radical CH2. How would you do this?
  • (b) You can add molecules that are not in the database by specifying the coordinates. Use the following lines:
 atoms = Atoms('2H', positions=[(0., 0., 0.), (0., 0., 1.0)])
 view(atoms)
  • (c) Below are the coordinates for the radical CH2. Visualize the radical and indicate whether the geometry is linear or bent.
atoms = Atoms('CH2', positions=[     (.000000,     .000000,     .174343),
     (.000000,     .862232,    -.523029), (.000000,    -.862232,    -.523029)  ])

Exercise 3: Visualizing Molecules from File

You can visualize molecules from a text (.txt) or trajectory (.traj) file.

  • (a) Enter the files folder in your home directory, then type
ase gui file.txt
  • (b) In the same folder now type
ase gui file.traj
  • (c) you can also open a file inside a python script. Make a folder with your name. Enter the folder and edit with vi a file called gpaw.py with the header above. Also include
 atoms = read("/home/user/files/file.txt")
 view(atoms)

Challenge

Try the challenge. After you are done send the result by email to your instructor or upload the challenge to the shared Google Drive folder: document

Learning Goals

The learning goals of the part of the training are: document

Session 5: GPAW

In this session you will learn how to code in python and use GPAW in order to carry (we call this run) simulations of molecules and materials. GPAW is a quantum-mechanics code (QM, go and review the GenChem chapter that deals with this) that calculates the internal energy of molecules and materials. The code is freely available under the GNU LGPL license. You need to keep these headers (same as in the previous session) all through the tutorial

  #!/usr/bin/env python
  from ase import *
  from ase.visualize import view
  from ase.calculators.emt import EMT
  from ase.optimize import *
  from ase.io import *
  from ase.build import *
  from gpaw import *
  from ase.lattice.surface import *
  from time import sleep
  from utilities import *

Remember to "sudo refresh" twice your system and use a brand new shell after refreshing. Every exercise has a set of questions. You will have to answer those in the Results Worksheet, befor e the challenge.

Exercise 1: Optimizing a Molecule

In this exercise you will learn the basics of GPAW, that is, how to optimize the structure of a molecule. Optimizing is a math technique used to calculate the minimum of a function. Let's say you need to obtain the structure of a molecule, or material but you don't know fore sure how is going to be. What we do is start with a relatively bad geometry and let the software find the best one (the optimized geometry). Make a folder with named E5-1. Enter the folder and edit with vi a file called test.py with the header above. Add the following lines (remember to include always the heading above)

name='H2'
system = molecule(name)
system.center(vacuum=4)
calc=GPAW(txt=name+'.txt')
system.set_calculator(calc)
RUNFIRE(system,name,calc, 0.01, 1)

Now execute the python file by doing

submit
  • (a) Quickly in the same folder you should see a H2.txt and H2.traj files now, created after your executed the python script. Tail the txt file
tail -f H2.txt

Describe what happens in the Results Worksheet (just before each session challenge in the wikipedia).

  • (b) after the txt file stops growing (at this point the optimization is done), now vi the file and take a look at all the information inside.
vi H2.txt

From inside the file, describe (1) one term you understand the meaning of, and (2) one term you don't understand. Write all these results in the Results Worksheet (just before each session challenge in the wikipedia).

Exercise 2: Optimizing More Molecules

In this exercise you will learn the basics of GPAW, that is, how to optimize the structure of a molecule. Make a folder with named E5-2. Enter the folder and edit with vi a file called test.py with the header above. Add the following lines (remember to include always the heading above)

name='H2'
system = molecule(name)
system.center(vacuum=4)
calc=GPAW(txt=name+'.txt')
system.set_calculator(calc)
RUNFIRE(system,name,calc, 0.01, 3)

Now execute the python file by doing

submit
  • (a) Play with the code above. Do some changes: use steps=3 (this is the number 3 in the last line of the script) instead. Explain what happens in the Results Worksheet
  • (b) Play with the code above. Do some changes: use steps=1000 instead (again use 1000 instead of 3 in the last line of the script). Explain what happens in the Results Worksheet
  • (c) For the last case, visualize the trajectory:
ase gui H2.traj

you can right click on the mouse to move the molecule around. Write all these results in the Results Worksheet

Exercise 3: Analyzing the results of an Optimization

In this exercise you will learn how to analyze the result of a molecular optimization: Make a folder names E5-3. Enter the folder and edit with vi a file called test.py with the header above. Add the following lines (remember to include always the heading above)

name='HCl'
system = molecule(name)
system.center(vacuum=4)
calc=GPAW(txt=name+'.txt')
system.set_calculator(calc)
RUNFIRE(system,name,calc, 0.01, 1000)

Now execute the python file by doing

submit
  • (a) when the software stops working, visualize the result
ase gui HCl.traj

You can right click on the mouse to move the molecule. if you press the Control key and select two atoms you can calculate the distance between them. Write down the H-Cl distance in the Results Worksheet

  • (b) For the last case, calculate the internal energy of the molecule (review your chem notes to know what is internal energy) typing
energy

Write all these results in the Results Worksheet

Exercise 4: Optimizing Other Molecules

In this exercise you will use what you have learnt to optimize the structure of a molecule. Make a folder named E5-4. Enter the folder and edit with vi a file called test.py with the header above. Use the examples above to come with the code needed to optimize a NH3 molecule. Write down the code in the worksheet. Now execute the python file by doing

submit
  • (a) Visualize the molecule and calculate the H-N distance. Write all these results in the Results Worksheet
  • (b) Calculate the energy of the molecule. Write all these results in the Results Worksheet

Exercise 5: Making sure the simulation is finished

The goal is to run simulations of materials or molecules. For example, imagine a water molecule moving in space, until, the H-O bonds have the right distance as in a real water molecule. You start with a very bad molecules and GPAW will make it better. The problem is how to know whether the simulation is finished? The answer to this question is in the txt file.

  • (a) In your files folder you will find several txt files. Some of them are fully finished simulations other are not. Go to that folder and use the command
end

that will tell you if the txt file is done. Is you see a Timing word after the file means that the simulation is done. If you don't means it is not. indicate which files are finished and which are not.

Results Worksheet

Write down all answers for the exercise questions in this worksheet. After you are done send the result by email to your instructor or upload the file to the shared Google Drive folder: document

Challenge

Try the challenge. After you are done send the result by email to your instructor or upload the challenge to the shared Google Drive folder: document

Learning Goals

The learning goals of the part of the training are: document

Session 6: HPC Cluster

Thinks about all the simulations that you've been running in the last session using your personal computer. Do they take time to finish? You can do this faster by use supercomputers. In this session you will learn how to access and use the services of CUNY HPC, a supercomputer center in CUNY. In order to carry simulations we need supercomputer, that are powerful computers normally connected in parallel so that the simulations can run faster.

Exercise 0: Setting up the access to CUNY HPC

In this exercise you will set up the access to CUNY HPC. A high performance computer center at CUNY. You will make sure you can access the servers without password:

  • (a)Open Type in a shell
ssh-keygen -t rsa

type the password give by your instructor.

  • (b) Now, type in the shell:
cat $HOME/.ssh/id_rsa.pub | ssh daniel.torres@karle.csi.cuny.edu 'cat >> .ssh/authorized_keys'   
  • (c) Finally, type in the shell:
 cat $HOME/.ssh/id_rsa.pub | ssh daniel.torres@penzias.csi.cuny.edu 'cat >> .ssh/authorized_keys'     

c) Now, let's make sure it works. In a shell type:

tunelcunyhpc

d) Now, without closing the previous shell, open a fresh new shell and type:

cunyhpc

Using this you should be able to login into the cluster without password. To leave just type

exit

and that will close the connection to the remote computer.

Exercise 1: Listing the jobs at the queue

Supercomputers are user by many other users and normally there is a queue, which means, you send your simulation (we call this job) and it goes to the queue. Whenever is your turn the simulation will start running. Often times you send several jobs to the queue and one needs to see those jobs in waiting status or in running status, when the start running. In this exercise you will learn how to check the jobs running and waiting in the queue at the cluster:

  • (a) Access cuny hpc by doing this two steps process (you will have to do this every time you need to access the cluster). Open a new shell and type:
tunelcunyhpc

This is the tunnel window that needs to stay open all the time. Besides being open you should not use this window for anything else so make the window very small so that you don't get confused and use it by mistake. Now keeping the previous shell open, open a new shell and type:

 cunyhpc

this shell is the one that is actually connected to the supercomputer, by means of the tunnel connection.

  • (b) in order to list all the jobs in the qeueu for a given user you can use the command 'qcheck LASTNAME'. For example, type
 qcheck TORRES

How many jobs do you see? How many jobs are running with a 'R'? Write this in the Worksheet.

Exercise 2: Making yourself a home at CUNY HPC

In this exercise you will make your own folder at CUNY's supercomputer (the server is called PENZIAS)

  • (a) Access cuny hpc by doing this two steps process (you will have to do this every time you need to access the cluster). Open a new shell and type:
tunelcunyhpc

Now keeping the previous shell open, open a new shell and type:

 cunyhpc
  • (b) List the files in the $HOME directory by doing
 ls

write down the results in the WS.

  • (c) make a folder with your lastname
 mkdir lastname

where 'YOURLASTNAME' is your own lastname.

  • (d) enter your folder. You are only allowed to stay in this folder anytime you access cuny and this is called your home directory.

Exercise 3: Submitting a job

In this exercise you will learn how to submit and kill jobs in the cluster. First, access cuny hpc by doing this two steps process (you will have to do this every time you need to access the cluster). Open a new shell and type:

tunelcunyhpc

and in the other shell

cunyhpc
  • (a) In your home directory at CUNY HPC make a folder calles E6-3. In that folder, vi a file named script
vi script

Add the following text to the file. The spaces and character have to be exactly as below. Use your real lastname in 'YOURLASTNAME'

#!/bin/bash
#PBS -q production 
#PBS -N YOURLASTNAME
#PBS -l select=1:ncpus=1:mpiprocs=1
#PBS -V 
#PBS -l place=free
export PYTHONPATH=${PYTHONPATH}:$HOME/daniel/soft/scripts/
export GPAW_SETUP_PATH=${GPAW_SETUP_PATH}:$HOME/daniel/pp/
cd $PBS_O_WORKDIR
cat $PBS_NODEFILE
mpirun -np 1  gpaw-python *.py > out.log
  • (b) Now in the same folder vi a file calles E5-3.py and write the following lines:
#!/usr/bin/env python
from ase import *
from ase.visualize import view
from ase.calculators.emt import EMT
from ase.optimize import *
from ase.io import *
from ase.build import *
from gpaw import *
from ase.lattice.surface import *
from time import sleep
sleep(360)
  • (c) Now submit your job by doing:
submit
  • (d) Now check in the queue and make sure you see your job by doing:
qchek YOURLASTNAME

beware all these commands are key sensitive, what means you need to preserve the capital letters. You you wrote your lastname as TORRES you need to do qcheck TORRES and not Torres or torres. Write the ID, the first number you see when checking your job in the queue, in the WorkSheet.

  • (e) Now kill your job by doing
qdel ID

where ID is the first number you see when checking your job in the queue

Exercise 4: Submitting another job

Let's do it again. The goal of this exercise is to practicing submitting jobs and killing jobs at CUNY. Mind that each job needs basically two files to work: a script file (which sends the job to the queue) and a py file (a python file that runs the simulation). After that you use submit to send the job and qdel to kill it, if you need to.

  • (a) access CUNYHPC and make a folder called E6-4.
  • (b) In that folder, bring the same script file you used in the previous exercise.
  • (c) In the same folder, vi a python file called E6-4.py with the following code:
#!/usr/bin/env python
from ase import *
from ase.visualize import view
from ase.calculators.emt import EMT
from ase.optimize import *
from ase.io import *
from ase.build import *
from gpaw import *
from ase.lattice.surface import *
from time import sleep
sleep(200)
print "Hello"
  • (c) Now submit your job by doing:
submit
  • (d) Now check in the queue and make sure you see your job by doing:
qchek YOURLASTNAME

Write the ID, the first number you see when checking your job in the queue, in the WorkSheet.

  • (e) Now kill your job by doing
qdel ID

where ID is the first number you see when checking your job in the queue

Exercise 5: Submitting a simulation

The goal here is to send a simulation to CUNY, the same simulations you did in the previous exercises. Make sure you review the following training session.

  • (a) Access CUNYHPC; make a folder called E6-5.
  • (b) Copy the script file from any of your previous exercises. PS the scrips is spelled out in Exercise 3.
  • (c) create a python file called E6-5.py and there write the code to optimize the structure of N2.
  • (d) submit the job to the queue (its the command submit)
  • (e) After the job is running follow the output and make sure it grows and the simulation works properly.
  • (f) After the simulation has finished, calculate and write down in the WS the energy of the molecule.

Results Worksheet

Write down all answers for the exercise questions in this worksheet. After you are done send the result by email to your instructor or upload the file to the shared Google Drive folder: document

Challenge

Try the challenge. After you are done send the result by email to your instructor or upload the challenge to the shared Google Drive folder: document

Learning Goals

The learning goals of the part of the training are: document


Advanced Sessions

These are a few advanced sessions. Mind to sudo refresh twice before trying any of the sessions

How to make your own USB Linux Key

The USB linux key is a debian-based Live (Jessie) Linux distribution that is made to run with your computer (with the help of a USB wifi key) without affecting any of your personal files. This work in order to make you own USB linux with your USB key (has to be bigger than 10GB) or even to restore the USB linux given to you. You need to follow these steps, and allocate at least 2hs of time:

  • You are about to replicate your OLD Linux USB key into a NEW USB key. Now open a shell, type the command below and follow the instruction
 sudo replicate
  • The replication script will reboot the system now. At this point, when the computer starts you want to start using the NEW usb key, so remove the old one and leave the new one in. After that, open a shell and type the following commands and follow the instructions:
data=$(for devlink in /dev/disk/by-id/usb*; do readlink -f ${devlink}; done | head -n 1)
sudo mkdir /mnt/data ; sudo mount ${data}3 /mnt/data ; sudo bash /mnt/data/startup
  • After the system reboot type:
sudo setup

at this point you should be all set!

Get and put files into/from CUNY HPC

From your local computer (the USB key), you can use the command

sftpcunyhp

that would let you in into the cluster. After that you need to move yourself into the folder that contains the file you want to get/put. Finally the comands

get
put

Get files from the cluster and puts files into the cluster. In SFTP mode you can use the normal commands:

ls
cd

to list files and enter or leave folder.

Extract the coordinates

you can use the function coordinates. For example

system=read(file.traj)
coordinates(system)

when you execute the python script the coordinates and labels of the traj file will be printed

Create an xcrysden file

you can use the function toxcrysden. For example

name='HCl'
system = molecule(name)
system.center(vacuum=4)
toxcrysden(system)

This will create a .xsf file that can be open in xcrysden. Top open the file created you just need to use

xcrysden nameoffile

Change the label of an atom

you can use the function changelabel. For example

system=read(file.traj)
index=2
changelabel(system,index,'Cu') # this changes the label of index=2 into 'Cu'

Assign a magnetic moment to an atom

you can use the function changelabel. For example

system=read(file.traj)
index=1
mom=2
system[index].magmom=mom
# this assigns a magnetic moment of 2 into the atom with index=1

Calculate the magnetic moment of a simulation

you can simply type the command

mom

Obtain direct coordinates

you can use the function directcoordinates. For example

system=read(file.traj)
directcoordinates(system)

Freeze the last layer of a slab

you can use the function FreezLastLayer. For example

system=read(file.traj)
FreezLastLayer(system)

Calculate the WorkFunction of a slab

you can use the function called workfunction to obtain the WF value and the plot. You need a gpw file to be read, lets say the name is file.gpw

name='file'
workfunction(name)

Calculate the Magnetization Density of a system

You need a gpw file to be read, lets say the name is file.gpw

name='file'
getmagnetization(name)

Calculate the DOS(Density of states) of a system

You need a gpw file to be read, lets say the name is file.gpw

name='file'
label='spd' # This refers to the s, p and d orbitals to be computed
atoms=[] # if empty it calculates DOS for all atoms, if you use [1] it will calculate DOS for the atom #1
LDOS(file, label, atoms)

How to slice up a .cube file

You can use the following script

#!/usr/bin/env python
from gpawscripts import *
cube2plot('Co.cube', 'Z', 2, 'Co2Layer.png', (2,2,1))  # Co.cube is the cube file, Z is the direction to slice (parallel to the XY plane) and 2 is the index of the atom in the plane to slice, Co2Layer.png is the name of the image that will be generate. (2,2,1) is the replication of the cell

The different queues in the cluster

in your script file for CUNY HPC you have a line

#PBS -q production

This will send your job to the queue and the job will start running only when there is space at the cluster. If you use

#PBS -q interactive

the job will start running right away, BUT it will only run for 15 mins. You use the interactive queue to do small and quick testing

What to do if the energy does not converge

It is very common to run into convergence issued. You can fix these by using the function convergeEnergy. For example

name='Cu'
system = molecule(name)
system.center(vacuum=4)
calc=GPAW(txt=name+'.txt')
beta=[0.03, 0.02, 0.01 ]
nmaxold=[3,2,1]
convergeEnergy(system, calc, beta, nmaxold, [100], 600, name)

The result of this is a set of simulation with different beta and nmaxold, and only a few combinations would converge. Once you figure out the combination then you can resubmit with these values

name='Cu'
system = molecule(name)
system.center(vacuum=4)
calc=GPAW(txt=name+'.txt')
calc.set(mixer=MixerSum(0.03, 3, 100), maxiter=600)
RUNFIRE(atoms,name,calc, 0.01, 1000)