-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
120 lines (105 loc) · 2.84 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <cstdlib>
#include <iostream>
#include <vector>
#include <getopt.h>
#include "CapSimulation.h"
#include "ThreadedCapSimulationRunner.h"
#include "ImplantedDiamond.h"
#include "DamageModelFactory.h"
void print_data(const std::vector <CapPoint> & data, std::ostream & out = std::cout);
std::string to_upper(const std::string &);
int main(int argc, char *argv[])
{
double start_time = 0e-12;
double stop_time = 200e-12;
double time_step = 0.25e-12;
double fluence = 1e15;
double reflectivity = 0.75;
std::string model_string = "undamaged";
bool quiet = false;
int num_threads = 2;
std::stringstream ss;
int c;
static struct option long_options[] =
{
{"fluence", required_argument, 0, 'f'},
{"start", required_argument, 0, 's'},
{"stop", required_argument, 0, 'e'},
{"step", required_argument, 0, 'i'},
{"model", required_argument, 0, 'm'},
{"reflectivity", required_argument, 0, 'R'},
{"quiet", no_argument, 0, 'q'},
{"threads", required_argument, 0, 't'},
{0, 0, 0, 0}
};
int option_index = 0;
while (1)
{
c = getopt_long(argc, argv, "f:s:e:i:m:R:qt:", long_options, &option_index);
if (c == -1)
break;
if (c != 'q')
{
ss.clear();
ss.str(optarg);
}
switch (c)
{
case 'f':
ss >> fluence;
break;
case 's':
ss >> start_time;
break;
case 'e':
ss >> stop_time;
break;
case 'i':
ss >> time_step;
break;
case 'm':
model_string = ss.str();
break;
case 'R':
ss >> reflectivity;
break;
case 'q':
quiet = true;
break;
case 't':
ss >> num_threads;
break;
}
}
DamageModelInterface * model = DamageModelFactory::ParseCommandLine(model_string);
TransducingLayer transducing_layer(reflectivity, 7.6e-9, 0.91, 2.70, 0.334, 23e-6);
ImplantedDiamond material(model, fluence);
material.set_transducing_layer(transducing_layer);
CapSimulation simulation;
simulation.set_material(&material);
ThreadedCapSimulationRunner runner(&simulation);
runner.set_time_delays(start_time, stop_time, time_step);
runner.set_number_of_threads(num_threads);
runner.PrintParameters(std::cout, "# ");
if (!quiet) runner.PrintParameters(std::cerr, "");
print_data(runner.Run());
return 0;
}
void print_data(const std::vector <CapPoint> & data, std::ostream & out)
{
out << "# Column 1: Time Delay (s)" << std::endl;
out << "# Column 2: Reflectivity [(R - R0) / R0]" << std::endl;
for (unsigned int i = 0; i < data.size(); i++)
{
out << data[i].time_delay << '\t' << data[i].reflectivity << std::endl;
}
}
std::string to_upper(const std::string & s)
{
std::string out = s;
for (unsigned int i = 0; i < out.length(); i++)
{
if (out[i] >= 'a' && out[i] <= 'z') out[i] = out[i] + ('A' - 'a');
}
return out;
}