This project uses a knowledge graph to represent and explore the hierarchical structure and spatial relationships within microstructural data – with a special focus on dislocation phenomena – as they appear in synthetic datasets especially designed for machine learning studies. Within such a graph, the microstructure is treated as a geometric entity with features such as pileups and dislocations. The ontology focuses on modeling dislocation pileups, their associated dislocations, and their geometric characteristics, making it suitable for advanced reasoning tasks and graph-based querying.
The dislocation microstructure ontology consists of four primary node types and five relationship types, organized in a hierarchical and spatial layout as follows:
-
🧱 Microstructure
- Represents the top-level dislocation microstructure under investigation.
- It is the entry point of the graph and aggregates the entire microstructural configuration.
-
💥 Pileup
- A localized group of dislocations accumulating at a barrier.
- Characterized by:
start location of first dislocationslip widthslip directionnumber of dislocations
-
🧵 Dislocation
- Individual line defect within a pileup.
- Characterized by:
spline-idpositionspacing(distance to the next dislocation in the pileup)
-
SlipTrace
- Represents the pair of lines that indicate the direction and presence of slip (plastic deformation). These are sometimes very clearly visible in TEM micrographs.
- Associated with one or more pileups.
-
Microstructure → HAS_PILEUP → Pileup
- A microstructure may have one or more pileups.
-
Pileup → CONTAINS → Dislocation
- A pileup contains one or more dislocations.
-
Dislocation → NEIGHBOR → Dislocation
- Indicates spatial adjacency or sequencing between dislocations in a pileup.
-
Pileup → HAS_SLIP_TRACE → SlipTrace
- One pileup may be associated with slip trace lines.
- Python 3.9
- Docker & Docker Compose
- pyenv & pyenv-virtualenv
- OpenAI API Key
git clone https://github.com/kgovind0001/GraphRAG-Dislocation.git
cd GraphRAG-DislocationCreate a .env file in the root directory and add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here
NEO4J_URI="neo4j://localhost:7687"
NEO4J_USERNAME = "neo4j"
NEO4J_PASSWORD = "password"Use pyenv and pyenv-virtualenv to create and activate a Python 3.9.0 environment:
pyenv install 3.9.0
pyenv virtualenv 3.9.0 graphrag-env
pyenv activate graphrag-envInstall the required Python package:
pip install -e . Ensure Docker and Docker Compose are installed, then start the Neo4j server:
docker-compose up -dThis will set up a Neo4j instance with the necessary plugins for vectorized storage and OpenAI integration. Next step is to create database in Neo4j. A small sample data of 5 microstructures has been provided to test the application.
python src/inject.pyStart the GraphRAG application:
streamlit run app.pyGraphRAG-Dislocation/
├── sample_data # Input data files
src
├── agent_nodes
│ ├── cypher_generator.py
│ ├── cypher_validator.py
│ ├── guardrails.py
│ ├── __init__.py
├── config.py
├── executor.py
├── __init__.py
├── inject.py # Create database and define nodes, relations
├── llm_query.py
├── .env # Environment variables
├── requirements.txt # Python dependencies
├── app.py # Streamlit application
└── docker-compose.yml # Docker Compose configuration
After running the application, you can test its functionality by:
- Adding more sample data to the
sample_data/directory. - Ensuring the data is ingested and processed correctly.
- Submitting queries and verifying the responses are accurate and contextually relevent.
- Ontology of the database can be obtained by pasting
http://localhost:7474/rdf/neo4j/ontoin the browser to get rdf file.
Contributions are welcome! If you have suggestions for improvements or new features, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Developed by Kishan Govind.
Feel free to customize this README further to match your project's specific details and requirements.
