Commit 75b9e83a authored by Daniel Brown's avatar Daniel Brown

Siginificant changes to new isolator component. Now referred to as a...

Siginificant changes to new isolator component. Now referred to as a directional beasmsplitter (dbs). Node order changed to matche that of a normal bs: 1,2,3,4 going clock wise. Adding in tracing of for dbs. Still needs matrix filling completed
parent dd370cc7
......@@ -464,7 +464,7 @@ typedef struct memory {
int num_squeezers; //!< number of squeezers
int num_light_inputs; //!< number of input light fields (i.e. lasers)
int num_diodes; //!< number of Faraday isolators (diodes)
int num_isolators; //!< number of 4 port faraday isolators
int num_dbss; //!< number of 4 port direction BSs
int num_signal_inputs; //!< number of signal inputs
int num_variables; //!< number of dummy parameters (used with xaxis)
int num_sagnacs; //!< number of sagnac elements
......@@ -1823,7 +1823,7 @@ typedef struct diode {
/*!
4 port version of isolator
!*/
typedef struct isolator {
typedef struct dbs {
int comp_index; // component index
char name[MAX_TOKEN_LEN]; //!< diode name
......@@ -1840,21 +1840,20 @@ typedef struct isolator {
bitflag mismatching;
complex_t ****a31f;
complex_t ****a12f;
complex_t ****a24f;
complex_t ****a43f;
coupling_info_t a_cplng_31, a_cplng_12;
coupling_info_t a_cplng_43, a_cplng_24;
complex_t ****a34f;
complex_t ****a13f;
complex_t ****a21f;
complex_t ****a42f;
zmatrix k31, k12, k24, k43;
coupling_info_t a_cplng_34, a_cplng_13;
coupling_info_t a_cplng_42, a_cplng_21;
zmatrix k34, k13, k21, k42;
double *k31_sqrd_sum; // effective per mode loss due to scattering from node 3 to 1
double *k12_sqrd_sum; // effective per mode loss due to scattering from node 1 to 2
double *k24_sqrd_sum; // effective per mode loss due to scattering from node 2 to 4
double *k43_sqrd_sum; // effective per mode loss due to scattering from node 4 to 3
double *k34_sqrd_sum; // effective per mode loss due to scattering from node 3 to 1
double *k13_sqrd_sum; // effective per mode loss due to scattering from node 1 to 2
double *k21_sqrd_sum; // effective per mode loss due to scattering from node 2 to 4
double *k42_sqrd_sum; // effective per mode loss due to scattering from node 4 to 3
ABCD_t qq; //!< transformation matrix for q of diode
......@@ -1862,7 +1861,7 @@ typedef struct isolator {
bitflag knm_flags;
int nnz_count;
} isolator_t;
} dbs_t;
//! information describing a lens
......@@ -2498,7 +2497,7 @@ typedef struct interferometer {
derivative_t *deriv_list; //!< list of derivatives
scale_t *scale_list; //!< list of scales
diode_t *diode_list; //!< diode list
isolator_t *isolator_list;
dbs_t *dbs_list;
lens_t *lens_list; //!< list of lenses
attr_t *attr_list; //!< list of attributes
gauss_t *gauss_list; //!< Gaussian beam list
......@@ -2540,7 +2539,7 @@ typedef struct interferometer {
int num_mirror_phase_outputs; //!< number of output convolution
int num_scale_cmds; //!< number of scales
int num_diodes; //!< number of diodes
int num_isolators; //!< number of 4 port isolators
int num_dbss; //!< number of 4 port direction BSs
int num_lenses; //!< number of lenses
int num_attributes; //!< number of attributes
int num_gauss_cmds; //!< number of Gaussian commands
......
This diff is collapsed.
......@@ -2974,7 +2974,7 @@ int get_overall_component_index(int type, int component_index) {
inter.num_diodes + inter.num_light_inputs + inter.num_modulators +
inter.num_signals + inter.num_variables + inter.num_outputs;
break;
case ISOLATOR:
case DBS:
overall_component_index = inter.num_mirrors + inter.num_beamsplitters +
inter.num_spaces + inter.num_lenses + inter.num_gratings +
inter.num_diodes + inter.num_light_inputs + inter.num_modulators +
......@@ -3243,8 +3243,8 @@ int get_component_type(int component_index) {
return OUT;
} else if ((component_index -= inter.num_outputs) < inter.num_gauss_cmds) {
return BEAMPARAM;
} else if ((component_index -= inter.num_gauss_cmds) < inter.num_isolators) {
return ISOLATOR;
} else if ((component_index -= inter.num_gauss_cmds) < inter.num_dbss) {
return DBS;
} else {
bug_error("unknown type");
}
......@@ -3297,7 +3297,7 @@ int get_component_index(int overall_component_index) {
< inter.num_outputs) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_outputs)
< inter.num_isolators) {
< inter.num_dbss) {
return overall_component_index;
} else {
bug_error("unknown type");
......@@ -3343,6 +3343,9 @@ int get_component_type_decriment_index(int *component_index) {
< inter.num_modulators) {
return MODULATOR;
} else if ((*component_index -= inter.num_modulators)
< inter.num_dbss) {
return DBS;
} else if ((*component_index -= inter.num_dbss)
< inter.num_signals) {
return FSIG;
} else if ((*component_index -= inter.num_signals)
......@@ -3399,6 +3402,8 @@ char *get_component_name(int component_index) {
return duplicate_string(inter.output_data_list[component_index].name);
} else if ((component_index -= inter.num_outputs) < inter.num_gauss_cmds) {
return duplicate_string(inter.gauss_list[component_index].name);
} else if ((component_index -= inter.num_gauss_cmds) < inter.num_dbss) {
return duplicate_string(inter.dbs_list[component_index].name);
} else {
bug_error("component index out of range");
}
......@@ -3442,6 +3447,8 @@ char *get_component_type_name(int component_index) {
return duplicate_string("OUTPUT");
} else if ((component_index -= inter.num_outputs) < inter.num_gauss_cmds) {
return duplicate_string("BEAM PARAMETER");
} else if ((component_index -= inter.num_gauss_cmds) < inter.num_dbss) {
return duplicate_string("DBS");
} else {
bug_error("component index out of range");
}
......
......@@ -43,7 +43,7 @@ void check_sagnac(sagnac_t *lens);
void check_mirror(mirror_t *mirror);
void check_grating(grating_t *grating);
void check_diode(diode_t *diode);
void check_isolator(isolator_t *diode);
void check_dbs(dbs_t *diode);
void check_beamsplitter(beamsplitter_t *bs);
void check_space(space_t *space);
void check_modulator(modulator_t *modulator);
......
......@@ -246,7 +246,7 @@
#define QFEEDBACK 18
#define MOTIONLINK 19
#define SPACECONNECTION 20
#define ISOLATOR 21 //!< Isolator component type
#define DBS 21 //!< Isolator component type
#define X1 -12 //!< x axis tag
#define X2 -13 //!< y axis tag
......
This diff is collapsed.
......@@ -469,8 +469,8 @@ void pre_scan(FILE *fp) {
mem.num_node_names++;
mem.num_nodes = mem.num_nodes + 2;
} else if (string_matches(s, "isol1 ")) {
mem.num_isolators++;
} else if (string_matches(s, "dbs ")) {
mem.num_dbss++;
mem.num_node_names++;
mem.num_nodes += 4;
......@@ -648,7 +648,7 @@ void pre_scan(FILE *fp) {
// number of components, used for allocating memory for component numbers
mem.num_components = mem.num_mirrors + mem.num_spaces + mem.num_beamsplitters
+ mem.num_modulators + mem.num_light_inputs
+ mem.num_diodes + mem.num_lenses + mem.num_isolators +
+ mem.num_diodes + mem.num_lenses + mem.num_dbss +
+ mem.num_gratings + mem.num_squeezers + mem.num_sagnacs + mem.num_blocks;
debug_msg("kat_mem(): found %d components in interferometer\n", mem.num_components);
......@@ -675,7 +675,7 @@ void pre_scan(FILE *fp) {
message("%d beamsplitters, ", mem.num_beamsplitters);
message("%d spaces, ", mem.num_spaces);
message("%d modulators\n", mem.num_modulators);
message("%d isolators, ", mem.num_isolators);
message("%d dbs, ", mem.num_dbss);
message("%d diode, ", mem.num_diodes);
message("%d lenses, ", mem.num_lenses);
message("%d gratings, ", mem.num_gratings);
......@@ -890,7 +890,7 @@ int allocate_memory(long int *bytes, long int *bytes1, long int *bytes2) {
}
// allocate memory for diodes
error_code = allocate_memory_for_isolator_list(bytes);
error_code = allocate_memory_for_dbs_list(bytes);
if (error_code != 0) {
return error_code;
}
......@@ -2571,43 +2571,43 @@ int allocate_memory_for_diode_list(long int *bytes) {
int allocate_memory_for_isolator_list(long int *bytes) {
if (mem.num_isolators) {
inter.isolator_list = (isolator_t *) calloc(mem.num_isolators + 1, sizeof (isolator_t));
if (inter.isolator_list == NULL) {
int allocate_memory_for_dbs_list(long int *bytes) {
if (mem.num_dbss) {
inter.dbs_list = (dbs_t *) calloc(mem.num_dbss + 1, sizeof (dbs_t));
if (inter.dbs_list == NULL) {
return (23);
}
*bytes += (mem.num_isolators + 1) * sizeof (isolator_t);
*bytes += (mem.num_dbss + 1) * sizeof (dbs_t);
// field amplitudes
int i;
for (i = 0; i < mem.num_isolators; i++) {
inter.isolator_list[i].comp_index = i;
for (i = 0; i < mem.num_dbss; i++) {
inter.dbs_list[i].comp_index = i;
allocate_zmatrix(&inter.isolator_list[i].k12, mem.num_fields, bytes);
allocate_zmatrix(&inter.isolator_list[i].k31, mem.num_fields, bytes);
allocate_zmatrix(&inter.isolator_list[i].k24, mem.num_fields, bytes);
allocate_zmatrix(&inter.isolator_list[i].k43, mem.num_fields, bytes);
allocate_zmatrix(&inter.dbs_list[i].k13, mem.num_fields, bytes);
allocate_zmatrix(&inter.dbs_list[i].k34, mem.num_fields, bytes);
allocate_zmatrix(&inter.dbs_list[i].k21, mem.num_fields, bytes);
allocate_zmatrix(&inter.dbs_list[i].k42, mem.num_fields, bytes);
isolator_t *d = &inter.isolator_list[i];
dbs_t *d = &inter.dbs_list[i];
int err;
d->k12_sqrd_sum = (double*) malloc(mem.num_fields * sizeof(double));
d->k31_sqrd_sum = (double*) malloc(mem.num_fields * sizeof(double));
d->k24_sqrd_sum = (double*) malloc(mem.num_fields * sizeof(double));
d->k43_sqrd_sum = (double*) malloc(mem.num_fields * sizeof(double));
d->k13_sqrd_sum = (double*) malloc(mem.num_fields * sizeof(double));
d->k34_sqrd_sum = (double*) malloc(mem.num_fields * sizeof(double));
d->k21_sqrd_sum = (double*) malloc(mem.num_fields * sizeof(double));
d->k42_sqrd_sum = (double*) malloc(mem.num_fields * sizeof(double));
err = alloc_field_freq_ptrs(&d->a12f, bytes, 24, 24, 25);
err = alloc_field_freq_ptrs(&d->a13f, bytes, 24, 24, 25);
if(err) return err;
err = alloc_field_freq_ptrs(&d->a31f, bytes, 24, 24, 25);
err = alloc_field_freq_ptrs(&d->a34f, bytes, 24, 24, 25);
if(err) return err;
err = alloc_field_freq_ptrs(&d->a24f, bytes, 24, 24, 25);
err = alloc_field_freq_ptrs(&d->a21f, bytes, 24, 24, 25);
if(err) return err;
err = alloc_field_freq_ptrs(&d->a43f, bytes, 24, 24, 25);
err = alloc_field_freq_ptrs(&d->a42f, bytes, 24, 24, 25);
if(err) return err;
}
}
......
......@@ -78,7 +78,7 @@ int allocate_memory_for_function_list(long int *bytes);
int allocate_memory_for_amplitude_list(long int *bytes);
int allocate_memory_for_quantum_amplitude_list(long int *bytes);
int allocate_memory_for_quantum_input_list();
int allocate_memory_for_isolator_list(long int *bytes);
int allocate_memory_for_dbs_list(long int *bytes);
void free_memory_for_mirror_list();
......
......@@ -647,7 +647,7 @@ void check_diode(diode_t *diode) {
void check_isolator(isolator_t *diode) {
void check_dbs(dbs_t *diode) {
node_t node1, node2, node3, node4;
// assert that the node indices are in the correct range:
......
......@@ -437,15 +437,15 @@ void find_quantum_components(){
}
}
for(i=0; i<inter.num_isolators; i++) {
isolator_t *isol = &inter.isolator_list[i];
for(i=0; i<inter.num_dbss; i++) {
dbs_t *isol = &inter.dbs_list[i];
// TODO - add in lossy parts
if(is_open_port(isol->node1_index) ||
is_open_port(isol->node2_index) ||
is_open_port(isol->node3_index) ||
is_open_port(isol->node4_index)) {
inter.quantum_components[inter.num_quantum_components++] = get_overall_component_index(ISOLATOR, isol->comp_index);
inter.quantum_components[inter.num_quantum_components++] = get_overall_component_index(DBS, isol->comp_index);
}
}
......@@ -558,9 +558,9 @@ size_t count_quantum_components(bool count){
//__check_quant_noise_for_node(count, m->node1_index, &num, m->name, j, type, 0, false);
//__check_quant_noise_for_node(count, m->node2_index, &num, m->name, j, type, 0, false);
//__check_quant_noise_for_node(count, m->node3_index, &num, m->name, j, type, 0, false);
} else if(type == ISOLATOR) {
} else if(type == DBS) {
isolator_t *isol = &inter.isolator_list[j];
dbs_t *isol = &inter.dbs_list[j];
// TODO - Handle loss at isolator properly
__check_quant_noise_for_node(count, isol->node1_index, &num, isol->name, j, type, 0, false);
__check_quant_noise_for_node(count, isol->node2_index, &num, isol->name, j, type, 0, false);
......
......@@ -341,7 +341,7 @@ void check_all_commands(FILE *fp){
(strncasecmp(s, "laser ", 6) == 0) ||
(strncasecmp(s, "light ", 6) == 0) ||
(strncasecmp(s, "isol ", 5) == 0) ||
(strncasecmp(s, "isol1 ", 6) == 0) ||
(strncasecmp(s, "dbs ", 4) == 0) ||
(strncasecmp(s, "diode ", 6) == 0) ||
(strncasecmp(s, "variable ", 9) == 0) ||
(strncasecmp(s, "var ", 4) == 0) ||
......@@ -582,8 +582,8 @@ void read_file(FILE *fp) {
read_grating(s);
} else if (strncasecmp(s, "isol ", 5) == 0 || strncasecmp(s, "diode ", 6) == 0) {
read_diode(s);
} else if (strncasecmp(s, "isol1 ", 6) == 0) {
read_isolator(s);
} else if (strncasecmp(s, "dbs ", 4) == 0) {
read_dbs(s);
} else if (strncasecmp(s, "variable ", 9) == 0) {
read_variable(s);
} else if (strncasecmp(s, "var ", 4) == 0) {
......@@ -12625,9 +12625,7 @@ void read_diode(const char *command_string) {
}
void read_isolator(const char *command_string) {
if(inter.tem_is_set)
gerror("4-port isolator not HOM ready yet.\n");
void read_dbs(const char *command_string) {
char suppression_string[MAX_TOKEN_LEN] = {0};
char object_name[MAX_TOKEN_LEN] = {0};
......@@ -12640,62 +12638,67 @@ void read_isolator(const char *command_string) {
debug_msg("read_isolator\n");
isolator_t *isol;
isol = &(inter.isolator_list[inter.num_isolators]);
dbs_t *dbs;
dbs = &(inter.dbs_list[inter.num_dbss]);
// TODO - Add suppression later
suppression_string[0] = '0';
int num_vars_read = sscanf(command_string, "%s %s %s %s %s %s %[^\n]",
command_name, object_name,
node1_name, node2_name, node3_name, node4_name, rest_string);
node1_name, node3_name, node2_name, node4_name, rest_string);
// NOTE: that node 3 and 2 are swapped. Originall wrote matrix filling
// to couple nodes differently as an isolator component. Now it is a
// directional BS so the node pattern matches that .
int num_vars_max = 6;
double suppression;
if(num_vars_read < num_vars_max){
gerror("Line `%s':\nexpected 'isol1 name node1 node2 node3 node4'\n", command_string);
gerror("Line `%s':\nexpected 'dbs name node1 node2 node3 node4'\n", command_string);
}
if (num_vars_read > num_vars_max) {
warn("Line `%s':\ntext '%s' ignored\n", command_string, rest_string);
}
if (inter.num_isolators >= mem.num_isolators) {
if (inter.num_dbss >= mem.num_dbss) {
gerror("Line `%s':\ntoo many isolator \n", command_string);
}
check_name(command_string, object_name);
strcpy(isol->name, object_name);
strcpy(dbs->name, object_name);
if (atod(suppression_string, &suppression))
gerror("Line `%s':\nUnable to read suppression value\n", command_string);
if (suppression >= 0.0) {
isol->S = suppression;
dbs->S = suppression;
} else {
gerror("Line `%s':\nsuppression must not be negative\n", command_string);
}
// grab node indices
isol->node1_index = update_node_index_for(node1_name, IN_OUT);
isol->node2_index = update_node_index_for(node2_name, IN_OUT);
isol->node3_index = update_node_index_for(node3_name, IN_OUT);
isol->node4_index = update_node_index_for(node4_name, IN_OUT);
dbs->node1_index = update_node_index_for(node1_name, IN_OUT);
dbs->node2_index = update_node_index_for(node2_name, IN_OUT);
dbs->node3_index = update_node_index_for(node3_name, IN_OUT);
dbs->node4_index = update_node_index_for(node4_name, IN_OUT);
warn("%i %i %i %i\n", dbs->node1_index, dbs->node2_index, dbs->node3_index, dbs->node4_index);
connect_component_to_node(isol->node1_index, (void*)isol, ISOLATOR);
connect_component_to_node(isol->node2_index, (void*)isol, ISOLATOR);
connect_component_to_node(isol->node3_index, (void*)isol, ISOLATOR);
connect_component_to_node(isol->node4_index, (void*)isol, ISOLATOR);
connect_component_to_node(dbs->node1_index, (void*)dbs, DBS);
connect_component_to_node(dbs->node2_index, (void*)dbs, DBS);
connect_component_to_node(dbs->node3_index, (void*)dbs, DBS);
connect_component_to_node(dbs->node4_index, (void*)dbs, DBS);
// calculate the reduced node indices from the node indices
isol->node1_reduced_index = get_reduced_index_for(isol->node1_index);
isol->node2_reduced_index = get_reduced_index_for(isol->node2_index);
dbs->node1_reduced_index = get_reduced_index_for(dbs->node1_index);
dbs->node2_reduced_index = get_reduced_index_for(dbs->node2_index);
++inter.num_isolators;
++inter.num_dbss;
++inter.num_components;
check_isolator(isol);
check_dbs(dbs);
}
......
......@@ -147,7 +147,7 @@ void read_powers(const char *s);
void read_verbose_grating(const char *s);
void read_phase(const char *s);
void read_diode(const char *s);
void read_isolator(const char *command_string);
void read_dbs(const char *command_string);
void read_intmethod(const char *command_string);
void read_QF_mech_transfer_function(const char *command_string);
void read_mhd_out(const char *command_string);
......
......@@ -2948,9 +2948,9 @@ void fill_matrix_isolator_elements(ifo_matrix_vars_t *matrix) {
// fill matrix for diodes
int diode_index;
for (diode_index = 0; diode_index < inter.num_isolators; diode_index++) {
isolator_t *diode;
diode = &(inter.isolator_list[diode_index]);
for (diode_index = 0; diode_index < inter.num_dbss; diode_index++) {
dbs_t *diode;
diode = &(inter.dbs_list[diode_index]);
// f_offset is used to select the pointers to the various frequency elements
// for either the carrier or signal frequencies
......@@ -2979,40 +2979,40 @@ void fill_matrix_isolator_elements(ifo_matrix_vars_t *matrix) {
for (k = 0; k < inter.num_fields; k++) {
get_tem_modes_from_field_index(&nk, &mk, k);
if (diode->a12f[f_offset+f][j][k] != NULL) {
*diode->a12f[f_offset+f][j][k] = complex_m1;
if (diode->a13f[f_offset+f][j][k] != NULL) {
*diode->a13f[f_offset+f][j][k] = complex_m1;
//*(diode->a12f[f_offset+f][j][k]) = z_by_z(*(diode->a12f[f_offset+f][j][k]), diode->k12[j][k]);
if(do_conj)
diode->a12f[f_offset+f][j][k]->im *= -1;
diode->a13f[f_offset+f][j][k]->im *= -1;
}
if (diode->a31f[f_offset+f][j][k] != NULL) {
*diode->a31f[f_offset+f][j][k] = complex_m1;
if (diode->a34f[f_offset+f][j][k] != NULL) {
*diode->a34f[f_offset+f][j][k] = complex_m1;
//*(diode->a31f[f_offset+f][j][k]) = z_by_z(*(diode->a31f[f_offset+f][j][k]), diode->k31[j][k]);
if(do_conj)
diode->a31f[f_offset+f][j][k]->im *= -1;
diode->a34f[f_offset+f][j][k]->im *= -1;
}
if (diode->a24f[f_offset+f][j][k] != NULL) {
*diode->a24f[f_offset+f][j][k] = complex_m1;
if (diode->a21f[f_offset+f][j][k] != NULL) {
*diode->a21f[f_offset+f][j][k] = complex_m1;
//*(diode->a24f[f_offset+f][j][k]) = z_by_z(*(diode->a24f[f_offset+f][j][k]), diode->k24[j][k]);
if(do_conj)
diode->a24f[f_offset+f][j][k]->im *= -1;
diode->a21f[f_offset+f][j][k]->im *= -1;
}
if (diode->a43f[f_offset+f][j][k] != NULL) {
*diode->a43f[f_offset+f][j][k] = complex_m1;
if (diode->a42f[f_offset+f][j][k] != NULL) {
*diode->a42f[f_offset+f][j][k] = complex_m1;
//*(diode->a43f[f_offset+f][j][k]) = z_by_z(*(diode->a43f[f_offset+f][j][k]), diode->k43[j][k]);
if(do_conj)
diode->a43f[f_offset+f][j][k]->im *= -1;
diode->a42f[f_offset+f][j][k]->im *= -1;
}
}
}
......
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