Use the modified class
This commit is contained in:
parent
848e854320
commit
87c5da12ef
79
src/main.cpp
79
src/main.cpp
@ -11,36 +11,20 @@
|
|||||||
* */
|
* */
|
||||||
#include "WaveSimulation.hpp"
|
#include "WaveSimulation.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
void probability_deviation()
|
void probability_deviation()
|
||||||
{
|
{
|
||||||
WaveSimulation sim_narrow(.005, 2.5e-5, .008, .25, .5, .05, .05, 200., 0.);
|
WaveSimulation sim_no_slits(.005, 2.5e-5, .008, .25, .5, .05, .05, 200.,
|
||||||
|
0.);
|
||||||
|
|
||||||
WaveSimulation sim_wide(.005, 2.5e-5, .008, .25, .5, .05, .10, 200., 0.,
|
WaveSimulation sim_slits(.005, 2.5e-5, .008, .25, .5, .05, .10, 200., 0.,
|
||||||
0.02, .5, .05, .05, 2);
|
0.02, .5, .05, .05, 2);
|
||||||
|
|
||||||
std::ofstream ofile;
|
sim_no_slits.probability_deviation(
|
||||||
utils::mkpath("data");
|
"data/probability_deviation_no_slits.txt", true);
|
||||||
ofile.open("data/probability_deviation.txt");
|
sim_slits.probability_deviation("data/probability_deviation_slits.txt", true);
|
||||||
|
|
||||||
double sum_narrow, sum_wide;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < 320; i++) {
|
|
||||||
sum_narrow = 0;
|
|
||||||
sum_wide = 0;
|
|
||||||
for (size_t j = 0; j < sim_narrow.U.n_elem; j++) {
|
|
||||||
sum_narrow += (sim_narrow.U(j) * std::conj(sim_narrow.U(j))).real();
|
|
||||||
sum_wide += (sim_wide.U(j) * std::conj(sim_wide.U(j))).real();
|
|
||||||
}
|
|
||||||
|
|
||||||
sim_narrow.step();
|
|
||||||
sim_wide.step();
|
|
||||||
ofile << i << ',' << utils::scientific_format(sum_narrow) << ','
|
|
||||||
<< utils::scientific_format(sum_wide) << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
ofile.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void color_map()
|
void color_map()
|
||||||
@ -48,19 +32,8 @@ void color_map()
|
|||||||
WaveSimulation sim(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0., 0.02,
|
WaveSimulation sim(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0., 0.02,
|
||||||
.5, .05, .05, 2);
|
.5, .05, .05, 2);
|
||||||
|
|
||||||
std::ofstream ofile;
|
std::vector<double> times{0., .001, .002};
|
||||||
ofile.open("data/color_map.txt");
|
sim.solve("data/color_map.txt", times);
|
||||||
ofile << sim.N << '\n';
|
|
||||||
sim.write_U(ofile);
|
|
||||||
for (size_t i = 0; i < 40; i++) {
|
|
||||||
sim.step();
|
|
||||||
}
|
|
||||||
sim.write_U(ofile);
|
|
||||||
for (size_t i = 0; i < 40; i++) {
|
|
||||||
sim.step();
|
|
||||||
}
|
|
||||||
sim.write_U(ofile);
|
|
||||||
ofile.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void detector_screen()
|
void detector_screen()
|
||||||
@ -68,46 +41,29 @@ void detector_screen()
|
|||||||
WaveSimulation *sim = new WaveSimulation(
|
WaveSimulation *sim = new WaveSimulation(
|
||||||
.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0., 0.02, .5, .05, .05, 1);
|
.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0., 0.02, .5, .05, .05, 1);
|
||||||
|
|
||||||
std::ofstream ofile;
|
sim->solve("data/screen/single_slit.txt");
|
||||||
utils::mkpath("data/screen");
|
|
||||||
ofile.open("data/screen/single_slit.txt");
|
|
||||||
ofile << sim->N << '\n';
|
|
||||||
for (size_t i = 0; i < 80; i++) {
|
|
||||||
sim->step();
|
|
||||||
}
|
|
||||||
sim->write_U(ofile);
|
|
||||||
ofile.close();
|
|
||||||
|
|
||||||
delete sim;
|
delete sim;
|
||||||
sim = new WaveSimulation(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0.,
|
sim = new WaveSimulation(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0.,
|
||||||
0.02, .5, .05, .05, 2);
|
0.02, .5, .05, .05, 2);
|
||||||
|
|
||||||
ofile.open("data/screen/double_slit.txt");
|
sim->solve("data/screen/double_slit.txt");
|
||||||
ofile << sim->N << '\n';
|
|
||||||
for (size_t i = 0; i < 80; i++) {
|
|
||||||
sim->step();
|
|
||||||
}
|
|
||||||
sim->write_U(ofile);
|
|
||||||
ofile.close();
|
|
||||||
|
|
||||||
delete sim;
|
delete sim;
|
||||||
sim = new WaveSimulation(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0.,
|
sim = new WaveSimulation(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0.,
|
||||||
0.02, .5, .05, .05, 3);
|
0.02, .5, .05, .05, 3);
|
||||||
|
|
||||||
ofile.open("data/screen/triple_slit.txt");
|
sim->solve("data/screen/triple_slit.txt");
|
||||||
ofile << sim->N << '\n';
|
|
||||||
for (size_t i = 0; i < 80; i++) {
|
|
||||||
sim->step();
|
|
||||||
}
|
|
||||||
sim->write_U(ofile);
|
|
||||||
ofile.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
//probability_deviation();
|
DEBUG("Before probability deviation");
|
||||||
|
probability_deviation();
|
||||||
|
DEBUG("Before color map");
|
||||||
//color_map();
|
//color_map();
|
||||||
detector_screen();
|
DEBUG("Before detector screen");
|
||||||
|
//detector_screen();
|
||||||
|
|
||||||
// std::ofstream ofile;
|
// std::ofstream ofile;
|
||||||
// ofile.open("test.txt");
|
// ofile.open("test.txt");
|
||||||
@ -115,6 +71,5 @@ int main()
|
|||||||
// 0.02, .5, .05, .05, 2);
|
// 0.02, .5, .05, .05, 2);
|
||||||
// sim.solve(ofile);
|
// sim.solve(ofile);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user