Simulating the Schrödinger wave equation using the Crank-Nicolson method in 2+1 dimensions
Simulating the Schrödinger wave equation using the Crank-Nicolson method in 2+1 dimensions
Loading...
Searching...
No Matches
WaveSimulation Class Reference

Simulate the evolution of a wave packet in 2 + 1 domensions. More...

#include <WaveSimulation.hpp>

Public Member Functions

 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 (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.
 
void step ()
 Evolve a step forward in time.
 
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.
 
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.
 
void probability_deviation (std::string outfile, bool write_each_step=false)
 Write the deviation of the sum of the probability of U from 1.
 

Private Member Functions

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.
 
void initialize_V (double thickness, double pos_x, double aperture_separation, double aperture, uint32_t slits)
 Initialize the V matrix.
 
void initialize_V ()
 Initialize the V matrix with no wall.
 
void initialize_A ()
 Initialize the A matrix according to the Crank-Nicolson method.
 
void initialize_B ()
 Initialize the B matrix according to the Crank-Nicolson method.
 
void write_U (std::ofstream &ofile)
 Write the U matrix in a single line to the file buffer given.
 

Private Attributes

int32_t M
 The size.
 
int32_t N
 The size of the inner part.
 
arma::cx_mat V
 The potential matrix.
 
arma::cx_mat U
 The particle wave matrix.
 
arma::sp_cx_mat B
 The B matrix.
 
arma::sp_cx_mat A
 The A matrix.
 
double h
 The step size in both x and y direction.
 
double dt
 The step size int the time direction.
 
double T
 The end time.
 

Detailed Description

Simulate the evolution of a wave packet in 2 + 1 domensions.

Definition at line 22 of file WaveSimulation.hpp.

Constructor & Destructor Documentation

◆ WaveSimulation() [1/2]

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.

Parameters
hThe step size in the x and y direction.
dtThe step size in the temporal dimension.
TThe total time to simulate.
x_cThe center of the packet in the x direction.
y_cThe center of the packet in the y direction.
sigma_xThe The initial width in the x direction.
sigma_yThe The initial width in the y direction.
p_xThe wave packet momentum in the x direction.
p_yThe wave packet momentum in the y direction.
thicknessThe thickness of the wall in the x direction.
pos_xThe center of the wall in the x direction.
ap_sepThe separation between each aperture.
apThe aperture width.
slitsThe number of slits.

◆ WaveSimulation() [2/2]

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.

Parameters
hThe step size in the x and y direction.
dtThe step size in the temporal dimension.
TThe total time to simulate.
x_cThe center of the packet in the x direction.
y_cThe center of the packet in the y direction.
sigma_xThe The initial width in the x direction.
sigma_yThe The initial width in the y direction.
p_xThe wave packet momentum in the x direction.
p_yThe wave packet momentum in the y direction.

Member Function Documentation

◆ initialize_U()

void WaveSimulation::initialize_U ( double  x_c,
double  y_c,
double  sigma_x,
double  sigma_y,
double  p_x,
double  p_y 
)
private

Initialize the U matrix using an unormalized Gaussian wave packet.

Parameters
x_cThe center of the packet in the x direction.
y_cThe center of the packet in the y direction.
sigma_xThe The initial width in the x direction.
sigma_yThe The initial width in the y direction.
p_xThe wave packet momentum in the x direction.
p_yThe wave packet momentum in the y direction.

◆ initialize_V()

void WaveSimulation::initialize_V ( double  thickness,
double  pos_x,
double  aperture_separation,
double  aperture,
uint32_t  slits 
)
private

Initialize the V matrix.

Parameters
thicknessThe thickness of the wall in the x direction.
pos_xThe center of the wall in the x direction.
ap_sepThe separation between each aperture.
apThe aperture width.
slitsThe number of slits.

◆ probability_deviation()

void WaveSimulation::probability_deviation ( std::string  outfile,
bool  write_each_step = false 
)

Write the deviation of the sum of the probability of U from 1.

Parameters
outfileThe name of the file to write to to file

◆ simulate() [1/2]

void WaveSimulation::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.

Parameters
outfileThe name of the file to write to
write_each_stepBoolean for deciding to write each step to file or just the last step

◆ simulate() [2/2]

void WaveSimulation::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.

Parameters
outfileThe name of the file to write to
stepsWhat time steps to write U to file.

◆ write_U()

void WaveSimulation::write_U ( std::ofstream &  ofile)
private

Write the U matrix in a single line to the file buffer given.

Parameters
ofileThe file buffer to write to

Member Data Documentation

◆ A

arma::sp_cx_mat WaveSimulation::A
private

The A matrix.

Definition at line 29 of file WaveSimulation.hpp.

◆ B

arma::sp_cx_mat WaveSimulation::B
private

The B matrix.

Definition at line 28 of file WaveSimulation.hpp.

◆ dt

double WaveSimulation::dt
private

The step size int the time direction.

Definition at line 31 of file WaveSimulation.hpp.

◆ h

double WaveSimulation::h
private

The step size in both x and y direction.

Definition at line 30 of file WaveSimulation.hpp.

◆ M

int32_t WaveSimulation::M
private

The size.

Definition at line 24 of file WaveSimulation.hpp.

◆ N

int32_t WaveSimulation::N
private

The size of the inner part.

Definition at line 25 of file WaveSimulation.hpp.

◆ T

double WaveSimulation::T
private

The end time.

Definition at line 32 of file WaveSimulation.hpp.

◆ U

arma::cx_mat WaveSimulation::U
private

The particle wave matrix.

Definition at line 27 of file WaveSimulation.hpp.

◆ V

arma::cx_mat WaveSimulation::V
private

The potential matrix.

Definition at line 26 of file WaveSimulation.hpp.


The documentation for this class was generated from the following file: