qmpy Toolkit
repository·master·Indexed 41 days ago
https://github.com/wolverton-research-group/qmpyA 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).
What's inside qmpy
- qmpy is the backend system responsible for creating and running the Open Quantum Materials Database (OQMD). It serves as the core infrastructure for managing and serving quantum materials data hosted at http://oqmd.org.
Access thermodynamic data sources in qmpy
masterThe
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.
Manage computational resources in qmpy
masterTheqmpylibrary provides a set of abstractions for managing computational resources, including infrastructure (Hosts, Accounts, Users), organizational structures (Projects, Allocations), and execution models (Tasks, Jobs).Use aggregation and annotation for complex database queries
masterYou 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 anEntryand then filter for entries that have more than a specific number of structures. - Aggregation: Use
.aggregate()to calculate summary statistics (likeAvg,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'))- Annotation: Use
Configure qmpy job submission templates
masterqmpy 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 theAllocationassociated with the calculation.{header}: Used for setup tasks like unzipping files (e.g.,CHGCAR).{mpi}: Contains thempiruncommand and arguments for parallel calculations (left blank for serial).{binary}: The path to the calculation binary defined inhosts.yml.{pipes}: Used to pipe stdout/stderr (defaults tostdout.txtandstderr.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}Use Host, Account, and User abstractions
masterTo 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.
Define material structures with Structure and Prototype
masterTo represent the physical arrangement of atoms in a material, use theStructureandPrototypeclasses.Structuretypically represents a specific instance of an atomic arrangement, whilePrototypedefines the underlying template or symmetry rules used to generate such structures.Search for models using filter, exclude, and get
masterqmpy leverages Django's query engine for database searches:
filter(...): Returns aQuerySetof objects matching the criteria.exclude(...): Returns aQuerySetof 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)Represent a VASP calculation with the Calculation class
masterIn
qmpy, a VASP calculation is managed using theCalculationobject. This object serves as the primary interface for:- Writing calculation input files.
- Reading calculation output files.
- Automatically correcting errors within calculations.
Manage Projects and Allocations
masterTo organize computational work and resource limits, use the following classes:
Project: Represents a logical grouping of work or a research initiative.Allocation: Represents the specific amount of resources (e.g., CPU, memory, time) assigned to aProjectorUser.
Define chemical identity with Element and Species
masterChemical identity is managed throughElementandSpeciesclasses.Elementrefers to the fundamental chemical element (e.g., Carbon, Iron), whereasSpeciesis used to describe specific chemical entities or configurations within a material context.Perform structural analysis using PDF and XRD tools
masterFor structural characterization,
qmpyprovides classes to handle diffraction data:XRD: Tools for X-ray diffraction analysis.Peak: Represents individual peaks within a diffraction pattern.PDF: Tools for Pair Distribution Function analysis.