Commit d061bed4 authored by Daniel Brown's avatar Daniel Brown

fixing tracing at dbs, hopefully

parent 3c2ec206
......@@ -3192,7 +3192,9 @@ int set_k_dbs(int dbs_index) {
double kmx, kmy;
double phase = 0.0;
complex_t qx1, qy1, qx2, qy2, qx3, qy3, qx4, qy4;
complex_t qx1i, qy1i, qx2i, qy2i, qx3i, qy3i, qx4i, qy4i;
complex_t qx1o, qy1o, qx2o, qy2o, qx3o, qy3o, qx4o, qy4o;
dbs_t *dbs;
node_t node1, node2, node3, node4;
......@@ -3221,16 +3223,21 @@ int set_k_dbs(int dbs_index) {
nr1 = *node1.n;
if (node1.component_index == component) {
// reverse q so that beam comes _to_ the bs from node1
qx1 = cminus(cconj(node1.qx));
qy1 = cminus(cconj(node1.qy));
qx1i = cminus(cconj(node1.qx));
qy1i = cminus(cconj(node1.qy));
qx1o = node1.qx;
qy1o = node1.qy;
} else {
qx1 = node1.qx;
qy1 = node1.qy;
qx1i = node1.qx;
qy1i = node1.qy;
qx1o = cminus(cconj(node1.qx));
qy1o = cminus(cconj(node1.qy));
}
} else {
qx1 = complex_0;
qy1 = complex_0;
qx1i = complex_0;
qy1i = complex_0;
qx1o = complex_0;
qy1o = complex_0;
}
if (NOT node2.gnd_node) {
......@@ -3238,48 +3245,63 @@ int set_k_dbs(int dbs_index) {
nr2 = *node2.n;
if (node2.component_index == component) {
qx2 = node2.qx;
qy2 = node2.qy;
qx2i = cminus(cconj(node2.qx));
qy2i = cminus(cconj(node2.qy));
qx2o = node2.qx;
qy2o = node2.qy;
} else {
// reverse q so that beam goes _from_ the bs to node2
qx2 = cminus(cconj(node2.qx));
qy2 = cminus(cconj(node2.qy));
qx2i = node2.qx;
qy2i = node2.qy;
qx2o = cminus(cconj(node2.qx));
qy2o = cminus(cconj(node2.qy));
}
} else {
qx2 = complex_0;
qy2 = complex_0;
qx2i = complex_0;
qy2i = complex_0;
qx2o = complex_0;
qy2o = complex_0;
}
if (NOT node3.gnd_node) {
node3 = inter.node_list[node3_index];
nr3 = *node3.n;
if (node3.component_index == component) {
// reverse q so that beam comes _to_ the bs from node3
qx3 = cminus(cconj(node3.qx));
qy3 = cminus(cconj(node3.qy));
qx3i = cminus(cconj(node3.qx));
qy3i = cminus(cconj(node3.qy));
qx3o = node3.qx;
qy3o = node3.qy;
} else {
qx3 = node3.qx;
qy3 = node3.qy;
qx3i = node3.qx;
qy3i = node3.qy;
qx3o = cminus(cconj(node3.qx));
qy3o = cminus(cconj(node3.qy));
}
} else {
qx3 = complex_0;
qy3 = complex_0;
qx3i = complex_0;
qy3i = complex_0;
qx3o = complex_0;
qy3o = complex_0;
}
if (NOT node4.gnd_node) {
node4 = inter.node_list[node4_index];
nr4 = *node4.n;
if (node4.component_index == component) {
qx4 = node4.qx;
qy4 = node4.qy;
qx4i = cminus(cconj(node4.qx));
qy4i = cminus(cconj(node4.qy));
qx4o = node4.qx;
qy4o = node4.qy;
} else {
// reverse q so that beam goes _from_ the bs to node4
qx4 = cminus(cconj(node4.qx));
qy4 = cminus(cconj(node4.qy));
qx4i = node4.qx;
qy4i = node4.qy;
qx4o = cminus(cconj(node4.qx));
qy4o = cminus(cconj(node4.qy));
}
} else {
qx4 = complex_0;
qy4 = complex_0;
qx4i = complex_0;
qy4i = complex_0;
qx4o = complex_0;
qy4o = complex_0;
}
if (inter.debug & 32 || inter.trace & 64) {
......@@ -3291,11 +3313,11 @@ int set_k_dbs(int dbs_index) {
complex_t qxt, qyt, qxt2, qyt2;
if (NOT node1.gnd_node && NOT node3.gnd_node) {
qxt = qx1;
qyt = qy1;
qxt = qx1i;
qyt = qy1i;
qxt2 = qx3;
qyt2 = qy3;
qxt2 = qx3o;
qyt2 = qy3o;
if (!ceq(qxt, qxt2) || !ceq(qyt, qyt2)) {
dbs->mismatching |= 1;
......@@ -3350,11 +3372,11 @@ int set_k_dbs(int dbs_index) {
}
if (NOT node2.gnd_node && NOT node1.gnd_node) {
qxt = qx2;
qyt = qy2;
qxt = qx2i;
qyt = qy2i;
qxt2 = qx1;
qyt2 = qy1;
qxt2 = qx1o;
qyt2 = qy1o;
if (!ceq(qxt, qxt2) || !ceq(qyt, qyt2)) {
dbs->mismatching |= 2;
......@@ -3410,11 +3432,11 @@ int set_k_dbs(int dbs_index) {
}
if (NOT node3.gnd_node && NOT node4.gnd_node) {
qxt = qx3;
qyt = qy3;
qxt = qx3i;
qyt = qy3i;
qxt2 = qx4;
qyt2 = qy4;
qxt2 = qx4o;
qyt2 = qy4o;
if (!ceq(qxt, qxt2) || !ceq(qyt, qyt2)) {
dbs->mismatching |= 4;
......@@ -3470,11 +3492,11 @@ int set_k_dbs(int dbs_index) {
}
if (NOT node4.gnd_node && NOT node2.gnd_node) {
qxt = qx4;
qyt = qy4;
qxt = qx4i;
qyt = qy4i;
qxt2 = qx2;
qyt2 = qy2;
qxt2 = qx2o;
qyt2 = qy2o;
if (!ceq(qxt, qxt2) || !ceq(qyt, qyt2)) {
dbs->mismatching |= 8;
......@@ -5624,11 +5646,27 @@ int component_matrix(ABCD_t *matrix, int component_index,
bug_error("dbs no such node");
}
if (node1_index == node2_index) {
return (1);
bool allow = false;
if (node1_index == dbs->node1_index &&
node2_index == dbs->node3_index) {
allow = true;
} else if (node1_index == dbs->node2_index &&
node2_index == dbs->node1_index) {
allow = true;
} else if (node1_index == dbs->node3_index &&
node2_index == dbs->node4_index) {
allow = true;
} else if (node1_index == dbs->node4_index &&
node2_index == dbs->node2_index) {
allow = true;
}
if (!allow) {
return 1;
} else {
*matrix = dbs->qq;
}
*matrix = dbs->qq;
break;
......@@ -5848,20 +5886,27 @@ void set_qbase(int component_index) {
assert(component_index >= 0);
assert(component_index < inter.num_components);
// ddb - this returns a list of all the nodes at a component
// for then checking if it is set.
which_nodes(component_index, GND_NODE, &no, node_indices);
int k;
int k, i, j;
// ddb - What on earth is 'k' loop for?
for (k = 0; k < 2; k++) {
int i;
for (i = 0; i < no; i++) {
node_i = inter.node_list[node_indices[i]];
if (node_i.q_is_set) {
int j;
for (j = 0; j < no; j++) {
node_j = inter.node_list[node_indices[j]];
// set q if q is not yet set
if (NOT node_j.q_is_set && NOT node_j.gnd_node) { // || get_component_type(component)==SPACE)
err = component_matrix(&transform, component_index,
node_indices[i], node_indices[j], TANGENTIAL);
if (!err) {
if (inter.debug & 256) {
fprintf(stdout, "set_qbase: q set: %s\n",
......@@ -5873,7 +5918,9 @@ void set_qbase(int component_index) {
get_node_name(node_indices[j]));
dump_ABCD(fp_log, transform);
}
// q -> q(-z)=-q* if necessary (reverse beam direction)
// ddb - always get beam coming into the node
if (node_i.component_index == component_index) {
qx = cminus(cconj(node_i.qx));
qy = cminus(cconj(node_i.qy));
......@@ -5884,10 +5931,13 @@ void set_qbase(int component_index) {
nr1 = *node_i.n;
nr2 = *node_j.n;
qxt = q1_q2(transform, qx, nr1, nr2);
err = component_matrix(&transform, component_index,
node_indices[i], node_indices[j], SAGITTAL);
qyt = q1_q2(transform, qy, nr1, nr2);
set_q(node_indices[j], component_index, qxt, qyt);
} else if (inter.debug & 256) {
message("set_qbase: err -> %s %s\n",
......@@ -6193,10 +6243,6 @@ void which_nodes(int component_index, int current_node,
}
} else {
if (current_node == dbs->node1_index) {
if (NOT node2->gnd_node) {
node_indices[no++] = dbs->node2_index;
}
if (NOT node3->gnd_node) {
node_indices[no++] = dbs->node3_index;
}
......@@ -6206,27 +6252,15 @@ void which_nodes(int component_index, int current_node,
if (NOT node1->gnd_node) {
node_indices[no++] = dbs->node1_index;
}
if (NOT node4->gnd_node) {
node_indices[no++] = dbs->node4_index;
}
}
if (current_node == dbs->node3_index) {
if (NOT node4->gnd_node) {
node_indices[no++] = dbs->node4_index;
}
if (NOT node1->gnd_node) {
node_indices[no++] = dbs->node1_index;
}
}
if (current_node == dbs->node4_index) {
if (NOT node3->gnd_node) {
node_indices[no++] = dbs->node3_index;
}
if (NOT node2->gnd_node) {
node_indices[no++] = dbs->node2_index;
}
......
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