Develop #14
20
src/main.cpp
20
src/main.cpp
@ -170,16 +170,20 @@ void potential_resonance_wide_sweep()
|
|||||||
std::ofstream ofile;
|
std::ofstream ofile;
|
||||||
|
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
|
// Insert frequencies
|
||||||
for (size_t i = 0; i < freq_iterations; i++) {
|
for (size_t i = 0; i < freq_iterations; i++) {
|
||||||
res[0][i] = freq_start + freq_increment * i;
|
res[0][i] = freq_start + freq_increment * i;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
{
|
{
|
||||||
|
// Each thread creates a PenningTrap instance and reuses it throughout
|
||||||
|
// the sweep.
|
||||||
PenningTrap trap((unsigned int)100);
|
PenningTrap trap((unsigned int)100);
|
||||||
#pragma omp for collapse(2)
|
#pragma omp for collapse(2)
|
||||||
for (size_t i = 0; i < 3; i++) {
|
for (size_t i = 0; i < 3; i++) {
|
||||||
for (size_t j = 0; j < freq_iterations; j++) {
|
for (size_t j = 0; j < freq_iterations; j++) {
|
||||||
|
// Reset particles and give new time dependent potential.
|
||||||
trap.reinitialize(std::bind(
|
trap.reinitialize(std::bind(
|
||||||
[](double f, double r, double t) {
|
[](double f, double r, double t) {
|
||||||
return (25. * V / 1000.) * (1. + f * std::cos(r * t));
|
return (25. * V / 1000.) * (1. + f * std::cos(r * t));
|
||||||
@ -191,6 +195,7 @@ void potential_resonance_wide_sweep()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write results to file
|
||||||
ofile.open(path + "wide_sweep.txt");
|
ofile.open(path + "wide_sweep.txt");
|
||||||
for (size_t i = 0; i < freq_iterations; i++) {
|
for (size_t i = 0; i < freq_iterations; i++) {
|
||||||
ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
|
ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
|
||||||
@ -225,17 +230,15 @@ void potential_resonance_no_interaction_narrow_sweep()
|
|||||||
|
|
||||||
std::ofstream ofile;
|
std::ofstream ofile;
|
||||||
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (size_t i = 0; i < freq_iterations; i++) {
|
|
||||||
res[0][i] = freq_start + freq_increment * i;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
{
|
{
|
||||||
|
// Each thread creates a PenningTrap instance and reuses it throughout
|
||||||
|
// the sweep.
|
||||||
PenningTrap trap((unsigned int)100);
|
PenningTrap trap((unsigned int)100);
|
||||||
#pragma omp for collapse(2)
|
#pragma omp for collapse(2)
|
||||||
for (size_t i = 0; i < 3; i++) {
|
for (size_t i = 0; i < 3; i++) {
|
||||||
for (size_t j = 0; j < freq_iterations; j++) {
|
for (size_t j = 0; j < freq_iterations; j++) {
|
||||||
|
// Reset particles and give new time dependent potential.
|
||||||
trap.reinitialize(std::bind(
|
trap.reinitialize(std::bind(
|
||||||
[](double f, double r, double t) {
|
[](double f, double r, double t) {
|
||||||
return (25. * V / 1000.) * (1. + f * std::cos(r * t));
|
return (25. * V / 1000.) * (1. + f * std::cos(r * t));
|
||||||
@ -247,6 +250,7 @@ void potential_resonance_no_interaction_narrow_sweep()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write results to file
|
||||||
ofile.open(path + "narrow_sweep.txt");
|
ofile.open(path + "narrow_sweep.txt");
|
||||||
for (size_t i = 0; i < freq_iterations; i++) {
|
for (size_t i = 0; i < freq_iterations; i++) {
|
||||||
ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
|
ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
|
||||||
@ -288,10 +292,13 @@ void potential_resonance_with_interaction_narrow_sweep()
|
|||||||
|
|
||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
{
|
{
|
||||||
|
// Each thread creates a PenningTrap instance and reuses it throughout
|
||||||
|
// the sweep.
|
||||||
PenningTrap trap((unsigned int)100);
|
PenningTrap trap((unsigned int)100);
|
||||||
#pragma omp for collapse(2)
|
#pragma omp for collapse(2)
|
||||||
for (size_t i = 0; i < 3; i++) {
|
for (size_t i = 0; i < 3; i++) {
|
||||||
for (size_t j = 0; j < freq_iterations; j++) {
|
for (size_t j = 0; j < freq_iterations; j++) {
|
||||||
|
// Reset particles and give new time dependent potential.
|
||||||
trap.reinitialize(std::bind(
|
trap.reinitialize(std::bind(
|
||||||
[](double f, double r, double t) {
|
[](double f, double r, double t) {
|
||||||
return (25. * V / 1000.) * (1. + f * std::cos(r * t));
|
return (25. * V / 1000.) * (1. + f * std::cos(r * t));
|
||||||
@ -302,6 +309,7 @@ void potential_resonance_with_interaction_narrow_sweep()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write results to file
|
||||||
ofile.open(path + "narrow_sweep_interactions.txt");
|
ofile.open(path + "narrow_sweep_interactions.txt");
|
||||||
for (size_t i = 0; i < freq_iterations; i++) {
|
for (size_t i = 0; i < freq_iterations; i++) {
|
||||||
ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
|
ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
|
||||||
@ -312,7 +320,7 @@ void potential_resonance_with_interaction_narrow_sweep()
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
double start,end,t1,t2;
|
double start, end, t1, t2;
|
||||||
start = omp_get_wtime();
|
start = omp_get_wtime();
|
||||||
|
|
||||||
simulate_single_particle();
|
simulate_single_particle();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user