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

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
......
......@@ -405,7 +405,7 @@ void alloc_ifo_matrix_ccs(long *bytes, ifo_matrix_vars_t *matrix_ccs){
memset(matrix_ccs->diode_rhs_idx, -1, try_bytes);
}
try_bytes = inter.num_isolators * sizeof(int);
try_bytes = inter.num_dbss * sizeof(int);
matrix_ccs->isolator_rhs_idx = (int *) malloc(try_bytes);
if (matrix_ccs->isolator_rhs_idx == NULL){
......@@ -510,7 +510,7 @@ int get_comp_rhs_idx(ifo_matrix_vars_t *matrix, int type, void *comp){
case MODULATOR: return matrix->modulator_rhs_idx[((modulator_t*)comp)->comp_index];
case LENS: return matrix->lens_rhs_idx[((lens_t*)comp)->comp_index];
case DIODE: return matrix->diode_rhs_idx[((diode_t*)comp)->comp_index];
case ISOLATOR: return matrix->isolator_rhs_idx[((isolator_t*)comp)->comp_index];
case DBS: return matrix->isolator_rhs_idx[((dbs_t*)comp)->comp_index];
case SPACE: return matrix->space_rhs_idx[((space_t*)comp)->list_index];
case BEAMSPLITTER: return matrix->bs_rhs_idx[((beamsplitter_t*)comp)->comp_index];
case GRATING: return matrix->grating_rhs_idx[((grating_t*)comp)->comp_index];
......@@ -535,7 +535,7 @@ int get_comp_rhs_idx2(ifo_matrix_vars_t *matrix, int type, int comp_index){
case MODULATOR: return matrix->modulator_rhs_idx[comp_index];
case LENS: return matrix->lens_rhs_idx[comp_index];
case DIODE: return matrix->diode_rhs_idx[comp_index];
case ISOLATOR: return matrix->isolator_rhs_idx[comp_index];
case DBS: return matrix->isolator_rhs_idx[comp_index];
case SPACE: return matrix->space_rhs_idx[comp_index];
case BEAMSPLITTER: return matrix->bs_rhs_idx[comp_index];
case GRATING: return matrix->grating_rhs_idx[comp_index];
......@@ -631,19 +631,19 @@ void get_next_space_node(int type, void *comp, space_t *space, node_t **node_con
break;
case ISOLATOR:
case DBS:
if( space->node1_index == ((isolator_t *)comp)->node1_index
|| space->node1_index == ((isolator_t *)comp)->node2_index
|| space->node1_index == ((isolator_t *)comp)->node3_index
|| space->node1_index == ((isolator_t *)comp)->node4_index) {
if( space->node1_index == ((dbs_t *)comp)->node1_index
|| space->node1_index == ((dbs_t *)comp)->node2_index
|| space->node1_index == ((dbs_t *)comp)->node3_index
|| space->node1_index == ((dbs_t *)comp)->node4_index) {
*node_next = &inter.node_list[space->node2_index];
*node_conn = &inter.node_list[space->node1_index];
}
else if( space->node2_index == ((isolator_t *)comp)->node1_index
|| space->node2_index == ((isolator_t *)comp)->node2_index
|| space->node2_index == ((isolator_t *)comp)->node3_index
|| space->node2_index == ((isolator_t *)comp)->node4_index) {
else if( space->node2_index == ((dbs_t *)comp)->node1_index
|| space->node2_index == ((dbs_t *)comp)->node2_index
|| space->node2_index == ((dbs_t *)comp)->node3_index
|| space->node2_index == ((dbs_t *)comp)->node4_index) {
*node_next = &inter.node_list[space->node1_index];
*node_conn = &inter.node_list[space->node2_index];
} else
......@@ -2408,7 +2408,7 @@ void get_beamsplitter_elements(beamsplitter_t *bs, ifo_matrix_vars_t *matrix, in
bug_error("unexpected mode value");
}
void get_isolator_elements(isolator_t *isolator, ifo_matrix_vars_t *matrix, int *pcol_nnz, int mode) {
void get_isolator_elements(dbs_t *isolator, ifo_matrix_vars_t *matrix, int *pcol_nnz, int mode) {
assert(mode == GETELEMENT || mode == COUNT);
assert(isolator != NULL);
assert(matrix != NULL);
......@@ -2464,15 +2464,15 @@ void get_isolator_elements(isolator_t *isolator, ifo_matrix_vars_t *matrix, int
set_diagonal_element(matrix, isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n1_port, f, i, mode);
if(!node2->gnd_node){
if(isolator->a_cplng_12.coupling_off){
set_element(matrix, &(isolator->a12f[f_offset+f][i][i]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n2_port+1, f, i, mode);
if(isolator->a_cplng_13.coupling_off){
set_element(matrix, &(isolator->a13f[f_offset+f][i][i]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n2_port+1, f, i, mode);
} else {
for(j=0; j < inter.num_fields; j++){
int nj, mj;
get_tem_modes_from_field_index(&nj, &mj, j);
bool couples = i == j || include_mode_coupling(&isolator->a_cplng_12, ni, nj, mi, mj);
bool couples = i == j || include_mode_coupling(&isolator->a_cplng_13, ni, nj, mi, mj);
if(couples)
set_element(matrix, &(isolator->a12f[f_offset+f][i][j]),isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n2_port+1, f, j, mode);
set_element(matrix, &(isolator->a13f[f_offset+f][i][j]),isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n2_port+1, f, j, mode);
}
}
}
......@@ -2502,15 +2502,15 @@ void get_isolator_elements(isolator_t *isolator, ifo_matrix_vars_t *matrix, int
set_diagonal_element(matrix, isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n2_port, f, i, mode);
if(!node4->gnd_node){
if(isolator->a_cplng_24.coupling_off){
set_element(matrix, &(isolator->a24f[f_offset+f][i][i]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n4_port+1, f, i, mode);
if(isolator->a_cplng_21.coupling_off){
set_element(matrix, &(isolator->a21f[f_offset+f][i][i]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n4_port+1, f, i, mode);
} else {
for(j=0; j < inter.num_fields; j++){
int nj, mj;
get_tem_modes_from_field_index(&nj, &mj, j);
bool couples = i == j || include_mode_coupling(&isolator->a_cplng_24, ni, nj, mi, mj);
bool couples = i == j || include_mode_coupling(&isolator->a_cplng_21, ni, nj, mi, mj);
if(couples)
set_element(matrix, &(isolator->a24f[f_offset+f][i][j]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n4_port+1, f, j, mode);
set_element(matrix, &(isolator->a21f[f_offset+f][i][j]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n4_port+1, f, j, mode);
}
}
}
......@@ -2538,15 +2538,15 @@ void get_isolator_elements(isolator_t *isolator, ifo_matrix_vars_t *matrix, int
if(!node1->gnd_node){
if(isolator->a_cplng_31.coupling_off){
set_element(matrix, &(isolator->a31f[f_offset+f][i][i]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n1_port+1, f, i, mode);
if(isolator->a_cplng_34.coupling_off){
set_element(matrix, &(isolator->a34f[f_offset+f][i][i]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n1_port+1, f, i, mode);
} else {
for(j=0; j < inter.num_fields; j++){
int nj, mj;
get_tem_modes_from_field_index(&nj, &mj, j);
bool couples = i == j || include_mode_coupling(&isolator->a_cplng_31, ni, nj, mi, mj);
bool couples = i == j || include_mode_coupling(&isolator->a_cplng_34, ni, nj, mi, mj);
if(couples)
set_element(matrix, &(isolator->a31f[f_offset+f][i][j]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n1_port+1, f, j, mode);
set_element(matrix, &(isolator->a34f[f_offset+f][i][j]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n1_port+1, f, j, mode);
}
}
}
......@@ -2578,15 +2578,15 @@ void get_isolator_elements(isolator_t *isolator, ifo_matrix_vars_t *matrix, int
if(!node1->gnd_node){
if(isolator->a_cplng_43.coupling_off){
set_element(matrix, &(isolator->a43f[f_offset+f][i][i]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n3_port+1, f, i, mode);
if(isolator->a_cplng_42.coupling_off){
set_element(matrix, &(isolator->a42f[f_offset+f][i][i]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n3_port+1, f, i, mode);
} else {
for(j=0; j < inter.num_fields; j++){
int nj, mj;
get_tem_modes_from_field_index(&nj, &mj, j);
bool couples = i == j || include_mode_coupling(&isolator->a_cplng_43, ni, nj, mi, mj);
bool couples = i == j || include_mode_coupling(&isolator->a_cplng_42, ni, nj, mi, mj);
if(couples)
set_element(matrix, &(isolator->a43f[f_offset+f][i][j]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n3_port+1, f, j, mode);
set_element(matrix, &(isolator->a42f[f_offset+f][i][j]), isolator_rhs_idx, &col, &got_nnz, &isolator->nnz_count, n3_port+1, f, j, mode);
}
}
}
......@@ -3614,7 +3614,7 @@ int __get_output_rhs_port(ifo_matrix_vars_t *matrix, node_t *node, node_connecti
case MIRROR:
case BEAMSPLITTER:
case GRATING:
case ISOLATOR:
case DBS:
// for these the primary port is the reflected one, i.e. the outgoing port
if(node->direction == IN_OUT){
primary_port = matrix->node_rhs_idx_2[node->list_index]; // output
......@@ -3754,7 +3754,7 @@ void build_ccs_matrix(ifo_matrix_vars_t *matrix){
modulator_t *mod = NULL;
lens_t *lens = NULL;
diode_t *diode = NULL;
isolator_t *isol = NULL;
dbs_t *isol = NULL;
sagnac_t *sagnac = NULL;
grating_t *gr = NULL;
block_t *block = NULL;
......@@ -4068,8 +4068,8 @@ void build_ccs_matrix(ifo_matrix_vars_t *matrix){
}
}
for (i = 0; i < inter.num_isolators; i++) {
isol = &(inter.isolator_list[i]);
for (i = 0; i < inter.num_dbss; i++) {
isol = &(inter.dbs_list[i]);
matrix->isolator_rhs_idx[i] = INT_MAX;
node_t *nodes[4];
......@@ -4094,7 +4094,7 @@ void build_ccs_matrix(ifo_matrix_vars_t *matrix){
if (node_num == 0)
gerror("No nodes were found on %s", isol->name);
else {
pseudocolumn_t *p = create_pseudocol((void*)isol, ISOLATOR, counted_nnz, total_node_num);
pseudocolumn_t *p = create_pseudocol((void*)isol, DBS, counted_nnz, total_node_num);
get_isolator_elements(isol, matrix, &p->nnz, COUNT);
// store pseudo-column in linked list
......@@ -4102,7 +4102,7 @@ void build_ccs_matrix(ifo_matrix_vars_t *matrix){
counted_nnz += p->nnz;
pseudocolumn_item_t itm = {matrix->isolator_rhs_idx[i], ISOLATOR, (void*) isol};
pseudocolumn_item_t itm = {matrix->isolator_rhs_idx[i], DBS, (void*) isol};
utarray_push_back(p->items, &itm);
eqns += node_num * 2 * fields_per_port;
......@@ -4465,8 +4465,8 @@ void build_ccs_matrix(ifo_matrix_vars_t *matrix){
get_unknown_space_node(matrix, curr->component, diode->node3_index, &nodes_next[2], &spaces[2]);
break;
case ISOLATOR:
isol = (isolator_t *) curr->component;
case DBS:
isol = (dbs_t *) curr->component;
get_unknown_space_node(matrix, curr->component, isol->node1_index, &nodes_next[0], &spaces[0]);
get_unknown_space_node(matrix, curr->component, isol->node2_index, &nodes_next[1], &spaces[1]);
get_unknown_space_node(matrix, curr->component, isol->node3_index, &nodes_next[2], &spaces[2]);
......@@ -4710,8 +4710,8 @@ void get_ccs_matrix(ifo_matrix_vars_t *matrix){
case DIODE:
get_diode_elements((diode_t*)curr->component, matrix, NULL, GETELEMENT);
break;
case ISOLATOR:
get_isolator_elements((isolator_t*)curr->component, matrix, NULL, GETELEMENT);
case DBS:
get_isolator_elements((dbs_t*)curr->component, matrix, NULL, GETELEMENT);
break;
case SPACE:
get_space_elements((space_t*)curr->component, matrix, NULL, GETELEMENT);
......
......@@ -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);
}