PyCharge is an open-source computational electrodynamics Python simulator

Overview

PyCharge

PyCharge is an open-source computational electrodynamics Python simulator that can calculate the electromagnetic fields and potentials generated by moving point charges and can self-consistently simulate dipoles modeled as Lorentz oscillators.

build Codecov CodeFactor Documentation Status License

PyCharge was developed to allow both novice and experienced users model a wide range of classical electrodynamics systems using point charges: the package can be used as a pedagogical tool for undergraduate and graduate-level EM theory courses to provide an intuitive understanding of the EM waves generated by moving point charges, and can also be used by researchers in the field of nano-optics to investigate the complex interactions of light in nanoscale environments.

Key Features

  • Calculate the relativistically-correct electromagnetic fields and potentials generated by moving point charge sources in a system at specified grid points in space and time. The moving point charges can have custom trajectories.
  • Self-consistent simulatations of dipoles modeled as Lorentz oscillators which are driven by the electric field in the system. PyCharge dynamically determines the dipole moment at each time step.
  • Expected coupling between dipoles predicted by QED theory is captured in the simulations, and the modified radiative properties of the dipoles (radiative decay rate and frequency shift) can be extracted using the dipole's energy at each time step.
  • Moving dipoles can be modelled by specifying the dipole's origin position as a function of time.
  • Parallelized version of the dipole simulation method using mpi4py to enable the parallel execution of computationally demanding simulations on high performance computing environments to significantly improve run time.

Our computational physics paper introducing the PyCharge package is available on arXiv and includes an extensive review of the rich physics that govern the coupled dipole simulations.

Documentation

See the manual hosted at pycharge.readthedocs.io for the latest documentation.

Installation

PyCharge and its dependencies can be installed using pip:

pip install pycharge

To install in development mode, clone the GitHub repository and install with pip using the editable option:

git clone https://github.com/MatthewFilipovich/pycharge
pip install -e ./pycharge

Usage

An overview of the classes and methods implemented in the PyCharge package is shown in the figure below:

The electromagnetic fields and potentials generated by moving point charges can be calculated using PyCharge with only a few lines of code. The following script calculates the electric field components and scalar potential along a spatial grid in the x-y plane generated by two stationary charges:

import pycharge as pc
from numpy import linspace, meshgrid
from scipy.constants import e
sources = (pc.StationaryCharge((10e-9, 0, 0), e),
           pc.StationaryCharge((-10e-9, 0, 0), -e))
simulation = pc.Simulation(sources)
coord = linspace(-50e-9, 50e-9, 1001)
x, y, z = meshgrid(coord, coord, 0, indexing='ij')
Ex, Ey, Ez = simulation.calculate_E(0, x, y, z)
V = simulation.calculate_V(0, x, y, z)

Two dipoles separated by 80 nm along the x-axis are simulated over 40,000 timesteps in the script below:

import pycharge as pc
from numpy import pi
timesteps = 40000
dt = 1e-18
omega_0 = 100e12*2*pi
origins = ((0, 0, 0), (80e-9, 0, 0))
init_d = (0, 1e-9, 0)
sources = (pc.Dipole(omega_0, origins[0], init_d),
           pc.Dipole(omega_0, origins[1], init_d))
simulation = pc.Simulation(sources)
simulation.run(timesteps, dt, 's_dipoles.dat')

For more examples and usage, please refer to the documentation.

Contributing

We welcome all bug reports and suggestions for future features and enhancements, which can be filed as GitHub issues. To contribute a feature:

  1. Fork it (https://github.com/MatthewFilipovich/pycharge/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Submit a Pull Request

Citing PyCharge

If you are using PyCharge for research purposes, we kindly request that you cite the following paper:

M. Filipovich and S. Hughes, PyCharge: An open-source Python package for self-consistent electrodynamics simulations of Lorentz oscillators and moving point charges, arXiv:2107.12437.

License

PyCharge is distributed under the GNU GPLv3. See LICENSE for more information.

Acknowledgements

PyCharge was written as part of a graduate research project at Queen's University (Kingston, Canada) by Matthew Filipovich and supervised by Stephen Hughes.

You might also like...
made a life sim game because i was tired of a astray gamedev company, everything here is open-source

Srel made a life sim game because i was tired of a astray gamedev company, everything here is open-source Progress Currently making the cmd-line versi

Brawl Stars open source server for v20
Brawl Stars open source server for v20

Laser Scratch Brawl Stars open source server for v20! Implemented Features Battle End Leaderboard Player Profile Lobby Info Menu Notifications Club Wa

Open source Brawl Stars server emulator for version 29 of the game!
Open source Brawl Stars server emulator for version 29 of the game!

Welcome to Classic-Brawl v29 Remake šŸ‘‹ Open source Brawl Stars server emulator for version 29 of the game! (Remake) What's working ? Battles Trophies

Bingo game now in python play as much you want :) no need to give me credit it's open as fuck
Bingo game now in python play as much you want :) no need to give me credit it's open as fuck

Bingo-py-game A game coded with Python Introduction This is a Terminal-based game currently in its initial stage. I am working on adding more efficien

Pokemon game made in Python with open ended requirements from Codecademy

Pokemon game made in Python with open ended requirements from Codecademy. This is one of my first projects utilizing OOP and classes! -This game is a

An open-world game made in Python.
An open-world game made in Python.

Dragon Realms Notes Windows OS only Contributors This project follows the all-contributors specification (emoji key, command Issue). See what you can

A project to san the internet of all open Minecraft servers.

MC-Server-Finder A project that scans the internet to find open Minecraft servers. Install the dependencies by running pip install -r requirements.txt

Launch any Heroic-Games-Launcher game using bash scripts without having to open Heroic.

HeroicBashLauncher Ever wanted to launch your EGS games installed through Heroic Games Launcher directly from the terminal, Lutris or any other fronte

Automates cubemap generation for Source Engine games.

AutoCube Automates cubemap generation for Source Engine games during compile-time. Download: see the release page Installation Using with CompilePal A

Comments
Releases(v1.0)
Owner
Matthew Filipovich
Master's Student in Neuromorphic Photonics and ML. Studied Engineering Physics and Computing @ Queen's University.
Matthew Filipovich
The main objective of the game is to destroy multiple waves of asteroids with the help of a blaster mounted on the spaceship.

Astronomia: let the exploration begin The main objective of the game is to destroy multiple waves of asteroids with the help of a blaster mounted on t

Aryan Nath 8 Nov 18, 2022
Jogo Flappy Bird com phyton e phygame

Flappy-Bird Tecnologias usadas Requisitos para inicializar o jogo: Python faƧa o download em: https://www.python.org/ Pygame faƧa o download em: https

JoĆ£o Guilherme 1 Dec 06, 2021
Pyvidplayer - An extremely easy to use module that plays videos on Pygame

pyvidplayer An extremely easy to use module that plays videos on Pygame Example

17 Dec 05, 2022
Snake (PyGame-based) port for Minecraft:Bedrock Edition using PEWSAPI

Snake_PEWSAPI Snake (PyGame-based) port for Minecraft:Bedrock Edition using PEWSAPI And we are not going to make any change to the original Snake sour

Azuki 1 Mar 17, 2022
Wordle-prophecy - The comprehensive list of all Wordle answers, past and future

About This repo contains the comprehensive list of all Wordle answers, past and

Hayden Moritz 2 Dec 15, 2022
Simple python 3D vector3 math library wrapping some types from GLM library using pybind11.

vmath Simple python 3D vector3 math library wrapping some types from GLM library using pybind11. Description Both pure python version and C++ version

6 Aug 02, 2022
FlappyBird game with python and pygame

FlappyBird game with python and pygame

Mohammad Dori 4 Jul 15, 2022
Creating Tetris with Pygame

Tetris šŸ¤ Contributing Contributions, issues and feature requests are welcome! Feel free to check issues page. Show your support Give a ā­ļø if this pro

Gavin Capriola 0 Mar 01, 2022
A pure-Python Wordle and Absurdle solver

Pyrdle A pure-Python Wordle and Absurdle solver Find the originals here: Wordle Absurdle Basic solving: Wordle To solve today's Wordle, simply run: ./

3 Feb 09, 2022
A python project to help you solve the Wordle game.

A python project to help you solve the Wordle game.

Jia Ping Chu 2 Feb 06, 2022
Simple python program to simulate Conway's game of life with custom variables.

ConwaysGameOfLife Simple python program to simulate Conway's game of life with custom variables. Custom Variables Grid-size : Change the size of the p

davidgasinski 1 Oct 28, 2021
This is a simple game made using pygame.

Ball breaker This is a simple game made using pygame game view The game view have been updated wait for the new view to be uploaded Game_show.mp4 Lear

Rishikesh Kumar 3 Nov 05, 2021
A quantum version of Ladders and Snakes

QPath-and-Snakes A quantum version of Ladders and Snakes Desarrollo Para continuar el desarrollo sin pensar en instalaciĆ³n de dependencias: Descargue

2 Oct 22, 2021
QuizGame is a quiz with different topics. You can choose a topic and take the quiz

QuizGame is a quiz with different topics. You can choose a topic and take the quiz. In the end you will get your result. The program is under active development, so there may be errors or flaws in it

Lev Likhachev 2 Nov 12, 2021
Repository for the DecodED2 Game Project!

DecodED2 Game Project Hello everyone! Welcome to the GitHub Repository for DecodED2, as a start you'll need to clone this repository and make sure you

6 Sep 29, 2021
CoinTex: Cross-platform Multi-Level Game created in Python using Kivy

CoinTex: Cross-platform Multi-Level Game created in Python using Kivy CoinTex is a multi-level adventure game created using the Kivy cross-platform Py

Ahmed Gad 57 Dec 11, 2022
A DDQN that learned to play tic tac toe by playing against itself

TicTacToeAI A DDQN that learned to play tic tac toe by playing against itself Cu

Anik Patel 3 Apr 09, 2022
A python program for playing rock-paper-scissors with computer .

Rock_Paper_Scissors_Cut A time passing famous hand game known as rock paper scissors cut game. Starting from children to adults everyone plays this ga

Arghya Banerjee 1 Dec 16, 2021
Snake Game in Python

Snake game is one of the most popular arcade games of all time. In this game, the main objective of the player is to catch the maximum number of fruits without hitting the wall or itself.

Pavan Ananth Sharma 4 Jul 05, 2022
Chess turnament organizer (short construct concept)

Turnament Organizer Chess turnament organizer (short construct concept). It is my hobby app I want to write to support lightweight tool for smart roun

kkuba91 3 Dec 16, 2022