|
CPP-snippets 0.0.1
A silly C++ project to use for demonstrating code integration
|
Stores and advances a dynamically sized set of 1D superparticles. More...
#include <particles.hpp>
Public Member Functions | |
| Particles ()=default | |
| Default constructor, creates an empty particle set. | |
| Particles (int N, double q, double m, double w) | |
| Construct a particle set with N superparticles. | |
| void | resize (int N) |
| Resize particle arrays to contain N superparticles. | |
| double | interp_linear (const Eigen::VectorXd &x_nodes, const Eigen::VectorXd &E_nodes, double x) |
| void | emit (int N, double xpos, double dt, double energy_eV, const Eigen::VectorXd &node_pos, const Eigen::VectorXd &efield, std::mt19937 &rng) |
| Emit N particles at position xpos with Maxwellian velocity distribution. | |
| void | push_leapfrog (double dt, const Eigen::VectorXd &node_pos, const Eigen::VectorXd &efield) |
| Advance particles using leapfrog (velocity half-step scheme). | |
| Eigen::Vector4d | fluxes (const Eigen::Vector4d &el_pos, std::mt19937 &rng, double p_ce, double p_ag) |
| Compute absorbed particle fluxes on four electrodes. | |
| Eigen::VectorXd | deposit_charge (const Eigen::VectorXd &node_pos, const Eigen::VectorXd &dx) const |
| Deposit particle charge onto grid nodes (CIC scheme). | |
| Eigen::VectorXd | energy_distribution (int n_bins, double W_max) const |
Data Fields | |
| Eigen::VectorXd | m_positions |
| Particle positions (1D). | |
| Eigen::VectorXd | m_pos_prev |
| Previous positions for boundary‐crossing detection. | |
| Eigen::VectorXd | m_vel_half |
| Half-step velocities for leapfrog integration. | |
| double | m_charge |
| Charge of a single physical particle (C). | |
| double | m_mass |
| Mass of a single physical particle (kg). | |
| double | m_weight = 1.0 |
| Superparticle statistical weight. | |
Stores and advances a dynamically sized set of 1D superparticles.
Handles particle emission, leapfrog pushing under electric fields, charge deposition onto grid nodes, and absorbing boundary flux diagnostics.
Definition at line 13 of file particles.hpp.
| Particles | ( | int | N, |
| double | q, | ||
| double | m, | ||
| double | w ) |
Construct a particle set with N superparticles.
| N | Number of particles. |
| q | Charge per physical particle. |
| m | Mass per physical particle. |
| w | Statistical weight per superparticle. |
Definition at line 11 of file particles.cpp.
| Eigen::VectorXd deposit_charge | ( | const Eigen::VectorXd & | node_pos, |
| const Eigen::VectorXd & | dx ) const |
Deposit particle charge onto grid nodes (CIC scheme).
| node_pos | Node positions. |
| dx | Cell widths. |
Definition at line 216 of file particles.cpp.
| void emit | ( | int | N, |
| double | xpos, | ||
| double | dt, | ||
| double | energy_eV, | ||
| const Eigen::VectorXd & | node_pos, | ||
| const Eigen::VectorXd & | efield, | ||
| std::mt19937 & | rng ) |
Emit N particles at position xpos with Maxwellian velocity distribution.
| N | Number of emitted particles. |
| xpos | Injection position. |
| dt | Injection time intervall. |
| energy_eV | Thermal energy (eV) for Maxwellian sampling. |
| rng | Random generator for velocity/time sampling. |
Definition at line 71 of file particles.cpp.
| Eigen::VectorXd energy_distribution | ( | int | n_bins, |
| double | W_max ) const |
Definition at line 275 of file particles.cpp.
| Eigen::Vector4d fluxes | ( | const Eigen::Vector4d & | el_pos, |
| std::mt19937 & | rng, | ||
| double | p_ce, | ||
| double | p_ag ) |
Compute absorbed particle fluxes on four electrodes.
Flux order: 0: filament
1: control electrode
2: acceleration grid
3: ion collector
Randomized absorption at the control electrode and acceleration grid is controlled by probabilities p_ce and p_ag.
| el_pos | Positions of the four electrodes. |
| rng | Random generator for absorption events. |
| p_ce | Absorption probability at control electrode. |
| p_ag | Absorption probability at acceleration grid. |
Definition at line 153 of file particles.cpp.
| double interp_linear | ( | const Eigen::VectorXd & | x_nodes, |
| const Eigen::VectorXd & | E_nodes, | ||
| double | x ) |
Definition at line 45 of file particles.cpp.
| void push_leapfrog | ( | double | dt, |
| const Eigen::VectorXd & | node_pos, | ||
| const Eigen::VectorXd & | efield ) |
Advance particles using leapfrog (velocity half-step scheme).
| dt | Time step. |
| efield | Cell averaged electric fields. |
| node_pos | Nodal positions. |
Definition at line 130 of file particles.cpp.
| void resize | ( | int | N | ) |
Resize particle arrays to contain N superparticles.
| N | New total particle count. |
Definition at line 18 of file particles.cpp.
| double m_charge |
Charge of a single physical particle (C).
Definition at line 35 of file particles.hpp.
| double m_mass |
Mass of a single physical particle (kg).
Definition at line 38 of file particles.hpp.
| Eigen::VectorXd m_pos_prev |
Previous positions for boundary‐crossing detection.
Definition at line 29 of file particles.hpp.
| Eigen::VectorXd m_positions |
Particle positions (1D).
Definition at line 26 of file particles.hpp.
| Eigen::VectorXd m_vel_half |
Half-step velocities for leapfrog integration.
Definition at line 32 of file particles.hpp.
| double m_weight = 1.0 |
Superparticle statistical weight.
Definition at line 41 of file particles.hpp.