Commit ab8b34b7 authored by Daniel Brown's avatar Daniel Brown
Browse files

recent changes made to q's used for each solver when including more than 2...

recent changes made to q's used for each solver when including more than 2 effect separations wasn't quite right
parent 28e59f9e
......@@ -996,8 +996,7 @@ int set_k_mirror(int mirror_index) {
// between the same q values
// In this case the integration knm matrix won't be computed and the BH
// knm matrix will not handle the mode-mismatch
if (!integrating && mirror->num_maps == 0 && ((mirror->knm_change_q == 2 && mirror->knm_order[0] == 2)
|| (mirror->knm_change_q == 1 && mirror->knm_order[0] == 1))){
if (!integrating && mirror->num_maps == 0 && mirror->knm_change_q == 1){
if (inter.debug && !options.quiet && !defaultKNMChangeWarning){
defaultKNMChangeWarning = true;
......@@ -1020,57 +1019,29 @@ int set_k_mirror(int mirror_index) {
if (CALC_MR_KNM(mirror,11)){
mirror->knm_q.qxt1_11 = knm_q.qxt1_11;
mirror->knm_q.qyt1_11 = knm_q.qyt1_11;
// if first solver should handle q change
if(mirror->knm_change_q == 1) {
mirror->knm_q.qxt2_11 = knm_q.qxt2_11;
mirror->knm_q.qyt2_11 = knm_q.qyt2_11;
} else {
mirror->knm_q.qxt2_11 = knm_q.qxt1_11;
mirror->knm_q.qyt2_11 = knm_q.qyt1_11;
}
mirror->knm_q.qxt2_11 = knm_q.qxt1_11;
mirror->knm_q.qyt2_11 = knm_q.qyt1_11;
}
if (CALC_MR_KNM(mirror,12)){
mirror->knm_q.qxt1_12 = knm_q.qxt1_12;
mirror->knm_q.qyt1_12 = knm_q.qyt1_12;
// if first solver should handle q change
if(mirror->knm_change_q == 1) {
mirror->knm_q.qxt2_12 = knm_q.qxt2_12;
mirror->knm_q.qyt2_12 = knm_q.qyt2_12;
} else {
mirror->knm_q.qxt2_12 = knm_q.qxt1_12;
mirror->knm_q.qyt2_12 = knm_q.qyt1_12;
}
mirror->knm_q.qxt2_12 = knm_q.qxt1_12;
mirror->knm_q.qyt2_12 = knm_q.qyt1_12;
}
if (CALC_MR_KNM(mirror,21)){
mirror->knm_q.qxt1_21 = knm_q.qxt1_21;
mirror->knm_q.qyt1_21 = knm_q.qyt1_21;
// if first solver should handle q change
if(mirror->knm_change_q == 1) {
mirror->knm_q.qxt2_21 = knm_q.qxt2_21;
mirror->knm_q.qyt2_21 = knm_q.qyt2_21;
} else {
mirror->knm_q.qxt2_21 = knm_q.qxt1_21;
mirror->knm_q.qyt2_21 = knm_q.qyt1_21;
}
mirror->knm_q.qxt2_21 = knm_q.qxt1_21;
mirror->knm_q.qyt2_21 = knm_q.qyt1_21;
}
if (CALC_MR_KNM(mirror,22)){
mirror->knm_q.qxt1_22 = knm_q.qxt1_22;
mirror->knm_q.qyt1_22 = knm_q.qyt1_22;
// if first solver should handle q change
if(mirror->knm_change_q == 1) {
mirror->knm_q.qxt2_22 = knm_q.qxt2_22;
mirror->knm_q.qyt2_22 = knm_q.qyt2_22;
} else {
mirror->knm_q.qxt2_22 = knm_q.qxt1_22;
mirror->knm_q.qyt2_22 = knm_q.qyt1_22;
}
mirror->knm_q.qxt2_22 = knm_q.qxt1_22;
mirror->knm_q.qyt2_22 = knm_q.qyt1_22;
}
// set tmp matrix to identity, this is the matrix we will apply each knm too
......@@ -1086,32 +1057,62 @@ int set_k_mirror(int mirror_index) {
switch(num){
case 1:
message(" %i Merged map\n", i+1);
message(" %i Merged map (1)", i+1);
break;
case 2:
message(" %i Bayer-Helms\n", i+1);
message(" %i Bayer-Helms (2)", i+1);
break;
case 3:
if(mirror->aperture_type == CIRCULAR)
message(" %i Circular aperture\n", i+1);
message(" %i Circular aperture (3)", i+1);
else
message(" %i Square sperture\n", i+1);
message(" %i Square sperture (3)", i+1);
break;
case 4:
message(" %i ROMHOM\n", i+1);
message(" %i ROMHOM (4)", i+1);
break;
default:
bug_error("not handled");
}
if(num == mirror->knm_change_q){
message(" [Computes mode-mismatching]\n");
} else {
message("\n");
}
}
}
// loop over the 3 distortions that can be applied
// loop over the 4 distortions that can be applied
for(i=0; i<NUM_KNM_TYPES; i++){
int num = mirror->knm_order[i]; // the distortion which should be applied
bitflag mm = 0, astig = 0;
// Check if this solver should handle the mode mismatch
if (mirror->knm_change_q == mirror->knm_order[i]){
// if so them the second q for this solver should be the output q2
if (CALC_MR_KNM(mirror,11)){
mirror->knm_q.qxt2_11 = knm_q.qxt2_11;
mirror->knm_q.qyt2_11 = knm_q.qyt2_11;
}
if (CALC_MR_KNM(mirror,12)){
mirror->knm_q.qxt2_12 = knm_q.qxt2_12;
mirror->knm_q.qyt2_12 = knm_q.qyt2_12;
}
if (CALC_MR_KNM(mirror,21)){
mirror->knm_q.qxt2_21 = knm_q.qxt2_21;
mirror->knm_q.qyt2_21 = knm_q.qyt2_21;
}
if (CALC_MR_KNM(mirror,22)){
mirror->knm_q.qxt2_22 = knm_q.qxt2_22;
mirror->knm_q.qyt2_22 = knm_q.qyt2_22;
}
}
if (inter.debug & 128){
if(i==0)
message("* knm q values used:\n");
......@@ -1162,8 +1163,9 @@ int set_k_mirror(int mirror_index) {
// - any maps are present
// Basically anything that has altered the map_merged.knm variable that also
// includes effects that are integrated instead of calculated analytically
if ((integrating > 0) || mirror->map_merged.knm_calculated)
if ((integrating > 0) || mirror->map_merged.knm_calculated){
mirror_knm_matrix_mult(&(mirror->knm_map), &(mirror->knm_no_rgouy), &(mirror->knm_no_rgouy));
}
if ((mirror->knm_flags & PRINT_COEFFS) && mirror->map_merged.save_knm_matrices) {
sprintf(buf, "%s_merged", mirror->map_merged.filename);
......@@ -1232,9 +1234,10 @@ int set_k_mirror(int mirror_index) {
bug_error("Could not handle knm_order digit %i",mirror->knm_order[i]);
}
if (i == 0 && mirror->knm_change_q == 1){
// If the q changes at the start then we the first solver
// has handled any mode mismatch so we're not only using q2
// if this solver handled the mode mismatch then the following solvers
// just see q2
if (mirror->knm_change_q == mirror->knm_order[i]){
// If the final solver should handle mode mismatch...
if (CALC_MR_KNM(mirror,11)){
mirror->knm_q.qxt1_11 = knm_q.qxt2_11;
mirror->knm_q.qyt1_11 = knm_q.qyt2_11;
......@@ -1254,27 +1257,6 @@ int set_k_mirror(int mirror_index) {
mirror->knm_q.qxt1_22 = knm_q.qxt2_22;
mirror->knm_q.qyt1_22 = knm_q.qyt2_22;
}
} else if (i == NUM_KNM_TYPES-1 && mirror->knm_change_q == 2){
// If the final solver should handle mode mismatch...
if (CALC_MR_KNM(mirror,11)){
mirror->knm_q.qxt2_11 = knm_q.qxt2_11;
mirror->knm_q.qyt2_11 = knm_q.qyt2_11;
}
if (CALC_MR_KNM(mirror,12)){
mirror->knm_q.qxt2_12 = knm_q.qxt2_12;
mirror->knm_q.qyt2_12 = knm_q.qyt2_12;
}
if (CALC_MR_KNM(mirror,21)){
mirror->knm_q.qxt2_21 = knm_q.qxt2_21;
mirror->knm_q.qyt2_21 = knm_q.qyt2_21;
}
if (CALC_MR_KNM(mirror,22)){
mirror->knm_q.qxt2_22 = knm_q.qxt2_22;
mirror->knm_q.qyt2_22 = knm_q.qyt2_22;
}
}
}
......
......@@ -382,12 +382,12 @@
#define BETA_SCALE 2.0 //!< Scaling for misalignment angles
#define DEFAULT_KNM_CHANGE_Q 1
#define DEFAULT_KNM_CHANGE_Q 2
#define DEFAULT_KNM_ORDER_FIRST 2
#define DEFAULT_KNM_ORDER_SECOND 4
#define DEFAULT_KNM_ORDER_SECOND 1
#define DEFAULT_KNM_ORDER_THIRD 3
#define DEFAULT_KNM_ORDER_FOURTH 1
#define DEFAULT_KNM_ORDER_FOURTH 4
#endif // KAT_CONSTANTS_H
......
......@@ -1429,14 +1429,14 @@ void do_newton_cotes_int(void *userdata, KNM_COMPONENT_t knmcmp, complex_t *resu
// if there is a mode_mismatch here we have to use the complex values to store a result
for(p=0; p<ndx; p++) {
for(q=0; q<ndy; q++) {
u_xy[p][q] = z_by_x(z_by_z(cx->zvalues[idx][p], cy->zvalues[idy][q]), W_xy[p][q]);
u_xy[q][p] = z_by_x(z_by_z(cx->zvalues[idx][p], cy->zvalues[idy][q]), W_xy[q][p]);
}
}
} else {
for(p=0; p < ndx; p++) {
for(q=0; q < ndy; q++) {
u_xy[p][q].re = cx->values[idx][p] * cy->values[idy][q] * W_xy[p][q];
u_xy[p][q].im = 0;
u_xy[q][p].re = cx->values[idx][p] * cy->values[idy][q] * W_xy[q][p];
u_xy[q][p].im = 0;
}
}
}
......@@ -1462,13 +1462,13 @@ void do_newton_cotes_int(void *userdata, KNM_COMPONENT_t knmcmp, complex_t *resu
// for reflection from side 2 we need a minus sign on the phase
for(i=0; i<ndx; i++) {
for(j=0; j<ndy; j++) {
u_xy[i][j] = z_by_xphr(u_xy[i][j], A[i][j], -phi[i][j]);
u_xy[j][i] = z_by_xphr(u_xy[j][i], A[j][i], phi[j][i]);
}
}
} else {
for(i=0; i<ndx; i++) {
for(j=0; j<ndy; j++) {
u_xy[i][j] = z_by_xphr(u_xy[i][j], A[i][j], phi[i][j]);
u_xy[j][i] = z_by_xphr(u_xy[j][i], A[j][i], -phi[j][i]);
}
}
}
......
......@@ -6959,13 +6959,13 @@ void read_conf(const char *command_string) {
int j;
if( strlen(config_setting) != NUM_KNM_TYPES)
gerror("knm_order must be 4 digits long, including only the numbers 1,2,3 and 4.");
gerror("knm_order must be 4 digits long, including only the numbers 1, 2, 3 and 4.");
for(j=0; j<NUM_KNM_TYPES; j++){
int i = config_setting[j] - '0';
if(!(i==1 || i==2 || i==3 || i==4))
gerror("knm_order can only contain digits 1, 2, 3 or 4 not '%c'",i);
gerror("knm_order can only contain digits 1 (Merged Map), 2 (Bayer-Helms), 3 (Aperture) or 4 (ROMHOM) not '%c'",i);
mirror->knm_order[j] = i;
}
......@@ -6973,7 +6973,7 @@ void read_conf(const char *command_string) {
GET_INT
if (ival < 1 || ival > 2)
gerror("knm_change_q must be either 1 or 2\n");
gerror("knm_change_q must be either 1 (Bayer-Helms) or 2 (Merged map)\n");
mirror->knm_change_q = ival;
} else if (strcmp(config_name, "knm_force_saved") == 0) {
......
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