コード例 #1
0
def castep_structure(filename, extension):
    #Get structure attributes
    if pure:
        atoms = casread(filename)
        nAtoms = atoms.get_global_number_of_atoms()
        elems = ' '.join(atoms.get_chemical_symbols())
        cell = atoms.get_cell()
        posns = atoms.get_scaled_positions()
    else:
        extension = filename.split(".")[-1]
        assert extension in ["cell", "castep"], "Mixtures are only supported\
                if they are .cell or .castep files."

        if extension == "cell":
            atoms = rc.readcell(filename)
        elif extension == "castep":
            atoms = rc.readcas(filename)
        else:
            ValueError("Could not read the file since it was a mixture and not\
                        a .cell or .castep file.")

        nAtoms = atoms.Nions
        elems = ' '.join(atoms.get_elements())
        cell = atoms.get_cell()
        posns = atoms.get_posns()

        if verbose:
            print("Number of atoms:", nAtoms)
            print("Lattice vectors: ", cell)
            print("Fractional positions: ", posns)

    latvecs = [' '.join([str(c) for c in cell[i, :]])+'\r\n' for i in \
                range(3)]

    return nAtoms, elems, cell, posns, latvecs
コード例 #2
0
def get_structure(cellname):

  cas = rc.readcell(cellname)
  pureatoms = cas.extract_struc()
  kpoints, offset = cas.get_kpoints()
  constrs = cas.get_cell_constrs()
  psps = cas.get_psps()

  return pureatoms, kpoints, offset, constrs, psps
コード例 #3
0
                                                       rtn_dist=False)
    pinchatoms.set_chemical_symbols(fixelems)
    pinchatoms.set_positions(pinchposnew)
    return pinchatoms


##########################################################################

if __name__ == '__main__':
    """ Run from the command line, pinch the second cell to match the first """
    cellfile0 = sys.argv[1]
    cellfile1 = sys.argv[2]

    # Load the fixed cell (incl generating pure structure)
    if '.cell' in cellfile0:
        mix0 = rc.readcell(cellfile0)
    elif '.castep' in cellfile0:
        mix0 = rc.readcas(cellfile0)
    mixatoms0 = mix0.extract_struc()
    mixkey0 = mix0.get_mixkey()
    mapping0 = mixmap.mixmap(mixatoms0, mixkey0)
    pureatoms0 = mapping0.mix2pure(mixatoms0)
    posns0 = pureatoms0.get_positions()
    Nions = len(pureatoms0)

    # Load the cell to be pinched (incl generating pure structure)
    mix1 = rc.readcell(cellfile1)
    mixatoms1 = mix1.extract_struc()
    mixkey1 = mix1.get_mixkey()
    mapping1 = mixmap.mixmap(mixatoms1, mixkey1)
    pureatoms1 = mapping1.mix2pure(mixatoms1)
コード例 #4
0
""" A silly script to test that all the functionality works.
Running this script should test that most functions and classes run without
errors (although as yet no checks test that the results are sensible). """

########################################################
########################################################

###################################
# Manipulating pure & mixed cells #
###################################

# Read mix cell

print('\n\n\nMix Cell\n\n\n')

cas = rc.readcell('examples/Ca2.15Sr0.85Ti2O7_Amam.cell')

print(cas.get_kpoints())
print(cas.get_psps())
print(cas.get_elements())
print(cas.get_init_spin())
print(cas.get_mixkey())
print(cas.get_posns())
print(cas.get_ext_press())
print(cas.get_cell_constrs())
print(cas.get_cell())

mixkey = cas.get_mixkey()

########################################################
コード例 #5
0
#!/usr/bin/env python3

import sys
import mixmap
import readmixcastep as rc
import numpy as np

cellfile = sys.argv[1]
shift = np.array([float(s) for s in sys.argv[2:5]])  # frac coords

cas = rc.readcell(cellfile)
mixatoms = cas.extract_struc()
mixkey = cas.get_mixkey()
mapping = mixmap.mixmap(mixatoms, mixkey)
posns = mixatoms.get_scaled_positions()
posns += shift
mixatoms.set_scaled_positions(posns)
mapping.casprint(mixatoms, cellfile)
コード例 #6
0
#!/usr/bin/env python3

import mixmap
import readmixcastep as rc
import sys
""" Command line tool to quickly get a pure cell file from a solid soln. """

# Load the input file (accepts .castep or .cell)
casfile = str(sys.argv[1])
if '.castep' in casfile:
    chem = casfile.replace('.castep', '')
    cas = rc.readcas(casfile)
elif '.cell' in casfile:
    chem = casfile.replace('.cell', '')
    cas = rc.readcell(casfile)

# Extract calculation parameters and convert from mix to pure structure
mixatom = cas.extract_struc(iteration=None)
mixkey = cas.get_mixkey(iteration=None)
press = cas.get_ext_press()
kpoints, offset = cas.get_kpoints()
pseudos = cas.get_psps()
constraints = cas.get_cell_constrs()
mapping = mixmap.mixmap(mixatom, mixkey)
pureatom = mapping.mix2pure(mixatom)

# Write the pure cell (always with the same handle plus the suffix _nonSS)
mapping.setcellparams(pressure=press,
                      cell_constrs=constraints,
                      pseudos=pseudos,
                      kpoints=kpoints,