How singularitty/genetic-algorithm-structure-prediction works
Project type and purpose
• This is an open-source, command-line Python tool that uses a genetic algorithm (GA) to predict equilibrium crystal structures in 2D for a user-specified potential. It’s not a full-stack app but a scientific computation/algorithm library with pluggable potential models and optional parallel execution.
File structure
• Top-level:
• “Genetic Algorithm/” directory containing core modules.
• LICENSE and README.md.
• Inside “Genetic Algorithm/”:
• GA.py – serial GA driver
• GA_Parallel.py (mentioned in README; if present, this is the parallel driver)
• Structure.py – data structures and representation for crystal configurations
• daoud_cotton_model.py – current potential implementation (fitness function)
• settings.py – central configuration (GA parameters, potential selection, parallel flags)
README for additional insights
• Purpose: predict ground-state (GS) structures for a given potential.
• Extensible: swap or add potential modules by dropping new “*.py” into the folder and selecting it in settings.py.
• Two modes: serial (GA.py) and parallel (GA_Parallel.py).
a. Main components:
• Configuration (settings.py)
• GA Engine (GA.py / GA_Parallel.py)
• Data Model (Structure.py)
• Potential Modules (daoud_cotton_model.py + future plugins)
• Parallelization Layer (multiprocessing wrapper in GA_Parallel.py)
• Output/Reporting (final structure files, logs, console output)
b. Relationships & interactions:
1. User edits settings.py → defines GA parameters, selects potential, toggles parallel flag.
2. Main driver (GA.py or GA_Parallel.py) reads settings → initializes the GA Engine.
3. GA Engine uses Structure.py to generate and mutate candidate configurations.
4. For each candidate, the Engine calls the selected potential module to compute fitness.
5. In parallel mode, evaluations are forked to worker processes (via Python’s multiprocessing).
6. Results flow back to the GA Engine (selection, crossover, mutation).
7. After termination, Engine writes output structures and logs.
c. Architectural patterns & principles:
• Modular separation: core GA logic vs. potential implementations vs. configuration.
• Plugin pattern for potentials: drop-in fitness modules.
• Strategy pattern: interchangeable fitness evaluation.
• Optionally parallel execution via process pool.
d. Key technologies & libraries:
• Python 3.x
• multiprocessing (for GA_Parallel.py)
• Standard library modules (os, sys, argparse if used)