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
main.cpp
Go to the documentation of this file.
1
12#include "WaveSimulation.hpp"
13#include "utils.hpp"
14
15#include <fstream>
16
17 void probability_deviation()
18{
19 DEBUG("Sim no slits");
20 WaveSimulation sim_no_slits(.005, 2.5e-5, .008, .25, .5, .05, .05, 200.,
21 0.);
22
23 DEBUG("Sim with slits");
24 WaveSimulation sim_slits(.005, 2.5e-5, .008, .25, .5, .05, .10, 200., 0.,
25 0.02, .5, .05, .05, 2);
26
27 DEBUG("Probability deviation");
28 sim_no_slits.probability_deviation(
29 "data/probability_deviation_no_slits.txt", true);
30 DEBUG("Probability deviation with slits");
31 sim_slits.probability_deviation("data/probability_deviation_slits.txt",
32 true);
33}
34
35 void color_map()
36{
37 WaveSimulation sim(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0., 0.02,
38 .5, .05, .05, 2);
39
40 std::vector<double> times{0., .001, .002};
41 sim.simulate("data/color_map.txt", times);
42}
43
44 void detector_screen()
45{
46 WaveSimulation *sim = new WaveSimulation(
47 .005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0., 0.02, .5, .05, .05, 1);
48
49 sim->simulate("data/screen/single_slit.txt");
50
51 delete sim;
52 sim = new WaveSimulation(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0.,
53 0.02, .5, .05, .05, 2);
54
55 sim->simulate("data/screen/double_slit.txt");
56
57 delete sim;
58 sim = new WaveSimulation(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0.,
59 0.02, .5, .05, .05, 3);
60
61 sim->simulate("data/screen/triple_slit.txt");
62}
63
64 void animation()
65{
66 std::ofstream ofile;
67 ofile.open("test.txt");
68 WaveSimulation sim(.005, 2.5e-5, .008, .25, .5, .05, .10, 200., 0., 0.02,
69 .5, .05, .05, 2);
70 sim.simulate("data/animation.txt", true);
71}
72
73 int main()
74{
75 probability_deviation();
76 color_map();
77 detector_screen();
78 animation();
79
80 return 0;
81}
WaveSimulation.hpp
The definition of the WaveSimulation class.
WaveSimulation
Simulate the evolution of a wave packet in 2 + 1 domensions.
Definition: WaveSimulation.hpp:22
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.
utils.hpp
Function prototypes and macros that are useful.
DEBUG
#define DEBUG(msg)
Writes a debug message.
Definition: utils.hpp:39