Refactor
- Change PenningTrap so that perturbation is its own field - Add Calcium mass and charge to constants
This commit is contained in:
@@ -31,7 +31,8 @@
|
||||
class PenningTrap {
|
||||
private:
|
||||
double B_0; ///< Magnetic field strength
|
||||
std::function<double(double)> V_0; ///< Applied potential
|
||||
double V_0; ///< Applied potential
|
||||
std::function<double(double)> perturbation; ///< Time-dependent perturbation
|
||||
double d; ///< Characteristic dimension
|
||||
double t; ///< Current time
|
||||
std::vector<Particle> particles; ///< The particles in the Penning trap
|
||||
@@ -50,7 +51,7 @@ private:
|
||||
*
|
||||
* @return vec_3d
|
||||
* */
|
||||
vec_3d v_func(unsigned int i, unsigned int j, double dt);
|
||||
vec_3d v_func(uint i, uint j, double dt);
|
||||
|
||||
/** @brief Helper for evolve_RK4 when calculating \f$k_{r,i,j}\f$ values
|
||||
*
|
||||
@@ -62,7 +63,7 @@ private:
|
||||
*
|
||||
* @return vec_3d
|
||||
* */
|
||||
vec_3d r_func(unsigned int i, unsigned int j, double dt);
|
||||
vec_3d r_func(uint i, uint j, double dt);
|
||||
|
||||
public:
|
||||
/** @brief Constructor for the PenningTrap class
|
||||
@@ -74,8 +75,7 @@ public:
|
||||
* */
|
||||
PenningTrap(
|
||||
double B_0 = T,
|
||||
std::function<double(double)> V_0
|
||||
= [](double t) { return (25. * V) / 1000.; },
|
||||
double V_0 = (25. * V) / 1000.,
|
||||
double d = 500., double t = 0.);
|
||||
|
||||
/** @brief Constructor for the PenningTrap class
|
||||
@@ -87,9 +87,8 @@ public:
|
||||
* @param t The starting time
|
||||
* */
|
||||
PenningTrap(
|
||||
unsigned int i, double B_0 = T,
|
||||
std::function<double(double)> V_0
|
||||
= [](double t) { return 25. * V / 1000.; },
|
||||
uint i, double B_0 = T,
|
||||
double V_0 = (25. * V) / 1000.,
|
||||
double d = 500., double t = 0.);
|
||||
|
||||
/** @brief Constructor for the PenningTrap class
|
||||
@@ -102,10 +101,11 @@ public:
|
||||
* */
|
||||
PenningTrap(
|
||||
std::vector<Particle> particles, double B_0 = T,
|
||||
std::function<double(double)> V_0
|
||||
= [](double t) { return 25. * V / 1000.; },
|
||||
double V_0 = (25. * V) / 1000.,
|
||||
double d = 500., double t = 0.);
|
||||
|
||||
void set_pertubation(double f, double omega_V);
|
||||
|
||||
/** @brief Give all particles new positions and velocities, and change t
|
||||
* and V_0.
|
||||
*
|
||||
@@ -113,8 +113,7 @@ public:
|
||||
* @param t The starting time
|
||||
* */
|
||||
void reinitialize(
|
||||
std::function<double(double)> V_0
|
||||
= [](double t) { return 25. * V / 1000.; },
|
||||
double f, double omega_V,
|
||||
double t = 0.);
|
||||
|
||||
/** @brief Add a particle to the system
|
||||
@@ -149,7 +148,7 @@ public:
|
||||
*
|
||||
* @return vec_3d
|
||||
* */
|
||||
vec_3d force_on_particle(unsigned int i, unsigned int j);
|
||||
vec_3d force_on_particle(uint i, uint j);
|
||||
|
||||
/** @brief Calculate the total external force on a particle.
|
||||
*
|
||||
@@ -160,7 +159,7 @@ public:
|
||||
*
|
||||
* @return vec_3d
|
||||
* */
|
||||
vec_3d total_force_external(unsigned int i);
|
||||
vec_3d total_force_external(uint i);
|
||||
|
||||
/** @brief Calculate the total force on a particle p_i from other
|
||||
* particles.
|
||||
@@ -169,7 +168,7 @@ public:
|
||||
*
|
||||
* @return vec_3d
|
||||
* */
|
||||
vec_3d total_force_particles(unsigned int i);
|
||||
vec_3d total_force_particles(uint i);
|
||||
|
||||
/** @brief calculate the total force on a particle p_i.
|
||||
*
|
||||
@@ -177,7 +176,7 @@ public:
|
||||
*
|
||||
* @return vec_3d
|
||||
* */
|
||||
vec_3d total_force(unsigned int i);
|
||||
vec_3d total_force(uint i);
|
||||
|
||||
/** @brief Go forward one timestep using the RK4 method
|
||||
*
|
||||
@@ -203,7 +202,7 @@ public:
|
||||
*
|
||||
* @return simulation_t
|
||||
* */
|
||||
simulation_t simulate(double time, unsigned int steps,
|
||||
simulation_t simulate(double time, uint steps,
|
||||
std::string method = "rk4",
|
||||
bool particle_interaction = true);
|
||||
|
||||
@@ -216,7 +215,7 @@ public:
|
||||
* @param particle_interaction Turn particle interactions on/off
|
||||
* */
|
||||
void write_simulation_to_dir(std::string path, double time,
|
||||
unsigned int steps,
|
||||
uint steps,
|
||||
std::string method = "rk4",
|
||||
bool particle_interaction = true);
|
||||
|
||||
@@ -230,12 +229,9 @@ public:
|
||||
*
|
||||
* @return double
|
||||
* */
|
||||
double fraction_of_particles_left(double time, unsigned int steps,
|
||||
double fraction_of_particles_left(double time, uint steps,
|
||||
std::string method = "rk4",
|
||||
bool particle_interaction = true);
|
||||
|
||||
vec_3d get_r(int i);
|
||||
double get_t();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,4 +18,8 @@
|
||||
|
||||
#define V 9.64852558*1e7 ///< 1 Volt. unit: \f$ \frac{u (\mu m)^2}{(\mu s)^2 e} \f$
|
||||
|
||||
#define CA_MASS 40.078 ///< Mass of a single calcium ion. unit: amu
|
||||
|
||||
#define CA_CHARGE 1. ///< Charge of a singly charged calcium ion. unit: e
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user