moldyn package
Submodules
moldyn.base module
- class moldyn.base.Box(BOX_SIDE_LENGTH, R_CUT)[source]
Bases:
objectClass 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.
- class moldyn.base.Ensemble(BOX_SIDE_LENGTH, PARTICLE_NUMBER, R_CUT)[source]
Bases:
BoxClass 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.
- 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.
- propagate_velocity_verlet(dt)[source]
Propagate particle positions and velocities using the Velocity-Verlet algorithm.
Parameters
- dtfloat
Time step for the integration.
- class moldyn.base.Interaction(R_CUT)[source]
Bases:
objectClass 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.
- class moldyn.base.Particle(location=[None, None], velocity=[None, None], acceleration=[None, None])[source]
Bases:
objectClass 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.