Table Of Contents

Previous topic

demo Package

Next topic

geometry Package

This Page

forces Package

forces Package

force Module

class pyparticles.forces.force.Force(size, dim, m=None, Conts=1.0)

Bases: object

The main abstract class used as interface for the forces classes

Constructor

Parameters:
  • size – the number of particles in the system
  • dim – the dimension of the system (3D, 2D..)
  • m – a vector containig the masses
  • Const – the force constants (Like G, K ...)
A

(property) return the array of the acclerations

F

(property) returns the array of the forces

const

(property) returns the force contants

getA()

return the array of the acclerations

getF()

returns the array of the forces

get_const()

returns the force contants

set_masses(m)

Set the masses used for computing the forces.

Parameters:m – An array containig the masses
update_force(p_set)

Computes the forces of the current status ad return the accelerations of the particles

Parameters:p_set – Particles set obj.

force_constrained Module

class pyparticles.forces.force_constrained.ForceConstrained(size, dim, m=None, Conts=1.0, f_inter=None)

Bases: pyparticles.forces.force.Force

force_interactions
get_force_interactions()
set_force_interactions(fi)

gravity Module

class pyparticles.forces.gravity.Gravity(size, dim=3, m=None, Consts=1.0)

Bases: pyparticles.forces.force.Force

Compute the gravitational force between the particles

The gravity between two particles is defined as follow:

\mathbf{F}_{12}=-G \frac{m_1 m_2 }{r^2}\hat{r}_{12}

Constructor

Parameters:
  • size – the number of particles in the system
  • dim – the dimension of the system
  • m – a vector containig the masses
  • Const – the gravitational constant
A

Return the currents accelerations of the particles (getter only)

F

Return the currents forces on the particles (getter only)

getA()

Return the currents accelerations of the particles

getF()

Return the currents forces on the particles

set_masses(m)

Set the masses used for computing the forces.

update_force(p_set)

Compute the force of the current status of the system and return the accelerations of every particle in a size by dim array

const_force Module

class pyparticles.forces.const_force.ConstForce(size, dim=3, m=None, u_force=[0, 0, 0], Consts=1.0)

Bases: pyparticles.forces.force.Force

Constant force field.

Constructor

Parameters:
  • size – the number of particles in the system
  • dim – the dimension of the system
  • m – a vector containig the masses
  • u_force – The force vector (Force per unit of mass)
A
F
getA()
getF()
set_masses(m)
update_force(p_set)

drag Module

class pyparticles.forces.drag.Drag(size, dim=3, m=None, Consts=1.0)

Bases: pyparticles.forces.force.Force

Calculate the forces of resistance. Drag is a force that reacts to the movement with respect to a square law speed. It’s commonly used for describing the resistance of a fluid

The force is given the equation:

F_i=-\frac{1}{2}K\dot{X}^2

Constructor:

Parameters:
  • size – the number of particles in the system
  • dim – the dimension of the system
  • m – a vector containig the masses
  • Const – the drag factor K
A
F
getA()
getF()
set_masses(m)
update_force(pset)

damping Module

class pyparticles.forces.damping.Damping(size, dim=3, m=None, Consts=1.0)

Bases: pyparticles.forces.force.Force

Compute the damping forces, the damping is a force that react proportionally to the velocity

The force is given the equation:

F_i = -C\dot{X}

Constructor

Parameters:
  • size – the number of particles in the system
  • dim – the dimension of the system
  • m – a vector containig the masses
  • Const – the damping factor
A
F
getA()
getF()
set_masses(m)
update_force(pset)

electrostatic Module

class pyparticles.forces.electrostatic.Electrostatic(size, dim=3, m=None, q=None, Consts=1.0)

Bases: pyparticles.forces.force.Force

Compute the electrostatic force using the Culomb law.

..note:

The real forces of an electrodynamic system is given by the **Maxwell equations**! and not from the Culomb law.

The Culomb law is adapt for computing forces in a static system of particles and not for moving particles.

But for a very slow movement it should be a good approximation.

\vec F = k \, q_1 \, q_2 \, \frac {\vec r_1 - \vec r_2}{\left \| \vec r_1 - \vec r_2 \right \|^3}

A
F
getA()
getF()
set_charges(q)
set_masses(m)
update_force(p_set)

electromagnetic_field Module

class pyparticles.forces.electromagnetic_field.ElectromagneticField(size, dim=3, m=None, q=None, Consts=1.0)

Bases: pyparticles.forces.force.Force

Compute the electromagnetic force of a system of charged and non-selfinteracting particles system immersed in an electromagnetic filed according to the Lorenz formulation.

\mathbf{F} = q(\mathbf{E} + \mathbf{v} \times \mathbf{B})

A
F
append_electric_field(ef, key=None)

Append a vector field funcion to the list of electric field funtions.

The field function must be in the form | ef( E , X ) | | Where: | E is a n by 3 numpy array of vectors used for the resulting filed. | X is a n by 3 numpy array of coordinates

append_magnetic_field(bf, key=None)

Append a vector field funcion to the list of megnetic field funtions.

It return the key used to identify the funtion, if key == None it uses a random number.

The filed function must be in the form | bf( B , X ) | | Where: | B is a n by 3 numpy array of vectors used for the resulting filed. | X is a n by 3 numpy array of coordinates

getA()
getF()
set_charges(q)
set_masses(m)
update_force(pset)

lennard_jones Module

class pyparticles.forces.lennard_jones.LenardJones(size, dim=3, m=None, Consts=(1.0, 1.0))

Bases: pyparticles.forces.force.Force

Compute the lenard jones force between the particles

The L. J. force between two particles is defined as follow:

\mathbf{F}(r) = 4 \epsilon \left(12\,{\frac{{\sigma}^{12}}{{r}^{13}}}-6\,{\frac{{\sigma}^{6}}{{r}^{7}}}\right)\hat{\mathbf{r}}

Constructor:

Parameters:
  • size – the number of particles in the system
  • dim – the dimension of the system
  • m – a vector containig the masses
  • Const – An indexable object[*] with the two contants
[*] Const[0] = \epsilon
Const[1] = \sigma
A

Return the currents accelerations of the particles (getter only)

F

Return the currents forces on the particles (getter only)

getA()

Return the currents accelerations of the particles

getF()

Return the currents forces on the particles

set_masses(m)

Set the masses used for computing the forces.

update_force(p_set)

Compute the force of the current status of the system and return the accelerations of every particle in a size by dim array

Parameters:p_set – Particles set obj.

linear_spring Module

class pyparticles.forces.linear_spring.LinearSpring(size, dim=3, m=None, Consts=1.0)

Bases: pyparticles.forces.force.Force

Compute the forces according to the Hooke’s law.

F_i = -k X

Parameters:
  • size – size of the particles system
  • dim – dimension of the system
  • m – an array containing the masses
  • const – spring constant ( K )
A
F
const
getA()
getF()
get_const()
set_masses(m)

set the masses of the particles

update_force(p_set)

linear_spring_constrained Module

class pyparticles.forces.linear_spring_constrained.LinearSpringConstrained(size, dim, m=None, Consts=1.0, f_inter=None)

Bases: pyparticles.forces.force_constrained.ForceConstrained

A
F
const
getA()
getF()
get_const()
set_masses(m)

set the masses of the particles

update_force(pset)

multiple_force Module

class pyparticles.forces.multiple_force.MultipleForce(size, dim=3, m=None, Conts=None)

Bases: object

Combine the effect of some forces, for example constant force and springs. It behaves like any other force, and can be used with all methods of numerical integration.

A
F
append_force(force)

Append a new force to the forces list

getA()
getF()
set_masses(m)

Set the masses in the forces system

update_force(p_set)

pseudo_bubble Module

class pyparticles.forces.pseudo_bubble.PseudoBubble(size, dim=3, m=None, Consts=(0.3, 2.0))

Bases: pyparticles.forces.force.Force

Pseudo Bubble is a fake force that produce the effect of the bubbles in a fluid.

\begin{cases}
 & \text{ if } d_{i,j} < R \,\,\, \text{then} \,\,\,F_{i,j}= -\frac{B}{R}d_{i,j}+\frac{B}{d_{i,j}} \\ 
 & \text{ if } d_{i,j} \geqslant  R \,\,\, \text{then} \,\,\,F_{i,j}= 0
\end{cases}

A
F
getA()
getF()
set_masses(m)
update_force(pset)

van_der_waals_force Module

class pyparticles.forces.van_der_waals_force.VanDerWaals(size, dim=3, m=None, Consts=1.0)

Bases: pyparticles.forces.force.Force

A
F
getA()
getF()
set_masses(m)
update_force(p_set)

vector_field_force Module

class pyparticles.forces.vector_field_force.VectorFieldForce(size, dim=3, m=None)

Bases: pyparticles.forces.force.Force

A
F
getA()
getF()
set_masses(m)
update_force(p_set)
vect_fun(X)