Commit 81bdd849 authored by Daniel Brown's avatar Daniel Brown
Browse files

Fixing issue with tf2 where it duplicates real poles and zeros, only doubles...

Fixing issue with tf2 where it duplicates real poles and zeros, only doubles and conjugates complex ones now
parent 7078f9dd
...@@ -80,12 +80,14 @@ added features: ...@@ -80,12 +80,14 @@ added features:
anymore, however this shouldn't really have been a use case anyway. anymore, however this shouldn't really have been a use case anyway.
bug fixes: bug fixes:
o tf2 won't add duplicate of a real pole/zero, it only adds a conjugate if it's a complex ones
o Minus sign fixes have been applied for suspended components: mirrors and beamsplitters o Minus sign fixes have been applied for suspended components: mirrors and beamsplitters
this doesn't seem to have affected any results shown before, but does affect the sign this doesn't seem to have affected any results shown before, but does affect the sign
of some transfer functions. The minus sign problem was the direction in which a mirror moves of some transfer functions. The minus sign problem was the direction in which a mirror moves
relative the force applied to it. relative the force applied to it.
o RF frequency mixing matrix wasn't getting reset between runs and causing spurious frequency couplings o RF frequency mixing matrix wasn't getting reset between runs and causing spurious frequency couplings
o Fixed problem with small signals jumping between being either a TF or a signal, getting an odd factor of two occasionally o Fixed problem with small signals jumping between being either a TF or a signal, getting
an odd factor of two occasionally
o Beamsplitter fsig targetting z was not being applied o Beamsplitter fsig targetting z was not being applied
o $fs was not working correctly when fsig was first frequency and RF the second o $fs was not working correctly when fsig was first frequency and RF the second
o Beam trace wasn't taking into account axis flip for sagittal plane on reflection o Beam trace wasn't taking into account axis flip for sagittal plane on reflection
......
...@@ -2243,7 +2243,9 @@ void print_help() { ...@@ -2243,7 +2243,9 @@ void print_help() {
" dbs name node1 node2 node3 node4 - directional BS\n" " dbs name node1 node2 node3 node4 - directional BS\n"
" mod name f midx order am/pm [phase] node1 node2 - modulator\n" " mod name f midx order am/pm [phase] node1 node2 - modulator\n"
" lens name f node1 node2 - thin lens (Focal length)\n" " lens name f node1 node2 - thin lens (Focal length)\n"
" lens* name P node1 node2 - thin lens (Dioptres)\n" " lens* name P node1 node2 - thin lens (Dioptres)\n"
" lens** name fx fy node1 node2 - astigmatic thin lens (Focal length)\n"
" lens*** name Px Py node1 node2 - astigmatic thin lens (Dioptres)\n"
" sq name f r angle node - squeezed input\n" " sq name f r angle node - squeezed input\n"
"** Detectors:\n" "** Detectors:\n"
" pd[n] name [f1 [phase1 [f2... ]]] node[*] - photodetector [mixer]\n" " pd[n] name [f1 [phase1 [f2... ]]] node[*] - photodetector [mixer]\n"
...@@ -2289,7 +2291,7 @@ void print_help() { ...@@ -2289,7 +2291,7 @@ void print_help() {
" conf component_name setting value - configures component\n" " conf component_name setting value - configures component\n"
" vacuum components_names - specific quantum noise\n" " vacuum components_names - specific quantum noise\n"
" tf name factor phase [{p/z f Q [p/z f2 Q2 ...]] - f,Q transfer function\n" " tf name factor phase [{p/z f Q [p/z f2 Q2 ...]] - f,Q transfer function\n"
" tf2 name factor phase [p1,p2,...] [z1,z2,...] - complex transfer function\n" " tf2 name factor phase [{p1,p2,...}] [{z1,z2,...}]- complex transfer function\n"
"** Plot and Output related commands :\n" "** Plot and Output related commands :\n"
" xaxis[*] component param. lin/log min max steps - parameter to tune\n" " xaxis[*] component param. lin/log min max steps - parameter to tune\n"
" x2axis[*] component param. lin/log min max steps - second axis for 3D plot\n" " x2axis[*] component param. lin/log min max steps - second axis for 3D plot\n"
......
...@@ -1403,14 +1403,13 @@ void read_general_mech_transfer_function(const char *command_string){ ...@@ -1403,14 +1403,13 @@ void read_general_mech_transfer_function(const char *command_string){
char rest[LINE_LEN] = {0}; char rest[LINE_LEN] = {0};
int n = sscanf(command_string, "%s %s %s %s %s %s %[^\n]",command_name, component_name, gain, phase, poles, zeros, rest); int n = sscanf(command_string, "%s %s %s %s %s %s %[^\n]",command_name, component_name, gain, phase, poles, zeros, rest);
//[%[^]]]
if(n < 4 || n > 6){ if(n < 4 || n > 6){
gerror("Line `%s':\ntf2 usage is `tf2 name factor phase {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" "\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" "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" "should be comma separated. Maximum number of poles and zeros per {} is %i\n"
"e.g. tf2 pendulum 1 0 {1+100i,1-100i} {-3+10i,-3-10i}\n", command_string, MAX_POLES_ZEROS); "e.g. tf2 pendulum 1 0 {1+100i,1+102i} {-3+10i,-4-50i}\n", command_string, MAX_POLES_ZEROS);
} }
transfer_func_t *mtf = &inter.tf_list[inter.num_transfer_funcs]; transfer_func_t *mtf = &inter.tf_list[inter.num_transfer_funcs];
...@@ -1423,12 +1422,13 @@ void read_general_mech_transfer_function(const char *command_string){ ...@@ -1423,12 +1422,13 @@ void read_general_mech_transfer_function(const char *command_string){
char tmp[MAX_TOKEN_LEN]; char tmp[MAX_TOKEN_LEN];
char *a = NULL; char *a = NULL;
if(atod(gain, &(mtf->gain))) if(atod(gain, &(mtf->gain))){
gerror("Line `%s':\ncould not process gain value provided\n", command_string); gerror("Line `%s':\ncould not process gain value provided\n", command_string);
}
if(atod(phase, &(mtf->phase))) if(atod(phase, &(mtf->phase))){
gerror("Line `%s':\ncould not process phase value provided\n", command_string); gerror("Line `%s':\ncould not process phase value provided\n", command_string);
}
n = sscanf(poles, "{%[^}]", tmp); n = sscanf(poles, "{%[^}]", tmp);
if(n > 0){ if(n > 0){
...@@ -1436,21 +1436,25 @@ void read_general_mech_transfer_function(const char *command_string){ ...@@ -1436,21 +1436,25 @@ void read_general_mech_transfer_function(const char *command_string){
while(a != NULL){ while(a != NULL){
if(mtf->num_poles >= MAX_POLES_ZEROS) { if(mtf->num_poles >= MAX_POLES_ZEROS) {
gerror("Line `%s' : Exceeded maximum number of poles (%i)\n", command_string, MAX_POLES_ZEROS); gerror("Line `%s' : Exceeded maximum number of poles (%i)\n", command_string, MAX_POLES_ZEROS);
} }
n = sscanf(a, "%lf%lfi", &(mtf->poles[mtf->num_poles].re), &(mtf->poles[mtf->num_poles].im)); n = sscanf(a, "%lf%lfi", &(mtf->poles[mtf->num_poles].re), &(mtf->poles[mtf->num_poles].im));
mtf->poles[mtf->num_poles+1].re = mtf->poles[mtf->num_poles].re;
mtf->poles[mtf->num_poles+1].im = -mtf->poles[mtf->num_poles].im;
if(n != 2) { if(n != 2) {
gerror("Line `%s' : could not process pole value `%s'. Format must be `+-[real]+-[imag]i' no whitespace and both real and imag must be stated even if 0\n", command_string, a); gerror("Line `%s' : could not process pole value `%s'. Format must be `+-[real]+-[imag]i' no whitespace and both real and imag must be stated even if 0\n", command_string, a);
} }
a = strtok(NULL, ",");
mtf->num_poles += 2; // only add conjugate if a complex pole
if(mtf->poles[mtf->num_poles].im != 0){
mtf->poles[mtf->num_poles+1].re = mtf->poles[mtf->num_poles].re;
mtf->poles[mtf->num_poles+1].im = -mtf->poles[mtf->num_poles].im;
mtf->num_poles += 2;
} else {
mtf->num_poles += 1;
}
a = strtok(NULL, ","); // find next
} }
} }
...@@ -1461,21 +1465,25 @@ void read_general_mech_transfer_function(const char *command_string){ ...@@ -1461,21 +1465,25 @@ void read_general_mech_transfer_function(const char *command_string){
while(a != NULL){ while(a != NULL){
if(mtf->num_zeros >= MAX_POLES_ZEROS) { if(mtf->num_zeros >= MAX_POLES_ZEROS) {
gerror("Line `%s': Exceeded maximum number of zeros (%i)\n", command_string, MAX_POLES_ZEROS); gerror("Line `%s': Exceeded maximum number of zeros (%i)\n", command_string, MAX_POLES_ZEROS);
} }
n = sscanf(a, "%lf%lfi", &(mtf->zeros[mtf->num_zeros].re), &(mtf->zeros[mtf->num_zeros].im)); n = sscanf(a, "%lf%lfi", &(mtf->zeros[mtf->num_zeros].re), &(mtf->zeros[mtf->num_zeros].im));
mtf->zeros[mtf->num_zeros+1].re = mtf->zeros[mtf->num_zeros].re;
mtf->zeros[mtf->num_zeros+1].im = -mtf->zeros[mtf->num_zeros].im;
if(n != 2) { if(n != 2) {
gerror("Line `%s': could not process zeros value `%s`. Format must be `+-[real]+-[imag]i` no whitespace and both real and imag must be stated \n", command_string, a); gerror("Line `%s': could not process zeros value `%s`. Format must be `+-[real]+-[imag]i` no whitespace and both real and imag must be stated \n", command_string, a);
} }
a = strtok(NULL, ","); // only add conjugate if a complex zero
if(mtf->zeros[mtf->num_zeros].im != 0){
mtf->zeros[mtf->num_zeros+1].re = mtf->zeros[mtf->num_zeros].re;
mtf->zeros[mtf->num_zeros+1].im = -mtf->zeros[mtf->num_zeros].im;
mtf->num_zeros += 2;
} else {
mtf->num_zeros += 1;
}
mtf->num_zeros += 2; a = strtok(NULL, ",");
} }
} }
......
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