24void simulate_100_particles()
29 for (
int i = 0; i < PARTICLES; i++) {
30 arma::vec r = arma::vec(3).randn() * 0.1 *
32 arma::vec v = arma::vec(3).randn() * 0.1 *
38 double dt = time / (double)N;
40 auto res =
new arma::vec::fixed<3>[PARTICLES][N];
45 for (
int j = 0; j < N; j++) {
46#pragma omp parallel for
47 for (
int i = 0; i < PARTICLES; i++) {
48 res[i][j] = trap.get_particle(i);
53 std::cout << counter << std::endl;
55 arma::vec::fixed<3> *cur_row;
56 arma::vec::fixed<3> cur_elem;
58 mkdir(
"output", 0777);
59 mkdir(
"output/simulate_100_particles", 0777);
64#pragma omp parallel for private(cur_row, cur_elem, ofile)
65 for (
int i = 0; i < PARTICLES; i++) {
67 ofile.open(
"output/simulate_100_particles/p" + std::to_string(i) +
".txt");
68 for (
int j = 0; j < N; j++) {
69 cur_elem = cur_row[j];
70 ofile << cur_elem(0) <<
"," << cur_elem(1) <<
"," << cur_elem(2)
79 double start = omp_get_wtime();
81 simulate_100_particles();
83 double end = omp_get_wtime();
85 std::cout <<
"Time: " << end - start <<
" seconds" << std::endl;
A class for simulating a Penning trap.
A class that holds attributes of a particle.
A class that simulates a Penning trap.
void add_particle(Particle particle)
Add a particle to the system.
void evolve_RK4(double dt)
Go forward one timestep using the RK4 method.