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
This is a 2D Link to the Past-esque game made using Python 3.2.5 and pygame 1.9.2

Queen-s-Demise Queen's Demise This is a 2D Link to the Past-esque game made using Python 3.2.5 and pygame 1.9.2 I made this for a game development cla

Zoey 1 Dec 15, 2021
An automation bot to play Myuu Discord game

Auto selfbot Myuu is a self Discordbot, meaning it will use your TOKEN to logged as your account and take commands from yourself to play the game.

6 Dec 15, 2022
A solution program of 24. game.

A solution program of 24. game.

1 Dec 12, 2022
A very simple 3D maze game with ray tracing.

PytracingMaze MOST RECENT VERSION: Pytracing Maze.py Also, executable for Windows available on itch.io Simple ray tracing game in Python, based on my

FinFET 15 Dec 20, 2022
A Pygame Hangman Game coded in Python 3. Run Hangman.py in a terminal if you have Python 3

Hangman A Pygame Hangman Game coded in Python 3. Run python3 Hangman.py in a terminal if you have Python 3.

1 Dec 24, 2022
Breakout-KD - A fantastic game created in python with pygame ✌️

Breakout-KD About This Game Breakout-KD is a fantastic breakout game. It's a python based game officialy made by me on december holiday. This game wor

Keep Distance 1 Jan 01, 2022
uses Entropy to find the best next guess for Wordle, given the color clues

WordleSolver uses Entropy to find the best next guess for Wordle, given the color clues use player.py and enter in the string for the suggested clue w

Steve Earth 1 Jan 26, 2022
HackNC 2021 Project

pyTunes HackNC 2021 Project Setting Up Once the repo is cloned, install the requirements through pip install -r ./requirements.txt Once that is done,

Demo 1 Nov 07, 2021
WORDLE Helper and Solver

WORDLE Helper and Solver There is a pupular game around WORDLE The game could be hard for non-English speaking people so I started to think of a helpe

1 Jan 24, 2022
WIP python/pygame 2D zombie shooter

2d-shooter project A single/multiplayer co-op survival small space zombie shooter. If you'd like to contribute, feel free to join the discord! INSTALL

36 Dec 08, 2022
Rock Paper Scissors Game with PyQt5

Rock-Paper-Scissors-Game rock paper scissors is a old game that all of us played it but this time let's play with computer Description This is Rock Pa

MohammadAli.HBA 4 Nov 11, 2021
A Tetris Game for programming education

Tetris Game プログラミング学習を目的とした、ブロックを操作してスコアを競うゲームです。 FAQはこちら。 tutorialはこちら。 実行環境準備 Mac環境 Finder→Application→Utility→Terminalから、ターミナルを起動して以下コマンドを実行する。 # i

11 Dec 01, 2022
Implementation of the famous puzle Tower of Hanoi

Tower_of_Hanoi Implementation of the famous puzle "Tower of Hanoi". The setup consists of three pegs (sticks) and a certain amount of discs (in this i

Raffaele Fiorillo 3 Mar 08, 2022
A small script to help me solve Wordle because I'm that lazy

Wordle Solver A small script to help me solve Wordle because I'm that lazy. Warning: I didn't write this to be efficient nor elegant at all, so you'll

K4YT3X 3 Feb 11, 2022
AI that plays Flappy Bird Game using the python module NEAT.

Flappy Bird AI [NEAT] AI that plays Flappy Bird Game using the python module NEAT. Instructions Install Python Modules: pip3 install -r requirements.t

Abhisht 5 Jan 26, 2022
Solution for automation games play-to-earn

Pillow automation used processing images

Luis Eduardo Camilo 1 Jan 19, 2022
PLVRA is a TUI (Terminal User Interface) implementation of wordle / termo in portuguese, written in Python

PLVRA is a TUI (Terminal User Interface) implementation of wordle / termo in portuguese, written in Python

Enzo Shiraishi 1 Feb 11, 2022
You want to uto-update your private minecraft client? Give this to developer and enjoy!

minecraft-hack-installer You want to uto-update your private minecraft client? Give this to developer and enjoy! Steps to do: Install libraries: pip i

EuropeStudio 1 Jun 03, 2022
Synthesizer based on Conway's Game of Life

Conway Synth Synthesizer based on Conway's Game of Life Trying to avoid step sequencer fashions that have been done before and basing it on actual cel

Giacomo Loparco 4 Mar 15, 2022
a simple keyboard game

Maxwell-Demon-Game Powered by Taichi. a simple keyboard game This is hw2 of Taichi course, as a basic exercise of class. Rigid 2d bodies and resolve c

8 Feb 01, 2022