Commit 52fa13a6 authored by Daniel Brown's avatar Daniel Brown

Closes #8: Added ability to sweep lock offset

parent 8ee183e4
......@@ -21,12 +21,15 @@ main changes:
device couldn't handle the mix of quantum noise easily. The three port isolator component
was removed. Pykat and Finesse now talk to each other via a pipe command, which will be
used more in future and save writing things to disk first before reading it in to Python.
Added ability to set offset via the lock command now, rather than having to define a separate
function.
syntax change:
o tf2: For each pole or zero added the funcion will automatically add the conjugate pole
so you don't need to specify each
o Three port isolator is no longer available
o pitch and yaw can now be used instead of ybeta and xbeta
o Added optional offset parameter: lock name $var gain accuracy [offset]
added features:
o added 'powers' command which prints the light power in all node to the terminal
......@@ -80,6 +83,22 @@ added features:
ad u $fs n3
ad l $mfs n3
o Lock offset: Can set the offset to a lock more easily now instead of having
to define a func and do the math.
Example:
l l1 10 0 0.0 n1
m m1 0 1 0 n1 n2
pd P n2
set P.re P re
lock test $P.re -0.01 1e-4 -2
put l1 P $test
xaxis test offset lin -1 -10 10
bug fixes:
......
......@@ -3261,6 +3261,14 @@ int get_component_index_from_name(const char *component_name_string) {
}
}
j += inter.num_transfer_funcs;
for(i=0; i< inter.num_locks; i++){
if(strcmp(component_name_string, inter.lock_list[i].name) == 0){
return j+i;
}
}
return NOT_FOUND;
}
......@@ -3300,6 +3308,10 @@ 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_transfer_funcs) {
return TF;
} else if ((component_index -= inter.num_transfer_funcs) < inter.num_locks) {
return LOCK_CMD;
} else {
bug_error("unknown type");
}
......@@ -3321,38 +3333,33 @@ int get_component_index(int overall_component_index) {
return overall_component_index;
} else if (overall_component_index < inter.num_mirrors) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_mirrors)
< inter.num_beamsplitters) {
} else if ((overall_component_index -= inter.num_mirrors) < inter.num_beamsplitters) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_beamsplitters) < inter.num_gratings) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_gratings) < inter.num_spaces) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_spaces) < inter.num_lenses) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_beamsplitters)
< inter.num_gratings) {
} else if ((overall_component_index -= inter.num_lenses) < inter.num_diodes) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_gratings)
< inter.num_spaces) {
} else if ((overall_component_index -= inter.num_diodes) < inter.num_light_inputs) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_spaces)
< inter.num_lenses) {
} else if ((overall_component_index -= inter.num_light_inputs) < inter.num_modulators) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_lenses)
< inter.num_diodes) {
} else if ((overall_component_index -= inter.num_modulators) < inter.num_dbss) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_diodes)
< inter.num_light_inputs) {
} else if ((overall_component_index -= inter.num_dbss) < inter.num_signals) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_light_inputs)
< inter.num_modulators) {
} else if ((overall_component_index -= inter.num_signals) < inter.num_variables) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_modulators)
< inter.num_dbss) {
} else if ((overall_component_index -= inter.num_variables) < inter.num_outputs) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_dbss)
< inter.num_signals) {
} else if ((overall_component_index -= inter.num_outputs) < inter.num_gauss_cmds) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_signals)
< inter.num_variables) {
} else if ((overall_component_index -= inter.num_gauss_cmds) < inter.num_transfer_funcs) {
return overall_component_index;
} else if ((overall_component_index -= inter.num_variables)
< inter.num_outputs) {
} else if ((overall_component_index -= inter.num_transfer_funcs) < inter.num_locks) {
return overall_component_index;
} else {
bug_error("unknown type");
......@@ -3373,48 +3380,36 @@ int get_component_type_decriment_index(int *component_index) {
if (*component_index >= 0) {
if (*component_index < inter.num_mirrors) {
return MIRROR;
} else if ((*component_index -= inter.num_mirrors)
< inter.num_beamsplitters) {
} else if ((*component_index -= inter.num_mirrors) < inter.num_beamsplitters) {
return BEAMSPLITTER;
} else if ((*component_index -= inter.num_beamsplitters)
< inter.num_gratings) {
} else if ((*component_index -= inter.num_beamsplitters) < inter.num_gratings) {
return GRATING;
} else if ((*component_index -= inter.num_gratings)
< inter.num_spaces) {
} else if ((*component_index -= inter.num_gratings) < inter.num_spaces) {
return SPACE;
} else if ((*component_index -= inter.num_spaces)
< inter.num_sagnacs) {
} else if ((*component_index -= inter.num_spaces) < inter.num_sagnacs) {
return SAGNAC;
} else if ((*component_index -= inter.num_sagnacs)
< inter.num_lenses) {
} else if ((*component_index -= inter.num_sagnacs) < inter.num_lenses) {
return LENS;
} else if ((*component_index -= inter.num_lenses)
< inter.num_diodes) {
} else if ((*component_index -= inter.num_lenses) < inter.num_diodes) {
return DIODE;
} else if ((*component_index -= inter.num_diodes)
< inter.num_light_inputs) {
} else if ((*component_index -= inter.num_diodes) < inter.num_light_inputs) {
return LIGHT_INPUT;
} else if ((*component_index -= inter.num_light_inputs)
< inter.num_modulators) {
} else if ((*component_index -= inter.num_light_inputs) < inter.num_modulators) {
return MODULATOR;
} else if ((*component_index -= inter.num_modulators)
< inter.num_dbss) {
} else if ((*component_index -= inter.num_modulators) < inter.num_dbss) {
return DBS;
} else if ((*component_index -= inter.num_dbss)
< inter.num_signals) {
} else if ((*component_index -= inter.num_dbss) < inter.num_signals) {
return FSIG;
} else if ((*component_index -= inter.num_signals)
< inter.num_variables) {
} else if ((*component_index -= inter.num_signals) < inter.num_variables) {
return VARIABLE;
} else if ((*component_index -= inter.num_variables)
< inter.num_outputs) {
} else if ((*component_index -= inter.num_variables) < inter.num_outputs) {
return OUT;
} else if ((*component_index -= inter.num_outputs)
< inter.num_gauss_cmds) {
} else if ((*component_index -= inter.num_outputs) < inter.num_gauss_cmds) {
return BEAMPARAM;
} else if ((*component_index -= inter.num_gauss_cmds)
< inter.num_transfer_funcs) {
} else if ((*component_index -= inter.num_gauss_cmds) < inter.num_transfer_funcs) {
return TF;
} else if ((*component_index -= inter.num_transfer_funcs) < inter.num_locks) {
return LOCK_CMD;
}
}
......@@ -3459,6 +3454,10 @@ 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_transfer_funcs) {
return duplicate_string(inter.tf_list[component_index].name);
} else if ((component_index -= inter.num_transfer_funcs) < inter.num_locks) {
return duplicate_string(inter.lock_list[component_index].name);
} else {
bug_error("component index out of range");
}
......@@ -3504,6 +3503,10 @@ 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_transfer_funcs) {
return duplicate_string("TF");
} else if ((component_index -= inter.num_transfer_funcs) < inter.num_locks) {
return duplicate_string("LOCK");
} else {
bug_error("component index out of range");
}
......
......@@ -235,7 +235,7 @@
#define MODULATOR 7 //!< Modulator component type
#define FSIG 8 //!< Input for transfer function computation
#define OUT 9 //!< Output light field component type
#define GRATING 10 //!< Grating component type
#define GRATING 10 //!< Grating component type
#define SQUEEZER 11 //!< Squeezer component type
#define BEAMPARAM 12 //!< not a component!! but needed for setting with xaxis or put
#define VARIABLE 13 //!< dummy component, used for storing a parameter
......@@ -247,6 +247,7 @@
#define MOTIONLINK 19
#define SPACECONNECTION 20
#define DBS 21 //!< Isolator component type
#define LOCK_CMD 22
#define X1 -12 //!< x axis tag
#define X2 -13 //!< y axis tag
......
......@@ -808,6 +808,10 @@ void read_file(FILE *fp) {
read_init_dummy(fp, 0);
} else if (strncasecmp(s, "/*", 2) == 0) {
read_init_dummy(fp, 1);
} else if (strncasecmp(s, "lock ", 5) == 0) {
read_lock_command(s);
} else if (strncasecmp(s, "lock* ", 6) == 0) {
read_lock2(s);
}
}
......@@ -873,10 +877,6 @@ void read_file(FILE *fp) {
read_func_command(s);
} else if (strncasecmp(s, "showiterate ", 12) == 0) {
read_showiterate(s);
} else if (strncasecmp(s, "lock ", 5) == 0) {
read_lock_command(s);
} else if (strncasecmp(s, "lock* ", 6) == 0) {
read_lock2(s);
} else if (strncasecmp(s, "gnuplot", 7) == 0) {
read_init_dummy(fp, 0);
} else if (strncasecmp(s, "python", 6) == 0) {
......@@ -8795,10 +8795,12 @@ void read_xaxis(const char *command_string) {
}
int component_index = get_component_index_from_name(component_name);
if (component_index == NOT_FOUND) {
//################################################################################
// never used can be removed here in other xaxis put function
int detector_index = get_detector_or_node_index_from_name(component_name);
if (detector_index == NOT_FOUND) {
gerror("Line `%s':\ncomponent name '%s' not found.\n",
command_string, component_name);
......@@ -11199,63 +11201,65 @@ int assign_fsig_parameter(component_param_t *component_param) {
* \todo split up if/elseif sections into separate routines
*/
int assign_detector_parameter(component_param_t *component_param) {
output_data_t *output_data;
output_data = &inter.output_data_list[component_param->component_index];
if (output_data->detector_type == PD0 ||
output_data->detector_type == SHOT ||
output_data->detector_type == BP ||
output_data->detector_type == PG
) {
server_gerror("Line `%s':\n"
"cannot tune any parameter at this detector type "
"(pd0/shot/bp/gouy)\n", component_param->command_string);
return (-1);
} else if(output_data->detector_type == HOMODYNE){
homodyne_t *hom = &inter.homodyne_list[output_data->detector_index];
assign_homodyne_detector_params(hom, component_param);
} else if(output_data->detector_type == QD){
output_data_t *output_data;
output_data = &inter.output_data_list[component_param->component_index];
if (output_data->detector_type == PD0 ||
output_data->detector_type == SHOT ||
output_data->detector_type == BP ||
output_data->detector_type == PG
) {
server_gerror("Line `%s':\n"
"cannot tune any parameter at this detector type "
"(pd0/shot/bp/gouy)\n", component_param->command_string);
return (-1);
} else if(output_data->detector_type == HOMODYNE){
homodyne_t *hom = &inter.homodyne_list[output_data->detector_index];
assign_homodyne_detector_params(hom, component_param);
} else if(output_data->detector_type == QD){
int detector_index = output_data->detector_index;
light_out_t *detector;
detector = &inter.light_out_list[detector_index];
assign_qd_detector_params(detector, component_param);
} else {
if (output_data->detector_type == UFUNCTION) {
bug_error("outtype FBACK 1");
}
if(output_data->detector_type == FEEDBACK){
assign_lock_params(&inter.lock_list[output_data->detector_index], component_param);
} else {
int detector_index = output_data->detector_index;
light_out_t *detector;
detector = &inter.light_out_list[detector_index];
assign_qd_detector_params(detector, component_param);
} else {
if (output_data->detector_type == FEEDBACK ||
output_data->detector_type == UFUNCTION) {
bug_error("outtype FBACK 1");
}
int detector_index = output_data->detector_index;
light_out_t *detector;
detector = &inter.light_out_list[detector_index];
if (output_data->detector_type == BEAM) {
assign_beam_detector_params(detector, component_param);
} else if (output_data->detector_type == AD) {
int error_num =
assign_amplitude_detector_params(detector, component_param);
if (error_num != 0) {
return error_num;
}
} else if (detector->num_demods == 1) {
int error_num =
assign_one_demod_detector_params(detector, component_param);
if (error_num != 0) {
return error_num;
}
}// handle f<number> as a parameter
else if (detector->num_demods > 1) {
int error_num =
assign_multi_demod_detector_params(detector, component_param);
if (error_num != 0) {
return error_num;
light_out_t *detector = &inter.light_out_list[detector_index];
if (output_data->detector_type == BEAM) {
assign_beam_detector_params(detector, component_param);
} else if (output_data->detector_type == AD) {
int error_num = assign_amplitude_detector_params(detector, component_param);
if (error_num != 0) {
return error_num;
}
} else if (detector->num_demods == 1) {
int error_num = assign_one_demod_detector_params(detector, component_param);
if (error_num != 0) {
return error_num;
}
} else if (detector->num_demods > 1) {
int error_num =
assign_multi_demod_detector_params(detector, component_param);
if (error_num != 0) {
return error_num;
}
} else {
bug_error("detector_type(new) xparam");
}
} else {
bug_error("detector_type(new) xparam");
}
}
......@@ -11389,6 +11393,15 @@ int assign_beam_parameter(component_param_t *component_param) {
return (0);
}
void assign_lock_params( lock_command_t *lock, component_param_t *component_param) {
if (strcasecmp("offset", component_param->parameter) == 0) {
*component_param->xparam = &(lock->offset);
strcpy(component_param->unit, " [au]");
*component_param->lborder = 0;
*component_param->uborder = 0;
}
}
void assign_homodyne_detector_params(
homodyne_t *hom,
component_param_t *component_param) {
......
......@@ -198,6 +198,7 @@ int assign_one_demod_detector_params(light_out_t *detector, component_param_t *c
int assign_multi_demod_detector_params(light_out_t *detector, component_param_t *component_param);
int assign_beam_parameter(component_param_t *component_param);
int assign_tf_parameter(component_param_t *component_param);
void assign_lock_params( lock_command_t *lock, component_param_t *component_param);
void init_beamsplitter_signal(signal_t *signal,
int component_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