Skip to main content

Welcome to MatGraphDB, a powerful Python package designed to interface with primary and graph databases for advanced material analysis.

Project description

MatGraphDB

Table of Contents

Introduction to MatGraphDB

To be written..

Installing

Installing via pip

pip install matgraphdb

Installing from github

git clone https://github.com/lllangWV/MatGraphDB.git
cd MatGraphDB
pip install -e .

Usage

Interacting with the materials database.

Initialize MatGraphDB

from matgraphdb import MatGraphDB

# Initialize MatGraphDB
mgdb = MatGraphDB(storage_path="MatGraphDB")
print(mgdb.summary())

Adding material properties

You can add any material to the database by either providing a structure or coords, species, and lattice, then using the create_material or create_materials function.

Any material add to the database gets indexed. This is stored in the id column.

from pymatgen.core import Structure

# Add material to the database
material_data_1 = {
    "structure": structure,
    "properties": {
        "material_id": "mp-1",
        "source": "example",
        "thermal_conductivity": {"value": 2.5, "unit": "W/mK"},
    },
}

# or by coords, species, lattice
material_data_2 = {
    "coords":  [[0, 0, 0], [0.5, 0.5, 0.5]],
    "species": ["Mg", "O"],
    "lattice": [[0, 2.13, 2.13], [2.13, 0, 2.13], [2.13, 2.13, 0]],
    "properties": {
        "material_id": "mp-2",
        "source": "example_manual",
        "band_gap": {"value": 1.2, "unit": "eV"},
    },
}

result = mgdb.create_material(
    coords=material_data_2["coords"],
    species=material_data_2["species"],
    lattice=material_data_2["lattice"],
    properties=material_data_2["properties"],
)
# Add material by structure
db.create_material(
                structure=material_data_1["structure"],
                properties=material_data_1["properties"])


materials=[material_data_1,material_data_2]

# Add multiple materials
mgdb.create_materials(materials)

Reading Materials

To read materials from the database, you can use the read_materials function. This function takes in a columns parameter, which specifies the columns to read from the database. The filters parameter specifies the filters to apply to the database. This will only read the matched materials to memory.

materials = mgdb.read_materials( 
    columns=["material_id", "elements", "band_gap.value"],
    filters=[pc.field("band_gap.value") == 1.2]
    )

Updating Materials

To update materials in the database, you can use the update_materials function. For updates you must provide the id of the material you want to update. You can also provide the update_keys parameter to specify the columns to update on as well, this is usefull if you import an existing dataset from another database.

update_data = [
    {
        "id": 0,
        "band_gap": {"value": 3.6, "unit": "eV"},
    },
]

materials = mgdb.update_materials(update_data)


update_data = [
    {
        "material_id": "mp-1",
        "band_gap": {"value": 3.6, "unit": "eV"},
    },
]
materials = mgdb.update_materials(update_data, update_keys=["material_id"])

Deleting Materials

To delete materials from the database, you can use the delete_materials function. You can provide a list of ids to delete.

materials = mgdb.delete_materials(ids=[0])

Interacting with the graph database

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Authors

Logan Lang, Aldo Romero, Eduardo Hernandez,


Note: This project is in its initial stages. Features and APIs are subject to change. Please refer to the latest documentation and release notes for updates.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matgraphdb-0.2.0.tar.gz (14.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matgraphdb-0.2.0-py3-none-any.whl (7.6 MB view details)

Uploaded Python 3

File details

Details for the file matgraphdb-0.2.0.tar.gz.

File metadata

  • Download URL: matgraphdb-0.2.0.tar.gz
  • Upload date:
  • Size: 14.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for matgraphdb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1d5f20b6ff52b58361d2bf746a68b23f71e8b0a1cbbda33a7bfc6eb39d92b5e8
MD5 2a9fef896a615d9255040f747a8ed588
BLAKE2b-256 a76c6ca3804665c9028d01f557fe406c4188a7495e0553a9c597421c0a2c6346

See more details on using hashes here.

File details

Details for the file matgraphdb-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: matgraphdb-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for matgraphdb-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1bbc0a390aa2b51960d9681522e22463eb9981d8720c57fb373934aaa15fdc8d
MD5 92a0bd7a82241ddbbc75d76233b697d4
BLAKE2b-256 22784f1023d91326e8d5015e008710f7c1d38d937e6b6c225e7912f34a900d88

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page