Commit 86d6c833 authored by Daniel Brown's avatar Daniel Brown
Browse files

romhom updates and adding in --trace option which produces separate files for tracing

parent 8c946751
......@@ -357,6 +357,11 @@ int main(int argc, char *argv[]) {
options.perl1 = 1;
++num_options;
--argc;
found = true;
} else if (strcasecmp(argv[1 + num_options], "--trace") == 0) {
options.trace_output = 1;
++num_options;
--argc;
found = true;
} else if (strcasecmp(argv[1 + num_options], "--no-backspace") == 0) {
options.no_output_bksp = 1;
......@@ -550,7 +555,6 @@ int main(int argc, char *argv[]) {
exit(0);
}
// process the arguments
if (argc == 2) { // only the basename is specified...
inter.basename = duplicate_string(argv[num_options + 1]);
......
......@@ -1846,6 +1846,7 @@ typedef struct options {
int help; //!< is the help page asked for?
int maxmin; //!< is max and min output asked for?
int perl1; //!< switch off some of the output?
int trace_output; // If set trace data is output to text files for pykat processing
int no_output_bksp; //!< use newline instead of backspace for outputs
int quiet; //!< switch off all output?
int new; //!< is this a new feature of finesse?
......
......@@ -1299,6 +1299,11 @@ int set_k_mirror(int mirror_index) {
}
}
// if(strcmp(mirror->name, "ETMY") == 0 && !mirror->map_rom){
// mirror->knm_no_rgouy.k11[0][0].re = 0.9814582625035128 + 1e-8;
// mirror->knm_no_rgouy.k11[0][0].im = 0;
// }
// Here we adjust the odd reflected horizontal modes. We do this because on
// reflection, just like in a mirror, the horizontal direction is flipped
// left to right. We also reverse the extra gouy phase present and rescale the
......@@ -1374,6 +1379,8 @@ int set_k_mirror(int mirror_index) {
if(inter.debug & 4096){
double k_sqrd_sum[4] = {0};
warn("%s\n", mirror->name);
for (n = 0; n < inter.num_fields; n++) {
for (m = 0; m < inter.num_fields; m++) {
k_sqrd_sum[0] += z_mag_sqrd(mirror->knm.k11[n][m]);
......@@ -1384,16 +1391,17 @@ int set_k_mirror(int mirror_index) {
int i;
for(i=0;i<4;i++){
if(i==0)
printf("K11:%i,%i: ", n1,m1);
else if(i==1)
printf("K12:%i,%i: ", n1,m1);
else if(i==2)
printf("K21:%i,%i: ", n1,m1);
else if(i==3)
printf("K22:%i,%i: ", n1,m1);
printf("%.15f\n",k_sqrd_sum[i]);
if(i==0 && CALC_MR_KNM(mirror, 11)){
warn("K11:%i,%i: ", n1,m1);
} else if(i==1 && CALC_MR_KNM(mirror, 12)) {
warn("K12:%i,%i: ", n1,m1);
} else if(i==2 && CALC_MR_KNM(mirror, 21)) {
warn("K21:%i,%i: ", n1,m1);
} else if(i==3 && CALC_MR_KNM(mirror, 22)) {
warn("K22:%i,%i: ", n1,m1);
}
printf("%.15f\n", sqrt(k_sqrd_sum[i]));
k_sqrd_sum[i] = 0;
}
}
......
......@@ -3403,12 +3403,12 @@ char *complex_form(const complex_t z) {
} else if (fabs(z.re) >= init.small && fabs(z.im) < init.small) {
sprintf(result, "%g", z.re);
} else if (fabs(z.re) < init.small && fabs(z.im) >= init.small) {
sprintf(result, "%gJ", z.im);
sprintf(result, "%gj", z.im);
} else {
if (z.im < 0) {
sprintf(result, "%g-%gJ", z.re, -z.im);
sprintf(result, "%g-%gj", z.re, -z.im);
} else {
sprintf(result, "%g+%gJ", z.re, z.im);
sprintf(result, "%g+%gj", z.re, z.im);
}
}
......
......@@ -389,12 +389,14 @@ void dump_trace(FILE *fp) {
// make sure the file pointer isn't null
assert(fp != NULL);
fprintf(fp, "--- tracing the beam through optical system, \n");
fprintf(fp, " found %d of %d nodes:\n", n_index, inter.num_nodes);
fprintf(fp, " (w0 : waist radius, w : beam radius, z: distance to waist, \n");
fprintf(fp, " z_R: Rayleigh range, q : complex beam parameter\n");
fprintf(fp, " and gamma: far field angle\n");
if(!options.trace_output && fp != stdout) {
fprintf(fp, "--- tracing the beam through optical system, \n");
fprintf(fp, " found %d of %d nodes:\n", n_index, inter.num_nodes);
fprintf(fp, " (w0 : waist radius, w : beam radius, z: distance to waist, \n");
fprintf(fp, " z_R: Rayleigh range, q : complex beam parameter\n");
fprintf(fp, " and gamma: far field angle\n");
}
int i;
for (i = 0; i < n_index; i++) {
n = vlocal.trace_n[0][i];
......@@ -407,14 +409,13 @@ void dump_trace(FILE *fp) {
vlocal.trace_n[2][i], nr,
get_component_name(inter.node_list[n].component_index), node_print(n));
if (zabs(z_m_z(g.qx, g.qy)) < init.eqsmall) {
if (!options.trace_output && zabs(z_m_z(g.qx, g.qy)) < init.eqsmall) {
fprintf(fp,
" x, y: w0=%sm w=%sm z=%sm z_R=%sm Rc=%sm\n q=%s gamma=%srad\n",
xdouble_form(w0_size(g.qx, nr)), xdouble_form(w_size(g.qx, nr)),
xdouble_form(z_q(g.qx)), xdouble_form(z_r(g.qx)),
xdouble_form(roc(g.qx)), complex_form(g.qx),
xdouble_form(w0_size(g.qx, nr) / z_r(g.qx)));
// fprintf(fp, " k=%s\n", xdouble_form(npow(w0_size(g.qx, nr)*0.5/z_r(g.qx), 2)));
} else {
fprintf(fp,
" x: w0=%sm w=%sm z=%sm z_R=%sm Rc=%sm\n q=%s gamma=%srad\n",
......@@ -422,14 +423,12 @@ void dump_trace(FILE *fp) {
xdouble_form(z_q(g.qx)), xdouble_form(z_r(g.qx)),
xdouble_form(roc(g.qx)), complex_form(g.qx),
xdouble_form(w0_size(g.qx, nr) / z_r(g.qx)));
// fprintf(fp, " x: k=%s\n", xdouble_form(npow(w0_size(g.qx, nr)*0.5/z_r(g.qx), 2)));
fprintf(fp,
" y: w0=%sm w=%sm z=%sm z_R=%sm Rc=%sm\n q=%s gamma=%srad\n\n",
xdouble_form(w0_size(g.qy, nr)), xdouble_form(w_size(g.qy, nr)),
xdouble_form(z_q(g.qy)), xdouble_form(z_r(g.qy)),
xdouble_form(roc(g.qy)), complex_form(g.qy),
xdouble_form(w0_size(g.qy, nr) / z_r(g.qy)));
// fprintf(fp, " y: k=%s\n", xdouble_form(npow(w0_size(g.qy, nr)*0.5/z_r(g.qy), 2)));
}
}
fprintf(fp, "\n");
......
......@@ -51,6 +51,8 @@
#undef min
#endif
unsigned int nTraces = 0; // Number of traces performed so far
extern bool bCygserverRunning;
extern init_variables_t init;
extern interferometer_t inter;
......@@ -405,7 +407,6 @@ void setup_system(void) {
M_ifo_car.M.num_eqns = -1;
M_ifo_sig.M.num_eqns = -1;
// calculate number of non-zero elements in matrix. Currently this is
// 2 * nodes * fields + num_of_diagonal_elements or rank+rank
......@@ -975,6 +976,10 @@ void set_output_scaling_factors(void) {
//! Checks for plottable outputs
void check_for_plottable_outputs(void) {
// If we are just doing a trace then continue here
if (options.trace_output)
return;
if (inter.num_outputs == 0) {
gerror("no outputs have been specified in the input file\n");
}
......@@ -1194,10 +1199,19 @@ void setup_hermite_gauss_extension(void) {
trace_hermite_gauss_beam();
if(options.trace_output){
char fname[FNAME_LEN] = {0};
sprintf(fname, "%s_%i.trace", inter.basename, nTraces);
FILE *f = fopen(fname, "w");
dump_trace(f);
fclose(f);
}
if (inter.trace & 8) {
if (NOT options.quiet) {
dump_trace(stdout);
}
dump_trace(fp_log);
}
......@@ -1623,7 +1637,8 @@ void trace_hermite_gauss_beam(void) {
}
}
}
//!< \todo return from here one day!!!
nTraces++;
}
//! Set parameters for progress print
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment