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:

pip install pyvicsek

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:

  • 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.1.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.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyvicsek-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 8cd1d568bf512848dab0f4f006a3845b7b3f929ce84a59425e977e2424518b15
MD5 19d9a1938011a9e6fc00c0f3c5a666c2
BLAKE2b-256 a00c02efe30db81b2007d80f6804c696b8848fbddeeeddacabe1a569bd444acb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyvicsek-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6a05cb7f4fdafc48af1559f4273b50b11285b33a9df555366281ab3649037502
MD5 4edb82788c434f6bfccf4cfb68709761
BLAKE2b-256 403b505d0a118361ac2373f8c2047519f05b2aab2a4bf64013a86728132d3f7a

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