Modify class

This commit is contained in:
Cory Balaton 2023-12-22 16:01:57 +01:00
commit 7b83a3eed3
Signed by: coryab
GPG key ID: F7562F0EC4E4A61B
2 changed files with 297 additions and 118 deletions

View file

@ -21,31 +21,96 @@
class WaveSimulation {
protected:
uint32_t M;
int32_t N;
arma::cx_mat V;
arma::cx_mat U;
arma::sp_cx_mat B;
arma::sp_cx_mat A;
double h;
double dt;
double T;
void build_A();
void build_B();
/* @brief Initialize the U matrix using an unormalized Gaussian wave
* packet.
*
* @param x_c The center of the packet in the x direction.
* @param y_c The center of the packet in the y direction.
* @param sigma_x The The initial width in the x direction.
* @param sigma_y The The initial width in the y direction.
* @param p_x The wave packet momentum in the x direction.
* @param p_y The wave packet momentum in the y direction.
* **/
void initialize_U(double x_c, double y_c, double sigma_x, double sigma_y,
double p_x, double p_y);
void build_V(double thickness, double pos_x, double aperture_separation,
double aperture, uint32_t slits);
/* @brief Initialize the V matrix.
*
* @param thickness The thickness of the wall in the x direction.
* @param pos_x The center of the wall in the x direction.
* @param ap_sep The separation between each aperture.
* @param ap The aperture width.
* @param slits The number of slits.
* **/
void initialize_V(double thickness, double pos_x,
double aperture_separation, double aperture,
uint32_t slits);
/* @brief Initialize the V matrix with no wall.
* **/
void initialize_V();
/* @brief Initialize the A matrix according to the Crank-Nicolson method
* **/
void initialize_A();
/* @brief Initialize the B matrix according to the Crank-Nicolson method
* **/
void initialize_B();
public:
int32_t N;
arma::cx_mat V;
arma::cx_mat U;
arma::sp_cx_mat A;
/* @brief Constructor for the WaveSimulation class.
*
* @param h The step size in the x and y direction.
* @param dt The step size in the temporal dimension.
* @param T The total time to simulate.
* @param x_c The center of the packet in the x direction.
* @param y_c The center of the packet in the y direction.
* @param sigma_x The The initial width in the x direction.
* @param sigma_y The The initial width in the y direction.
* @param p_x The wave packet momentum in the x direction.
* @param p_y The wave packet momentum in the y direction.
* @param thickness The thickness of the wall in the x direction.
* @param pos_x The center of the wall in the x direction.
* @param ap_sep The separation between each aperture.
* @param ap The aperture width.
* @param slits The number of slits.
* **/
WaveSimulation(double h, double dt, double T, double x_c, double y_c,
double sigma_x, double sigma_y, double p_x, double p_y,
double thickness, double pos_x, double ap_sep, double ap,
uint32_t slits);
/* @brief Constructor for the WaveSimulation class with no wall.
*
* @param h The step size in the x and y direction.
* @param dt The step size in the temporal dimension.
* @param T The total time to simulate.
* @param x_c The center of the packet in the x direction.
* @param y_c The center of the packet in the y direction.
* @param sigma_x The The initial width in the x direction.
* @param sigma_y The The initial width in the y direction.
* @param p_x The wave packet momentum in the x direction.
* @param p_y The wave packet momentum in the y direction.
* **/
WaveSimulation(double h, double dt, double T, double x_c, double y_c,
double sigma_x, double sigma_y, double p_x, double p_y);
virtual void solve(std::ofstream &ofile);
void write_U(std::ofstream &ofile);
void step();
void solve(std::string outfile, bool write_each_step = false);
void solve(std::string outfile, std::vector<double> &steps);
void probability_deviation(std::string outfile,
bool write_each_step = false);
void write_U(std::ofstream &ofile);
};
#endif