Commit 253dfc5f authored by Daniel Brown's avatar Daniel Brown

updating mismatching output

parent dd0a2d07
......@@ -2705,6 +2705,8 @@ typedef struct interferometer {
double fsig; //!< positive signal frequency
double mfsig; //!< negative signal frequency
double mismatch_lower; // lower level or mismatch to report
int *gnuterm; //!< list of gnuplot terminals
char **gnutermfn; //!< gnuplot terminal function
char *gnuplotcommand; //!< list of gnuplot plotting commands
......
......@@ -77,12 +77,12 @@ double mismatch(complex_t q1, complex_t q2) {
* Given two beam parameters this computes a figure of merit for
* how much they overlap, or the amount of mismatch between them.
*
* 0 being no matching
* 1 being perfect matching
* 1 being no matching
* 0 being perfect matching
*
* Will return nan if the beam parameter imaginary part is zero or negative.
*
* See ddb thesis equation 1.63.
* See ddb thesis equation 1.63 (this uses 1 - Eq.1.63 though)
*
* @param q1
* @param q2
......@@ -100,9 +100,18 @@ double mismatch(complex_t q1, complex_t q2) {
assert((result >= 0 && result <=1) || isnan(result));
return result;
return 1- result;
}
void __print_mismatch(const char *dir, double mx, double my) {
const char *fmt = "\t%s: %18.10g (x) %18.10g (y)\n";
if(!(isnan(mx) && isnan(my))){
if(mx >= inter.mismatch_lower || my >= inter.mismatch_lower){
message(fmt, dir, mx, my);
}
}
}
/**
* When called this will output the current mismatch status of the interferometer.
*/
......@@ -114,50 +123,57 @@ void output_mismatch() {
// for each beam direction within the component.
int i = 0;
double mx, my;
message("\n---- Start interferometer mismatches ----\n");
for(i=0; i<inter.num_mirrors; i++) {
mirror_t *m = &inter.mirror_list[i];
message("mirror: %s\n", m->name);
mx = mismatch(m->qm.qxt1_11, m->qm.qxt2_11);
my = mismatch(m->qm.qyt1_11, m->qm.qyt2_11);
__print_mismatch("1->1", mismatch(m->qm.qxt1_11, m->qm.qxt2_11),
mismatch(m->qm.qyt1_11, m->qm.qyt2_11));
message("\t11: %g %g\n", mx, my);
__print_mismatch("1->2", mismatch(m->qm.qxt1_12, m->qm.qxt2_12),
mismatch(m->qm.qyt1_12, m->qm.qyt2_12));
mx = mismatch(m->qm.qxt1_12, m->qm.qxt2_12);
my = mismatch(m->qm.qyt1_12, m->qm.qyt2_12);
__print_mismatch("2->1", mismatch(m->qm.qxt1_21, m->qm.qxt2_21),
mismatch(m->qm.qyt1_21, m->qm.qyt2_21));
message("\t12: %g %g\n", mx, my);
__print_mismatch("2->2", mismatch(m->qm.qxt1_22, m->qm.qxt2_22),
mismatch(m->qm.qyt1_22, m->qm.qyt2_22));
}
for(i=0; i<inter.num_beamsplitters; i++) {
beamsplitter_t *bs = &inter.bs_list[i];
mx = mismatch(m->qm.qxt1_21, m->qm.qxt2_21);
my = mismatch(m->qm.qyt1_21, m->qm.qyt2_21);
message("bs: %s\n", bs->name);
__print_mismatch("1->2", mismatch(bs->qm.qxt1_12, bs->qm.qxt2_12),
mismatch(bs->qm.qyt1_12, bs->qm.qyt2_12));
message("\t21: %g %g\n", mx, my);
__print_mismatch("1->3", mismatch(bs->qm.qxt1_13, bs->qm.qxt2_13),
mismatch(bs->qm.qyt1_13, bs->qm.qyt2_13));
mx = mismatch(m->qm.qxt1_22, m->qm.qxt2_22);
my = mismatch(m->qm.qyt1_22, m->qm.qyt2_22);
__print_mismatch("2->1", mismatch(bs->qm.qxt1_21, bs->qm.qxt2_21),
mismatch(bs->qm.qyt1_21, bs->qm.qyt2_21));
message("\t22: %g %g\n", mx, my);
}
for(i=0; i<inter.num_spaces; i++) {
space_t *s = &inter.space_list[i];
__print_mismatch("2->4", mismatch(bs->qm.qxt1_24, bs->qm.qxt2_24),
mismatch(bs->qm.qyt1_24, bs->qm.qyt2_24));
message("space: %s\n", s->name);
__print_mismatch("3->1", mismatch(bs->qm.qxt1_31, bs->qm.qxt2_31),
mismatch(bs->qm.qyt1_31, bs->qm.qyt2_31));
mx = mismatch(s->qm12.qxi, s->qm12.qxo);
my = mismatch(s->qm12.qyi, s->qm12.qyo);
__print_mismatch("3->4", mismatch(bs->qm.qxt1_34, bs->qm.qxt2_34),
mismatch(bs->qm.qyt1_34, bs->qm.qyt2_34));
message("\t12: %g %g\n", mx, my);
__print_mismatch("4->2", mismatch(bs->qm.qxt1_42, bs->qm.qxt2_42),
mismatch(bs->qm.qyt1_42, bs->qm.qyt2_42));
mx = mismatch(s->qm21.qxi, s->qm21.qxo);
my = mismatch(s->qm21.qyi, s->qm21.qyo);
__print_mismatch("4->3", mismatch(bs->qm.qxt1_43, bs->qm.qxt2_43),
mismatch(bs->qm.qyt1_43, bs->qm.qyt2_43));
message("\t21: %g %g\n", mx, my);
}
message("\n---- End interferometer mismatches ----\n");
......
......@@ -34,6 +34,7 @@
void set_coupling_info();
void knm_matrix_mult(zmatrix A, zmatrix B, zmatrix C);
void output_mismatch();
void __print_mismatch(const char *dir, double mx, double my);
inline complex_t rev_gouy(complex_t k, int n1, int m1, int n2, int m2,
complex_t qx1, complex_t qx2, complex_t qy1, complex_t qy2);
......
......@@ -171,6 +171,7 @@ void initialise_simulation_variables(void) {
inter.pause = 0;
inter.printmatrix = 0;
inter.mismatches = 0;
inter.mismatch_lower = 1e-6;
inter.printqnoiseinputs = false;
inter.trace = 0;
inter.splot = 0;
......
......@@ -945,7 +945,7 @@ void read_file(FILE *fp) {
} else if (strncasecmp(s, "printmatrix", 11) == 0) {
inter.printmatrix = 1;
} else if (strncasecmp(s, "mismatches", 10) == 0) {
inter.mismatches = 1;
read_mismatches_command(s);
} else if (strncasecmp(s, "frequency", 9) == 0) {
read_frequency_command(s);
} else if (strncasecmp(s, "powers", 6) == 0) {
......@@ -1340,6 +1340,20 @@ void read_QF_mech_transfer_function(const char *command_string){
inter.num_transfer_funcs++;
}
void read_mismatches_command(const char *command_string){
char command_name[MAX_TOKEN_LEN] = {0};
char flag[MAX_TOKEN_LEN] = {0};
char rest[MAX_TOKEN_LEN] = {0};
int n = sscanf(command_string, "%s %s %[^\n]", command_name, flag, rest);
if(n > 1){
atod(flag, &inter.mismatch_lower);
}
inter.mismatches = 1;
}
void read_frequency_command(const char *command_string){
char command_name[MAX_TOKEN_LEN] = {0};
char flag[MAX_TOKEN_LEN] = {0};
......
......@@ -45,6 +45,7 @@ typedef struct component_attribute {
} component_attribute_t;
bool check_for_include_kat(FILE **ifp);
void read_mismatches_command(const char *command_string);
void read_dof(const char* command_string);
void read_slink(const char* command_string);
void read_qd_out(const char *command_string);
......
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