pychemia.code.abinit package

Set of classes and functions to manipulate

ABINIT ‘.in’ input files ABINIT ‘.files’ files ABINIT ‘_OUT.nc’ output files

Submodules

pychemia.code.abinit.abifiles module

class pychemia.code.abinit.abifiles.AbiFiles(*args, **kwargs)[source]

Bases: object

Read an ‘abinit.files’ file and extract the names of input, output filenames and put them into dictionary called ‘files’.

basedir = '.'
clean()[source]

Remove all the output

cleanall()[source]
create()[source]

Create the ‘.files’ file and the directory if it does not exists

execute(abinit_binary)[source]

Utility that copy a given script and execute the given command inside the directory

filename = 'abinit.files'
files = {'in': 'abinit.in', 'out': 'abinit.out', 'tmpin': 'abinit-i', 'tmpout': 'abinit-o', 'tmp': 'abinit', 'psps': ''}
get_input_filename()[source]

Return the input filename

get_out_filename()[source]

Return the OUT.nc filename

get_output()[source]

Return the output as a dictionary

get_output_filename()[source]

Return the output filename

set_input(inp)[source]

Associate an inputvars object to the abifiles object

set_psps(exchange='LDA', kind='FHI')[source]

Set the pseudopotentials acording to given exchange and kind The pair (exchange,kind) could be: (‘LDA’,’FHI’) (‘LDA’,’TM’) (‘GGA’,’FHI’)

write(filename)[source]

Write the file ‘filename’ with the format of an usual ‘.files’

Parameters:filename – (str) Filename to write the ‘abinit.files’ file

pychemia.code.abinit.abinit module

class pychemia.code.abinit.abinit.AbinitJob[source]

Bases: pychemia.code.codes.Codes

finalize()[source]
get_outputs()[source]
initialize(workdir, structure=None, input_file='abinit.in', binary='abinit', psp_kind='FHI', psp_exchange='LDA')[source]

Initialize the mandatory variables for a AbinitJob

Parameters:
  • psp_kind – (str) Source of Pseudopotentials
  • psp_exchange – (str) ‘LDA’ or ‘GGA’
  • workdir – (str) The directory where the input files will be
  • structure – (pychemia.Structure) A pychemia structure for the input
  • input_file – (str) Input file for ABINIT
  • binary – (str) The name or path for the ABINIT binary file
Returns:

job_ecut_convergence()[source]
job_ion_relax(internal_opt=True, external_opt=True, ionmov=2, nstep=20, ntime=30, tolmxf=1e-07, tolrff=0.001, dilatmx=1.05)[source]
job_static()[source]

Prepares a static calculation.

Returns:
set_ecut(ecut=50)[source]
set_inputs()[source]

Prepare all the inputs before running ABINIT

Returns:
set_kpoints(kpoints=None)[source]
set_psps(exchange='LDA', kind='FHI')[source]
write_abifiles()[source]
write_abiinput()[source]
write_all()[source]

pychemia.code.abinit.htmlparser module

class pychemia.code.abinit.htmlparser.MyHTMLParser(*, convert_charrefs=True)[source]

Bases: html.parser.HTMLParser

Create a subclass and override the handler methods

error(message)[source]
handle_data(data)[source]
handle_endtag(tag)[source]
handle_starttag(tag, attrs)[source]

pychemia.code.abinit.input module

class pychemia.code.abinit.input.InputVariables(*args, **kwargs)[source]

Bases: collections.abc.MutableMapping

An input object contains:

data:
variables = Dictionary whose keys are ABINIT variable names
methods:
write = Write the input into as a text file that ABINIT
can use as an input file

get_value = Get the value of a particular variable set_value = Set the value of a particular variable

get_atomic_structure =

atom_name(iatom, idtset='')[source]

Return the name of the atom and the position in the list of atoms such as H3, N4, etc

clean()[source]
from_structure(structure)[source]

Set input variables for a given structure

Parameters:structure – (pychemia.Structure) Structure to set ABINIT input variables
Returns:
get_dtsets_keys()[source]

Get the list of dtset suffix acording to the values given by ndtset, jdtset and udtset

get_structure(idtset=None, units='bohr')[source]

Return the atomic structure from the input object for a given dataset (no dataset by default)

get_value(varname, idtset=None, return_iterable=False)[source]

Get the value of the input variable ‘varname’ associated with the dataset ‘idtset’ If ‘idtset’ is not given will asume that the value is not dataset dependent

has_variable(varname)[source]
set_value(varname, value, idtset='')[source]

Set the value ‘value’ into the dictionary input with key ‘varname’+str(idtset) The value could be an integer, real, list or numpy array, the internal representation is always serializable.

view_projections()[source]

Show the 3 projections of the molecule in a single figure

write(filename)[source]

Write an input object into a text file that ABINIT can use as an input file

Args:
filename:
The ‘abinit.in’ filename that will be written
write_key(varname)[source]

Receives an input variable and write their contents properly according with their kind and length

Args:
varname:
The name of the input variable
pychemia.code.abinit.input.merge(abi_into, abi_from, filename=None)[source]

From the variables present in the file ‘abi_into’ will try to recover the value from ‘abi_from’ if the value has changed, the value will be updated.

The new variables will be save in the given filename If filename==None the new values will overwrite abi_into

Example:

merge(‘abinit.in’,’abinit_xo_OUT.nc’)

It will update the abinit input with the values of the output

Parameters:
  • abi_into – (str) Merge abinit variables using this destination
  • abi_from – (str) and this source
  • filename – (str) Storing the final input variables on file
pychemia.code.abinit.input.xyz2input(filename)[source]

Reads a .xyz and return an ABINIT input as a python dictionary

pychemia.code.abinit.output module

class pychemia.code.abinit.output.AbinitOutput(filename='abinit.out')[source]

Bases: object

get_dmatpawu()[source]
get_energetics()[source]
get_occupation_matrix()[source]
is_finished
static read_output_netcdf(filename)[source]
reload()[source]
pychemia.code.abinit.output.netcdf2dict(filename)[source]

Read a NetCDF file and create a python dictionary with numbers or lists for each variable

Args:
filename:
NetCDF filename

pychemia.code.abinit.parser module

pychemia.code.abinit.parser.parser(filename)[source]

Take a filename and returns a dictionary of ABINIT input variables

The values on each key are lists of numbers The values are converted to atomic units always that it found other variables (eV, angstrom, etc) Repetitions are expanded (3*1.5 => [1.5 1.5 1.5])

Args:
filename:
Path for an ABINIT input file
Returns:
inputvars:
Dictionary, the keys are names of variables and the values are list of numbers.

pychemia.code.abinit.utils module

pychemia.code.abinit.utils.abihelp(varname)[source]
pychemia.code.abinit.utils.netcdf2dict(filename)[source]

Read a NetCDF file and create a python dictionary with numpy arrays for variables

Args:
filename:
NetCDF filename
pychemia.code.abinit.utils.plot_simple(variables, varname)[source]
pychemia.code.abinit.utils.psp_name(atomicnumber, exchange, kind)[source]

Return the filename of a certain PSP given the atomic number, exchange (‘LDA’ or ‘GGA’) and kind (‘FHI’,’TM’)

Parameters:
  • atomicnumber – (int) Atomic number
  • exchange – (str) ‘LDA’ or ‘GGA’
  • kind – (str) Source of Pseudopotentials
Returns:

pychemia.code.abinit.utils.split_varname(varname)[source]