152 GalaxyCell *neighborhood_cells,
const int neighborhood_size,
168 const std::vector<double> &displacement_vector);
242 static std::vector<double>
compute_accel(
const std::vector<double> &total_force,
double mass);
This file contains the custom datatypes used in the Cellular Automata project.
A CellularAutomata class for simulating cellular automata models.
Definition: CAdatatypes.h:176
Class that represents a star system.
Definition: galaxydatatypes.h:26
int state
CellularAutomata requirement; 0: empty space.
Definition: galaxydatatypes.h:28
bool operator!=(const GalaxyCell &other)
CellularAutomata requirement (inequality operator)
GalaxyCell & operator=(const GalaxyCell &other)
CellularAutomata requirement (assignment operator)
GalaxyCell()
Construct a new Galaxy Cell object.
double velocity[3]
velocity vector
Definition: galaxydatatypes.h:31
GalaxyCell(const GalaxyCell &other)
CellularAutomata requirement (copy constructor)
double mass
cell mass
Definition: galaxydatatypes.h:32
Class for create a galaxy cellular automata model.
Definition: galaxydatatypes.h:74
static int round_int(double dbl)
Rounds a double to an int.
double density
density of galaxy
Definition: galaxydatatypes.h:78
static GalaxyCell & get_cell_state(int *cell_index, const std::vector< int > &offset_index)
Get the cell state object at position cell_index + offset_index from the CellularAutomata instance.
int boundary_radius
cutoff radius above which forces are not considered
Definition: galaxydatatypes.h:79
static double time_step
time_step for computing forces during each simulation step
Definition: galaxydatatypes.h:83
static std::vector< double > compute_accel(const std::vector< double > &total_force, double mass)
Computes the acceleration vector A = F/M.
static std::vector< int > get_periodic_vector(int *cell_index, const std::vector< int > &offset_index)
Get the periodic vector.
static void set_new_position(int *cell_index, GalaxyCell &new_cell_state, const std::vector< double > &displacement_vector)
Set the new_cell_state's new position.
~Galaxy()=default
Destroy the Galaxy object.
static double compute_vector_norm(const std::vector< int > &vector)
Computes the norm of a vector.
static void galaxy_formation_rule(int *cell_index, const int index_size, GalaxyCell *neighborhood_cells, const int neighborhood_size, GalaxyCell &new_cell_state)
Custom CA rule for simulating the motion of star systems.
static std::vector< double > compute_vector_difference(const std::vector< double > &vec1, const std::vector< double > &vec2)
Computes the difference in vector for determining the direction and magnitude of the force vector.
int simulation(int steps)
Runs the simulation for the specified amount of steps.
int min_mass
minimum cell mass (int required for rand)
Definition: galaxydatatypes.h:76
int axis1_dim
cellular automata axis1 dimension
Definition: galaxydatatypes.h:80
int axis3_dim
cellular automata axis3 dimension
Definition: galaxydatatypes.h:82
int max_mass
maximum cell mass (int required for rand)
Definition: galaxydatatypes.h:77
static CellularAutomata< GalaxyCell > CA
the CA the simulation utilizes to model the formation of a galaxy
Definition: galaxydatatypes.h:84
int axis2_dim
cellular automata axis2 dimension
Definition: galaxydatatypes.h:81
static void update_velocity_after_collision(GalaxyCell &new_cell, GalaxyCell collied_cell)
compute the velocity after an inelastic collision https://www.plasmaphysics.org.uk/collision3d....
static std::vector< double > compute_gravitational_force(const GalaxyCell &cell_of_interest, const GalaxyCell &neighbor_cell, const std::vector< int > &neighbor_index)
Computes the force between cell of interest and neighbor_index Note: cell of interest is at (0,...
Galaxy()
Construct a new Galaxy object using the following default parameters: min_mass = 1; max_mass = 100;...
int init_galaxy()
Sets up the galaxy CA instance.
Galaxy(double time_step, int min_mass, int max_mass, double density, int boundary_radius, int axis1_dim, int axis2_dim, int axis3_dim)
Create a Galaxy model instance using the provided values.
static bool did_galaxies_collide(int *cell_index, const std::vector< int > &offset_index, GalaxyCell &new_cell_state)
Determines if the new_cell_state collides with a cell at the current position: cell_index + offset_in...
static std::vector< double > compute_velocity(const std::vector< double > &accel, const GalaxyCell &cell_of_interest, double time_step)
Computes the velocity vector.
static std::vector< double > compute_displacement(const std::vector< double > &velocity, const GalaxyCell &cell_of_interest, double time_step)
Computes the displacement vector.