pycharge
Differentiable electromagnetics simulation library for moving point charges built on JAX
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 4 DOI reference(s) in README -
✓Academic publication links
Links to: arxiv.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.8%) to scientific vocabulary
Keywords
Repository
Differentiable electromagnetics simulation library for moving point charges built on JAX
Basic Info
- Host: GitHub
- Owner: MatthewFilipovich
- License: gpl-3.0
- Language: Python
- Default Branch: main
- Homepage: https://pycharge.readthedocs.io
- Size: 4.51 MB
Statistics
- Stars: 73
- Watchers: 6
- Forks: 35
- Open Issues: 0
- Releases: 6
Topics
Metadata Files
README.md
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.
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 research paper, published in Computational Physics Communications and available on arXiv, introduces the PyCharge package and provides a comprehensive 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:
sh
pip install pycharge
To install in development mode, clone the GitHub repository and install with pip using the editable option:
sh
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:
python
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:
python
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:
- Fork it (https://github.com/MatthewFilipovich/pycharge/fork)
- Create your feature branch (
git checkout -b feature/fooBar) - Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - 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, Comput. Phys. Commun. 274, 108291 (2022).
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.
Owner
- Name: Matthew Filipovich
- Login: MatthewFilipovich
- Kind: user
- Repositories: 2
- Profile: https://github.com/MatthewFilipovich
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
preferred-citation:
type: article
authors:
- family-names: "Filipovich"
given-names: "Matthew J."
orcid: "https://orcid.org/0000-0002-2195-698X"
- family-names: "Hughes"
given-names: "Stephen"
doi: "10.1016/j.cpc.2022.108291"
journal: "Computer Physics Communications"
month: 5
start: 108291 # First page number
title: "PyCharge: An open-source Python package for self-consistent electrodynamics simulations of Lorentz oscillators and moving point charges"
volume: 274
year: 2022
GitHub Events
Total
- Create event: 2
- Release event: 1
- Issues event: 2
- Watch event: 11
- Delete event: 1
- Issue comment event: 3
- Push event: 8
- Fork event: 4
Last Year
- Create event: 2
- Release event: 1
- Issues event: 2
- Watch event: 11
- Delete event: 1
- Issue comment event: 3
- Push event: 8
- Fork event: 4
Committers
Last synced: almost 3 years ago
All Time
- Total Commits: 25
- Total Committers: 3
- Avg Commits per committer: 8.333
- Development Distribution Score (DDS): 0.36
Top Committers
| Name | Commits | |
|---|---|---|
| Matthew | m****i@g****m | 16 |
| Matthew Filipovich | m****v@g****m | 8 |
| Matthew Filipovich | 4****h@u****m | 1 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 5
- Total pull requests: 0
- Average time to close issues: about 2 months
- Average time to close pull requests: N/A
- Total issue authors: 2
- Total pull request authors: 0
- Average comments per issue: 0.4
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: 2 days
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 2.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- MatthewFilipovich (4)
- dec1 (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 361 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 6
- Total maintainers: 1
pypi.org: pycharge
Electrodynamics simulator for calculating the fields and potentials generated by moving point charges and simulating oscillating dipoles.
- Homepage: https://github.com/MatthewFilipovich/pycharge
- Documentation: https://pycharge.readthedocs.io/
- License: GNU General Public License v3 (GPLv3)
-
Latest release: 1.1.0
published 6 months ago
Rankings
Maintainers (1)
Dependencies
- dill ==0.3.3
- jinja2 <3.1.0
- matplotlib ==3.4.2
- mkdocs-material ==7.1.5
- mkdocstrings ==0.15.1
- numpy ==1.20.3
- python-markdown-math ==0.8
- scipy ==1.6.3
- tqdm ==4.61.2
- mpi4py ==3.0.3
- dill ==0.3.4
- matplotlib ==3.4.2
- numpy ==1.21.1
- scipy ==1.7.0
- tqdm ==4.61.2
- dill *
- matplotlib *
- numpy *
- scipy *
- tqdm *
- actions/checkout master composite
- actions/setup-python master composite
- codecov/codecov-action v1 composite