moldyn package

Submodules

moldyn.base module

class moldyn.base.Box(BOX_SIDE_LENGTH, R_CUT)[source]

Bases: object

Class representing a simulation box.

Parameters

BOX_SIDE_LENGTHfloat

Side length of the simulation box.

R_CUTfloat

Cutoff radius for interactions.

Attributes

_BOX_SIDE_LENGTHfloat

Side length of the simulation box.

_interactionInteraction

Interaction object for particle interactions.

Methods

set_periodic_boundary(r)

Apply periodic boundary conditions to a distance.

set_periodic_boundary(r)[source]

Apply periodic boundary conditions to a distance.

Parameters

rfloat

Distance to apply periodic boundary conditions.

Returns

float

Distance with periodic boundary conditions applied.

class moldyn.base.Ensemble(BOX_SIDE_LENGTH, PARTICLE_NUMBER, R_CUT)[source]

Bases: Box

Class representing an ensemble of particles within a simulation box.

Parameters

BOX_SIDE_LENGTHfloat

Side length of the simulation box.

PARTICLE_NUMBERint

Number of particles in the ensemble.

R_CUTfloat

Cutoff radius for interactions.

Attributes

_PARTICLE_NUMBERint

Number of particles in the ensemble.

_particleslist of Particle

List containing Particle objects.

kinetic_energyfloat

Total kinetic energy of the ensemble.

potential_energyfloat

Total potential energy of the ensemble.

total_energyfloat

Total energy of the ensemble.

temperaturefloat

Temperature of the ensemble.

Methods

generate_particles()

Generate particles and set their initial positions.

set_initial_velocities(VELOCITY_AMPLITUDE)

Set initial velocities for all particles in the ensemble.

calculate_ensemble_momentum()

Calculate the total momentum of the ensemble.

calculate_ensemble_energy()

Calculate the total energy of the ensemble.

get_ensemble_temperature()

Calculate the temperature of the ensemble.

normalize_momentum()

Normalize the momentum of the ensemble.

update_ensemble_acceleration()

Update the acceleration of each particle in the ensemble.

propagate_velocity_verlet(dt)

Propagate particle positions and velocities using the Velocity-Verlet algorithm.

change_temperature(eta)

Change the temperature of the ensemble.

get_particle_positions()

Get the positions of all particles in the ensemble.

plot_ensemble()

Plot the ensemble configuration.

calculate_ensemble_energy()[source]

Calculate the total energy of the ensemble.

Returns

float

Total energy of the ensemble.

calculate_ensemble_momentum()[source]

Calculate the total momentum of the ensemble.

Returns

float

Total momentum of the ensemble.

change_temperature(eta)[source]

Change the temperature of the ensemble.

Parameters

etafloat

Scaling factor for velocities.

generate_particles()[source]

Generate particles and set their initial positions.

get_ensemble_temperature()[source]

Calculate the temperature of the ensemble.

Returns

float

Temperature of the ensemble.

get_particle_positions()[source]

Get the positions of all particles in the ensemble.

Returns

list of numpy.ndarray

List of particle positions.

normalize_momentum()[source]

Normalize the momentum of the ensemble.

plot_ensemble()[source]

Plot the ensemble configuration.

propagate_velocity_verlet(dt)[source]

Propagate particle positions and velocities using the Velocity-Verlet algorithm.

Parameters

dtfloat

Time step for the integration.

set_initial_velocities(VELOCITY_AMPLITUDE)[source]

Set initial velocities for all particles in the ensemble.

Parameters

VELOCITY_AMPLITUDEfloat

Amplitude for generating initial velocities.

update_ensemble_acceleration()[source]

Update the acceleration of each particle in the ensemble.

class moldyn.base.Interaction(R_CUT)[source]

Bases: object

Class representing particle interactions.

Parameters

R_CUTfloat

Cutoff radius for interactions.

Attributes

__R_CUTfloat

Cutoff radius for interactions.

Methods

LJ_potential(r)

Calculate the Lennard-Jones potential for a given distance.

LJ_force(r)

Calculate the Lennard-Jones force for a given distance.

LJ_force(r)[source]

Calculate the Lennard-Jones force for a given distance.

Parameters

rfloat

Distance between particles.

Returns

float

Lennard-Jones force.

LJ_potential(r)[source]

Calculate the Lennard-Jones potential for a given distance.

Parameters

rfloat

Distance between particles.

Returns

float

Lennard-Jones potential.

class moldyn.base.Particle(location=[None, None], velocity=[None, None], acceleration=[None, None])[source]

Bases: object

Class representing a particle in a simulation.

Parameters

locationlist of float, optional

Initial position of the particle. Default is [None, None].

velocitylist of float, optional

Initial velocity of the particle. Default is [None, None].

accelerationlist of float, optional

Initial acceleration of the particle. Default is [None, None].

Attributes

_MASSfloat

Mass of the particle.

locationnumpy.ndarray

Current position of the particle.

velocitynumpy.ndarray

Current velocity of the particle.

accelerationnumpy.ndarray

Current acceleration of the particle.

Methods

get_kinetic_energy()

Calculate the kinetic energy of the particle.

get_momentum()

Calculate the momentum of the particle.

get_kinetic_energy()[source]

Calculate the kinetic energy of the particle.

Returns

float

The kinetic energy of the particle.

get_momentum()[source]

Calculate the momentum of the particle.

Returns

numpy.ndarray

The momentum of the particle.

Module contents