janitaws/latex #14

Merged
coryab merged 34 commits from janitaws/latex into develop 2024-01-01 16:38:44 +00:00
Showing only changes of commit 8637cad168 - Show all commits

View File

@ -11,36 +11,20 @@
* */
#include "WaveSimulation.hpp"
#include "utils.hpp"
#include <fstream>
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);
std::ofstream ofile;
utils::mkpath("data");
ofile.open("data/probability_deviation.txt");
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();
sim_no_slits.probability_deviation(
"data/probability_deviation_no_slits.txt", true);
sim_slits.probability_deviation("data/probability_deviation_slits.txt", true);
}
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,
.5, .05, .05, 2);
std::ofstream ofile;
ofile.open("data/color_map.txt");
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();
std::vector<double> times{0., .001, .002};
sim.solve("data/color_map.txt", times);
}
void detector_screen()
@ -68,53 +41,35 @@ void detector_screen()
WaveSimulation *sim = new WaveSimulation(
.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0., 0.02, .5, .05, .05, 1);
std::ofstream ofile;
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();
sim->solve("data/screen/single_slit.txt");
delete sim;
sim = new WaveSimulation(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0.,
0.02, .5, .05, .05, 2);
ofile.open("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();
sim->solve("data/screen/double_slit.txt");
delete sim;
sim = new WaveSimulation(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0.,
0.02, .5, .05, .05, 3);
ofile.open("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();
sim->solve("data/screen/triple_slit.txt");
}
int main()
{
//probability_deviation();
DEBUG("Before probability deviation");
probability_deviation();
DEBUG("Before color map");
//color_map();
detector_screen();
//std::ofstream ofile;
//ofile.open("test.txt");
//WaveSimulation sim(.005, 2.5e-5, .008, .25, .5, .05, .10, 200., 0.,
//0.02, .5, .05, .05, 2);
//sim.solve(ofile);
DEBUG("Before detector screen");
//detector_screen();
// std::ofstream ofile;
// ofile.open("test.txt");
// WaveSimulation sim(.005, 2.5e-5, .008, .25, .5, .05, .10, 200., 0.,
// 0.02, .5, .05, .05, 2);
// sim.solve(ofile);
return 0;
}