For an in-depth explanation of the methods and results, check out my Medium blog: Optimizing Self-Potential Models with Particle Swarm Optimization: A Geophysical Approach
This project involves optimizing the parameters of a self-potential model using Particle Swarm Optimization (PSO). The self-potential method is used in geophysics to detect anomalies in subsurface materials. The goal of this project is to find the optimal parameters that best fit a self-potential profile using PSO.
-
analyticalSig.py
: Contains the main script for running the PSO optimization, generating plots, and creating a GIF of particle movements. -
potential.py
: Defines the potential functions used in the optimization:PotentialSphere
: Calculates the potential due to a sphere.PotentialCylinder
: Calculates the potential due to a cylinder.AnalyticalSignal
: Calculates the analytical signal.
-
logs/pso_log.log
: Log file that records the details of the PSO optimization process. -
images/
: Directory where results are saved, including:Error PSO.png
: Plot of error vs. number of iterations.SP_Profile.png
: Plot of self-potential profile.particle_movement_PSO.gif
: GIF showing particle movements during optimization.
Ensure you have the following Python packages installed:
numpy
matplotlib
tqdm
imageio
You can install these packages using pip:
pip install numpy matplotlib tqdm imageio
- Run the Optimization: Execute the analyticalSig.py script to start the PSO optimization process. This script will:
- Initialize the PSO parameters.
- Optimize the parameters using PSO.
- Save the results and generate plots and GIFs.
- View Results:
After running the script, the following files will be generated in the images/ directory:
- Error PSO.png: Shows the error vs. the number of iterations.
- SP_Profile.png: Compares the actual self-potential profile with the optimized profile.
- particle_movement_PSO.gif: Visualizes the particle movements during the optimization process.
pip install numpy matplotlib tqdm imageio
- Initialization: Particles are initialized randomly within a specified range.
- Velocity Update: Particles’ velocities are updated based on their personal best and the global best positions.
- Position Update: Particles’ positions are updated based on their velocities.
- Error Calculation: The error is calculated as the root mean square difference between the predicted and actual self-potential values.
- Stopping Criteria: The optimization stops when the error falls below a predefined threshold.
- PotentialSphere: Calculates the self-potential due to a sphere.
- PotentialCylinder: Calculates the self-potential due to a cylinder.
- AnalyticalSignal: Calculates the analytical signal for comparison.
The optimization process is logged in logs/pso_log.log
. The log file contains information about the optimization runs, including:
- The number of iterations.
- Parameters used in each run.
- Error values.
This project is licensed under the MIT License. See the LICENSE file for details.
The self-potential model and optimization techniques used in this project are based on established geophysical methods and optimization algorithms.
For any questions or feedback, please reach out to:
Raj Sahu
Email: sahuraj457@gmail.com