jkitchin / vasp

New ASE compliant Python interface to VASP
122 stars 58 forks source link

matplotlib #10

Closed TorresAWS closed 2 years ago

TorresAWS commented 8 years ago

Hi I'm trying to use this module for the first time and while installing and testing I got this 'ImportError: No module named matplotlib' error message. Is there a way to bypass this without installing matplotlib? My python file:

!/usr/bin/env python

from ase import from ase.visualize import view from ase.lattice.surface import from ase.calculators.vasp import Vasp from ase.lattice import bulk from vasp import Vasp

system = Atoms('H2', positions=[[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]) system.center(vacuum=6) calc = Vasp(prec='Accurate', xc='PW91', kpts=(1, 1, 1), encut=400,nelm=250,sigma=0.01,ediff=1E-5, ibrion=2, edifg= -0.01, nsw=10, lreal=False)

jkitchin commented 8 years ago

at the moment it isn't possible. why can't you install matplotlib?

also, you should either use

from ase.calculators.vasp import Vasp

or

from vasp import Vasp

but not both.

Your script is setup for the first of these, and won't work with the second which requires a directory label for the first argument.

dtorresrangel writes:

Hi I'm trying to use this module for the first time and while installing and testing I got this 'ImportError: No module named matplotlib' error message. Is there a way to bypass this without installing matplotlib? My python file:

!/usr/bin/env python

from ase import from ase.visualize import view from ase.lattice.surface import from ase.calculators.vasp import Vasp from ase.lattice import bulk from vasp import Vasp

system = Atoms('H2', positions=[[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]) system.center(vacuum=6) calc = Vasp(prec='Accurate', xc='PW91', kpts=(1, 1, 1), encut=400,nelm=250,sigma=0.01,ediff=1E-5, ibrion=2, edifg= -0.01, nsw=10, lreal=False)


You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/jkitchin/vasp/issues/10

Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu

TorresAWS commented 8 years ago

Hi your VASP module is indeed very interesting and useful, so congrats! The thing is that sometimes some HPC systems have to graphical interface to render plots. A way to avoid having to use matplotlib in your VASP module, maybe for a future version, would make it even more accessible. As an example the GPAW community can still use GPAW/ASE without having to have matplotlib installed. Regards

jkitchin commented 8 years ago

matplotlib is only imported in bandstructure.py

you can comment out this line

import bandstructure

in vasp.py

to avoid it.

On the other hand you can install matplotlib and set the backend to Agg so it will work on compute nodes with no display.

Here is the line in bandstructure.py

turn off if in the queue.

if 'PBS_O_WORKDIR' in os.environ: import matplotlib matplotlib.use('Agg')

import matplotlib.pyplot as plt

One day I will figure out a better solution, but for now those are the things you could do.

dtorresrangel writes:

Hi I'm trying to use this module for the first time and while installing and testing I got this 'ImportError: No module named matplotlib' error message. Is there a way to bypass this without installing matplotlib? My python file:

!/usr/bin/env python

from ase import from ase.visualize import view from ase.lattice.surface import from ase.calculators.vasp import Vasp from ase.lattice import bulk from vasp import Vasp

system = Atoms('H2', positions=[[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]) system.center(vacuum=6) calc = Vasp(prec='Accurate', xc='PW91', kpts=(1, 1, 1), encut=400,nelm=250,sigma=0.01,ediff=1E-5, ibrion=2, edifg= -0.01, nsw=10, lreal=False)


You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/jkitchin/vasp/issues/10

Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu

TorresAWS commented 8 years ago

Hi that trick actually worked perfectly well. Thank for your help!! Daniel

veenum commented 5 years ago

Hi, I was trying to run the ase python scripts from dft-book vasp directory. But I didn't successfully run the scripts, I have used both pyhton2 and python3 for my calculations. and I have successfully installed the vasp and in bashfile made the changes as: export PYTHONPATH='/home/veenu/Downloads/ase-3.17.0/':$PYTHONPATH export PATH='/home/veenu/Downloads/ase-3.17.0/bin':$PATH export vasp='/home/veenu/vasp/vasp.5.4.1/bin/vasp_std'

my file as: from ase import Atoms, Atom from ase.calculators.vasp import Vasp co = Atoms([Atom('C', [0, 0, 0]), Atom('O', [1.2, 0, 0])], cell=(6., 6., 6.)) calc = Vasp(command='/home/veenu/vasp/vasp.5.4.1/bin/vasp_std' '/home/veenu/simple-co', # output dir xc='pbe', # the exchange-correlation functional nbands=6, # number of bands encut=350, # planewave cutoff ismear=1, # Methfessel-Paxton smearing sigma=0.01, # very small smearing factor for a molecule atoms=co) print('energy = {0} eV'.format(co.get_potential_energy())) print(co.get_forces())

and obtaining the error as: Traceback (most recent call last): File "script-19.py", line 13, in atoms=co) File "/home/veenu/Downloads/ase-3.17.0/ase/calculators/vasp/vasp.py", line 73, in init self.set(**kwargs) File "/home/veenu/Downloads/ase-3.17.0/ase/calculators/vasp/create_input.py", line 899, in set raise TypeError('Parameter not defined: ' + key) TypeError: Parameter not defined: command

and also whenever I used the from vasp import Vasp then the error comes: Traceback (most recent call last): File "script-19.py", line 2, in from vasp import Vasp ImportError: No module named vasp

kindly give your valuable suggestions. Thank you