A Python package to create and simulate physics models.
Project description
sage-physics
Category | Tools |
---|---|
Development | |
Package | |
Documentation | |
Communication |
Introduction
A Python package to create and simulate physics models.
Prerequisites
An installation of SageMath with version > 10.0 is required.
Installation
You can install sage-physics
either as a normal user or for development purposes.
User
For user installation, sage-physics
is currently available on the PyPi's repository, and you can
install it via pip
:
sage --pip install sage-physics
You can then start the Sage REPL with the command sage
and use sage-physics
through the Sage REPL:
import sagephys
Development
Development installation requires to clone the repository and change directory to the project's root:
git clone https://github.com/georgedouzas/sage-physics.git
cd sage-physics
Then create a Python virtual environment using the sage
command:
sage -python -m venv --system-site-packages .venv
Finally, use PDM to select the virtual environment and install the project as well as the main and development dependencies:
pdm use .venv
pdm install
You can then start the Sage REPL with the command PYTHONPATH=src sage
and use sage-physics
through the Sage REPL:
import sagephys
Usage
One of the sage-physics
main goals is to provide a unified interface for various physics models. For example let's define two
independent harmonic oscillators that oscillate in the axes x and y:
from sage.all import var, assume
from sagephys.classical_mechanics import NewtonianPointParticlesModel
k, x_particle1, y_particle2 = var('k x_particle1 y_particle2')
assume(k > 0)
forces = {
'particle1': {'elastic': [- k * x_particle1, 0, 0]},
'particle2': {'elastic': [0, -k * y_particle2, 0]}
}
model = NewtonianPointParticlesModel(forces)
We can get the dynamical equations:
model.analyze()
model.equations_
We can also try to solve them:
model.solve()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sage_physics-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc0611ac5a9c3b55a9168a673c2a6a160311f92293cae985aff1c57cbb8910ac |
|
MD5 | 719b6f70443d67a5e6f40b6c7ca8b958 |
|
BLAKE2b-256 | aa68a16d585b7e81ce79018889bfbc30658011cf5b408d5b244b0fccba51130b |