Category | Tools |
---|---|
Development | |
Package | |
Documentation | |
Communication |
A Python package to create and simulate complex systems.
Either sagemath-standard
or an installation of SageMath is required with a version greater than
10.0.
Initially, create a Python virtual environment with one of the following two ways:
-
Use the command
sage -python -m venv --system-site-packages .venv
to create and activate Python virtual environment with all the prerequisites installed: -
Use one of the standard ways to create a Python virtual environment and install the package
sagemath-standard
.
You can install scikit-complexity
either as a normal user or for development purposes.
For user installation, scikit-complexity
is currently available on the PyPi's repository, and you can
install it via pip
:
pip install scikit-complexity
Development installation requires to clone the repository and change directory to the project's root:
git clone https://github.com/georgedouzas/scikit-complexity.git
cd scikit-complexity
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
One of the scikit-complexity
main goals is to provide a unified interface for modelling various complex systems.
For example, let's define two independent harmonic oscillators that oscillate in the axes x and y:
from sage.all import assume, symbolic_expression, var, cos, sin, sqrt
from skcomplex.physics import (
ClassicalMechanicsSystem,
ExternalForce,
PointParticle,
)
from skcomplex.spaces import EuclideanSpace
k, x__1, y__2 = var('k x__1 y__2')
assume(k > 0)
system = ClassicalMechanicsSystem(
particles=[PointParticle('1'), PointParticle('2')],
external_interactions=[
ExternalForce('elastic1', '1', [-k * x__1, 0]),
ExternalForce('elastic2', '2', [0, -k * y__2])
],
space=EuclideanSpace('euclidean', n_dim=2),
)
We can simulate the system and solve the dynamical equations:
system.simulate()
var('_K1 _K2 m__1 m__2 t')
assert system.simulation_results_['dynamic_equations']['solutions'] == {
'1': [_K2*cos(sqrt(k)*t/sqrt(m__1)) + _K1*sin(sqrt(k)*t/sqrt(m__1)), _K2*t + _K1],
'2': [_K2*t + _K1, _K2*cos(sqrt(k)*t/sqrt(m__2)) + _K1*sin(sqrt(k)*t/sqrt(m__2))]
}