Develop #14

Merged
coryab merged 124 commits from develop into main 2023-10-24 20:43:56 +00:00
Showing only changes of commit 944c52d22f - Show all commits

View File

@ -170,16 +170,20 @@ void potential_resonance_wide_sweep()
std::ofstream ofile;
#pragma omp parallel for
// Insert frequencies
for (size_t i = 0; i < freq_iterations; i++) {
res[0][i] = freq_start + freq_increment * i;
}
#pragma omp parallel
{
// Each thread creates a PenningTrap instance and reuses it throughout
// the sweep.
PenningTrap trap((unsigned int)100);
#pragma omp for collapse(2)
for (size_t i = 0; i < 3; i++) {
for (size_t j = 0; j < freq_iterations; j++) {
// Reset particles and give new time dependent potential.
trap.reinitialize(std::bind(
[](double f, double r, double 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");
for (size_t i = 0; i < freq_iterations; 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;
#pragma omp parallel for
for (size_t i = 0; i < freq_iterations; i++) {
res[0][i] = freq_start + freq_increment * i;
}
#pragma omp parallel
{
// Each thread creates a PenningTrap instance and reuses it throughout
// the sweep.
PenningTrap trap((unsigned int)100);
#pragma omp for collapse(2)
for (size_t i = 0; i < 3; i++) {
for (size_t j = 0; j < freq_iterations; j++) {
// Reset particles and give new time dependent potential.
trap.reinitialize(std::bind(
[](double f, double r, double 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");
for (size_t i = 0; i < freq_iterations; 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
{
// Each thread creates a PenningTrap instance and reuses it throughout
// the sweep.
PenningTrap trap((unsigned int)100);
#pragma omp for collapse(2)
for (size_t i = 0; i < 3; i++) {
for (size_t j = 0; j < freq_iterations; j++) {
// Reset particles and give new time dependent potential.
trap.reinitialize(std::bind(
[](double f, double r, double 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");
for (size_t i = 0; i < freq_iterations; i++) {
ofile << res[0][i] << ',' << res[1][i] << ',' << res[2][i] << ','
@ -312,7 +320,7 @@ void potential_resonance_with_interaction_narrow_sweep()
int main()
{
double start,end,t1,t2;
double start, end, t1, t2;
start = omp_get_wtime();
simulate_single_particle();