Commit be4197ab authored by Daniel Brown's avatar Daniel Brown

adding in other components for mismatch output

parent c0896c3f
......@@ -103,24 +103,47 @@ double mismatch(complex_t q1, complex_t q2) {
return 1- result;
}
void __print_mismatch(const char *dir, double mx, double my) {
const char *fmt1 = "\t%s: %18.10g (x) %18.10g (y)\n";
const char *fmt2 = "\t%s: %18.10g\n";
bool __print_mismatch(const char *dir, double mx, double my, char *output) {
const char *fmt1 = "%s\t%s: %18.10g (x) %18.10g (y)\n";
const char *fmt2 = "%s\t%s: %18.10g\n";
if(!(isnan(mx) && isnan(my))){
if(inter.mismatches_options & AVERAGE_Q){
double am = (mx+my)/2;
if(am >= inter.mismatches_lower){
message(fmt2, dir, am);
sprintf(output, fmt2, output, dir, am);
return true;
}
} else {
if(mx >= inter.mismatches_lower || my >= inter.mismatches_lower){
message(fmt1, dir, mx, my);
sprintf(output, fmt1, output, dir, mx, my);
return true;
}
}
}
return false;
}
void __print_two_port_mismatches(const char *component_name, char *name, q_io_t *qm12, q_io_t *qm21, char *output){
bool displayed = false;
displayed |= __print_mismatch("1->2", mismatch(qm12->qxi, qm12->qxo),
mismatch(qm12->qyi, qm12->qyo),
output);
displayed |= __print_mismatch("2->1", mismatch(qm21->qxi, qm21->qxo),
mismatch(qm21->qyi, qm21->qyo),
output);
if(displayed) {
message("%s: %s\n", component_name, name);
message(output);
}
}
/**
* When called this will output the current mismatch status of the interferometer.
*/
......@@ -135,67 +158,139 @@ void output_mismatch() {
message("\n---- Start interferometer mismatches ----\n");
char output[1000] = {0};
for(i=0; i<inter.num_mirrors; i++) {
mirror_t *m = &inter.mirror_list[i];
message("mirror: %s\n", m->name);
output[0] = '\0';
bool print_refl = !((inter.mismatches_options & IGNORE_LOW_R_MIRROR_BS) && m->R < inter.mismatches_lower);
bool print_trans = !((inter.mismatches_options & IGNORE_LOW_T_MIRROR_BS) && m->T < inter.mismatches_lower);
bool displayed = false;
if(print_refl) {
__print_mismatch("1->1", mismatch(m->qm.qxt1_11, m->qm.qxt2_11),
mismatch(m->qm.qyt1_11, m->qm.qyt2_11));
displayed |= __print_mismatch("1->1", mismatch(m->qm.qxt1_11, m->qm.qxt2_11),
mismatch(m->qm.qyt1_11, m->qm.qyt2_11),
output);
}
if(print_trans){
__print_mismatch("1->2", mismatch(m->qm.qxt1_12, m->qm.qxt2_12),
mismatch(m->qm.qyt1_12, m->qm.qyt2_12));
displayed |= __print_mismatch("1->2", mismatch(m->qm.qxt1_12, m->qm.qxt2_12),
mismatch(m->qm.qyt1_12, m->qm.qyt2_12),
output);
__print_mismatch("2->1", mismatch(m->qm.qxt1_21, m->qm.qxt2_21),
mismatch(m->qm.qyt1_21, m->qm.qyt2_21));
displayed |= __print_mismatch("2->1", mismatch(m->qm.qxt1_21, m->qm.qxt2_21),
mismatch(m->qm.qyt1_21, m->qm.qyt2_21),
output);
}
if(print_refl) {
__print_mismatch("2->2", mismatch(m->qm.qxt1_22, m->qm.qxt2_22),
mismatch(m->qm.qyt1_22, m->qm.qyt2_22));
displayed |= __print_mismatch("2->2", mismatch(m->qm.qxt1_22, m->qm.qxt2_22),
mismatch(m->qm.qyt1_22, m->qm.qyt2_22),
output);
}
if(displayed) {
message("mirror: %s\n", m->name);
message(output);
}
}
for(i=0; i<inter.num_beamsplitters; i++) {
beamsplitter_t *bs = &inter.bs_list[i];
output[0] = '\0';
bool print_refl = !((inter.mismatches_options & IGNORE_LOW_R_MIRROR_BS) && bs->R < inter.mismatches_lower);
bool print_trans = !((inter.mismatches_options & IGNORE_LOW_T_MIRROR_BS) && bs->T < inter.mismatches_lower);
message("bs: %s\n", bs->name);
bool displayed = false;
if(print_refl) __print_mismatch("1->2", mismatch(bs->qm.qxt1_12, bs->qm.qxt2_12),
mismatch(bs->qm.qyt1_12, bs->qm.qyt2_12));
if(print_refl) displayed |= __print_mismatch("1->2", mismatch(bs->qm.qxt1_12, bs->qm.qxt2_12),
mismatch(bs->qm.qyt1_12, bs->qm.qyt2_12), output);
if(print_trans) displayed |= __print_mismatch("1->3", mismatch(bs->qm.qxt1_13, bs->qm.qxt2_13),
mismatch(bs->qm.qyt1_13, bs->qm.qyt2_13), output);
if(print_trans) __print_mismatch("1->3", mismatch(bs->qm.qxt1_13, bs->qm.qxt2_13),
mismatch(bs->qm.qyt1_13, bs->qm.qyt2_13));
if(print_refl) displayed |= __print_mismatch("2->1", mismatch(bs->qm.qxt1_21, bs->qm.qxt2_21),
mismatch(bs->qm.qyt1_21, bs->qm.qyt2_21), output);
if(print_refl) __print_mismatch("2->1", mismatch(bs->qm.qxt1_21, bs->qm.qxt2_21),
mismatch(bs->qm.qyt1_21, bs->qm.qyt2_21));
if(print_trans) displayed |= __print_mismatch("2->4", mismatch(bs->qm.qxt1_24, bs->qm.qxt2_24),
mismatch(bs->qm.qyt1_24, bs->qm.qyt2_24), output);
if(print_trans) __print_mismatch("2->4", mismatch(bs->qm.qxt1_24, bs->qm.qxt2_24),
mismatch(bs->qm.qyt1_24, bs->qm.qyt2_24));
if(print_trans) displayed |= __print_mismatch("3->1", mismatch(bs->qm.qxt1_31, bs->qm.qxt2_31),
mismatch(bs->qm.qyt1_31, bs->qm.qyt2_31), output);
if(print_trans) __print_mismatch("3->1", mismatch(bs->qm.qxt1_31, bs->qm.qxt2_31),
mismatch(bs->qm.qyt1_31, bs->qm.qyt2_31));
if(print_refl) displayed |= __print_mismatch("3->4", mismatch(bs->qm.qxt1_34, bs->qm.qxt2_34),
mismatch(bs->qm.qyt1_34, bs->qm.qyt2_34), output);
if(print_refl) __print_mismatch("3->4", mismatch(bs->qm.qxt1_34, bs->qm.qxt2_34),
mismatch(bs->qm.qyt1_34, bs->qm.qyt2_34));
if(print_trans) displayed |= __print_mismatch("4->2", mismatch(bs->qm.qxt1_42, bs->qm.qxt2_42),
mismatch(bs->qm.qyt1_42, bs->qm.qyt2_42), output);
if(print_trans) __print_mismatch("4->2", mismatch(bs->qm.qxt1_42, bs->qm.qxt2_42),
mismatch(bs->qm.qyt1_42, bs->qm.qyt2_42));
if(print_refl) displayed |= __print_mismatch("4->3", mismatch(bs->qm.qxt1_43, bs->qm.qxt2_43),
mismatch(bs->qm.qyt1_43, bs->qm.qyt2_43), output);
if(print_refl) __print_mismatch("4->3", mismatch(bs->qm.qxt1_43, bs->qm.qxt2_43),
mismatch(bs->qm.qyt1_43, bs->qm.qyt2_43));
if(displayed) {
message("bs: %s\n", bs->name);
message(output);
}
}
for(i=0; i<inter.num_modulators; i++) {
modulator_t *m = &inter.modulator_list[i];
__print_two_port_mismatches("modulator",
m->name,
&m->qm12,
&m->qm21,
output);
}
for(i=0; i<inter.num_dbss; i++) {
dbs_t *dbs = &inter.dbs_list[i];
output[0] = '\0';
bool displayed = false;
displayed |= __print_mismatch("1->3", mismatch(dbs->qm13.qxi, dbs->qm13.qxo),
mismatch(dbs->qm13.qyi, dbs->qm13.qyo),
output);
displayed |= __print_mismatch("2->1", mismatch(dbs->qm21.qxi, dbs->qm21.qxo),
mismatch(dbs->qm21.qyi, dbs->qm21.qyo),
output);
displayed |= __print_mismatch("3->4", mismatch(dbs->qm34.qxi, dbs->qm34.qxo),
mismatch(dbs->qm34.qyi, dbs->qm34.qyo),
output);
displayed |= __print_mismatch("4->2", mismatch(dbs->qm42.qxi, dbs->qm42.qxo),
mismatch(dbs->qm42.qyi, dbs->qm42.qyo),
output);
if(displayed) {
message("dbs: %s\n", dbs->name);
message(output);
}
}
for(i=0; i<inter.num_lenses; i++) {
lens_t *m = &inter.lens_list[i];
__print_two_port_mismatches("lens",
m->name,
&m->qm12,
&m->qm21,
output);
}
for(i=0; i<inter.num_diodes; i++) {
diode_t *m = &inter.diode_list[i];
__print_two_port_mismatches("diode",
m->name,
&m->qm12,
&m->qm21,
output);
}
message("\n---- End interferometer mismatches ----\n");
......
......@@ -34,7 +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);
bool __print_mismatch(const char *dir, double mx, double my, char *output);
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);
......
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