coexist.Simulation#

class coexist.Simulation[source]#

Bases: ABC

Abstract class defining the interface a DEM simulation engine must implement to be used by the Coexist and Access algorithms.

This interface is needed in order to manage a DEM simulation whose parameters will be modified dynamically as the algorithms learn them.

Alternatively, this interface has enough features to allow setting up, running, and analysing DEM simulations in Python.

Each method required is described below. As an example of an implemented LIGGGHTS front-end, see LiggghtsSimulation.

__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

copy()

Create a deep copy of the simulation, along with all its state.

load(filename)

Load the full state of a simulation from a file.

num_atoms()

Return the number of simulated particles.

positions()

Return a 2D numpy array of the particle positions at the current timestep, where the columns represent the cartesian coordinates.

radii()

A 1D numpy array listing the radius of each particle.

save(filename)

Save the full state of a simulation to a file.

set_position(particle_index, position)

Set the 3D position of the particle at an index (indexed from 0).

set_velocity(particle_index, velocity)

Set the 3D velocity of the particle at an index (indexed from 0).

step(num_steps)

Move the simulation forward in time for num_steps steps.

step_time(duration)

Move the simulation forward in time for duration seconds.

step_to(step)

Move the simulation forward in time up to timestep step.

step_to_time(time)

Move the simulation forward up to time time.

time()

Return the current simulation time.

timestep()

Return the current simulation timestep.

velocities()

Return the 2D numpy array of the particle velocities at the current timestep, where the columns represent the velocity in the x-, y-, and z-dimensions.

Attributes

parameters

A coexist.Parameters class instance containing the free simulation parameters, along with their bounds.

step_size

The time duration of a single simulated step.

abstract property parameters#

A coexist.Parameters class instance containing the free simulation parameters, along with their bounds.

abstract property step_size#

The time duration of a single simulated step.

abstract step(num_steps: int)[source]#

Move the simulation forward in time for num_steps steps.

abstract step_to(step: int)[source]#

Move the simulation forward in time up to timestep step.

abstract step_time(duration: float)[source]#

Move the simulation forward in time for duration seconds.

abstract step_to_time(time: float)[source]#

Move the simulation forward up to time time.

abstract time() float[source]#

Return the current simulation time.

abstract timestep() int[source]#

Return the current simulation timestep.

abstract num_atoms() int[source]#

Return the number of simulated particles.

abstract radii() ndarray[source]#

A 1D numpy array listing the radius of each particle.

abstract positions() ndarray[source]#

Return a 2D numpy array of the particle positions at the current timestep, where the columns represent the cartesian coordinates.

abstract velocities() ndarray[source]#

Return the 2D numpy array of the particle velocities at the current timestep, where the columns represent the velocity in the x-, y-, and z-dimensions.

abstract set_position(particle_index: int, position: ndarray)[source]#

Set the 3D position of the particle at an index (indexed from 0).

abstract set_velocity(particle_index: int, velocity: ndarray)[source]#

Set the 3D velocity of the particle at an index (indexed from 0).

abstract copy()[source]#

Create a deep copy of the simulation, along with all its state. It is important to be a deep copy as it will be used in asynchronous contexts.

abstract save(filename: str)[source]#

Save the full state of a simulation to a file.

abstract static load(filename: str)[source]#

Load the full state of a simulation from a file.