gonzales.simulator.space

  • class gonzales.simulator.space.Space(r=None, v=None, m=None)

    Class used to represent a 3D space which contains particles.

    __init__(r=None, v=None, m=None)

    Initialize the space.

    Parameters
    • r – N x 3 numpy array or None, position vectors of the particles

    • v – N x 3 numpy array or None, velocity vectors of the particles

    • m – N x 1 numpy array or None, mass vector

    add_cuboid(n, center, l_x, l_y, l_z, v_func, m_func)

    Generates uniform random particle distribution within a cuboid volume with given center and side lengths.

    Parameters
    • n – number of particles to generate

    • center – center of cuboid volume

    • l_x – length of cuboid in the x-direction

    • l_y – length of cuboid in the y-direction

    • l_z – length of cuboid in the z-direction

    • v_func – function of position vector

    • m_func – function of position vector

    add_cylinder(n, center, radius, l_z, v_func, m_func)

    Generates uniform random particle distribution within a cylindrical volume with a given center, radius and height.

    Parameters
    • n – number of particles to generate

    • center – center of cylindrical volume

    • radius – radius of cylindrical volume

    • l_z – height of cylindrical volume

    • v_func – function of position vector in cylindrical coordinates

    • m_func – function of position vector in cylindrical coordinates

    add_particle(r, v, m)

    Add a single particle with the specified position, velocity and mass.

    Parameters
    • r – numpy array, position vector of the particle

    • v – numpy array, velocity vector of the particle

    • m – float, particle mass

    add_particles(r, v, m)

    Adds N particles, specified by position and velocity matrices, and by mass vector.

    Parameters
    • r – N x 3 numpy array, position vectors of the particles

    • v – N x 3 numpy array, velocity vectors of the particles

    • m – N x 1 numpy array, mass vector

    add_sphere(n, center, radius, v_func, m_func)

    Generates uniform random particle distribution within a spherical volume with a given center and radius.

    Parameters
    • n – number of particles to generate

    • center – center of spherical volume

    • radius – radius of spherical volume

    • v_func – function of r, theta, phi

    • m_func – function of r, theta, phi

    clear_particles()

    Removes all particles from the space.

    from_hdf5(filepath)

    Reads data from hdf5 file.

    to_hdf5(filepath)

    Saves configuration to hdf5 file. Datasets are called “r”, “v” and “m”.