diff --git a/README.md b/README.md index b6214a3157ff47df6b23af5b9fea69b6e0a38144..0042803cbda6b05dac34d5c8ecd3fe5c49fa2ca4 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Currently it supports the following functions (feel free to add more): - 2D-mix-LP - 2D-mix-SP - PW-OPO-BB +- 2D-cav-LP - Focus diff --git a/snlohelper/main_window.py b/snlohelper/main_window.py index 6ed97fdfb6f885e95d90e032fc87a70b97db2cff..7fdd9f581a319bfb2d0b6a34e146ce81a188274d 100644 --- a/snlohelper/main_window.py +++ b/snlohelper/main_window.py @@ -35,6 +35,7 @@ from .two_d_mix_lp import TwoDMixLP from .two_d_mix_sp import TwoDMixSP from .q_mix import QMix from .pw_opo_bb import PW_OPO_BB +from .two_d_cav_lp import TwoDCavLP function_classes = { @@ -43,6 +44,7 @@ function_classes = { Functions.TWOD_MIX_LP: TwoDMixLP, Functions.TWOD_MIX_SP: TwoDMixSP, Functions.PW_OPO_BB: PW_OPO_BB, + Functions.TWOD_CAV_LP: TwoDCavLP, Functions.FOCUS: Focus, } @@ -73,7 +75,7 @@ class MainWindow: def open_refractive_index(self) -> RefractiveIndex: return self._open_function(RefractiveIndex) - + def open_q_mix(self) -> QMix: return self._open_function(QMix) @@ -82,9 +84,12 @@ class MainWindow: def open_two_d_mix_sp(self) -> TwoDMixSP: return self._open_function(TwoDMixSP) - + def open_pw_opo_bb(self) -> PW_OPO_BB: return self._open_function(PW_OPO_BB) + def open_two_d_cav_lp(self) -> TwoDCavLP: + return self._open_function(TwoDCavLP) + def open_focus(self) -> Focus: return self._open_function(Focus) diff --git a/snlohelper/two_d_cav_lp.py b/snlohelper/two_d_cav_lp.py new file mode 100644 index 0000000000000000000000000000000000000000..482d17771460865e86ac326f93cf619efb999f7d --- /dev/null +++ b/snlohelper/two_d_cav_lp.py @@ -0,0 +1,70 @@ +# MIT License + +# Copyright (c) 2024 Benedikt Burger + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +from .main_window import Functions +from .mix_methods import MixMethods + + +class TwoDCavLP(MixMethods): + """The '2D-cav-LP' method.""" + + _function = Functions.TWOD_CAV_LP + _accept_pos = (480, 537) + _run_pos = (148, 275) + _result_pos = (148, 357) + _change_inputs_pos = (157, 310) + _close_pos = (480, 135) + _configuration_pos = {"Wavelengths (nm)": [(330, 151), (397, 151), (464, 151)], + "Indexes of refraction": [(330, 167), (397, 167), (464, 167)], + "Crystal left reflectivity": [(330, 183), (397, 183), (464, 183)], + "Crystal right reflectivity": [(330, 199), (397, 199), (464, 199)], + "Crystal loss (per mm)": [(330, 215), (397, 215), (464, 215)], + "Enrgy/Pwr left (J/W)": [(330, 231), (397, 231), (464, 231)], + "Enrgy/Pwr right (J/W)": [(330, 247), (397, 247)], + "Pulse duration (FWHM ns)": [(330, 263), (397, 263), (464, 263)], + "Pulse delay (ns)": [(330, 279), (397, 279)], + "Beam diameter (FWHM mm)": [(330, 295), (397, 295), (464, 295)], + "Supergaussian coefficient": [(330, 311), (397, 311), (464, 311)], + "Walk off angle (mard)": [(330, 327), (397, 327), (464, 327)], + "Beam offset (mm)": [(397, 343), (464, 343)], + "Beam radius of curv. (mm)": [(330, 359), (397, 359), (464, 359)], + "Left mirror reflectivity": [(330, 375), (397, 375), (464, 375)], + "Right mirror reflectivity": [(330, 391), (397, 391), (464, 391)], + "Phase L-C (radians)": [(330, 407), (397, 407), (464, 407)], + "Phase C-R (radians)": [(330, 423), (397, 423), (464, 423)], + "Phase R-L (radians)": [(330, 439), (397, 439), (464, 439)], + "Mirror roc L R (mm)": [(330, 463), (397, 463)], + "Dist. L-C C-R R-L (mm)": [(330, 479), (397, 479), (464, 479)], + "Grid numbers z x y": [(330, 495), (397, 495), (464, 495)], + "Crystal/grid sizes (mm)": [(330, 511), (397, 511), (464, 511)], + "Cavity type/inversion": [(330, 527), (397, 527)], + "Deff (pm/V)/delta k (1/mm)": [(330, 543), (397, 543)]} + + def interpret_results(self, rows: list[str]) -> dict[str, float | list[float]]: + """Interpret the results.""" + return { + "Right input (W W -)": [float(i) for i in rows[0].split()[6:]], + "Left input (W W J)": [float(i) for i in rows[1].split()[6:]], + "Left output energy (J)": [float(i) for i in rows[2].split()[5:]], + "Right output energy (J)": [float(i) for i in rows[3].split()[5:]], + "So (W/sq cm)": float(rows[4].split()[4]), + }