Exemple #1
0
def getTransmission(ekev, ang):

    #params = load_params()

    refl_data = load_refl()
    refl = get_refl(refl_data, ekev, ang=ang)

    print("reflectivity: {}".format(refl))
    print("incidence angle: {} mrad".format(ang * 1e3))

    spb = Instrument()
    spb.adjust_mirror("HOM1", ekev=ekev, new_ang=ang)
    spb.build_elements(focus='nano')
    spb.build_beamline(focus='nano')

    spb.crop_beamline(element1="HOM1", element2="HOM1")

    bl = spb.get_beamline()

    wfr = define_wfr(ekev)

    i = np.sum(wfr.get_intensity())
    bl.propagate(wfr)
    f = np.sum(wfr.get_intensity())

    transmission = f / i
    print(transmission)
    return transmission, refl, ang
Exemple #2
0
    def adjust_mirror(self, mirror_name, ekev, new_ang, mirror_refl=None):

        if mirror_refl == None:
            if ekev >= 7.5:
                material = "B4C"
            else:
                material = "Ru"

            refl = get_refl(load_refl(material), ekev, new_ang)

        else:
            refl = mirror_refl

        new_ang = new_ang + np.tan(
            self.params[mirror_name]["xc"] /
            self.params[self.params[mirror_name]['next_drift']]['distance'])
        self.params[mirror_name]["incidence angle"] = new_ang
        self.params[mirror_name]['reflectivity'] = refl
Exemple #3
0
    def adjust_mirror(self, mirror_name, ekev, new_ang, mirror_refl=None):

        if mirror_refl is None:
            if ekev <= 7.5:
                material = "B4C"
            else:
                material = "Ru"

            refl = get_refl(load_refl(material), ekev, new_ang)

        new_ang = new_ang + np.tan(
            self.params[mirror_name]["xc"] /
            self.params[self.params[mirror_name]['next_drift']]['distance'])

        self.params[mirror_name]["design angle"] = new_ang
        self.params[mirror_name]["incidence angle"] = new_ang
        self.params[mirror_name]['reflectivity'] = (
            refl
        )  #**2 ### note, this maps to an absorption parameter (hence 1-refl)
Exemple #4
0
def setup_spb(parameter_file="../../../data/params/spb-sfx_nkb_FAST.json",
              options='nano',
              ekev=5.0,
              apertures=True,
              surface='real',
              crop=None,
              theta_HOM=2.3e-03,
              theta_KB=3.5e-03,
              save_params=False):
    """
    return desired beamline
    """

    spb = Instrument(parameter_file=parameter_file)

    mirrors = spb.mirrors

    spb.mirror_profiles(surface=surface, aperture=apertures)

    for mirror in mirrors:

        if mirror in spb.focus:
            spb.adjust_mirror(mirror, ekev, theta_KB)

        else:
            spb.adjust_mirror(mirror, ekev, theta_HOM)

    if ekev <= 7.5:
        material = "B4C"
    else:
        material = "Ru"

    if apertures == False:  ## aperture claus

        for mirror in mirrors:

            spb.params[mirror]["dx"] = 5
            spb.params[mirror]["dy"] = 5
            spb.params[mirror]["mirror profile"] = generate_infinite_mirror()

        for focus in spb.focus:

            spb.params[focus][
                "design angle"] = np.pi / 3  ### [A]s ## fix for now, should onkly accept elliptical mirrors
            spb.params[focus][
                "incidence angle"] = np.pi / 3  ### should be for elliptical mirror surfaces

    for mirror in mirrors:
        if mirror in spb.focus:
            spb.params[mirror]['reflectivity'] = get_refl(
                load_refl(material), ekev, theta_KB)
        else:
            spb.params[mirror]['reflectivity'] = get_refl(
                load_refl(material), ekev, theta_HOM)

    ### TO-DO: make a choice as to wether edits to the beamline will be via params or via beamline object
    ### TO-DO: eventually, exfel_spb should be a sub-class of the Instrument class (formally)
    ### TO-DO: a front-end script to load and label mirrors that ships to a json file would be useful.

    spb.build_elements(focus=options)
    spb.build_beamline(focus=options)

    if apertures == False and surface == 'flat':
        spb.remove_element("NVE_error")
        spb.remove_element("NHE_error")
        spb.remove_element("NKB_PSlit")

    if save_params:
        spb.export_params()

    if crop is not None:
        if type(crop) == list:
            spb.crop_beamline(*crop)
        else:
            spb.crop_beamline(crop)

    return spb