Commit b5652d71 authored by bliss administrator's avatar bliss administrator
Browse files

First version of triple monochromator.

Started to test motor movements.
parent 6fa446d1
#
# Diode configuration
#
- name: Diode
plugin: bliss
class: BboxDiode
package: id19.mono.bboxdiode
# Positioning
motors: [$ymon, $zmon]
in_pos: [0, 50]
out_pos: [70, 197]
This diff is collapsed.
#
# ID19 Monochromator configuration
# Triple monochromator with three crytal pairs
#
name: TripleMono
plugin: bliss
class: Id19Mono
package: id19.mono.id19mono
xtals:
- xtal_name: Si111
- xtal_name: Si333
# motors
X2: $vmx2
Y1: $vmy1
Y2: $vmy2
Z1: $vmz1
Z2: $vmz2
THY1: $thy1
THY2: $thy2
beam_stop: $bstop
slits_vgap: $ssvg
laue_THY2_offset: -0.245
laue_THY1_offset: 0.0015
X2_safe_position: 400
beam_stop_in_pos: 0
beam_stop_out_pos: -45
xtal_size: 300
stabilization_time: 3 #sec
# mode parameters
bragg_mode:
- description: 'Crystal1: Bragg - Crystal2: Bragg (E: 10-99 offset: 50 mm)'
min_energy: 10
max_energy: 99
beam_offset: 50
Y1_pos: 0
Y2_pos: 0
laue_mode_50:
- description: 'Crystal1: Laue - Crystal2: Laue (E: 25-99 offset: 50 mm)'
min_energy: 25
max_energy: 99
beam_offset: 50
Y1_pos: 186.0
Y2_pos: 186.0
laue_mode_24:
- description: 'Crystal1: Laue - Crystal2: Laue (E: 55-200 offset: 24 mm)'
min_energy: 55
max_energy: 200
beam_offset: 24
Y1_pos: 186.0
Y2_pos: 186.0
white_beam:
- description: 'Monochromator removed, parked in safe position'
Y1_pos: 0
Y2_pos: 0
#Z1_pos: -29
Z1_pos: -2.9
Z2_pos: 50
import math
from bliss.physics.units import ur
from bliss.physics.diffraction import CrystalPlane
"""
- class: DCMenergy
# Fix exit geometry
dist_fix_exit: 0.01
dist_xtal_fjs0: 25
# Crystals parameters
xtal1: Si111
xtal2: Si311
"""
class MonochromatorBase(object):
def __init__(self, name, config):
# keep config node
self.config_node = config
## Fix exit Geometry
#self.fix_exit_offset = self.config_node.get("fix_exit_offset")
self.fix_exit_offset = None
self.xtal_sel = None
# Crystals parameters
xtals = self.config_node.get("xtals")
self.xtal_names = []
self.xtal = {}
for xtali in range(len(xtals)):
name = xtals[xtali]["xtal_name"]
self.xtal_names.append(name)
self.xtal[name] = CrystalPlane.fromstring(name)
########################
#
# Fix Exit Monochromator
#
@property
def fix_exit(self):
if self.fix_exit_offset == None:
raise RuntimeError("Monochromator Base: No fix exit offset given!")
return self.fix_exit_offset
@fix_exit.setter
def fix_exit(self, value):
self.fix_exit_offset = value
#self.config_node["fix_exit_offset"] = value
#self.config_node.save()
def set_crystal(self, crystal):
if crystal in self.xtal_names:
self.xtal_sel = crystal
else:
self.xtal_sel = None
raise RuntimeError("Monochromator Base: Crystal (%s) not configured" % crystal)
def get_crystal(self):
if self.xtal_sel == None:
raise RuntimeError("Monochromator Base: No crystal selected!")
return self.xtal_sel
#####################
#
# Calculation methods
#
def energy2bragg(self, ene):
if self.xtal_sel == None:
raise RuntimeError("Monochromator Base: No crystal selected!")
xtal = self.xtal[self.xtal_sel]
bragg = xtal.bragg_angle(ene*ur.keV).to(ur.deg).magnitude
return(bragg)
def bragg2energy(self, bragg):
if self.xtal_sel == None:
raise RuntimeError("Monochromator Base: No crystal selected!")
xtal = self.xtal[self.xtal_sel]
energy = xtal.bragg_energy(bragg*ur.deg).to(ur.keV).magnitude
return energy
def bragg2dxtal(self, bragg):
if self.fix_exit_offset == None:
raise RuntimeError("Monochromator Base: No fix exit offset given!")
dxtal = self.fix_exit_offset / (2.0 * math.cos(math.radians(bragg)))
return dxtal
def energy2dxtal(self, ene):
if self.fix_exit_offset == None:
raise RuntimeError("Monochromator Base: No fix exit offset given!")
bragg = xtal.bragg_angle(ene*ur.keV).to('deg').magnitude
dxtal = self.fix_exit_offset / (2.0 * math.cos(math.radians(bragg)))
return dxtal
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