[gpaw-users] how to explicitly set occupation numbers
Rolf Wuerdemann
rowue at digitalis.org
Mon Jul 23 16:14:33 CEST 2012
On Fri, 20 Jul 2012 14:51:51 -0700, Joel Varley <jvarley at stanford.edu>
wrote:
> Hi,
re ....
> I saw that this question was asked before on the forums but never got
> directly answered as far as I could tell. I imagine there a way to
> manually set the electronic occupations, and could someone please give
> an example of how to do this for a spin-polarized and non-spin
> polarized system? Also once these values are set, does another keyword
> need to be used to constrain the specified occupations (i.e.
> fixmagmom=True or something similar), or does it automatically stay
> with those occupations if they are initially specified?
I'll give you a small piece of code I use for fixocc calcs:
.
.
.
from gpaw.occupations import FixedOccupations
.
.
.
iocc=[]
for occ in options.fixed_occupations.split(","):
tocc = [0] * options.bands
for i,locc in enumerate(occ.split(":")):
tocc[i] = float(locc)
iocc.append(tocc)
c.set(occupations=FixedOccupations(iocc))
if options.spinpol:
c.set(spinpol=True)
options.occupations is a 2D array, where the occupations for the channels
are entered as in 1:1:1:0:0 (spin-paired) or 1:1:1:0:0,1:1:0:0:0 (spin
polarized)
options.bands gives to number of bands I want to work on
options.spinpol is bool - I think you can guess its meaning
fixmagmom is set automatic (AFAIR) you only have to set spinpol or not
You should check if the rank of your array suits you spin-behaviour
like:
if len(iocc) == 2 and not options.spinpol:
raise ValueError(SOME_ANOYING_MESSAGE)
elif len(iocc) == 1 and options.spinpol:
raise ValueError(AN_OTHER_ANOYING_MESSAGE)
> Thanks,
> Joel
Kind,
Rolf
More information about the gpaw-users
mailing list