[ase-users] getting Hamiltonian and overlap matrices from NWChem

Simon Rittmeyer simon.rittmeyer at tum.de
Fri Jun 30 11:34:28 CEST 2017


Hi Panu,

as Ivan already pointed out, this mostly seems to be an issue with your python path.

Does your current pythonpath contain "/Users/Panu/Dropbox/Nanosciences/Codes/ASE/ase/"? Or did you install this branch via the setup.py script?
 
If not, then of course your python interpreter will not be able to find the respective modules but always resort to the ase version you probably installed beforehand. You then have two possibilities:

1) To find out, which files your python interpreter actually reads, type

	python -c "import ase; print(ase.__file__)

on the command line. This should point to the __init__.pyc in the above mentioned folder. If it does, but you still you cannot your calculator, you should check whether the files are actually there.

If, however, the correct __init__.pyc is not used, please check your PYTHONPATH environment variable. You can do this via 

	echo $PYTHONPATH

on the command line. If the directory mentioned above is not part of it, then add it. Again, this can be done via one line in your ~/.bashrc file (or on a Mac, probably rather ~/.bash_profile):

	export PYTHONPATH=/Users/Panu/Dropbox/Nanosciences/Codes/ASE/ase/:$PYTHONPATH

Note that you'll have to source the ~/.bashrc file first to apply the changes (or open a new terminal):

	source ~/.bashrc

Then check again, whether your PYTHONPATH contains the correct path.

2) An alternative to adjusting the PYTHONPATH would be to change to your kitnwchem branch and then run the setup.py file. This will install the current branch user-wide (which is presumably want you want anyway).

	cd /Users/Panu/Dropbox/Nanosciences/Codes/ASE/ase
	git checkout kitnwchem
	python setup.py install --user


Hope this helps.

 
Best,
Simon.

Simon P. Rittmeyer, M.Sc.

Technical University of Munich (TUM)
Department of Chemistry
Chair for Theoretical Chemistry

Lichtenbergstr. 4
85747 Garching, Germany

Tel: +49 89 289 13810
Room CH62110

simon.rittmeyer at tum.de
https://www.th4.ch.tum.de

> Am 29.06.2017 um 22:11 schrieb Panu Sam-Ang via ase-users <ase-users at listserv.fysik.dtu.dk>:
> 
> Hi Ivan,
> 
> Thank you for your answer.  I followed your instruction and I still got the same error message.  Below is the screenshot of the result:
> 
> <Screen Shot 2017-06-29 at 3.08.09 PM.png>
> 
> I also tried to switched branches again and got the same thing:
> 
> <Screen Shot 2017-06-29 at 4.09.47 PM.png>
> 
> <Screen Shot 2017-06-29 at 4.10.25 PM.png>
> 
> Do you know why this is so?
> 
> Best,
> Panu
> 
> On Thu, Jun 29, 2017 at 12:29 PM, Kondov, Ivan (SCC) <ivan.kondov at kit.edu> wrote:
> Hi Panu,
> 
> 
> you do not have to configure new PYTHONPATH if you have any git branch of ASE on your computer, then you should do:
> 
> 
> git checkout master
> git checkout -b kitnwchem
> 
> git remote add ikondov_ase https://gitlab.com/ikondov/ase.git
> 
> git pull ikondov_ase kitnwchem
> 
> You can switch any time to your master branch with "git checkout master"
> 
> If you have cloned kitnwchem branch directly into a new folder named 'kitnwchem', for example with 
> 
> 
> git clone https://gitlab.com/ikondov/ase kitnwchem
> 
> 
> then you should set PYTHONPATH correspondingly. 
> 
> Best regards,
> 
> Ivan
> 
>  
> Von: Panu Sam-Ang <panu.sam-ang at stonybrook.edu>
> Gesendet: Mittwoch, 28. Juni 2017 22:27
> An: Kondov, Ivan (SCC)
> Cc: ase-users at listserv.fysik.dtu.dk
> Betreff: Re: [ase-users] getting Hamiltonian and overlap matrices from NWChem
>  
> Hi Ivan,
> 
> I forked your ASE project and cloned it to my computer. I then did "$git checkout kitnwchem" to switch/get the kitnwchem branch (is this correct)?    I saved your script in the previous email and saved it as "NH3.py" and ran it using "$python NH3.py$ and got this import error:
> 
> Panus-MacBook-Air:ASE Panu$ python NH3.py
> Traceback (most recent call last):
>   File "NH3.py", line 2, in <module>
>     from ase.calculators.nwchem import KITnwchem
> ImportError: cannot import name KITnwchem
> 
> Could you tell me how to fix this?   I am very new to git and ASE and not sure what I did wrong here.   I am guessing I have to set the new path to ASE in kitnwchem, is this correct? 
> Thank you.
> 
> Best,
> Panu 
> 
> On Wed, Jun 21, 2017 at 12:46 PM, Kondov, Ivan (SCC) <ivan.kondov at kit.edu> wrote:
> Dear Panu,
> 
>  
> 
> you can check out this branch
> 
>  
> 
> https://gitlab.com/ikondov/ase/tree/kitnwchem
> 
>  
> 
> For historical reasons the mentioned methods are in a derived class which has a slightly different parameter keys. Here a simple use:
> 
>  
> 
> from ase.calculators.nwchem import KITnwchem
> 
> from ase.build import molecule
> 
> mol = molecule('NH3')
> 
> params = {
> 
>     'title': 'ammonia',
> 
>     'task': 'energy',
> 
>     'basis set name': 'sto-3g',
> 
>     'total charge': 0,
> 
>     'multiplicity': 1,
> 
>     'use dft': True,
> 
>     'density functional': 'b3lyp'
> 
> }
> 
> calc = KITnwchem(**params)
> 
> mol.set_calculator(calc)
> 
> print(calc.get_mos(mol))
> 
> print(calc.get_fock_overlap())
> 
>  
> 
> I think this can be used for the time being. I can migrate the relevant two or three methods to the base class but for that I will need time. Please let me know.
> 
>  
> 
> Best regards,
> 
> Ivan
> 
>  
> 
>  
> 
> From: Panu Sam-Ang [mailto:panu.sam-ang at stonybrook.edu] 
> Sent: Tuesday, June 20, 2017 5:22 PM
> To: Kondov, Ivan (SCC)
> 
> 
> Cc: ase-users at listserv.fysik.dtu.dk
> Subject: Re: [ase-users] getting Hamiltonian and overlap matrices from NWChem
> 
>  
> 
> Thank you, Ivan.  Could you share the code? 
> 
>  
> 
> Best,
> 
> Panu
> 
>  
> 
> On Tue, Jun 20, 2017 at 6:11 AM, Kondov, Ivan (SCC) <ivan.kondov at kit.edu> wrote:
> 
> Dear Panu,
> 
>  
> 
> you only need the eigenvectors (the molecular orbitals) and the eigenvalues (molecular orbital energies) to restore the fock matrix and the overlap matrix. To make nwchem write them out you have to put the line
> 
>  
> 
> print "final vectors analysis" "final vectors"
> 
>  
> 
> in the dft section of the input. See
> 
>  
> 
> http://www.nwchem-sw.org/index.php/Release66:Hartree-Fock_Theory_for_Molecules#Printing_Information_from_the_SCF_Module
> 
>  
> 
> I have an own code for all this including reading the orbitals with the ASE nwchem calculator. I can share it if you like.
> 
>  
> 
> Best regards,
> 
> Ivan
> 
>  
> 
>  
> 
>  
> 
> From: ase-users-bounces at listserv.fysik.dtu.dk [mailto:ase-users-bounces at listserv.fysik.dtu.dk] On Behalf Of Panu Sam-Ang via ase-users
> Sent: Tuesday, June 06, 2017 10:19 PM
> To: Ask Hjorth Larsen
> Cc: ase-users at listserv.fysik.dtu.dk
> Subject: Re: [ase-users] getting Hamiltonian and overlap matrices from NWChem
> 
>  
> 
> Thank you, Ask.  That's helpful!
> 
>  
> 
> On Tue, Jun 6, 2017 at 4:15 PM, Ask Hjorth Larsen <asklarsen at gmail.com> wrote:
> 
> Hi Panu,
> 
> 2017-06-06 21:38 GMT+02:00 Panu Sam-Ang <panu.sam-ang at stonybrook.edu>:
> > Hi Ask,
> >
> > Thank you for your suggestion.  I just got NWChem installed on my laptop and
> > haven't really used it before.  I thought ase.calculators.nwchem or
> > ase.calculators.interface would have a function that can do that.  But I
> > guess I have to write my own script?
> 
> ASE mostly does energies/forces and the more universal electronic
> structure quantities like KS eigenvalues and occupation numbers.  Many
> codes do not establish the Hamiltonian explicitly, so this is not part
> of the standard interface.  You can probably pass any keywords to
> NWChem through the standard interface, and then manually extract what
> you need from the files saved.  (One could add special functions for
> getting the Hamiltonian to the calculator to ease this in the future.)
> 
> Best regards
> Ask
> 
> 
> 
> 
> >
> > Best,
> > Panu
> >
> > On Tue, Jun 6, 2017 at 12:31 PM, Ask Hjorth Larsen <asklarsen at gmail.com>
> > wrote:
> >>
> >> Hi Panu,
> >>
> >> How would you get these from NWChem normally?  I guess the way is to
> >> enable a keyword so it is saved to a file, and then read the file
> >> manually from the script.
> >>
> >> Best regards
> >> Ask
> >>
> >> 2017-06-05 21:48 GMT+02:00 Panu Sam-Ang via ase-users
> >> <ase-users at listserv.fysik.dtu.dk>:
> >> > Hello,
> >> >
> >> > Does anyone know how to get the Hamiltonian and overlap matrices from
> >> > using
> >> > NWChem as the calculator?   What is the command?
> >> >
> >> > Thank you,
> >> > Panu
> >> >
> >> > _______________________________________________
> >> > ase-users mailing list
> >> > ase-users at listserv.fysik.dtu.dk
> >> > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
> >
> >
> 
>  
> 
>  
> 
> 
> 
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users




More information about the ase-users mailing list