Commit 6021918e authored by Andreas Freise's avatar Andreas Freise
Browse files

some code refactoring, making block names more consistent

parent 665695c0
Pipeline #1749 passed with stage
in 20 seconds
...@@ -13,9 +13,7 @@ ...@@ -13,9 +13,7 @@
# #
# Anna Green, 28th November 2016 # Anna Green, 28th November 2016
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
#
%%% FTblock References
###########################################################################
# References used for aLIGO parameters # References used for aLIGO parameters
# [1] R. Abbott. Advanced LIGO length sensing and control final design. LIGO Document T1000298, 2010. # [1] R. Abbott. Advanced LIGO length sensing and control final design. LIGO Document T1000298, 2010.
# [2] Advanced LIGO, CQG, 2015 # [2] Advanced LIGO, CQG, 2015
...@@ -61,10 +59,8 @@ ...@@ -61,10 +59,8 @@
# #
# #
###########################################################################
%%% FTend References
%%% FTblock Laser %%% FTblock laser
########################################################################### ###########################################################################
# Laser and input optics # Laser and input optics
l L0 125 0 n0 l L0 125 0 n0
...@@ -80,7 +76,7 @@ s lmod2 1 n2 n3 ...@@ -80,7 +76,7 @@ s lmod2 1 n2 n3
mod mod2 $f2 0.18 1 pm n3 n4 mod mod2 $f2 0.18 1 pm n3 n4
s lmod3 1 n4 nREFL # TODO s lmod3 1 n4 nREFL # TODO
########################################################################### ###########################################################################
%%% FTend Laser %%% FTend laser
%%% FTblock PRC %%% FTblock PRC
########################################################################### ###########################################################################
...@@ -230,7 +226,7 @@ m2 SRMAR 0 50n 0 nSRMs2 nSRM2 ...@@ -230,7 +226,7 @@ m2 SRMAR 0 50n 0 nSRMs2 nSRM2
attr SRM Rc -5.6938 attr SRM Rc -5.6938
########################################################################### ###########################################################################
%%% FTend SR %%% FTend SRC
%%% FTblock HOMs %%% FTblock HOMs
########################################################################### ###########################################################################
...@@ -247,7 +243,7 @@ cav cavSRY SRM nSRM1 ITMY nITMYs2 ...@@ -247,7 +243,7 @@ cav cavSRY SRM nSRM1 ITMY nITMYs2
########################################################################### ###########################################################################
%%% FTend HOMs %%% FTend HOMs
%%% FTblock Constants %%% FTblock constants
########################################################################### ###########################################################################
const nsilica 1.44963098985906 const nsilica 1.44963098985906
const nTGG 1.954 const nTGG 1.954
...@@ -258,9 +254,9 @@ const fM 36.397884M ...@@ -258,9 +254,9 @@ const fM 36.397884M
const fP 54.596826M const fP 54.596826M
const th_f 34.5k const th_f 34.5k
########################################################################### ###########################################################################
%%% FTend Constants %%% FTend constants
%%% FTblock Tunings %%% FTblock tunings
########################################################################### ###########################################################################
const phi_SRM 90.0 const phi_SRM 90.0
const phi_PRM 0.0 const phi_PRM 0.0
...@@ -270,11 +266,11 @@ const phi_ETMX 0.0 ...@@ -270,11 +266,11 @@ const phi_ETMX 0.0
const phi_ETMY 0.0 const phi_ETMY 0.0
const phi_BS 0 const phi_BS 0
########################################################################### ###########################################################################
%%% FTend Tunings %%% FTend tunings
# reintroduced: errsigs, locks, powers (partial) # reintroduced: errsigs, locks, powers (partial)
%%% FTblock Powers %%% FTblock powers
########################################################################### ###########################################################################
pd P_DC_AS nSRM2 pd P_DC_AS nSRM2
# pd P_DC_OMC nOMC_HROC_trans # pd P_DC_OMC nOMC_HROC_trans
...@@ -295,7 +291,7 @@ ad src0 0 nSRM1* ...@@ -295,7 +291,7 @@ ad src0 0 nSRM1*
ad srcf1 $f1 nSRM1* ad srcf1 $f1 nSRM1*
ad srcf2 $f2 nSRM1* ad srcf2 $f2 nSRM1*
########################################################################### ###########################################################################
%%% FTend Powers %%% FTend powers
%%% FTblock errsigs %%% FTblock errsigs
########################################################################### ###########################################################################
...@@ -320,6 +316,7 @@ pd1 AS_f2_Q $f2 103 nSRM2 ...@@ -320,6 +316,7 @@ pd1 AS_f2_Q $f2 103 nSRM2
%%% FTblock locks %%% FTblock locks
########################################################################### ###########################################################################
/*
set PRCL_err POP_f1_I re set PRCL_err POP_f1_I re
set MICH_err POP_f2_Q re set MICH_err POP_f2_Q re
set CARM_err REFL_f1_I re set CARM_err REFL_f1_I re
...@@ -362,7 +359,7 @@ noplot CARM_lock ...@@ -362,7 +359,7 @@ noplot CARM_lock
noplot mMICH_lock noplot mMICH_lock
noplot ETMX_lock noplot ETMX_lock
noplot ETMY_lock noplot ETMY_lock
*/
########################################################################### ###########################################################################
%%% FTend locks %%% FTend locks
......
...@@ -143,12 +143,12 @@ class aLIGO(object): ...@@ -143,12 +143,12 @@ class aLIGO(object):
else: else:
nmStr = "0 0" nmStr = "0 0"
code = """ code = """
ad f1p {0} {1} nPRM2 ad f1p {0} {1} nPRM2
ad f1m {0} -{1} nPRM2 ad f1m {0} -{1} nPRM2
xaxis mod1 f lin {2} {3} 200 xaxis mod1 f lin {2} {3} 200
put f1p f $x1 put f1p f $x1
put f1m f $mx1 put f1m f $mx1
""".format(nmStr, self.f1, startf, stopf) """.format(nmStr, self.f1, startf, stopf)
kat.parseCommands(code) kat.parseCommands(code)
out = kat.run() out = kat.run()
ax.plot(out.x-self.f1,np.abs(out["f1p"]), label=" f1") ax.plot(out.x-self.f1,np.abs(out["f1p"]), label=" f1")
...@@ -481,33 +481,60 @@ class aLIGO(object): ...@@ -481,33 +481,60 @@ class aLIGO(object):
self.DCoffsetW = AS_power self.DCoffsetW = AS_power
return self.DCoffset return self.DCoffset
def generate_tuning_block(self, kat):
code1 = """
%%% FTblock tunings
###########################################################################"""
code2 = """
const phi_ITMX {:.8}
const phi_ITMY {:.8}
const phi_ETMX {:.8}
const phi_ETMY {:.8}""".format(float(kat.ITMX.phi), float(kat.ITMY.phi), float(kat.ETMX.phi),float(kat.ETMY.phi))
code3 = """
const phi_BS {:.8}
const phi_PRM {:.8}
const phi_SRM {:.8}""".format(float(kat.BS.phi), float(kat.PRM.phi), float(kat.SRM.phi))
code4 = """
###########################################################################
%%% FTend tuning"""
return "".join([code1, code2, code3, code4])
def generate_errsig_block(self, kat, noplot=False): def generate_errsig_block(self, kat, noplot=False):
code1 = """
%%% FTblock errsigs
###########################################################################
"""
sigDARM = self.DARM.signal(kat) sigDARM = self.DARM.signal(kat)
sigCARM = self.CARM.signal(kat) sigCARM = self.CARM.signal(kat)
sigPRCL = self.PRCL.signal(kat) sigPRCL = self.PRCL.signal(kat)
sigMICH = self.MICH.signal(kat) sigMICH = self.MICH.signal(kat)
sigSRCL = self.SRCL.signal(kat) sigSRCL = self.SRCL.signal(kat)
code1 = "\n".join([sigDARM, sigCARM, sigPRCL, sigMICH, sigSRCL]) code2 = "\n".join([sigDARM, sigCARM, sigPRCL, sigMICH, sigSRCL])
code3= ""
if noplot: if noplot:
nameDARM = self.DARM.signal_name(kat) nameDARM = self.DARM.signal_name(kat)
nameCARM = self.CARM.signal_name(kat) nameCARM = self.CARM.signal_name(kat)
namePRCL = self.PRCL.signal_name(kat) namePRCL = self.PRCL.signal_name(kat)
nameMICH = self.MICH.signal_name(kat) nameMICH = self.MICH.signal_name(kat)
nameSRCL = self.SRCL.signal_name(kat) nameSRCL = self.SRCL.signal_name(kat)
code2 = """ code3 = """
noplot {} noplot {}
noplot {} noplot {}
noplot {} noplot {}
noplot {} noplot {}
noplot {} noplot {}""".format(nameDARM, nameCARM, namePRCL, nameMICH, nameSRCL)
""".format(nameDARM, nameCARM, namePRCL, nameMICH, nameSRCL)
return "".join([code1, code2]) code4 = """
else: ###########################################################################
return code1 %%% FTend errsigs"""
return "".join([code1, code2, code3, code4])
def generate_lock_block(self, _kat, gainsAdjustment = [0.5, 0.005, 1.0, 0.5, 0.025], gains=None, accuracies=None, verbose=True): def generate_locks(self, _kat, gainsAdjustment = [0.5, 0.005, 1.0, 0.5, 0.025], gains=None, accuracies=None, verbose=True):
""" """
gainsAdjustment: factors to apply to loop gains computed from optical gains gainsAdjustment: factors to apply to loop gains computed from optical gains
gains: override loop gain [W per deg] gains: override loop gain [W per deg]
...@@ -530,7 +557,8 @@ class aLIGO(object): ...@@ -530,7 +557,8 @@ class aLIGO(object):
gainMICH = round_to_n(gainsAdjustment[3] * factor / ogMICH, 2) # manually tuned gainMICH = round_to_n(gainsAdjustment[3] * factor / ogMICH, 2) # manually tuned
gainSRCL = round_to_n(gainsAdjustment[4] * factor / ogSRCL, 2) # gain hirarchy with MICH gainSRCL = round_to_n(gainsAdjustment[4] * factor / ogSRCL, 2) # gain hirarchy with MICH
gains = [ gainDARM, gainCARM, gainPRCL, gainMICH, gainSRCL] gains = [ gainDARM, gainCARM, gainPRCL, gainMICH, gainSRCL]
self.lockGains = gains.copy()
# rms: loop accuracies in meters (manually tuned for the loops to work # rms: loop accuracies in meters (manually tuned for the loops to work
# with the default file) # with the default file)
# to compute accuracies from rms, we convert # to compute accuracies from rms, we convert
...@@ -545,53 +573,15 @@ class aLIGO(object): ...@@ -545,53 +573,15 @@ class aLIGO(object):
accMICH = round_to_n(np.abs(factor * rms[3] * ogMICH),2) accMICH = round_to_n(np.abs(factor * rms[3] * ogMICH),2)
accSRCL = round_to_n(np.abs(factor * rms[4] * ogSRCL),2) accSRCL = round_to_n(np.abs(factor * rms[4] * ogSRCL),2)
accuracies = [accDARM, accCARM, accPRCL, accMICH, accSRCL] accuracies = [accDARM, accCARM, accPRCL, accMICH, accSRCL]
self.lockAccuracies = accuracies.copy()
nameDARM = self.DARM.signal_name(kat) nameDARM = self.DARM.signal_name(kat)
nameCARM = self.CARM.signal_name(kat) nameCARM = self.CARM.signal_name(kat)
namePRCL = self.PRCL.signal_name(kat) namePRCL = self.PRCL.signal_name(kat)
nameMICH = self.MICH.signal_name(kat) nameMICH = self.MICH.signal_name(kat)
nameSRCL = self.SRCL.signal_name(kat) nameSRCL = self.SRCL.signal_name(kat)
code1 = """ self.lockNames = [nameDARM, nameCARM, namePRCL, nameMICH, nameSRCL]
%%% FTblock locks
###########################################################################
set AS_f2_I_re {} re
set CARM_err {} re
set PRCL_err {} re
set MICH_err {} re
set SRCL_err {} re
func DARM_err = $AS_f2_I_re - {}
""".format(nameDARM, nameCARM, namePRCL, nameMICH, nameSRCL, self.DCoffsetW)
code2 = """lock DARM_lock $DARM_err {:8.2} {:8.2}
lock CARM_lock $CARM_err {:8.2g} {:8.2g}
lock PRCL_lock $PRCL_err {:8.2g} {:8.2g}
lock MICH_lock $MICH_err {:8.2g} {:8.2g}
lock SRCL_lock $SRCL_err {:8.2g} {:8.2g}""".format(gains[0], accuracies[0], gains[1], accuracies[1], gains[2], accuracies[2], gains[3], accuracies[3], gains[4], accuracies[4])
code3 = """
noplot ITMY_lock
func ITMY_lock = (-1.0) * $MICH_lock
func ETMX_lock = $CARM_lock + $MICH_lock + $DARM_lock
func ETMY_lock = $CARM_lock - $MICH_lock - $DARM_lock
put* PRM phi $PRCL_lock
put* ITMX phi $MICH_lock
put* ITMY phi $ITMY_lock
put* ETMX phi $ETMX_lock
put* ETMY phi $ETMY_lock
put* SRM phi $SRCL_lock
noplot PRCL_lock
noplot SRCL_lock
noplot MICH_lock
noplot DARM_lock
noplot CARM_lock
noplot ETMX_lock
noplot ETMY_lock
###########################################################################
%%% FTend locks
"""
factor1 = 2.0 * math.pi / 360.0 factor1 = 2.0 * math.pi / 360.0
factor2 = 2.0 * math.pi / kat.lambda0 factor2 = 2.0 * math.pi / kat.lambda0
factor3 = 360.0 / kat.lambda0 factor3 = 360.0 / kat.lambda0
...@@ -621,12 +611,60 @@ lock SRCL_lock $SRCL_err {:8.2g} {:8.2g}""".format(gains[0], accuracies[0], gain ...@@ -621,12 +611,60 @@ lock SRCL_lock $SRCL_err {:8.2g} {:8.2g}""".format(gains[0], accuracies[0], gain
print(" | PRCL: {:5.4} * {:12.6} = {:12.6} |".format(gainsAdjustment[2],factor4/ogPRCL, gainsAdjustment[2]*factor4/ogPRCL)) print(" | PRCL: {:5.4} * {:12.6} = {:12.6} |".format(gainsAdjustment[2],factor4/ogPRCL, gainsAdjustment[2]*factor4/ogPRCL))
print(" | MICH: {:5.4} * {:12.6} = {:12.6} |".format(gainsAdjustment[3],factor4/ogMICH, gainsAdjustment[3]*factor4/ogMICH)) print(" | MICH: {:5.4} * {:12.6} = {:12.6} |".format(gainsAdjustment[3],factor4/ogMICH, gainsAdjustment[3]*factor4/ogMICH))
print(" | SRCL: {:5.4} * {:12.6} = {:12.6} |".format(gainsAdjustment[4],factor4/ogSRCL, gainsAdjustment[4]*factor4/ogSRCL)) print(" | SRCL: {:5.4} * {:12.6} = {:12.6} |".format(gainsAdjustment[4],factor4/ogSRCL, gainsAdjustment[4]*factor4/ogSRCL))
print(" `--------------------------------------------------'")
def generate_lock_block(self, kat, verbose=False):
if self.lockNames == None or self.lockAccuracies == None or self.lockGains == None:
raise pkex.BasePyKatException("run gerate_locks before generate_lock_block")
code1 = """
%%% FTblock locks
###########################################################################
set AS_f2_I_re {} re
set CARM_err {} re
set PRCL_err {} re
set MICH_err {} re
set SRCL_err {} re
func DARM_err = $AS_f2_I_re - {}
""".format(self.lockNames[0], self.lockNames[1], self.lockNames[2], self.lockNames[3], self.lockNames[4], self.DCoffsetW)
code2 = """
lock DARM_lock $DARM_err {:8.2} {:8.2}
lock CARM_lock $CARM_err {:8.2g} {:8.2g}
lock PRCL_lock $PRCL_err {:8.2g} {:8.2g}
lock MICH_lock $MICH_err {:8.2g} {:8.2g}
lock SRCL_lock $SRCL_err {:8.2g} {:8.2g}""".format(self.lockGains[0], self.lockAccuracies[0], self.lockGains[1], self.lockAccuracies[1], self.lockGains[2], self.lockAccuracies[2], self.lockGains[3], self.lockAccuracies[3], self.lockGains[4], self.lockAccuracies[4])
code3 = """
noplot ITMY_lock
func ITMY_lock = (-1.0) * $MICH_lock
func ETMX_lock = $CARM_lock + $MICH_lock + $DARM_lock
func ETMY_lock = $CARM_lock - $MICH_lock - $DARM_lock
put* PRM phi $PRCL_lock
put* ITMX phi $MICH_lock
put* ITMY phi $ITMY_lock
put* ETMX phi $ETMX_lock
put* ETMY phi $ETMY_lock
put* SRM phi $SRCL_lock
noplot PRCL_lock
noplot SRCL_lock
noplot MICH_lock
noplot DARM_lock
noplot CARM_lock
noplot ETMX_lock
noplot ETMY_lock
###########################################################################
%%% FTend locks"""
if verbose:
print(" .--------------------------------------------------.")
print(" | Lock commands used: |")
print(" +--------------------------------------------------+") print(" +--------------------------------------------------+")
print(" | -- lock commands used: |")
for l in code2.splitlines(): for l in code2.splitlines():
print (" | {:49}|".format(l)) print (" | {:49}|".format(l))
print(" `--------------------------------------------------'") print(" `--------------------------------------------------'")
return "".join([code1, code2, code3]) return "".join([code1, code2, code3])
# --------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------
......
Supports Markdown
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