Skip to main content

A Python package to create and simulate physics models.

Project description

sage-physics

Category Tools
Development black ruff mypy docformatter
Package version pythonversion downloads
Documentation mkdocs
Communication gitter discussions

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sage-physics-0.1.0.tar.gz (8.4 kB view hashes)

Uploaded Source

Built Distribution

sage_physics-0.1.0-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page