forked from NANIMproj/NANIM_PNNL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDWN_scope.cpp
More file actions
181 lines (157 loc) · 4.96 KB
/
Copy pathDWN_scope.cpp
File metadata and controls
181 lines (157 loc) · 4.96 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#include "stdafx.h"
#include "DWN_scope.h"
//Structure for parameters of microscope simulation--
//Assignment operator---
scope_param& scope_param::operator = (const scope_param& spam)
{
scope_mode = spam.scope_mode;
cell_x = spam.cell_x;
cell_y = spam.cell_y;
cell_z = spam.cell_z;
tilt_x = spam.tilt_x;
tilt_y = spam.tilt_y;
tilt_z = spam.tilt_z;
//scan_x_min = spam.scan_x_min;
scan_y_min = spam.scan_y_min;
scan_x_max = spam.scan_x_max;
scan_y_max = spam.scan_y_max;
raster_x = spam.raster_x;
raster_y = spam.raster_y;
window_x_size = spam.window_x_size;
window_y_size = spam.window_y_size;
image_x_res = spam.image_x_res;
image_y_res = spam.image_y_res;
slice_thickness = spam.slice_thickness;
slice_count = spam.slice_count;
voltage = spam.voltage;
current = spam.current;
brightness = spam.brightness;
dwell_time = spam.dwell_time;
source_angle = spam.source_angle;
source_size = spam.source_size;
convergence_angle = spam.convergence_angle;
beam_tilt_x = spam.beam_tilt_x;
beam_tilt_y = spam.beam_tilt_y;
defocus = spam.defocus;
detector_inner_angle = spam.detector_inner_angle;
detector_outer_angle = spam.detector_outer_angle;
detector_inner_angle2 = spam.detector_inner_angle2;
detector_outer_angle2 = spam.detector_outer_angle2;
Cs3 = spam.Cs3;
Cs5 = spam.Cs5;
Cc = spam.Cc;
dE = spam.dE;
two_astig = spam.two_astig;
three_astig = spam.three_astig;
two_astig_angle = spam.two_astig_angle;
three_astig_angle = spam.three_astig_angle;
scope_temp = spam.scope_temp;
TDS_runs = spam.TDS_runs;
slice_output_count = spam.slice_output_count;
return *this;
//Proper return for this operation.
}
//Microscope simulation class---
//Constructors, destructors, and initialization functions---
scope_sim::scope_sim()
{
Initialize();
//Set microscope parameters to default state.
}
scope_sim::scope_sim(const scope_param& pam)
{
spam = pam;
}
scope_sim::~scope_sim()
{
}
void scope_sim::Initialize()
//Parameters from initial test simulations of PbS nanoparticles used.
{
spam.scope_mode = STEM_MODE;
spam.cell_x = spam.cell_y = spam.cell_z = 1;
spam.tilt_x = spam.tilt_y = spam.tilt_z = 0.0;
spam.scan_x_min = spam.scan_y_min = 0.0;
spam.scan_x_max = spam.scan_y_max = 60.0;
spam.raster_x = spam.raster_y = 120;
spam.window_x_size = spam.window_y_size = 10.0;
spam.image_x_res = spam.image_y_res = 0.05;
spam.slice_thickness = 2.967;
spam.slice_count = 50;
spam.voltage = 200.0;
spam.brightness = 150.0;
spam.dwell_time = 2.0;
spam.source_angle = 10.0;
spam.source_size = 1.0;
//FWHM effective gun size.
spam.convergence_angle = 30.0;
spam.beam_tilt_x = spam.beam_tilt_y = 0.0;
spam.defocus = -4.3;
spam.detector_inner_angle = 100.0;
spam.detector_outer_angle = 170.0;
spam.detector_inner_angle2 = 0.0;
spam.detector_outer_angle2 = 20.0;
spam.Cs3 = 0.005;
spam.Cs5 = 3.2;
spam.Cc = 1.1;
spam.dE = 0.6;
spam.two_astig = 10.0;
spam.two_astig_angle = 0.0;
spam.three_astig = 0.0;
spam.three_astig_angle = 0.0;
spam.scope_temp = 295.15;
spam.TDS_runs = 15;
spam.slice_output_count = 20;
}
//Properties setting/retrieval---
void scope_sim::Get_Parameters(scope_param& pam) const
{
pam = spam;
}
void scope_sim::Set_Parameters(const scope_param& pam)
{
spam = pam;
}
//Properties calculations---
double scope_sim::Calculate_Wavelength()
{
double scope_calc_temp1 = 1.0 + (1000.0*spam.voltage/(2.0*511000.0));
double scope_calc_temp2 = 2.0*9.109*pow(10.0, -31.0)*
1.602*pow(10.0, -19.0)*
1000*spam.voltage*scope_calc_temp1;
double scope_calc_temp3 = (6.626 * pow(10.0, -34.0))/sqrt(scope_calc_temp2);
double wavelength = scope_calc_temp3*pow(10.0, 9.0);
return wavelength;
}
double scope_sim::Rel_Energy_Spread()
{
return (spam.dE/(1000.0*spam.voltage));
}
void scope_sim::Set_Scherzer_Defocus()
{
double wavelength = Calculate_Wavelength();
double scherzer_defocus = -1.2*sqrt(spam.Cs3*pow(10.0, 6.0)*wavelength);
spam.defocus = scherzer_defocus;
}
void scope_sim::Scale_Thickness(double z_height)
{
double z_col = z_height * double(spam.cell_z);
//Get total z column length.
double slice_ratio = z_col / spam.slice_thickness;
int slice_temp = int(slice_ratio - FP_ERROR_FIX) + 1;
//Number of slices needed to span the whole column,
//without changing slice thickness.
spam.slice_thickness = z_col/double(slice_temp);
//Reduced slice thickness such that the slices exactly
//span the column.
spam.slice_count = int ( (z_col + FP_ERROR_FIX) / spam.slice_thickness);
//Number of slices needed to span the whole column, with new slice thickness.
}
int scope_sim::Probe_Array_Size_X()
{
return int( (spam.window_x_size + FP_ERROR_FIX) / spam.image_x_res);
}
int scope_sim::Probe_Array_Size_Y()
{
return int( (spam.window_y_size + FP_ERROR_FIX) / spam.image_y_res);
}