sarkas.particles.Particles#

class sarkas.particles.Particles[source]#

Class handling particles’ properties.

Variables
  • kB (float) – Boltzmann constant.

  • fourpie0 (float) – Electrostatic constant \(4\pi \epsilon_0\).

  • pos (numpy.ndarray) – Particles’ positions.

  • vel (numpy.ndarray) – Particles’ velocities.

  • acc (numpy.ndarray) – Particles’ accelerations.

  • box_lengths (numpy.ndarray) – Box sides’ lengths.

  • pbox_lengths (numpy.ndarray) – Initial particle box sides’ lengths.

  • masses (numpy.ndarray) – Mass of each particle. Shape = (attr:sarkas.core.Parameters.total_num_ptcls).

  • charges (numpy.ndarray) – Charge of each particle. Shape = (attr:sarkas.core.Parameters.total_num_ptcls).

  • id (numpy.ndarray,) – Species identifier. Shape = (attr:sarkas.core.Parameters.total_num_ptcls).

  • names (numpy.ndarray) – Species’ names. (attr:sarkas.core.Parameters.total_num_ptcls).

  • rdf_nbins (int) – Number of bins for radial pair distribution.

  • no_grs (int) – Number of independent \(g_{ij}(r)\).

  • rdf_hist (numpy.ndarray) – Histogram array for the radial pair distribution function.

  • prod_dump_dir (str) – Directory name where to store production phase’s simulation’s checkpoints. Default = ‘dumps’.

  • eq_dump_dir (str) – Directory name where to store equilibration phase’s simulation’s checkpoints. Default = ‘dumps’.

  • total_num_ptcls (int) – Total number of simulation’s particles.

  • num_species (int) – Number of species.

  • species_num (numpy.ndarray) – Number of particles of each species. Shape = (attr:sarkas.particles.Particles.num_species).

  • dimensions (int) – Number of non-zero dimensions. Default = 3.

  • potential_energy (float) –

    Instantaneous value of the potential energy of each particle. Note that the total potential energy requires the multiplication of the array’s sum by 0.5 to avoid double counting.

    For example: N = 3, particle_potential_energy[0] = U_12 + U_13 and particle_potential_energy[1] = U_21 + U_23 and particle_potential_energy[1] = U_31 + U_32

  • rnd_gen (numpy.random.Generator) – Random number generator.

Notes

Naming convention:

Properties/Quantities of each particle are stored in numpy.ndarray’s as .[property].

Species properties/quantities are stored in numpy.ndarray’s as .species_[property].

Total properties/quantities are stored as float/int identified by .total_[property].

For example:

total_num_ptcls is an int indicating the total number of particles. potential_energy is a 1-D array of length total_num_ptcls containing the potential energy of each particle.

species_num is a 1-D array of length num_species containing the number of particles of each species.

Methods for the calculation of properties/quantities follow the same convention as above but we the prefix .calculate_[quantity].

For example:

calculate_kinetic_energy() calculates the kinetic energy of each particle and stores it in kinetic_energy a 1-D array of length total_num_ptcls.

calculate_species_kinetic_energy() calculates the kinetic energy of each species and stores it in species_kinetic_energy a 1-D array of length num_species.

calculate_total_kinetic_energy() calculates the total kinetic energy and stores it in tottal_kinetic_energy a float.

Quantities requiring cross species evaluation are stored in numpy.ndarray as .[quantity]_species_tensor.

For example: virial_species_tensor is a 3 x 3 x num_species x num_species tensor. heat_flux_species_tensor is a 3 x num_species x num_species tensor. The attributes potential_energy, virial_species_tensor, heat_flux_species_tensor are calculated by the sarkas.potentials.core.Potential class.

Therefore, this class is missing the calculate_potential_energy(), calculate_virial(), calculate_heat_flux() methods.

Methods

Particles.__init__()

Particles.calculate_electric_current()

Calculate the electric current of each particle and store it into electric_current.

Particles.calculate_kinetic_energy()

Calculate the kinetic energy of each particle.

Particles.calculate_observables()

Calculate the observables in observables_list.

Particles.calculate_species_electric_current()

Calculate the energy current of each species from heat_flux_species_tensor and stores it into species_heat_flux.

Particles.calculate_species_enthalpy()

Particles.calculate_species_heat_flux()

Calculate the energy current of each species from heat_flux_species_tensor and stores it into species_heat_flux.

Particles.calculate_species_kinetic_temperature()

Calculate the kinetic energy and temperature of each species.

Particles.calculate_species_momentum()

Particles.calculate_species_potential_energy()

Calculate the potential energy of each species from potential_energy, calculated in the force loop, and stores it into species_potential_energy.

Particles.calculate_species_pressure_tensor()

Calculate the pressure, the kinetic part of the pressure tensor, the potential part of the kinetic tensor of each species and store them into species_pressure, species_pressure_kin_tensor, species_pressure_pot_tensor.

Particles.calculate_thermodynamic_quantities_full()

Calculate thermodynamics quantities from particles data.

Particles.calculate_thermodynamic_quantities_partial()

Calculate the main thermodynamics quantities from particles data and return a dictionary with their values.

Particles.calculate_total_electric_current()

Calculate the total electric current of the system, by summing the electric current of each species and store it into total_electric_current.

Particles.calculate_total_enthalpy()

Calculate the total enthalpy of the system, by summing the enthalpy of each species and store it into total_enthalpy.

Particles.calculate_total_kinetic_energy()

Calculate the total kinetic energy by summing the kinetic_energy array and store it into total_kinetic_energy.

Particles.calculate_total_momentum()

Particles.calculate_total_potential_energy()

Calculate the total potential energy by summing the potential_energy array.

Particles.calculate_total_pressure()

Particles.copy_params(params)

Copy necessary parameters.

Particles.dump_arrays(filename, data_to_save)

Save particles' data to binary file (uncompressed npz) for future restart.

Particles.dump_pva_h5(filename, data_to_save)

Save particles' data to HDF5 file.

Particles.gaussian(mean, sigma, size)

Initialize particles' velocities according to a normalized Maxwell-Boltzmann (Normal) distribution.

Particles.halton_reject(bases, r_reject)

Place particles according to a Halton sequence from 0 to LP (the initial particle box length) and uses a rejection radius to avoid placing particles to close to each other.

Particles.initialize_accelerations()

Initialize particles' accelerations.

Particles.initialize_arrays()

Initialize the needed arrays

Particles.initialize_positions()

Initialize particles' positions based on the load method.

Particles.initialize_velocities(species)

Initialize particles' velocities based on the species input values.

Particles.kinetic_temperature()

Calculate the kinetic energy and temperature of each species.

Particles.lattice([perturb])

Place particles in a simple cubic lattice with a slight perturbation ranging from 0 to 0.5 times the lattice spacing.

Particles.load()

Initialize particles' positions and velocities.

Particles.load_from_checkpoint(phase, it)

Load particles' data from a checkpoint of a previous run

Particles.load_from_file(f_name)

Load particles' data from a specific file.

Particles.load_from_npz(file_name)

Load particles' data from an .npz data file.

Particles.load_from_restart(phase, it)

Initialize particles' data from a checkpoint of a previous run.

Particles.make_thermodynamics_dictionary_full()

Put all thermodynamic quantities into a dictionary.

Particles.make_thermodynamics_dictionary_partial()

Put the main thermodynamic quantities into a dictionary.

Particles.random_reject(r_reject)

Place particles by sampling a uniform distribution from 0 to LP (the initial particle box length) and uses a rejection radius to avoid placing particles to close to each other.

Particles.random_unit_vectors(num_ptcls, ...)

Initialize random unit vectors for particles' velocities (e.g.

Particles.remove_drift()

Enforce conservation of total linear momentum.

Particles.setup(params, species)

Initialize class' attributes

Particles.uniform_no_reject(mins, maxs)

Randomly distribute particles along each direction.

Particles.update_attributes(species)

Assign particles attributes.