IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
PenningTrap.cpp
Go to the documentation of this file.
1// Penning Trap
2// Usage:
3// srun ./PenningTrap
4// <nx> [<ny>...] <Np> <Nt> <stype> <lbthres>
5// <t_method> --overallocate <ovfactor> --info 10
6// nx = No. cell-centered points in the x-direction
7// ny = No. cell-centered points in the y-direction
8// nz = No. cell-centered points in the z-direction
9// Np = Total no. of macro-particles in the simulation
10// Nt = Number of time steps
11// stype = Field solver type (FFT, CG, TG, and OPEN supported)
12// lbthres = Load balancing threshold i.e., lbthres*100 is the maximum load imbalance
13// percentage which can be tolerated and beyond which
14// particle load balancing occurs. A value of 0.01 is good for many typical
15// simulations.
16// t_method = Time-stepping method used e.g. Leapfrog
17// ovfactor = Over-allocation factor for the buffers used in the communication. Typical
18// values are 1.0, 2.0. Value 1.0 means no over-allocation.
19// Example:
20// srun ./PenningTrap 128 128 128 10000 300 FFT 0.01 LeapFrog --overallocate 1.0 --info 10
21
22constexpr unsigned Dim = 3;
23using T = double;
24const char* TestName = "PenningTrap";
25
26#include "Ippl.h"
27
28#include <Kokkos_MathematicalConstants.hpp>
29#include <Kokkos_MathematicalFunctions.hpp>
30#include <Kokkos_Random.hpp>
31#include <chrono>
32#include <iostream>
33#include <random>
34#include <set>
35#include <string>
36#include <vector>
37
38#include "Manager/datatypes.h"
39
40#include "Utility/IpplTimings.h"
41
42#include "Manager/PicManager.h"
43#include "PenningTrapManager.h"
44
45int main(int argc, char* argv[]) {
46 ippl::initialize(argc, argv);
47 {
48 Inform msg(TestName);
50
51 static IpplTimings::TimerRef mainTimer = IpplTimings::getTimer("total");
52 IpplTimings::startTimer(mainTimer);
53
54 // Read input parameters, assign them to the corresponding memebers of manager
55 int arg = 1;
57
58 for (unsigned d = 0; d < Dim; d++) {
59 nr[d] = std::atoi(argv[arg++]);
60 }
61 size_type totalP = std::atoll(argv[arg++]);
62 int nt = std::atoi(argv[arg++]);
63 std::string solver = argv[arg++];
64 double lbt = std::atof(argv[arg++]);
65 std::string step_method = argv[arg++];
66
67 std::vector<std::string> preconditioner_params;
68
69 // Create an instance of a manger for the considered application
70 if (solver == "PCG") {
71 for (int i = 0; i < 5; i++) {
72 preconditioner_params.push_back(argv[arg++]);
73 }
74 }
75
76 // Create an instance of a manger for the considered application
77 PenningTrapManager<T, Dim> manager(totalP, nt, nr, lbt, solver, step_method,
78 preconditioner_params);
79
80 // Perform pre-run operations, including creating mesh, particles,...
81 manager.pre_run();
82
83 manager.setTime(0.0);
84
85 msg << "Starting iterations ..." << endl;
86
87 manager.run(manager.getNt());
88
89 msg << "End." << endl;
90
91 IpplTimings::stopTimer(mainTimer);
93 IpplTimings::print(std::string("timing.dat"));
94 }
96
97 return 0;
98}
int main(int argc, char *argv[])
constexpr unsigned Dim
ippl::detail::size_type size_type
Definition datatypes.h:23
const char * TestName
ippl::Vector< T, Dim > Vector_t
Definition datatypes.h:38
Inform & endl(Inform &inf)
Definition Inform.cpp:42
#define INFORM_ALL_NODES
Definition Inform.h:38
void initialize(int &argc, char *argv[], MPI_Comm comm)
Definition Ippl.cpp:16
void finalize()
Definition Ippl.cpp:94
void run(int nt)
The main for loop fro running a simulation.
Definition BaseManager.h:63
Timing::TimerRef TimerRef
static TimerRef getTimer(const char *nm)
static void stopTimer(TimerRef t)
static void print()
static void startTimer(TimerRef t)
void setTime(double time_)
int getNt() const
void pre_run() override
A method that should be used for setting up the simulation.