Forces
Force functions for particles.
This module contains functions for applying forces to particles. It includes functions for moving, attracting, repelling and gravitating particles. It also includes variations of these functions for specific species of particles.
attract(particles, pos, mass, radius)
Attract the particles to a position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particles |
template
|
Particles. |
required |
pos |
vec2
|
Attraction position. |
required |
mass |
f32
|
Attraction mass. |
required |
radius |
f32
|
Attraction radius. |
required |
Source code in src/tolvera/vera/forces.py
attract_particle(p, pos, mass, radius)
Attract a particle to a position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particles |
Particle
|
Individual particle. |
required |
pos |
vec2
|
Attraction position. |
required |
mass |
f32
|
Attraction mass. |
required |
radius |
f32
|
Attraction radius. |
required |
Returns:
Type | Description |
---|---|
vec2
|
ti.math.vec2: Attraction velocity. |
Source code in src/tolvera/vera/forces.py
attract_species(particles, pos, mass, radius, species)
Attract the particles of a given species to a position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particles |
template
|
Particles. |
required |
pos |
vec2
|
Attraction position. |
required |
mass |
f32
|
Attraction mass. |
required |
radius |
f32
|
Attraction radius. |
required |
species |
i32
|
Species index. |
required |
Source code in src/tolvera/vera/forces.py
centripetal(particles, centre, direction, weight)
Apply a centripetal force to the particles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particles |
template
|
Particles. |
required |
centre |
vec2
|
Centripetal centre. |
required |
direction |
i32
|
Centripetal direction. |
required |
weight |
f32
|
Centripetal weight. |
required |
Source code in src/tolvera/vera/forces.py
centripetal_particle(p, centre, direction, weight)
Apply a centripetal force to a particle.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p |
Particle
|
Individual particle. |
required |
centre |
vec2
|
Centripetal centre. |
required |
direction |
i32
|
Centripetal direction. |
required |
weight |
f32
|
Centripetal weight. |
required |
Returns:
Type | Description |
---|---|
vec2
|
ti.math.vec2: Centripetal velocity. |
Source code in src/tolvera/vera/forces.py
gravitate(particles, G, radius)
Gravitate the particles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particles |
template
|
Particles. |
required |
G |
f32
|
Gravitational constant. |
required |
radius |
f32
|
Gravitational radius. |
required |
Source code in src/tolvera/vera/forces.py
gravitate_species(particles, G, radius, species)
Gravitate the particles of a given species.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particles |
template
|
Particles. |
required |
G |
f32
|
Gravitational constant. |
required |
radius |
f32
|
Gravitational radius. |
required |
species |
i32
|
Species index. |
required |
Source code in src/tolvera/vera/forces.py
gravitation(p1, p2, G)
Calculate the gravitational force between two particles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p1 |
Particle
|
Particle 1. |
required |
p2 |
Particle
|
Particle 2. |
required |
G |
f32
|
Gravitational constant. |
required |
Returns:
Type | Description |
---|---|
vec2
|
ti.math.vec2: Gravitational force. |
Source code in src/tolvera/vera/forces.py
move(particles, weight)
Move the particles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particles |
template
|
Particles. |
required |
Source code in src/tolvera/vera/forces.py
noise(particles, weight)
Add noise to the particles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particles |
template
|
Particles. |
required |
weight |
f32
|
Noise weight. |
required |
Source code in src/tolvera/vera/forces.py
repel(particles, pos, mass, radius)
Repel the particles from a position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particles |
template
|
Particles. |
required |
pos |
vec2
|
Repulsion position. |
required |
mass |
f32
|
Repulsion mass. |
required |
radius |
f32
|
Repulsion radius. |
required |
Source code in src/tolvera/vera/forces.py
repel_particle(p, pos, mass, radius)
Repel a particle from a position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p |
Particle
|
Individual particle. |
required |
pos |
vec2
|
Repulsion position. |
required |
mass |
f32
|
Repulsion mass. |
required |
radius |
f32
|
Repulsion radius. |
required |
Returns:
Type | Description |
---|---|
vec2
|
ti.math.vec2: Repulsion velocity. |
Source code in src/tolvera/vera/forces.py
repel_species(particles, pos, mass, radius, species)
Repel the particles of a given species from a position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
particles |
template
|
Particles. |
required |
pos |
vec2
|
Repulsion position. |
required |
mass |
f32
|
Repulsion mass. |
required |
radius |
f32
|
Repulsion radius. |
required |
species |
i32
|
Species index. |
required |