Commit 0ebc7229 authored by Daniel Brown's avatar Daniel Brown

fixing and renaming

parent 118fbb90
......@@ -819,7 +819,7 @@ int main(int argc, char *argv[]) {
M_ifo_sig.M.num_eqns = (M_ifo_sig.num_frequencies
* inter.num_fields
* (2 * inter.num_reduced_nodes))
+ inter.num_motion_eqns + inter.num_feedbacks;
+ inter.num_motion_eqns + inter.num_slinks;
alloc_ifo_matrix_ccs(&bytes, &M_ifo_sig);
......
......@@ -571,7 +571,7 @@ typedef struct feedback {
int nnz_out_count; /** Number of non-zeros elements taken up in the matrix for output */
transfer_func_t *tf;
} feedback_t;
} slink_t;
//! information pertaining to a mirror
typedef struct mirror {
......@@ -2118,7 +2118,7 @@ typedef struct interferometer {
surface_map_t *surface_motion_map_list;
char **tmp_put_cmds;
openloopgain_out_t *openloopgain_list;
feedback_t *feedback_list;
slink_t *slink_list;
int num_mirrors; //!< number of mirrors
int num_beamsplitters; //!< number of beam splitters
......@@ -2153,7 +2153,7 @@ typedef struct interferometer {
int num_quad_outputs;
int num_surface_motion_maps;
int num_tmp_put_cmds;
int num_feedbacks;
int num_slinks;
int num_quantum_components; /** Number of nodes that are a quantum input */
bool all_quantum_components; /** true if command 'vacuum all' is used. In this
......
......@@ -2370,7 +2370,7 @@ void data_point_new(){
// finally if we are computing some quantum noise we need to set that
// matrix up, as it differs when using modulators as they mix frequencies
// coherently in signal matrix
if(inter.num_qnoise_inputs > 0 && (nosignals || inter.num_modulators > 0 || inter.num_feedbacks > 0)){
if(inter.num_qnoise_inputs > 0 && (nosignals || inter.num_modulators > 0 || inter.num_slinks > 0)){
if(nosignals) {
// if there were no signals, we wouldn't have filled the signal
// matrix yet
......
......@@ -2045,6 +2045,24 @@ void print_help2(void) {
" angles of incidence, phases and tunings are given in [deg]\n"
" (a tuning of 360 deg corresponds to a position change of lambda)\n"
" misalignment angles are given in [rad]\n"
" ** Signal frequency variable\n"
" The variables $fs and $mfs can be used in functions, put commands\n"
" and as the frequency value in any of the detectors. $fs is the positive\n"
" frequency and $mfs is the negative.\n"
" ** Motion and suspension variables\n"
" Motion names are used in xd detectors, slinks and xlinks to select\n"
" particular motions of a suspended optic.\n"
" z = longitudinal motion\n"
" rx, yaw = x-z plane rotation\n"
" ry, pitch = y-z plane rotation\n"
" sN = The Nth surface motion set with the smotion command, from 0 -> N-1\n"
"\n"
" To set the suspension transfer function with the attr command you\n"
" need to set:\n"
" zmech = Longitudinal motion\n"
" rxmech = yaw motion\n"
" rymech = pitch motion\n"
"\n"
" ** Geometrical conventions:\n"
" tangential plane: x, z (index n), saggital plane: y, z (index m)\n"
" xbeta refers to a rotation in the x, z plane, i.e. around the y-axis\n"
......@@ -2222,23 +2240,20 @@ void print_help() {
" pdS[n] name [f1 phase1 [f2... ]] node[*] - sensitivity\n"
" pdN[n] name [f1 phase1 [f2... ]] node[*] - norm. photodetector\n"
" ad name [n m] f node[*] - amplitude detector\n"
" qd name carrier_frequency phase node[*] - Quantum quadrature detector\n"
" sd name carrier_frequency [n m] node[*] - Squeezing detector\n"
" qd name f phase node[*] - Quantum quadrature detector\n"
" sd name f [n m] node[*] - Squeezing detector\n"
" shot name node[*] - shot noise\n"
" bp name x/y parameter node[*] - plots beam parameters\n"
" cp cavity_name x/y parameter - plots cavity parameters\n"
" gouy name x/y space-list - plots gouy phase\n"
" beam name [f] node[*] - plots beam shape\n"
#ifdef DEVELOP
" conv name [f] HG/LG n m xsize ysize [w0x z0x [w0y z0y]] node[*]\n"
" - computes a convolution\n"
#endif
" qshot name n f1 [[phase1 [f2... ]]] node[*] - quantum shotnoise detector\n"
" qshotS name n f1 [[phase1 [f2... ]]] node[*] - quantum shotnoise sens.\n"
" qshotN name n f1 [[phase1 [f2... ]]] node[*] - quantum shotnoise norm.\n"
" qnoised name n f1 [[phase1 [f2... ]]] node[*] - quantum noise detector\n"
" qnoisedS name n f1 [[phase1 [f2... ]]] node[*] - quantum noise sens.\n"
" qnoisedN name n f1 [[phase1 [f2... ]]] node[*] - quantum noise norm.\n"
" oltfd name component motion - Open loop motion TF\n"
"** Available commands:\n"
" fsig name component [type] f phase [amp] - Apply signal\n"
" fsig name component [type] f transfer_func - Apply signal weighted by transfer function\n"
......@@ -2250,6 +2265,7 @@ void print_help() {
" attr component M value Rcx/y value x/ybeta value - attributes of m/bs\n"
" (alignment angles beta in [rad])\n"
" map component filename - read mirror map file\n"
" smotion component map_file transfer_function - set surface motion"
" knm component_name filename_prefix [flag] - save coefficients to file\n"
" maxtem order - TEM order: n+m<=order\n"
" gauss name component node w0 z [wy0 zy] - set q parameter\n"
......
......@@ -303,7 +303,7 @@ void alloc_ifo_matrix_ccs(long *bytes, ifo_matrix_vars_t *matrix_ccs){
memset(matrix_ccs->block_rhs_idx, -1, try_bytes);
}
try_bytes = inter.num_feedbacks * sizeof(int);
try_bytes = inter.num_slinks * sizeof(int);
matrix_ccs->feedback_rhs_idx = (int *) malloc(try_bytes);
if (matrix_ccs->feedback_rhs_idx == NULL){
......@@ -785,7 +785,7 @@ void set_element_mech(ifo_matrix_vars_t *matrix, complex_t** a, int rhs_idx, int
* @param pcol_nnz
* @param mode
*/
void get_feedback_output_elements(feedback_t *feedback, ifo_matrix_vars_t *matrix, int *pcol_nnz, int mode) {
void get_feedback_output_elements(slink_t *feedback, ifo_matrix_vars_t *matrix, int *pcol_nnz, int mode) {
assert(feedback != NULL);
assert(matrix != NULL);
......@@ -979,7 +979,7 @@ void get_motion_link_elements(motion_link_t *motion, ifo_matrix_vars_t *matrix,
* @param pcol_nnz
* @param mode
*/
void get_feedback_input_elements(feedback_t *feedback, ifo_matrix_vars_t *matrix, int *pcol_nnz, int mode) {
void get_feedback_input_elements(slink_t *feedback, ifo_matrix_vars_t *matrix, int *pcol_nnz, int mode) {
assert(feedback != NULL);
assert(matrix != NULL);
......@@ -2906,7 +2906,7 @@ void build_ccs_matrix(ifo_matrix_vars_t *matrix){
sagnac_t *sagnac = NULL;
grating_t *gr = NULL;
block_t *block = NULL;
feedback_t *feedback = NULL;
slink_t *feedback = NULL;
matrix->pcol_head = NULL;
......@@ -3358,8 +3358,8 @@ void build_ccs_matrix(ifo_matrix_vars_t *matrix){
* some place in the interferometer and need to feed it back into the motion
* of another component.
*/
for (i = 0; i < inter.num_feedbacks; i++) {
feedback = &(inter.feedback_list[i]);
for (i = 0; i < inter.num_slinks; i++) {
feedback = &(inter.slink_list[i]);
// feedback is only one extra equation to include in matrix
matrix->feedback_rhs_idx[i] = ccs_rhs_idx++;
......@@ -3725,13 +3725,13 @@ void get_ccs_matrix(ifo_matrix_vars_t *matrix){
get_block_elements((block_t*)curr->component, matrix, NULL, GETELEMENT);
break;
case QFEEDBACK:
get_feedback_output_elements((feedback_t*)curr->component, matrix, NULL, GETELEMENT);
get_feedback_output_elements((slink_t*)curr->component, matrix, NULL, GETELEMENT);
break;
default:
bug_error("Can't handle component type %i",curr->type);
}
} else if(itm->type == QFEEDBACK) {
get_feedback_input_elements((feedback_t*)itm->ptr, matrix, NULL, GETELEMENT);
get_feedback_input_elements((slink_t*)itm->ptr, matrix, NULL, GETELEMENT);
} else if(itm->type == MOTIONLINK){
get_motion_link_elements((motion_link_t*)itm->ptr, matrix, NULL, GETELEMENT);
} else
......
......@@ -466,7 +466,7 @@ void pre_scan(FILE *fp) {
} else if (string_matches(s, "set")) {
mem.num_set_cmds++;
mem.num_node_names++;
} else if (string_matches(s, "feedback")) {
} else if (string_matches(s, "slink")) {
mem.num_feedbacks++;
} else if (string_matches(s, "oltfd")) {
mem.num_openloopgains++;
......@@ -2206,24 +2206,24 @@ int allocate_memory_for_motion_detector_list(long int *bytes) {
int allocate_memory_for_feedback_list(long int *bytes) {
if (mem.num_feedbacks) {
inter.feedback_list = (feedback_t *) calloc(mem.num_feedbacks + 1, sizeof (feedback_t));
inter.slink_list = (slink_t *) calloc(mem.num_feedbacks + 1, sizeof (slink_t));
if (inter.feedback_list == NULL) {
if (inter.slink_list == NULL) {
return (14);
}
*bytes += (mem.num_feedbacks + 1) * sizeof (feedback_t);
*bytes += (mem.num_feedbacks + 1) * sizeof (slink_t);
int i;
for(i=0; i<mem.num_feedbacks; i++){
inter.feedback_list[i].a_d = (complex_t***) malloc(mem.num_frequencies * sizeof(complex_t**));
inter.slink_list[i].a_d = (complex_t***) malloc(mem.num_frequencies * sizeof(complex_t**));
*bytes += (mem.num_frequencies) * sizeof (complex_t**);
int j;
for(j=0; j<mem.num_frequencies; j++){
inter.feedback_list[i].a_d[j] = (complex_t**) calloc(mem.num_fields, sizeof(complex_t*));
inter.slink_list[i].a_d[j] = (complex_t**) calloc(mem.num_fields, sizeof(complex_t*));
*bytes += (mem.num_fields) * sizeof (complex_t*);
}
}
......
......@@ -877,8 +877,8 @@ void init_quantum_components(){
}
}
for(i=0; i<inter.num_feedbacks; i++){
feedback_t *fb = &inter.feedback_list[i];
for(i=0; i<inter.num_slinks; i++){
slink_t *fb = &inter.slink_list[i];
light_out_t *out = &inter.light_out_list[fb->output_list_idx];
if(inter.output_data_list[out->output_index].detector_type == QSHOT ||
......@@ -1157,7 +1157,7 @@ double compute_qnoised_output(int detector_index) {
}
// mystery factor of two required for noise propagated through the matrix
// to match up with that in the
// to match up with that in the qshot detector
rtn *= 2.0;
// Now we must loop over the contributions from the demodulation for frequencies
......
......@@ -146,7 +146,7 @@ void check_all_commands(FILE *fp){
(strncasecmp(s, "pd", 2) == 0) ||
(strncasecmp(s, "ad ", 3) == 0) ||
(strncasecmp(s, "oltfd ", 5) == 0) ||
(strncasecmp(s, "feedback ", 9) == 0) ||
(strncasecmp(s, "slink ", 6) == 0) ||
(strncasecmp(s, "sd ", 3) == 0) ||
(strncasecmp(s, "xd ", 3) == 0) ||
(strncasecmp(s, "xlink ", 6) == 0) ||
......@@ -470,8 +470,8 @@ void read_file(FILE *fp) {
read_motion_out(s);
} else if (strncasecmp(s, "oltfd ", 3) == 0) {
read_openloopTF_out(s);
} else if (strncasecmp(s, "feedback ", 9) == 0) {
read_feedback(s);
} else if (strncasecmp(s, "slink ", 6) == 0) {
read_slink(s);
} else if (strncasecmp(s, "vacuum ", 7) == 0) {
read_vacuum(s, false);
} else if (strncasecmp(s, "qnoised ", 8) == 0
......@@ -748,30 +748,30 @@ void read_file(FILE *fp) {
assert(inter.num_convolution_outputs == mem.num_convolution_outputs);
assert(inter.num_transfer_funcs == mem.num_transfer_funcs);
assert(inter.num_quad_outputs == mem.num_quad_outputs);
assert(inter.num_feedbacks == mem.num_feedbacks);
assert(inter.num_slinks == mem.num_feedbacks);
}
void read_feedback(const char* command_string) {
void read_slink(const char* command_string) {
char command_name[MAX_TOKEN_LEN] = {0};
char fb_name[MAX_TOKEN_LEN] = {0};
char slink_name[MAX_TOKEN_LEN] = {0};
char output_name[MAX_TOKEN_LEN] = {0};
char input_name[MAX_TOKEN_LEN] = {0};
char input_motion[MAX_TOKEN_LEN] = {0};
char transfer[MAX_TOKEN_LEN] = {0};
char rest[MAX_TOKEN_LEN] = {0};
int n = sscanf(command_string, "%s %s %s %s %s %s %s", command_name, fb_name, output_name, input_name, input_motion, transfer, rest);
int n = sscanf(command_string, "%s %s %s %s %s %s %s", command_name, slink_name, output_name, input_name, input_motion, transfer, rest);
if(n != 6 && n != 7)
gerror("Line `%s`:\nfeedback usage is 'feedback name output input motion transfer_function'\n", command_string, output_name);
gerror("Line `%s`:\nslink usage is 'slink name output input motion transfer_function'\n", command_string, output_name);
int idx = inter.num_feedbacks;
int idx = inter.num_slinks;
feedback_t *fb = &inter.feedback_list[idx];
slink_t *fb = &inter.slink_list[idx];
fb->list_index = idx;
strcpy(fb->name, fb_name);
strcpy(fb->name, slink_name);
strcpy(fb->motion_name, input_motion);
fb->comp_list_idx = get_component_index_from_name(input_name);
......@@ -802,12 +802,12 @@ void read_feedback(const char* command_string) {
int output_type = get_component_type_decriment_index(&(fb->output_list_idx));
if(output_type != OUT)
gerror("Line `%s`:\nFeedback output detector '%s' must be either a signal demodulated photodiode, a qnoised or a qshot detector\n", command_string, output_name);
gerror("Line `%s`:\nslink output detector '%s' must be either a signal demodulated photodiode, a qnoised or a qshot detector\n", command_string, output_name);
output_data_t *out = &inter.output_data_list[fb->output_list_idx];
if(out->detector_type != QNOISE && out->detector_type != QSHOT && out->detector_type != PD1)
gerror("Line `%s`:\nFeedback output detector '%s' must be either a signal demodulated photodiode, a qnoised or a qshot detector\n", command_string, output_name);
gerror("Line `%s`:\nslink output detector '%s' must be either a signal demodulated photodiode, a qnoised or a qshot detector\n", command_string, output_name);
int i;
......@@ -818,7 +818,7 @@ void read_feedback(const char* command_string) {
}
}
inter.num_feedbacks++;
inter.num_slinks++;
}
void read_openloopTF_out(const char* command_string){
......@@ -906,7 +906,7 @@ void read_QF_mech_transfer_function(const char *command_string){
int n = sscanf(command_string, "%s %s %s %s %[^\n]",command_name, component_name, gain, phase, rest);
if(n != 4 && n != 5)
gerror("Line `%s`:\ntf usage is 'tf name DCgain DCphase [p/z f1 Q1 [p/z f2 Q2 [p/z f3 Q3 ...]]]'\n", command_string);
gerror("Line `%s`:\ntf usage is 'tf name factor phase [p/z f1 Q1 [p/z f2 Q2 [p/z f3 Q3 ...]]]'\n", command_string);
transfer_func_t *mtf = &inter.tf_list[inter.num_transfer_funcs];
mtf->type = Q_F_TF;
......@@ -999,7 +999,7 @@ void read_general_mech_transfer_function(const char *command_string){
//[%[^]]]
if(n < 4 || n > 6){
gerror("Line `%s`:\ntf2 usage is 'tf2 name DCgain DCphase {p1,p2,...} {z1,z2,...}'\n"
gerror("Line `%s`:\ntf2 usage is 'tf2 name factor phase {p1,p2,...} {z1,z2,...}'\n"
"\nFormat for each pole (p) or zero (z) must be a complex number `+-real+-imagi'\n"
"no whitespace and both real and imag must be stated even if 0. Each complex number\n"
"should be comma separated. Maximum number of poles and zeros per {} is %i\n"
......@@ -10041,12 +10041,12 @@ int assign_detector_parameter(component_param_t *component_param) {
int assign_tf_parameter(component_param_t *component_param) {
transfer_func_t *tf = &inter.tf_list[component_param->component_index];
if(strcasecmp("DCgain", component_param->parameter) == 0){
if(strcasecmp("factor", component_param->parameter) == 0){
*component_param->xparam = &(tf->gain);
strcpy(component_param->unit, " [a.u]");
*component_param->lborder = 0;
*component_param->uborder = 0;
} else if(strcasecmp("DCphase", component_param->parameter) == 0){
} else if(strcasecmp("phase", component_param->parameter) == 0){
*component_param->xparam = &(tf->phase);
strcpy(component_param->unit, " [deg]");
*component_param->lborder = 0;
......
......@@ -44,7 +44,7 @@ typedef struct component_attribute {
const char *component_name; //!< name of the component to set
} component_attribute_t;
void read_feedback(const char* command_string);
void read_slink(const char* command_string);
void read_qd_out(const char *command_string);
void read_openloopTF_out(const char* command_string);
void read_surface_motion_map(const char *command_string);
......
......@@ -3093,11 +3093,11 @@ void fill_matrix_feedback_elements(ifo_matrix_vars_t *matrix) {
assert(matrix != NULL);
assert(matrix->type == SIGNAL_QCORR);
feedback_t *feedback;
slink_t *feedback;
int f,i,n;
for(n=0; n<inter.num_feedbacks; n++) {
feedback = &(inter.feedback_list[n]);
for(n=0; n<inter.num_slinks; n++) {
feedback = &(inter.slink_list[n]);
output_data_t *out = &inter.output_data_list[feedback->output_list_idx];
light_out_t *lout = &inter.light_out_list[out->detector_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