Loading...
Searching...
No Matches
WaveSimulation.hpp
Go to the documentation of this file.
#ifndef __WAVE_SIMULATION__
#define __WAVE_SIMULATION__
#include "constants.hpp"
#include "literals.hpp"
#include <armadillo>
#include <cstdint>
class WaveSimulation {
private:
int32_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 initialize_U(double x_c, double y_c, double sigma_x, double sigma_y,
double p_x, double p_y);
void initialize_V(double thickness, double pos_x,
double aperture_separation, double aperture,
uint32_t slits);
void initialize_V();
void initialize_A();
void initialize_B();
void write_U(std::ofstream &ofile);
public:
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);
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);
void step();
void simulate(std::string outfile, bool write_each_step = false);
void simulate(std::string outfile, std::vector<double> &steps);
void probability_deviation(std::string outfile,
bool write_each_step = false);
};
#endif
WaveSimulation
Simulate the evolution of a wave packet in 2 + 1 domensions.
Definition: WaveSimulation.hpp:22
WaveSimulation::U
arma::cx_mat U
The particle wave matrix.
Definition: WaveSimulation.hpp:27
WaveSimulation::dt
double dt
The step size int the time direction.
Definition: WaveSimulation.hpp:31
WaveSimulation::A
arma::sp_cx_mat A
The A matrix.
Definition: WaveSimulation.hpp:29
WaveSimulation::initialize_B
void initialize_B()
Initialize the B matrix according to the Crank-Nicolson method.
WaveSimulation::M
int32_t M
The size.
Definition: WaveSimulation.hpp:24
WaveSimulation::N
int32_t N
The size of the inner part.
Definition: WaveSimulation.hpp:25
WaveSimulation::B
arma::sp_cx_mat B
The B matrix.
Definition: WaveSimulation.hpp:28
WaveSimulation::initialize_V
void initialize_V(double thickness, double pos_x, double aperture_separation, double aperture, uint32_t slits)
Initialize the V matrix.
WaveSimulation::h
double h
The step size in both x and y direction.
Definition: WaveSimulation.hpp:30
WaveSimulation::initialize_A
void initialize_A()
Initialize the A matrix according to the Crank-Nicolson method.
WaveSimulation::simulate
void simulate(std::string outfile, bool write_each_step=false)
Evolve the wave packet until the time T has been reached and write U to file.
WaveSimulation::WaveSimulation
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)
Constructor for the WaveSimulation class with no wall.
WaveSimulation::initialize_V
void initialize_V()
Initialize the V matrix with no wall.
WaveSimulation::simulate
void simulate(std::string outfile, std::vector< double > &steps)
Evolve the wave packet and write U to fileto file at each time step in the vector given.
WaveSimulation::V
arma::cx_mat V
The potential matrix.
Definition: WaveSimulation.hpp:26
WaveSimulation::write_U
void write_U(std::ofstream &ofile)
Write the U matrix in a single line to the file buffer given.
WaveSimulation::WaveSimulation
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)
Constructor for the WaveSimulation class.
WaveSimulation::T
double T
The end time.
Definition: WaveSimulation.hpp:32
WaveSimulation::initialize_U
void initialize_U(double x_c, double y_c, double sigma_x, double sigma_y, double p_x, double p_y)
Initialize the U matrix using an unormalized Gaussian wave packet.
WaveSimulation::probability_deviation
void probability_deviation(std::string outfile, bool write_each_step=false)
Write the deviation of the sum of the probability of U from 1.
WaveSimulation::step
void step()
Evolve a step forward in time.
constants.hpp
Library of constants.
literals.hpp
Useful literals.