Пример #1
0
def vis_data(request):
    global custom_data
    data = {
        "crystal_data": """Cr Te O
 1.0
7.016000 0.000000 0.000000
0.000000 7.545000 0.000000
-1.637391 0.000000 9.589209
Cr O Te
4 22 8
direct
 0.319200 0.501900 0.384200
 0.680800 0.001900 0.115800
 0.680800 0.498100 0.615800
 0.319200 0.998100 0.884200
 0.205000 0.644000 0.212100
 0.795000 0.144000 0.287900
 0.795000 0.356000 0.787900
 0.205000 0.856000 0.712100
 0.500000 0.000000 0.500000
 0.500000 0.500000 0.000000
 0.127000 0.314000 0.342900
 0.873000 0.814000 0.157100
 0.873000 0.686000 0.657100
 0.127000 0.186000 0.842900
 0.468000 0.375000 0.262300
 0.532000 0.875000 0.237700
 0.532000 0.625000 0.737700
 0.468000 0.125000 0.762300
 0.563000 0.641000 0.451700
 0.437000 0.141000 0.048300
 0.437000 0.359000 0.548300
 0.563000 0.859000 0.951700
 0.158000 0.649000 0.486600
 0.842000 0.149000 0.013400
 0.842000 0.351000 0.513400
 0.158000 0.851000 0.986600
 0.139700 0.859900 0.176200
 0.860300 0.359900 0.323800
 0.860300 0.140100 0.823800
 0.139700 0.640100 0.676200
 0.672300 0.861800 0.415800
 0.327700 0.361800 0.084200
 0.327700 0.138200 0.584200
 0.672300 0.638200 0.915800"""
    }
    p = request.POST
    if request.method == "POST":
        custom_data = p.get("crystal_data", "")
        data["crystal_data"] = custom_data
        f = StringIO()
        f.write(custom_data)
        s = read(f)
        s.symmetrize()
        data["structure"] = s
    data.update(csrf(request))
    custom_data = data["crystal_data"]
    return render(request, "analysis/view_data.html", context=get_globals(data))
Пример #2
0
from qmpy import DOS, io
from numpy import mean

strc = io.read("../files/relaxation/POSCAR")
dos = DOS.read("../files/relaxation/DOSCAR")

# Get the total DOS
print("Getting total DOS...")
total_dos = dos.dos
my_dos = dos.get_projected_dos(strc, "Mg", debug=True)
my_dos = my_dos * 2 * (dos.energy[1] - dos.energy[0])
error = mean([abs(x) for x in (total_dos - my_dos)])
print("\tMean difference between total DOS and projected: ", error)

# Get only d orbitals
print("Getting d orbital DOS...")
dos.get_projected_dos(strc, "Mg", orbital="d", debug=True)
Пример #3
0
    def create(source, keywords=[], projects=[], **kwargs):
        """
        Attempts to create an Entry object from a provided input file.

        Processed in the following way:

        #. If an Entry exists at the specified path, returns that Entry.
        #. Create an Entry, and assign all fundamental attributes. (natoms,
           ntypes, input, path, elements, keywords, projects).
        #. If the input file is a CIF, and because CIF files have additional
           composition and reference information, if that file format is
           found, an additional test is performed to check that the reported
           composition matches the composition of the resulting structure. The
           reference for the work is also created and assigned to the entry.
        #. Attempt to identify another entry that this is either exactly
           equivalent to, or a defect cell of.

        Keywords:
            keywords: list of keywords to associate with the entry.
            projects: list of project names to associate with the entry.

        """
        source_file = os.path.abspath(source)
        path = os.path.dirname(source_file)

        # Step 1
        if Entry.objects.filter(path=path).exists():
            return Entry.objects.get(path=path)

        # Step 2
        entry = Entry(**kwargs)
        structure = io.read(source_file)
        structure.make_primitive()
        entry.source_file = source_file
        entry.path = os.path.dirname(source_file)
        entry.input = structure
        entry.ntypes = structure.ntypes
        entry.natoms = len(structure.sites)
        entry.elements = entry.comp.keys()
        entry.composition = Composition.get(structure.comp)
        for kw in keywords:
            entry.add_keyword(kw)
        entry.projects = projects

        # Step 3
        c1 = structure.composition
        if 'cif' in source_file:
            c2 = structure.reported_composition
            if not c1.compare(c2, 5e-2):
                entry.add_hold("composition mismatch in cif")
                entry.composition = c2
            entry.reference = io.cif.read_reference(source_file)

        # check for perfect crystals
        if not any([ s.partial for s in structure.sites ]):
            dup = Entry.get(structure)
            if not dup is None:
                entry.duplicate_of = dup
                entry.add_hold('duplicate')
            return entry

        # detect solid solution
        if all([ s.occupancy > 0.99 for s in structure.sites ]):
            if any([ len(s) > 1 for s in structure.sites ]):
                entry.add_keyword('solid solution')
        if any([ s.partial for s in structure.sites ]):
            entry.add_hold('partial occupancy')

        return entry
Пример #4
0
from qmpy import DOS, io
from numpy import mean

strc = io.read('../files/relaxation/POSCAR')
dos = DOS.read('../files/relaxation/DOSCAR')

# Get the total DOS
print "Getting total DOS..."
total_dos = dos.dos
my_dos = dos.get_projected_dos(strc, 'Mg', debug=True)
my_dos = my_dos * 2 * (dos.energy[1] - dos.energy[0])
error = mean([ abs(x) for x in (total_dos - my_dos)])
print "\tMean difference between total DOS and projected: ", error

# Get only d orbitals
print "Getting d orbital DOS..."
dos.get_projected_dos(strc, 'Mg', orbital='d', debug=True)
Пример #5
0
from qmpy import DOS, io
from numpy import mean

strc = io.read('../files/relaxation/POSCAR')
dos = DOS.read('../files/relaxation/DOSCAR')

# Get the total DOS
print "Getting total DOS..."
total_dos = dos.dos
my_dos = dos.get_projected_dos(strc, 'Mg', debug=True)
my_dos = my_dos * 2 * (dos.energy[1] - dos.energy[0])
error = mean([abs(x) for x in (total_dos - my_dos)])
print "\tMean difference between total DOS and projected: ", error

# Get only d orbitals
print "Getting d orbital DOS..."
dos.get_projected_dos(strc, 'Mg', orbital='d', debug=True)