Skip to content

Latest commit

 

History

History
64 lines (52 loc) · 3.05 KB

README.md

File metadata and controls

64 lines (52 loc) · 3.05 KB

Maxwell Equations: Gauss's Law Simulation with Python

This repository contains a simulation of Gauss's Law for electric fields, a fundamental part of Maxwell's equations. The script implemented in Python generates 2D and 3D visualizations that illustrate the divergence of the electric field and the behavior of vector fields in space.

Features

  • Electric Field Simulation: Calculates the components of the electric field in 2D using functions defined based on Gauss's Law.
  • Divergence Calculation: Computes the divergence of the electric field over a spatial grid, providing a visual representation of how charges affect the field.
  • 2D and 3D Visualization: Offers methods to graph the field in both 2D and 3D:
    • 2D Plot: Displays the electric field and its divergence using arrows that indicate the direction and magnitude of the field.
    • 3D Plot: Represents the electric field in a 3D space with colors indicating the magnitude of the divergence, using surface and vector field visualizations.
  • Adjustable Parameters: Allows modifying the electric field amplitude and other parameters to explore different scenarios.
  • Smoothed Visualization: Uses techniques like Gaussian filters to smooth the graphical representation, enhancing the visual quality of the simulations.

Requirements

  • Python 3.x
  • Libraries:
    • numpy
    • matplotlib
    • scipy
  • Optional: It is recommended to use a virtual environment to install dependencies and avoid conflicts with other projects.

Usage

  1. Clone the repository:
    git clone https://github.com/your_username/maxwell-equations.git
  2. Install the dependencies:
    pip install -r requirements.txt
  3. Run the main script:
    python GaussLawDivergence.py
  4. Modify parameters in the script to explore different electric field configurations and divergence results.

Repository Structure

  • GaussLawDivergence.py: The main script containing the implementation of Gauss's Law for electric fields, with methods to calculate, plot, and visualize the field and its divergence.
  • README.md: The description of the repository and a usage guide.
  • requirements.txt: A list of dependencies needed to run the script.
  • figures/: An optional folder to save the visualizations generated by the script.

Example Plots

2D Divergence of electric field Plot

2D Electric Field

3D Divergence Plot

3D Divergence

Future Improvements

  • Add simulations for other Maxwell's equations.
  • Implement an interactive environment to explore the electric field and its properties.
  • Optimize 3D visualizations for better performance with larger spatial grids.

Contributions

Contributions are welcome! If you would like to improve this project or fix any issues, feel free to fork the repository and submit a pull request.

Author

License

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