Skip to main content

No project description provided

Project description

PyVicsek

This is a Python library used to simulate systems using the Vicsek model. It currently has support for non periodic-boundary conditions, $N$-dimensional space, as well as particle heterogeneity.

Dependencies and Installation

VicsekPy is best run on Python 3.9+ and is supported by numpy, scipy, matplotlib, and tqdm. Additionally, unit tests are made with pytest. These packages are automatically included in requirements.txt.

To download VicsekPy, run the following commands in a UNIX terminal:

git clone https://github.com/mehtan-rahman/PyVicsek
cd vicsek
pip install .

Examples

Here is a basic script to initialize and create a 2-D homogenous Vicsek system.

import vicsek as vs

N = 1024
L = 16
v = 0.03

particles = vs.initialize_random_particles(
    n_particles=N,
    box_length=L,
    speed=v,
    n_dimensions=2,
    particle_type='standard'
)

vicsek = vs.Vicsek(
    particles=particles,
    length=L,
    interaction_range=1.0,
    speed=v,
    base_noise=0.5,
)

anim = vicsek.animate(frames=200)
anim.save(filename='example.gif')

Here is another example to initialize a 2-D heterogeneous Vicsek system.

import vicsek as vs

N = 1024
L = 16
v = 0.03

particles_A = vs.initialize_random_particles(
    n_particles=round(N * 0.5),
    box_length=L,
    speed=v,
    n_dimensions=2,
    particle_type='A'
)

particles_B = vs.initialize_random_particles(
    n_particles=round(N * 0.5),
    box_length=L,
    speed=v,
    n_dimensions=2,
    particle_type='B'
)

particles = particles_A + particles_B

alignment_weights = {
    ('A', 'A'): 1.0,
    ('B', 'B'): 1.0,
    ('A', 'B'): -1.0,
    ('B', 'A'): -1.0,
}

noise_weights = {
    ('A', 'A'): 0.5,  # low noise within groups
    ('B', 'B'): 0.5,
    ('A', 'B'): 2.0,  # high noise between groups
    ('B', 'A'): 2.0,
}

legend = {
    'A': 'red',
    'B': 'blue',
}


vicsek = vs.HeterogeneousVicsek(
    particles=particles,
    length=L,
    interaction_range=1.0,
    speed=v,
    base_noise=0.5,
    alignment_weights=alignment_weights,
    noise_weights=noise_weights
)

anim = vicsek.animate(frames=200, legend=legend)
anim.save(filename='hetero_example.gif')

You can find more information on the Vicsek class as well as other classes in the doc-strings located in the files of the vicsek directory. You can also find further examples in the scripts directory, where they are organized by system type.

Roadmap

If given more time, we would like to spend some time working on the following things for this library:

  • PyPI support.
  • Higher dimensional testing.
  • Lyapunov analysis of phase dimensions (based on this paper).
  • Geometry support for particles and boundaries using shapely.

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

pyvicsek-0.1.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvicsek-0.1.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file pyvicsek-0.1.0.tar.gz.

File metadata

  • Download URL: pyvicsek-0.1.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for pyvicsek-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b07be20df877855ad55e80982c03a8a1604cedd2a83c7fdce1587f0ccdd60aaf
MD5 15b1c936d509e68ddb06bba5520ed0c6
BLAKE2b-256 528760f53c7d8018d0af51216b6b7f669686678dd58d1d84270cf04a192a73e1

See more details on using hashes here.

File details

Details for the file pyvicsek-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyvicsek-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for pyvicsek-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c56bf6617275c4cfecfdddc8d13120497aaee786b94c133eccc71937331b3a2e
MD5 9f2f5e14f064b2bf9249ad50b1871ad7
BLAKE2b-256 1684f76d9f59cc2303fc9277ee1c8b7ec0ac59f7a6fd34f1aa7017c7b4504a78

See more details on using hashes here.

Supported by

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