38 double amplitudes[]{.1, .4, .7};
40 double freq_start = 1.1;
41 double freq_end = 1.7;
42 double freq_increment = .0005;
43 size_t freq_iterations =
44 (size_t)((freq_end - freq_start) / freq_increment) + 1;
46 double res[4][freq_iterations];
48 std::string path =
"output/time_dependent_potential/";
53#pragma omp parallel for
55 for (
size_t i = 0; i < freq_iterations; i++) {
56 res[0][i] = freq_start + freq_increment * i;
64#pragma omp for collapse(2)
65 for (
size_t i = 0; i < 3; i++) {
66 for (
size_t j = 0; j < freq_iterations; j++) {
76 ofile.open(path +
"narrow_sweep_fine.txt");
77 for (
size_t i = 0; i < freq_iterations; i++) {
78 ofile << res[0][i] <<
',' << res[1][i] <<
',' << res[2][i] <<
','
95 double amplitudes[]{.1, .4, .7};
97 double freq_start = 1.1;
98 double freq_end = 1.7;
99 double freq_increment = .0005;
100 size_t freq_iterations =
101 (size_t)((freq_end - freq_start) / freq_increment) + 1;
103 double res[4][freq_iterations];
105 std::string path =
"output/time_dependent_potential/";
110#pragma omp parallel for
111 for (
size_t i = 0; i < freq_iterations; i++) {
112 res[0][i] = freq_start + freq_increment * i;
120#pragma omp for collapse(2)
121 for (
size_t i = 0; i < 3; i++) {
122 for (
size_t j = 0; j < freq_iterations; j++) {
131 ofile.open(path +
"narrow_sweep_interactions_fine.txt");
132 for (
size_t i = 0; i < freq_iterations; i++) {
133 ofile << res[0][i] <<
',' << res[1][i] <<
',' << res[2][i] <<
','
134 << res[3][i] <<
'\n';
143 start = omp_get_wtime();
149 end = omp_get_wtime();
151 std::cout <<
"Time: " << end - start <<
" seconds" << std::endl;
A class for simulating a Penning trap.
A class that simulates a Penning trap.
void reinitialize(double f, double omega_V, double t=0.)
Give all particles new positions and velocities, and change t and V_0.
double fraction_of_particles_left(double time, uint steps, std::string method="rk4", bool particle_interaction=true)
Simulate and calculate what fraction of particles are still left inside the Penning trap after the si...
void potential_resonance_narrow_sweep()
Simulate 100 particles over 500 using a time dependent potential.
void potential_resonance_narrow_sweep_interaction()
Simulate 100 particles over 500 using a time dependent potential.
Function prototypes and macros that are useful.
bool mkpath(std::string path, int mode=0777)
Make path given.