Commit 4d117c98 authored by Daniel Brown's avatar Daniel Brown
Browse files

adding in n,m mode selection for qd detector. Fixing comparison in...

adding in n,m mode selection for qd detector. Fixing comparison in is_var_tuned which compared source not target. Fixing vacuum noise injection from laser and squeezer which wasn't injecting at anything other than 00.
parent dbea3bce
......@@ -2128,7 +2128,7 @@ int set_k_space(int space_index) {
space->mismatching |= 1;
}
if (inter.trace & 64) {
if (inter.trace & 64) {
if (!ceq(qxt, qxt2) || !ceq(qyt, qyt2)) {
mode_match(qxt, qxt2, &kx, &kmx);
mode_match(qyt, qyt2, &ky, &kmy);
......@@ -2984,6 +2984,8 @@ void mode_match(complex_t q1, complex_t q2, complex_t *k, double *km) {
void set_k_all_components(bool rebuilding) {
int initonly, noinit;
bool force = false; // force update of the knm matrices, used for debugging
// mode mismatch coefficients: TODO make use of them somewhere or remove.
int mm = 0;
int mbs = 0;
......@@ -3020,15 +3022,12 @@ void set_k_all_components(bool rebuilding) {
node_t n1 = inter.node_list[mirror->node1_index];
node_t n2 = inter.node_list[mirror->node2_index];
//warn("mirror %s node %s changed %d\n",mirror->name, n1.name, n1.q_changed);
//warn("mirror %s node %s changed %d\n",mirror->name, n2.name, n2.q_changed);
if(((!n1.gnd_node) && (n1.q_changed)) ||
((!n2.gnd_node) && (n2.q_changed))) {
if(force ||
((!n1.gnd_node) && (n1.q_changed)) ||
((!n2.gnd_node) && (n2.q_changed))) {
mm = set_k_mirror(i);
}
}
}
for (i = 0; i < inter.num_beamsplitters; i++) {
......@@ -3043,10 +3042,10 @@ void set_k_all_components(bool rebuilding) {
node_t n3 = inter.node_list[bs->node3_index];
node_t n4 = inter.node_list[bs->node4_index];
if(((!n1.gnd_node) && (n1.q_changed))
|| ((!n2.gnd_node) && (n2.q_changed))
|| ((!n3.gnd_node) && (n3.q_changed))
|| ((!n4.gnd_node) && (n4.q_changed))){
if(force || ((!n1.gnd_node) && (n1.q_changed))
|| ((!n2.gnd_node) && (n2.q_changed))
|| ((!n3.gnd_node) && (n3.q_changed))
|| ((!n4.gnd_node) && (n4.q_changed))){
mbs = set_k_beamsplitter(i);
}
}
......@@ -3062,8 +3061,8 @@ void set_k_all_components(bool rebuilding) {
node_t n1 = inter.node_list[s->node1_index];
node_t n2 = inter.node_list[s->node2_index];
if(((!n1.gnd_node) && (n1.q_changed))
|| ((!n2.gnd_node) && (n2.q_changed))){
if(force || ((!n1.gnd_node) && (n1.q_changed))
|| ((!n2.gnd_node) && (n2.q_changed))){
ms = set_k_space(i);
}
}
......@@ -3084,8 +3083,8 @@ void set_k_all_components(bool rebuilding) {
node_t n1 = inter.node_list[l->node1_index];
node_t n2 = inter.node_list[l->node2_index];
if(((!n1.gnd_node) && (n1.q_changed))
|| ((!n2.gnd_node) && (n2.q_changed))){
if(force || ((!n1.gnd_node) && (n1.q_changed))
|| ((!n2.gnd_node) && (n2.q_changed))){
ml = set_k_lens(i);
}
}
......@@ -3102,8 +3101,8 @@ void set_k_all_components(bool rebuilding) {
node_t n1 = inter.node_list[mod->node1_index];
node_t n2 = inter.node_list[mod->node2_index];
if(((!n1.gnd_node) && (n1.q_changed))
|| ((!n2.gnd_node) && (n2.q_changed))){
if(force ||((!n1.gnd_node) && (n1.q_changed))
|| ((!n2.gnd_node) && (n2.q_changed))){
mmd = set_k_modulator(i);
}
}
......@@ -3120,8 +3119,8 @@ void set_k_all_components(bool rebuilding) {
node_t n1 = inter.node_list[d->node1_index];
node_t n2 = inter.node_list[d->node2_index];
if(((!n1.gnd_node) && (n1.q_changed))
|| ((!n2.gnd_node) && (n2.q_changed))){
if(force || ((!n1.gnd_node) && (n1.q_changed))
|| ((!n2.gnd_node) && (n2.q_changed))){
md = set_k_diode(i);
}
}
......
......@@ -864,7 +864,7 @@ bool is_var_tuned(double *var) {
int i;
for(i=0; i<inter.num_put_cmds; i++){
if(inter.put_list[i].source == var) return true;
if(inter.put_list[i].target == var) return true;
}
return false;
......
......@@ -301,10 +301,12 @@ void bs_knm_matrix_ident(bs_knm_t* M) {
// the mismatch and astigmatism
#define CHK_BS_AST_MST(val, KNM) \
if ((knm_calc_flags & BS##KNM##Calc) == BS##KNM##Calc){\
if (!ceq(knm_q->qxt1_##KNM, knm_q->qxt2_##KNM) || !ceq(knm_q->qyt1_##KNM, knm_q->qyt2_##KNM))\
if (!ceq(knm_q->qxt1_##KNM, knm_q->qxt2_##KNM) || !ceq(knm_q->qyt1_##KNM, knm_q->qyt2_##KNM)){\
*mismatch = *mismatch | val;\
if (!ceq(knm_q->qxt1_##KNM, knm_q->qyt1_##KNM) || !ceq(knm_q->qxt2_##KNM, knm_q->qyt2_##KNM))\
}\
if (!ceq(knm_q->qxt1_##KNM, knm_q->qyt1_##KNM) || !ceq(knm_q->qxt2_##KNM, knm_q->qyt2_##KNM)) {\
*astigmatism = *astigmatism | val;\
}\
}
void check_bs_knm_mismatch_astig(bitflag knm_calc_flags, bs_knm_q_t *knm_q, bitflag *mismatch, bitflag *astigmatism){
......
......@@ -416,15 +416,15 @@ void __check_quant_noise_for_node(bool count, int node_index, size_t *num, const
(*num)++;
}
if(loss != 0 || loss_tuned){
if(!count) {
set_noise_port(&inter.qnoise_in_list[*num], comp_list_index, comp_type, COMPONENT_LOSS, node_index);
if(inter.printqnoiseinputs)
print_qnoise_output(comp_name, node_index, "LOSS");
}
(*num)++;
}
}
......@@ -736,16 +736,14 @@ void create_qnoise_input_matrix(matrix_ccs_t *M){
default:
bug_error("Solver not handled");
}
// get rid of the linked list memory
free(data);
//dump_matrix_ccs(M, "qnoise_input.dat");
//dump_matrix_ccs(M, "qnoise_input_%i.dat");
}
extern int count;
int count;
/**
* Fills the incoherent quantum noise input matrix.
......@@ -806,8 +804,11 @@ void fill_qnoise_input_matrix(){
// only apply squeezing to the squeezed laser frequency
if(inter.signal_f_list[j]->carrier == l->f){
phs = z_by_ph(complex_1, 2.0*l->squeeze_angle);
noise = z_by_x(l->power_coeff_list[k], l->noise_value/2.0);
phs = z_by_ph(complex_1, 2.0 * l->squeeze_angle);
double scale = zmod(l->power_coeff_list[k]);
// need to ensure we inject at least vacuum noise
// regardless of mode content scale of input
noise = z_by_xphr(complex_1, max(scale * l->noise_value, UNIT_VACUUM) /2.0, zphase(l->power_coeff_list[k]));
A = z_by_x(noise, coshr);
B = z_by_x(z_by_z(noise, phs), sinhr);
} else {
......@@ -885,7 +886,9 @@ void fill_qnoise_input_matrix(){
}
}
//dump_matrix_ccs(&M_qni, "qnoise_input.dat");
// char name[100] = {0};
// sprintf(name, "qnoise_input_%i.dat", count++);
// dump_matrix_ccs(&M_qni, name);
}
int __sort_int(const void *a,const void*b) {
......@@ -1490,9 +1493,6 @@ void compute_squeezing_factor(light_out_t *sd, double *r, double *phi, double *d
}
}
int xcount=0;
/**
* Calculate the quantum noise at detector
*
......
......@@ -675,7 +675,7 @@ void read_file(FILE *fp) {
} else if (strncasecmp(s, "ad ", 3) == 0) {
read_amp_out(s);
} else if (strncasecmp(s, "qd ", 3) == 0) {
read_qd_out(s);
read_qd_out(s);
} else if (strncasecmp(s, "xlink ", 6) == 0) {
read_motion_link(s);
} else if (strncasecmp(s, "xd ", 3) == 0) {
......@@ -4733,6 +4733,7 @@ void read_qd_out(const char *command_string) {
char homangle[MAX_TOKEN_LEN] = {0};
char node_name[MAX_TOKEN_LEN] = {0};
char carrier_frequency[MAX_TOKEN_LEN] = {0};
int _n, _m;
char rest_string[REST_STRING_LEN] = {0};
assert(inter.num_light_outputs < mem.num_light_outputs);
......@@ -4741,10 +4742,19 @@ void read_qd_out(const char *command_string) {
light_out_t *quad_detector = &(inter.light_out_list[inter.num_light_outputs]);
output_data_t *output_data = &(inter.output_data_list[inter.num_outputs]);
int n = sscanf(command_string, "%s %s %s %s %s %s", command_name, detector_name, carrier_frequency, homangle, node_name, rest_string);
int n = sscanf(command_string, "%s %s %s %d %d %s %s %s", command_name, detector_name, carrier_frequency, &_n, &_m, homangle, node_name, rest_string);
if(n != 5) {
gerror("Line `%s':\nexpected 'qd name carrier_frequency hom_angle node'\n", command_string);
if(n != 7) {
_n = _m = 0;
quad_detector->field_is_set = false;
quad_detector->field = 0;
n = sscanf(command_string, "%s %s %s %s %s %s", command_name, detector_name, carrier_frequency, homangle, node_name, rest_string);
if (n != 5){
gerror("Line `%s':\n"
"expected 'qd name carrier_frequency [n m] phase node[*]'\n", command_string);
}
}
check_name(detector_name);
......@@ -4765,6 +4775,14 @@ void read_qd_out(const char *command_string) {
output_data->is_second_beam = 0;
}
if(n==7){
if(_n+_m > inter.tem){
gerror("Line `%s':\nMode order greater than maxtem\n", command_string);
}
quad_detector->field_is_set = true;
quad_detector->field = get_field_index_from_tem(_n, _m);
}
int nidx = get_node_index_from_name(node_name);
if(nidx == NOT_FOUND) {
......
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