 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
51 a = de = sw = def_dev = ast_ang = firstzero = f = 0;
72 t1 = 0.5*
M_PI*wl*wl*wl*cs;
82 if ( !ctf )
return -1;
87 double volt() {
return av; }
88 void volt(
double v) { av = v; update_terms(); }
91 double Cs() {
return cs; }
92 void Cs(
double v) { cs = v; update_terms(); }
93 double Cc() {
return cc; }
94 void Cc(
double v) { cc = v; }
97 double dE() {
return de; }
98 void dE(
double v) { de = v; }
126 double fom() {
return f; }
127 void fom(
double v) { f = v; }
130 if ( def_avg < 1 || def_avg > 2e5 ) {
131 cerr <<
"Error: Defocus is out of range 0.0001 - 20 um! (" << def_avg*1e-4 <<
")" << endl;
132 if ( def_avg < 1 ) def_avg = 1;
133 else if ( def_avg > 2e5 ) def_avg = 2e5;
138 if ( cs < 1e3 || cs > 1e8 ) {
139 cerr <<
"Error: Cs is out of range 0.0001 - 10 mm! (" << cs*1e-7 <<
")" << endl;
140 if ( cs < 1e3 ) cs = 1e3;
141 else if ( cs > 1e8 ) cs = 1e8;
151 return oa/(2*fl*
lambda());
156 double defocus = def_avg + def_dev*cos(2*(angle - ast_ang));
157 return (t1*s2 - t2*defocus)*s2 - ac;
165 vector<double>
calculate(
int nrad,
int npsi,
double step_size);
172 double s2(s*s), b(0), ds;
195 cerr <<
"Error in CTFparam::calc_baseline: baseline value not finite!" << endl;
196 else if ( b <= 0 ) b = 0;
200 double s2(s*s), e(0);
203 e = env[0]*exp(env[1]*s2);
206 e = env[0] + env[1]*exp(env[2]*s2);
209 e = env[0]*exp(env[1]*s2) + env[2]*exp(env[3]*s2);
212 e = env[0] + env[1]*exp(env[2]*s2) + env[3]*exp(env[4]*s2);
217 cerr <<
"Error in CTFparam::calc_envelope: baseline value not finite!" << endl;
218 else if ( e <= 0 ) e = 0;
221 vector<double>
zeroes(
double max_s);
230 double l3Cs = l*l*l*cs;
231 double ctf_z = def_avg/(l*l*cs);
232 double f = 1.0/sqrt(ctf_z - sqrt(ctf_z*ctf_z - i*2.0/l3Cs));
234 if ( i == 1 ) firstzero = f;
238 if ( s < 1e-6 )
return -1;
240 return 0.5*l*l*cs*s*s + 1/(l*s*s);
243 cout <<
"Defocus average: " << def_avg*1e-4 <<
" um" << endl;
244 cout <<
"Defocus deviation: " << def_dev*1e-4 <<
" um" << endl;
245 cout <<
"Astigmatism angle: " << ast_ang*180/
M_PI <<
" degrees" << endl;
246 cout <<
"Amplitude phase shift: " << ac << endl;
247 cout <<
"Voltage: " << av*1e-3 <<
" kV" << endl;
248 cout <<
"Wavelength: " <<
lambda() <<
" A" << endl;
249 cout <<
"Spherical aberration (Cs): " << cs*1e-7 <<
" mm" << endl;
250 cout <<
"Chromatic aberration (Cc): " << cc*1e-7 <<
" mm" << endl;
251 cout <<
"Illumination halfangle (alpha): " << a*1e3 <<
" mrad" << endl;
252 cout <<
"Energy spread: " << de <<
" eV" << endl;
253 cout <<
"Energy filter slit width: " << sw <<
" eV" << endl;
254 cout <<
"Objective aperture: " << oa*1e-4 <<
" µm" << endl;
257 cout <<
"Baseline coefficients: " <<
263 cout <<
" " <<
baseline(4) <<
" (polynomial";
267 cout <<
" " <<
baseline(4) <<
" (double gaussian";
280 cout <<
"Envelope coefficients: ";
285 cout <<
" (single gaussian)";
288 cout <<
" (single gaussian with constant)";
291 cout <<
" (double gaussian)";
294 cout <<
" (double gaussian with constant)";
309 double beta2(
double volt);
310 double beta(
double volt);
311 vector<double>
C_curve(
long n,
double freq_step);
double calc_envelope(double s)
int update(CTFparam *ctf)
string base(string &filename)
void baseline(int i, double d)
double objective_aperture()
void defocus_deviation(double v)
double astigmatism_angle()
Class for complex numbers.
vector< double > envelope_energy_spread(long n, double freq_step)
Calculates the envelope curve based on energy spread.
double calc_baseline(double s)
double defocus_for_first_zero(double s)
int parse_baseline_equation(Bstring base_eq)
Extracts the coefficients from the baseline string.
double calculate(double s2, double angle)
void slit_width(double v)
double defocus_factor(CTFparam &ctf, double def_min, double def_max, double def_step)
Calculates an integrated defocus weighting factor for a raneg of defocus values.
void focal_length(double v)
CTFparam(double v, double sa, double ac)
Bstring envelope_equation()
Generates an envelope equation string from 4 coefficients.
vector< double > envelope_partial_coherence(long n, double freq_step)
Calculates the envelope curve based on partial coherence.
int parse_envelope_equation(Bstring env_eq)
Extracts the coefficients from the envelope string.
vector< double > C_curve(long n, double freq_step)
Calculates the carbon scattering curve.
Header file for the string class.
void baseline_type(long t)
double defocus_deviation()
vector< double > zeroes(double max_s)
Calculates the zeroes of a CTF curve on the spatial frequency scale.
Header file for general utilities.
double delta_phi(double s2, double angle)
void envelope(vector< double > &v)
bool isfinite(complex< T > &value)
vector< double > & baseline()
void envelope_type(long t)
double frequency_cutoff()
double beta(double volt)
Calculates the relative electron velocity.
double electron_wavelength(double volt)
Calculates the wavelength in angstrom from the acceleration voltage.
void objective_aperture(double v)
void envelope(int i, double d)
double beta2(double volt)
Calculates the square of the relative electron velocity.
void defocus_average(double v)
vector< double > defocus_range_profile(CTFparam &ctf, double freq_step, double def_min, double def_max, double def_step)
Calculates a weighting profile associated with a range of defocus values.
CTFparam ctf_from_json(JSvalue &js)
Converts a JSON object list to microscope parameters.
Bstring baseline_equation()
Generates a baseline equation string from 4 to 10 coefficients.
void baseline(vector< double > &b)
vector< double > & envelope()
Complex< double > calculate_complex(double s2, double angle)
JSvalue ctf_to_json(CTFparam &cp)
Converts microscope parameters to a JSON object list.
void astigmatism_angle(double v)