Skip to content

Gmoura137/MatrixPattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

MatrixPattern.py

Overview

MatrixPattern.py is a Python script that generates square matrices representing linear or cyclical connectivity patterns. These matrices are commonly used in:

  • Quantum chemistry
  • Solid-state physics
  • Tight-binding models
  • Graph theory (adjacency matrices)

The script also integrates with Wolfram Alpha by generating clickable links that allow users to perform symbolic computations such as eigenvalue analysis and matrix diagonalization.


Features

  • Generate linear (chain) matrices
  • Generate cyclical (ring) matrices
  • Output matrix in Wolfram-compatible format
  • Automatically generate links for:
    • Eigenvalues
    • Diagonalization
    • Orthogonal diagonalization

Installation

No external dependencies are required.

Make sure you have Python installed (version 3.x recommended).


Usage

Run the script:

python MatrixPattern.py

Input

You will be prompted to enter:

  • n → size of the matrix (integer)

  • matrix type:

    • linear
    • cyclical

Example

Enter the size of the matrix (n): 4
Is the matrix linear or cyclical? cyclical

Output

Generated Matrix:
0 1 0 1
1 0 1 0
0 1 0 1
1 0 1 0

Wolfram Matrix Format:
{{0,1,0,1},{1,0,1,0},{0,1,0,1},{1,0,1,0}}

Wolfram Alpha Links:
Eigenvalues:
https://www.wolframalpha.com/input?i=...

Diagonalization:
https://www.wolframalpha.com/input?i=...

Orthogonal Eigenvectors:
https://www.wolframalpha.com/input?i=...

Matrix Types

Linear Matrix

Represents a chain structure where each element connects only to its nearest neighbors.

Example (n = 4):

0 1 0 0
1 0 1 0
0 1 0 1
0 0 1 0

Cyclical Matrix

Represents a ring structure where the first and last elements are also connected.

Example (n = 4):

0 1 0 1
1 0 1 0
0 1 0 1
1 0 1 0

Wolfram Alpha Integration

The script generates links that allow you to instantly analyze the matrix in Wolfram Alpha.

Supported Operations

  • Eigenvalues
  • Diagonalization
  • Orthogonal diagonalization

This enables:

  • Spectral analysis
  • Basis transformations
  • Exploration of quantum/physical systems

Applications

  • Tight-binding Hamiltonians
  • Lattice models
  • Graph adjacency matrices
  • Discrete Laplacians
  • Eigenvalue problems in physics and engineering

Future Improvements

  • Add NumPy support for local eigenvalue computation
  • Graph visualization (networkx)
  • Export to Mathematica notebook format
  • Support weighted matrices

License

This project is open source and free to use.

About

MatrixPattern.py is a Python script that generates square matrices representing linear or cyclical connectivity patterns. These matrices are commonly used in: Quantum chemistry Solid-state physics Tight-binding models Graph theory (adjacency matrices) The script also integrates with Wolfram Alpha

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages