Bases: object
The main class for storing the particles data set.
Constructor:
Parameters: |
|
---|
Note
The properties: position X and velocity V are mandatory.
return the reference to the array of the masses
return the reference to the array of the charges
return the reference to the velocities array
return the reference to the array of the positions
Insert a new property by name. If the dim is not specified it uses the current dimension of the set.
If the model of the property is ‘list’ the dim is forced to 1
Parameters: |
|
---|
For example add ‘friction’ or ‘radius’:
# Add the friction to the particles set
pset.add_property_by_name( "friction" , dim=1 , to_type=np.float32 )
pset.add_property_by_name( "radius" , dim=1 , to_type=np.float64 )
Add an object that contains a member methods called: particles_set_changed( pset ) that there will be called if the particle set will be modified.
Append the particle(s) described in the given dictionary
If the particle don’t contain every required data will be rejected.
The dictionary p_dict must contains the name of the property and it’s value, and it must include all property, also the user defined!
return the reference to the boundary, None if the boundary are not set or open
Return the stored center of mass.
Note
this function don’t compute the center of mass, but simply return the stored value.
This function must be called after the end of the simulation for closing the log procedure.
get the dim of the set
Eanble the X and V logging:
Parameters: |
|
---|
Parameters: | property_name – The name of a property |
---|
# set to [1,2,3] the coordinates of the 10th particle
pset.get_by_name('X')[10,:] = [1,2,3]
return a list containing all data of the i-th particle TODO: adapt to property by name
Return a list of containing the names of all properties
return the reference to the label list
return true if the logging of the position is enabled
return true if the logging of the velocity is enabled
return true if the logging of position or velocity is enabled
set and get the max allowed size of the log
set the unit mass
Call this methods when the particle set is modified.
Realloc the particle set, it uses the same args of the constructor,
Attention! this method remove the dictionary of the of the extra properties
Resize the particles set with the new_size.
If the new size is bigger the old data are copied in the new particles, according to the function numpy.resize if it is smaller it cancels the data.
If the property is a list, the new elements will be filled with ‘None’ or empty string for the labels
The dim of the set will be not changed.
get the size of the set
set the unit length
Update the particle set according to the boundary rule
Compute and return the center of mass
Bases: object
Class used for logging the status of the particles system, this class will be used by the ParticlesSet class. This class uses a matrix of size [ log_size by pasrticles_size by dim ] for saving the status.
Constructor
Parameters: |
|
---|
Return an numpy array containing the log if the i-th particles
Parameters: |
|
---|---|
Returns: | A tuple containing the log arrays ( log_x , [log_V] ) |
Save the current status of the particles-set in the log queue. If the log queue is filled it removes the oldest status
return true if the logging of the position is enabled
return true if the logging of the velocity is enabled
get the max allowed size of the log
Write in the arrays stored in the tuple ta the log if the i-th particles
Parameters: |
|
---|---|
Returns: | A tuple containing the log indices for using the segments array ( begin . end ). |
Bases: pyparticles.pset.constraint.Constraint
Adds the connections listed in fc . fc must be a list of list or a 2d array of pairs for example:
cfi = ConstrainedForceInteractions( pset )
a = [[1,1],[3,5]]
cfi.add_connections( a )
Return the dense reppresentations of the connections matrix. Don’t use this function in a loop, don’t use this function in a loop, but execute the conversion to a dense matix before the loop.
list of the commection ((i,j), value) pairs, ...)
Return the reference to the dok_matrix sparse matrix of the connections. For the operations with a dense matricies, don’t use this function in a loop, but execute the conversion to a dense matix before the loop.
list of the commection ((i,j), value) pairs, ...)
Removes the connections listed in fc . fc must be a list of list or a 2d array of pairs for example:
cfi = ConstrainedForceInteractions( pset )
a = [[1,1],[3,5]]
cfi.remove_connections( a )
Bases: pyparticles.pset.constraint.Constraint
Add new positional constraint and update the referenced particles set. constraints are concatenated to the stored constraints, we don’t tests the uniqueness of the indices. be careful with the double indices
Arguments indx indices of the new constraint constr the new constraint
If constr is a slice the constraints will be constants
return the constrained X elements
clear all positional constraints
Return an array or if it’s possible a slice containing the not constrained indices
Return a copy of the constrained indices
Return the current constrained particles set
get and set the particles set (pset)
Remove the element indexed in indxs from the constraints Arguments:
- indxs: an iterable containing the indices of the old constraints.
set the particles set. And it sets the constrained values in the particles set pset
Bases: object
Read the data from a csv formatted file:
The first row of the csv contains the size and the dim of the particles set.
The other rows are the data of the perticles in the order:
Close the file
Insert the particles described in the file in the ParticlesSet pset
Parameters: | pset – A reference to the particles set |
---|
Open the csv file named cfile.
Parameters: |
|
---|
Write out in the csv file the particles described in pset.
Parameters: | pset – A reference to the particles set |
---|
Bases: object
|OcTree particles container class
Build the octree with the given particles set
Arguments | |
---|---|
pset | a ParticlesSet object used to build the tree |
return the centre of mass of the particles set
return an array containing the indecies of the the particles included in the sheric region centred in X with a radius r
Define the size of the octree cube
Arguments | |
---|---|
ref_vertex | the ( down , near , left ) vertex |
edge_len | leght of the edge |
Bases: object
The element of a tree node
getter: return the total mass of the current element
return the centre of mass of the particle
Compute and returns the maximal depth of the octree
relative domanin for the down ‘sub-space’
relative domanin for the far ‘sub-space’
Z axis
relative domanin for the left ‘sub-space’
get the maximal vertex of the cube
get the minimal vertex of the cube
relative domanin for the near ‘sub-space’
Get the particle index of the tree element
Print the structure of the tree and return the maximal depth
relative domanin for the right ‘sub-space’
Search the elements included in the volume centred in X with the radius r and append the results in the list res_list. res_list contains the indicies of the particles included in the the sphere.
relative domanin for the up ‘sub-space’
Bases: pyparticles.pset.boundary.Boundary
Bases: pyparticles.pset.cluster.Cluster
Bases: pyparticles.pset.boundary.Boundary