qmpy Toolkit

repository·master·Indexed 41 days ago

https://github.com/wolverton-research-group/qmpy

A materials science research toolkit for storing crystal structure data, automating density-functional theory (DFT) calculations, managing computational resources, and performing thermodynamic analysis. It serves as the core infrastructure and underlying engine for the Open Quantum Materials Database (OQMD).

Tokens
15K
Snippets
46
Records
74
Agent score
50%

What's inside qmpy

  1. Access thermodynamic data sources in qmpy

    master

    The qmpy/data/thermodata/ directory contains various datasets used for thermodynamic calculations. Depending on your research needs, you can reference the following data sources:

    • iit.dat: Available via the TPTC IIT database (https://tptc.iit.edu/index.php/thermo-database).
    • ssub: Based on SGTE, Thermodynamic Properties of Inorganic Materials, vol. 19 (Springer-Verlag, 1999).
    • mat_proj: Data from the Materials Project (http://www.materialsproject.org).
    • konigs: Thermodynamic properties of actinides and actinide compounds by Konigs, et. al.
    • corrections: Kubachewski corrections.
    • legacy.dat: A test set containing previous iterations of OQMD calculations.
  2. Use aggregation and annotation for complex database queries

    master

    You can use Django's aggregation and annotation methods to perform calculations on database entries directly in SQL.

    • Annotation: Use .annotate() to add temporary fields to a queryset. This is useful for filtering based on related object counts or averages. For example, you can add a field representing the number of associated structures to an Entry and then filter for entries that have more than a specific number of structures.
    • Aggregation: Use .aggregate() to calculate summary statistics (like Avg, Count, Sum) across an entire queryset. This returns a dictionary containing the calculated value.
    from django.db.models import Count, Average
    
    # Annotation: Adding a temporary field 'n_structures' to filter entries
    entries = Entry.objects.annotate(n_structures=Count('structure'))
    many_structs = entries.filter(n_structures__gt=5)
    data = many_structs.values('id', 'path', 'n_structures')
    
    # Aggregation: Calculating the average number of element types
    avg_ntypes = Composition.objects.aggregate(Avg('ntypes'))
    # Filtering before aggregating
    icsd_avg = Composition.objects.filter(entry__meta_data__value='icsd').aggregate(Avg('ntypes'))
  3. Configure qmpy job submission templates

    master

    qmpy uses a template system for queue files (located in qmpy/configuration/qfiles) to tailor job submissions to specific clusters. The template uses {variable} syntax for automatic replacement.

    Common variables include:

    • {nodes}, {ppn}, {walltime}, {name}, {host}: Generally constant for a host.
    • {key}: The allocation ID defined in the Allocation associated with the calculation.
    • {header}: Used for setup tasks like unzipping files (e.g., CHGCAR).
    • {mpi}: Contains the mpirun command and arguments for parallel calculations (left blank for serial).
    • {binary}: The path to the calculation binary defined in hosts.yml.
    • {pipes}: Used to pipe stdout/stderr (defaults to stdout.txt and stderr.txt).
    • {footer}: Used for cleanup tasks like zipping output files (CHGCAR, OUTCAR, PROCAR, ELFCAR).
    #!/bin/bash
    #MSUB -l nodes={nodes}:ppn={ppn}
    #MSUB -l walltime={walltime}
    #MSUB -N {name}
    #MSUB -o jobout.txt
    #MSUB -e joberr.txt
    #MSUB -A {key}
    
    cd $PBS_O_WORKDIR
    NPROCS=`wc -l < $PBS_NODEFILE`
    #running on {host}
    
    {header}
    
    {mpi} {binary} {pipes}
    
    {footer}
  4. Use Host, Account, and User abstractions

    master

    To model the physical and administrative infrastructure of a computational environment, use the following classes:

    • Host: Represents a physical or virtual machine available for computation.
    • Account: Represents a high-level administrative or billing account.
    • User: Represents an individual or service identity within the system.
  5. Define material structures with Structure and Prototype

    master
    To represent the physical arrangement of atoms in a material, use the Structure and Prototype classes. Structure typically represents a specific instance of an atomic arrangement, while Prototype defines the underlying template or symmetry rules used to generate such structures.
  6. Search for models using filter, exclude, and get

    master

    qmpy leverages Django's query engine for database searches:

    • filter(...): Returns a QuerySet of objects matching the criteria.
    • exclude(...): Returns a QuerySet of objects that do NOT match the criteria.
    • get(...): Returns exactly one object. Raises an error if zero or multiple objects are found.

    Chaining and Deep Queries: You can chain filters together or use the double underscore (__) syntax to perform deep queries across relationships (e.g., formationenergy__stability__lt=0).

    # Search for stable entries (formation energy stability < 0)
    stable = Entry.objects.filter(formationenergy__stability__lt=0)
    
    # Search for stable compositions containing Oxygen
    stable_o = Composition.objects.filter(formationenergy__stability__lt=0, element_set='O')
    
    # Search for stable structures
    stable_s = Structure.objects.filter(calculated__formationenergy__stability__lt=0)