info:dacapo

# Jacapo

Python interface to the Fortran DACAPO code

## functions

read(ncfile)

read(ncfile) return atoms and calculator from ncfile

>>> atoms, calc = read('co.nc')

## class

class Jacapo
Python interface to the Fortran DACAPO code

### Jacapo

__init__(self, nc='out.nc', outnc=None, debug=30, stay_alive=False, **kwargs)

#### Parameters

Name Type Description
nc string output netcdf file, or input file if nc already exists
outnc string output file. by default equal to nc
debug integer logging debug level

#### Valid kwargs

Name Type Description
atoms ASE.Atoms instance atoms is an ase.Atoms object that will be attached to this calculator.
pw integer sets planewave cutoff
dw integer sets density cutoff
kpts iterable set chadi-cohen, monkhorst-pack kpt grid,
e.g. kpts = (2,2,1) or explicit list of kpts
spinpol Boolean sets whether spin-polarization is used or not.
fixmagmom float set the magnetic moment of the unit cell. only used in spin polarize calculations
ftfloatset the Fermi temperature used in occupation smearing
xcstringset the exchange-correlation functional. one of ['PZ','VWN','PW91','PBE','RPBE','revPBE'],
dipolebooleanturn the dipole correction on (True) or off (False)
dictionary dictionary of parameters to fine-tune behavior
  {'status':False,
'mixpar':0.2,
'initval':0.0,
'position':None}
nbandsintegerset the number of bands
symmetryBooleanTurn symmetry reduction on (True) or off (False)
stressBooleanTurn stress calculation on (True) or off (False)
debug level for logging could be something like logging.DEBUG or an integer 0-50. The higher the integer, the less information you see set debug level (0 = off, 10 = extreme)

Initialize the Jacapo calculator Modification of the nc file only occurs at calculate time if needed

>>> calc = Jacapo('CO.nc')

reads the calculator from CO.nc if it exists or minimally initializes CO.nc with dimensions if it does not exist.

>>> calc = Jacapo('CO.nc', pw=300)

reads the calculator from CO.nc or initializes it if it does not exist and changes the planewave cutoff energy to 300eV

 >>> atoms = Jacapo.read_atoms('CO.nc')

returns the atoms in the netcdffile CO.nc, with the calculator attached to it.

>>> atoms, calc = read('CO.nc')

### __str__

str(self) pretty-print the calculator and atoms.

we read everything directly from the ncfile to prevent triggering any calculations

### atoms_are_equal

atoms_are_equal(self, atoms) comparison of atoms to self.atoms using tolerances to account for float/double differences and float math.

### attach_child

attach_child(self, child)

### calculate

calculate(self) run a calculation.

you have to be a little careful with code in here. Use the calculation_required function to tell if a calculation is required. It is assumed here that if you call this, you mean it.

### calculation_required

calculation_required(self, atoms=None, quantities=None) determines if a calculation is needed.

return True if a calculation is needed to get up to date data. return False if no calculation is needed.

quantities is here because of the ase interface. ==== delete_ncattdimvar —- delete_ncattdimvar(self, ncf, ncattrs=None, ncdims=None, ncvars=None) helper function to delete attributes, dimensions and variables in a netcdffile

this functionality is not implemented for some reason in netcdf, so the only way to do this is to copy all the attributes, dimensions, and variables to a new file, excluding the ones you want to delete and then rename the new file.

if you delete a dimension, all variables with that dimension are also deleted.

### execute_external_dynamics

execute_external_dynamics(self, nc=None, txt=None, stoppfile='stop', stopprogram=None) Implementation of the stay alive functionality with socket communication between dacapo and python. Known limitations: It is not possible to start 2 independent Dacapo calculators from the same python process, since the python PID is used as identifier for the script[PID].py file.

### execute_parent_calculation

execute_parent_calculation(self) Implementation of an extra level of parallelization, where one jacapo calculator spawns several dacapo.run processes. This is used for NEBs parallelized over images.

get_ados(self, **kwargs)

attempt at maintaining backward compatibility with get_ados returning data

Now when we call calc.get_ados() it will return settings,

get_ados_data(self, atoms, orbitals, cutoff, spin) get atom projected data

:Parameters:

atoms

    list of atom indices (integers)

orbitals

    list of strings
['s','p','d'],
['px','py','pz']
['d_zz', 'dxx-yy', 'd_xy', 'd_xz', 'd_yz']

cutoff : string

  cutoff radius you want the results for 'short' or 'infinite'

spin

  : list of integers
spin you want the results for
[0] or [1] or [0,1] for both

returns (egrid, ados) egrid has the fermi level at 0 eV

### get_all_eigenvalues

get_all_eigenvalues(self, spin=0) return all the eigenvalues at all the kpoints for a spin.

:Parameters:

spin : integer

  which spin the eigenvalues are for

### get_ascii_debug

get_ascii_debug(self) Return the debug settings in Dacapo

### get_atoms

get_atoms(self) return the atoms attached to a calculator()

### get_bz_k_points

get_bz_k_points(self) return list of kpoints in the Brillouin zone

### get_calculate_stress

get_calculate_stress(self) return whether stress is calculated or not

### get_cd

get_cd = get_charge_density(self, spin=0)

### get_charge_density

get_charge_density(self, spin=0) return x,y,z,charge density data

x,y,z are grids sampling the unit cell cd is the charge density data

netcdf documentation::

ChargeDensity(number_of_spin,

              hardgrid_dim3,
hardgrid_dim2,
hardgrid_dim1)
ChargeDensity:Description = "realspace charge density" ;
ChargeDensity:unit = "-e/A^3" ;

#### get_charge_mixing

get_charge_mixing(self) return charge mixing parameters

### get_convergence

get_convergence(self) return convergence settings for Dacapo

### get_debug

get_debug(self) Return the python logging level

### get_decoupling

get_decoupling(self) return the electrostatic decoupling parameters

### get_dipole

get_dipole(self) return dictionary of parameters if the DipoleCorrection was used

### get_dipole_moment

get_dipole_moment(self, atoms=None) return dipole moment of unit cell

Defined by the vector connecting the center of electron charge density to the center of nuclear charge density.

Units = eV*angstrom

1 Debye = 0.208194 eV*angstrom get_dw(self) return the density wave cutoff get_ef = get_fermi_level(self) get_effective_potential(self, spin=1) returns the realspace local effective potential for the spin. the units of the potential are eV

:Parameters:

spin : integer

   specify which spin you want, 0 or 1

get_eigenvalues(self, kpt=0, spin=0) return the eigenvalues for a kpt and spin

:Parameters:

kpt : integer

  index of the IBZ kpoint

spin : integer

  which spin the eigenvalues are for

get_electronic_minimization(self) get method and diagonalizations per band for electronic minimization algorithms get_electronic_temperature = get_ft(self)

### get_electrostatic_potential

get_electrostatic_potential(self, spin=0) get electrostatic potential

Netcdf documentation::

double ElectrostaticPotential(number_of_spin,

                              hardgrid_dim3,
hardgrid_dim2,
hardgrid_dim1) ;
ElectrostaticPotential:
Description = "realspace local effective potential" ;
unit = "eV" ;

### get_ensemble_coefficients

get_ensemble_coefficients(self) returns exchange correlation ensemble coefficients

### get_esp

get_esp = get_electrostatic_potential(self, spin=0) get_external_dipole(self) return the External dipole settings

### get_extpot

get_extpot(self) return the external potential set in teh calculator

### get_extracharge

get_extracharge(self) Return the extra charge set in teh calculator

### get_fermi_level

get_fermi_level(self) return Fermi level

### get_fftgrid

get_fftgrid(self) return soft and hard fft grids

### get_fixmagmom

get_fixmagmom(self) returns the value of FixedMagneticMoment

### get_forces

get_forces(self, atoms=None) Calculate atomic forces

### get_ft

get_ft(self) return the FermiTemperature used in the calculation

### get_ibz_k_points

get_ibz_k_points = get_ibz_kpoints(self)

### get_ibz_kpoints

get_ibz_kpoints(self) return list of kpoints in the irreducible brillouin zone

### get_k_point_weights

get_k_point_weights(self) return the weights on the IBZ kpoints

### get_kpts

get_kpts(self) return the BZ kpts

### get_kpts_type

get_kpts_type(self) return the kpt grid type

### get_magnetic_moment

get_magnetic_moment(self, atoms=None) calculates the magnetic moment (Bohr-magnetons) of the supercell

### get_magnetic_moments

get_magnetic_moments(self, atoms=None) return magnetic moments on each atom after the calculation is run

### get_mdos

get_mdos(self) return multicentered projected dos parameters

### get_mdos_data

get_mdos_data(self, spin=0, cutoffradius='infinite') returns data from multicentered projection

returns (mdos, rotmat)

the rotation matrices are retrieved from the text file. I am not sure what you would do with these, but there was a note about them in the old documentation so I put the code to retrieve them here. the syntax for the return value is: rotmat[atom#][label] returns the rotation matrix for the center on the atom# for label. I do not not know what the label refers to.

### get_nbands

get_nbands(self) return the number of bands used in the calculation get_nc(self) return the ncfile used for output get_ncoutput(self) returns the control variables for the ncfile get_number_of_bands = get_nbands(self) get_number_of_electrons = get_valence(self, atoms=None) get_number_of_grid_points(self) return soft fft grid get_number_of_iterations(self) get_number_of_spins(self) if spin-polarized returns 2, if not returns 1 get_occ = get_occupation_numbers(self, kpt=0, spin=0) get_occupation_numbers(self, kpt=0, spin=0) return occupancies of eigenstates for a kpt and spin

:Parameters:

kpt : integer

  index of the IBZ kpoint you want the occupation of

spin : integer

  0 or 1

get_occupationstatistics(self) return occupation statistics method get_potential_energy(self, atoms=None, force_consistent=False) return the potential energy. get_pseudo_wave_function(self, band=0, kpt=0, spin=0, pad=True) return the pseudo wavefunction get_pseudopotentials(self) get pseudopotentials set for atoms attached to calculator get_psp(self, sym=None, z=None) get the pseudopotential filename from the psp database

:Parameters:

sym : string

  the chemical symbol of the species

z : integer

  the atomic number of the species

you can only specify sym or z. Returns the pseudopotential filename, not the full path. get_psp_nuclear_charge(self, psp) get the nuclear charge of the atom from teh psp-file.

This is not the same as the atomic number, nor is it necessarily the negative of the number of valence electrons, since a psp may be an ion. this function is needed to compute centers of ion charge for the dipole moment calculation.

We read in the valence ion configuration from the psp file and add up the charges in each shell. get_psp_valence(self, psp) get the psp valence charge on an atom from the pspfile. get_pw(self) return the planewave cutoff used get_reciprocal_bloch_function(self, band=0, kpt=0, spin=0) return the reciprocal bloch function. Need for Jacapo Wannier class. get_reciprocal_fft_index(self, kpt=0) return the Wave Function FFT Index get_scratch(self) finds an appropriate scratch directory for the calculation get_spin_polarized(self) Return True if calculate is spin-polarized or False if not get_spinpol(self) Returns the spin polarization setting, either True or False get_status(self) get status of calculation from ncfile. usually one of: 'new', 'aborted' 'running' 'finished' None get_stay_alive(self) return the stay alive settings get_stress(self, atoms=None) get stress on the atoms.

you should have set up the calculation to calculate stress first.

returns [sxx, syy, szz, syz, sxz, sxy] get_symmetry(self) return the type of symmetry used get_txt(self) return the txt file used for output get_ucgrid(self, dims) Return X,Y,Z grids for uniform sampling of the unit cell

dims = (n0,n1,n2)

n0 points along unitcell vector 0 n1 points along unitcell vector 1 n2 points along unitcell vector 2 get_valence(self, atoms=None) return the total number of valence electrons for the atoms. valence electrons are read directly from the pseudopotentials.

### set_nc

#### set_nc(self, nc='out.nc')

set filename for the netcdf and text output for this calculation

:Parameters:

nc : string

  filename for netcdf file


if the ncfile attached to the calculator is changing, the old file will be copied to the new file if it doesn not exist so that all the calculator details are preserved. Otherwise, the

if the ncfile does not exist, it will get initialized.

the text file will have the same basename as the ncfile, but with a .txt extension.

### set_ncoutput

#### set_ncoutput(self, wf=None, cd=None, efp=None, esp=None)

set the output of large variables in the netcdf output file

:Parameters:

wf : string

  controls output of wavefunction. values can
be 'Yes' or 'No'

cd : string

  controls output of charge density. values can
be 'Yes' or 'No'

efp : string

  controls output of effective potential. values can
be 'Yes' or 'No'

esp : string

  controls output of electrostatic potential. values can
be 'Yes' or 'No'

set_occupationstatistics(self, method) set the method used for smearing the occupations.

:Parameters:

method : string

  one of 'FermiDirac' or 'MethfesselPaxton'
Currently, the Methfessel-Paxton scheme (PRB 40, 3616 (1989).)
is implemented to 1th order (which is recommemded by most authors).
'FermiDirac' is the default

set_parent(self, parent) set_pseudopotentials(self, pspdict) Set all the pseudopotentials from a dictionary.

The dictionary should have this form::

{symbol1: path1,

   symbol2: path2}

### set_psp

#### set_psp(self, sym=None, z=None, psp=None)

set the pseudopotential file for a species or an atomic number.

:Parameters:

sym : string

 chemical symbol of the species

z : integer

  the atomic number of the species

psp : string

  filename of the pseudopotential

you can only set sym or z.

examples::

set_psp('N',psp='pspfile')

set_psp(z=6,psp='pspfile')

set_psp_database(self, xc=None) get the xc-dependent psp database

:Parameters:

xc : string

 one of 'PW91', 'PBE', 'revPBE', 'RPBE', 'PZ'

not all the databases are complete, and that means some psp do not exist.

note: this function is not supported fully. only pw91 is imported now. Changing the xc at this point results in loading a nearly empty database, and I have not thought about how to resolve that

#### set_pw(self, pw)

set the planewave cutoff.

:Parameters:

pw : integer

 the planewave cutoff in eV


this function checks to make sure the density wave cutoff is greater than or equal to the planewave cutoff.

#### set_spinpol(self, spinpol=False)

set Spin polarization.

:Parameters:

spinpol : Boolean

 set_spinpol(True)  spin-polarized.
set_spinpol(False) no spin polarization, default

Specify whether to perform a spin polarized or unpolarized calculation.

#### set_status(self, status)

set the status flag in the netcdf file

:Parameters:

status : string

  status flag, e.g. 'new', 'finished'

#### set_stay_alive(self, value)

set the stay alive setting

#### set_symmetry(self, val=False)

set how symmetry is used to reduce k-points

:Parameters:

val : Boolean

 set_sym(True) Maximum symmetry is used
set_sym(False) No symmetry is used

This variable controls the if and how DACAPO should attempt using symmetry in the calculation. Imposing symmetry generally speeds up the calculation and reduces numerical noise to some extent. Symmetry should always be applied to the maximum extent, when ions are not moved. When relaxing ions, however, the symmetry of the equilibrium state may be lower than the initial state. Such an equilibrium state with lower symmetry is missed, if symmetry is imposed. Molecular dynamics-like algorithms for ionic propagation will generally not break the symmetry of the initial state, but some algorithms, like the BFGS may break the symmetry of the initial state. Recognized options:

“Off”: No symmetry will be imposed, apart from time inversion symmetry in recipical space. This is utilized to reduce the k-point sampling set for Brillouin zone integration and has no influence on the ionic forces/motion.

“Maximum”: DACAPO will look for symmetry in the supplied atomic structure and extract the highest possible symmetry group. During the calculation, DACAPO will impose the found spatial symmetry on ionic forces and electronic structure, i.e. the symmetry will be conserved during the calculation.

#### set_xc(self, xc)

Set the self-consistent exchange-correlation functional

:Parameters:

xc : string

 Must be one of 'PZ', 'VWN', 'PW91', 'PBE', 'revPBE', 'RPBE'

Selects which density functional to use for exchange-correlation when performing electronic minimization (the electronic energy is minimized with respect to this selected functional) Notice that the electronic energy is also evaluated non-selfconsistently by DACAPO for other exchange-correlation functionals Recognized options :

* “PZ” (Perdew Zunger LDA-parametrization) * “VWN” (Vosko Wilk Nusair LDA-parametrization) * “PW91” (Perdew Wang 91 GGA-parametrization) * “PBE” (Perdew Burke Ernzerhof GGA-parametrization) * “revPBE” (revised PBE/1 GGA-parametrization) * “RPBE” (revised PBE/2 GGA-parametrization)

option “PZ” is not allowed for spin polarized calculation; use “VWN” instead.

#### strip(self)

remove all large memory nc variables not needed for anything I use very often. update_input_parameters(self) read in all the input parameters from the netcdfile

#### write(self, new=False)

write out everything to the ncfile : get_nc()

new determines whether to delete any existing ncfile, and rewrite it.

#### write_input(self)

write out input parameters as needed

you must define a self._set_keyword function that does all the actual writing.

### write_nc

write_nc(self, nc=None, atoms=None)

write out atoms to a netcdffile.

This does not write out the calculation parameters!

#### Parameters

NameTypeDescription
ncstring ncfilename to write to. this file will get clobbered if it already exists.
atomsASE.Atoms atoms to write. if None use the attached atoms if no atoms are attached only the calculator is written out.

the ncfile is always opened in  'a'  mode.

#### note

it is good practice to use the atoms argument to make sure that the geometry you mean gets written! Otherwise, the atoms in the calculator is used, which may be different than the external copy of the atoms.

### Static methods

read_atoms(filename)

read atoms and calculator from an existing netcdf file.

##### Parameters
NameTypeDescription
filenamestringname of file to read from
##### example
  >>> atoms = Jacapo.read_atoms(ncfile)
>>> calc = atoms.get_calculator()

This method is here for legacy purposes. I used to use it alot.

1)
n1,n2,n3
info/dacapo.txt · 最終更新: 2018/04/30 12:03 by kimi