sarkas.particles.Particles
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_ptclsis an int indicating the total number of particles.potential_energyis a 1-D array of lengthtotal_num_ptclscontaining the potential energy of each particle.species_numis 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 inkinetic_energya 1-D array of lengthtotal_num_ptcls.calculate_species_kinetic_energy()calculates the kinetic energy of each species and stores it inspecies_kinetic_energya 1-D array of lengthnum_species.calculate_total_kinetic_energy()calculates the total kinetic energy and stores it intottal_kinetic_energya float.Quantities requiring cross species evaluation are stored in numpy.ndarray as .[quantity]_species_tensor.
For example:
virial_species_tensoris a 3 x 3 xnum_speciesxnum_speciestensor.heat_flux_species_tensoris a 3 xnum_speciesxnum_speciestensor. The attributespotential_energy,virial_species_tensor,heat_flux_species_tensorare calculated by thesarkas.potentials.core.Potentialclass.Therefore, this class is missing the
calculate_potential_energy(),calculate_virial(),calculate_heat_flux()methods.Methods
Calculate the electric current of each particle and store it into
electric_current.Calculate the kinetic energy of each particle.
Calculate the observables in
observables_list.Calculate the energy current of each species from
heat_flux_species_tensorand stores it intospecies_heat_flux.Calculate the energy current of each species from
heat_flux_species_tensorand stores it intospecies_heat_flux.Calculate the kinetic energy and temperature of each species.
Calculate the potential energy of each species from
potential_energy, calculated in the force loop, and stores it intospecies_potential_energy.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.Calculate thermodynamics quantities from particles data.
Calculate the main thermodynamics quantities from particles data and return a dictionary with their values.
Calculate the total electric current of the system, by summing the electric current of each species and store it into
total_electric_current.Calculate the total enthalpy of the system, by summing the enthalpy of each species and store it into
total_enthalpy.Calculate the total kinetic energy by summing the
kinetic_energyarray and store it intototal_kinetic_energy.Calculate the total potential energy by summing the
potential_energyarray.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.
Initialize particles' accelerations.
Initialize the needed arrays
Initialize particles' positions based on the load method.
Particles.initialize_velocities(species)Initialize particles' velocities based on the species input values.
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.
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.
Put all thermodynamic quantities into a dictionary.
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.
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.