Make changes
This commit is contained in:
parent
114d2e2b57
commit
60373719cd
16
src/main.cpp
16
src/main.cpp
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*
|
*
|
||||||
* @brief Implementation of the testing library
|
* @brief The main program
|
||||||
*
|
*
|
||||||
* @bug No known bugs
|
* @bug No known bugs
|
||||||
* */
|
* */
|
||||||
@ -16,14 +16,18 @@
|
|||||||
|
|
||||||
void probability_deviation()
|
void probability_deviation()
|
||||||
{
|
{
|
||||||
|
DEBUG("Sim no slits");
|
||||||
WaveSimulation sim_no_slits(.005, 2.5e-5, .008, .25, .5, .05, .05, 200.,
|
WaveSimulation sim_no_slits(.005, 2.5e-5, .008, .25, .5, .05, .05, 200.,
|
||||||
0.);
|
0.);
|
||||||
|
|
||||||
|
DEBUG("Sim with slits");
|
||||||
WaveSimulation sim_slits(.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);
|
||||||
|
|
||||||
|
DEBUG("Probability deviation");
|
||||||
sim_no_slits.probability_deviation(
|
sim_no_slits.probability_deviation(
|
||||||
"data/probability_deviation_no_slits.txt", true);
|
"data/probability_deviation_no_slits.txt", true);
|
||||||
|
DEBUG("Probability deviation with slits");
|
||||||
sim_slits.probability_deviation("data/probability_deviation_slits.txt", true);
|
sim_slits.probability_deviation("data/probability_deviation_slits.txt", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +37,7 @@ void color_map()
|
|||||||
.5, .05, .05, 2);
|
.5, .05, .05, 2);
|
||||||
|
|
||||||
std::vector<double> times{0., .001, .002};
|
std::vector<double> times{0., .001, .002};
|
||||||
sim.solve("data/color_map.txt", times);
|
sim.simulate("data/color_map.txt", times);
|
||||||
}
|
}
|
||||||
|
|
||||||
void detector_screen()
|
void detector_screen()
|
||||||
@ -41,19 +45,19 @@ 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);
|
||||||
|
|
||||||
sim->solve("data/screen/single_slit.txt");
|
sim->simulate("data/screen/single_slit.txt");
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
sim->solve("data/screen/double_slit.txt");
|
sim->simulate("data/screen/double_slit.txt");
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
sim->solve("data/screen/triple_slit.txt");
|
sim->simulate("data/screen/triple_slit.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -69,7 +73,7 @@ int main()
|
|||||||
// ofile.open("test.txt");
|
// ofile.open("test.txt");
|
||||||
// WaveSimulation sim(.005, 2.5e-5, .008, .25, .5, .05, .10, 200., 0.,
|
// WaveSimulation sim(.005, 2.5e-5, .008, .25, .5, .05, .10, 200., 0.,
|
||||||
// 0.02, .5, .05, .05, 2);
|
// 0.02, .5, .05, .05, 2);
|
||||||
// sim.solve(ofile);
|
// sim.simulate(ofile);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
88
src/wave_simulation.cpp
Normal file
88
src/wave_simulation.cpp
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#include "WaveSimulation.hpp"
|
||||||
|
#include "utils.hpp"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
void execute_simulation(std::vector<std::string> &args)
|
||||||
|
{
|
||||||
|
DEBUG("Inside execute sim");
|
||||||
|
if (args.size() < 11) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG("Declare sim");
|
||||||
|
WaveSimulation *sim;
|
||||||
|
if (args.size() >= 11 && args.size() < 16) {
|
||||||
|
sim = new WaveSimulation(
|
||||||
|
std::stod(args[2]), std::stod(args[3]), std::stod(args[4]),
|
||||||
|
std::stod(args[5]), std::stod(args[6]), std::stod(args[7]),
|
||||||
|
std::stod(args[8]), std::stod(args[9]), std::stod(args[10]));
|
||||||
|
}
|
||||||
|
else if (args.size() >= 16) {
|
||||||
|
sim = new WaveSimulation(
|
||||||
|
std::stod(args[2]), std::stod(args[3]), std::stod(args[4]),
|
||||||
|
std::stod(args[5]), std::stod(args[6]), std::stod(args[7]),
|
||||||
|
std::stod(args[8]), std::stod(args[9]), std::stod(args[10]),
|
||||||
|
std::stod(args[11]), std::stod(args[12]), std::stod(args[13]),
|
||||||
|
std::stod(args[14]), std::stoi(args[15]));
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG("After instantiating sim");
|
||||||
|
if (args[0].compare("deviation") == 0) {
|
||||||
|
DEBUG("Deviation");
|
||||||
|
if (args.size() == 17) {
|
||||||
|
sim->probability_deviation(args[1], args[16].compare("false"));
|
||||||
|
}
|
||||||
|
else if (args.size() == 12) {
|
||||||
|
sim->probability_deviation(args[1], args[11].compare("false"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sim->probability_deviation(args[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args[0].compare("simulate") == 0) {
|
||||||
|
DEBUG("Simulate");
|
||||||
|
if (args.size() == 17) {
|
||||||
|
sim->simulate(args[1], args[16].compare("false"));
|
||||||
|
}
|
||||||
|
else if (args.size() == 12) {
|
||||||
|
sim->simulate(args[1], args[11].compare("false"));
|
||||||
|
}
|
||||||
|
else if (args.size() > 17) {
|
||||||
|
std::vector<double> arr;
|
||||||
|
for (size_t i = 16; i < args.size(); i++) {
|
||||||
|
arr.push_back(std::stod(args[i]));
|
||||||
|
}
|
||||||
|
sim->simulate(args[1], arr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sim->simulate(args[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete sim;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
DEBUG("Start of main");
|
||||||
|
if (argc < 2) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG("After arg check");
|
||||||
|
std::string filename = argv[1];
|
||||||
|
|
||||||
|
DEBUG("Open file");
|
||||||
|
std::ifstream infile;
|
||||||
|
infile.open(filename);
|
||||||
|
|
||||||
|
DEBUG("For line in lines");
|
||||||
|
for (std::string line; std::getline(infile, line);) {
|
||||||
|
std::vector<std::string> arr = utils::split(line, ';');
|
||||||
|
execute_simulation(arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG("Close file");
|
||||||
|
infile.close();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user