Beispiel #1
0
def plot(pp, mm):
    from matplotlib import pyplot as plt

    ba.plot_simulation_result(pp, postpone_show=True)
    plt.semilogy(mm.axis(), mm.array())
    plt.legend(['Up-Up', 'Down-Down'], loc='upper right')

    plt.show()
Beispiel #2
0
def plot_data():
    """
    Load data and plot results
    """
    data = load_data(f65569)
    plt.figure(figsize=(10, 10))
    ba.plot_simulation_result(data,
                              units=ba.AxesUnits.QSPACE,
                              intensity_min=0.1,
                              intensity_max=8e+01)
    plt.show()
def plot(result_wl, result_qz):
    """
    Plots data for several selected layers
    """

    ba.plot_simulation_result(result_qz, postpone_show=True)

    plt.semilogy(result_wl.axis(), result_wl.array(), 'ko', markevery=10)
    plt.legend([r'$q_z$-defined beam', r'$\lambda$-defined beam'],
               loc='upper right')

    plt.show()
Beispiel #4
0
def plot(results):
    """

    :param results:
    :return:
    """
    from matplotlib import pyplot as plt

    ba.plot_simulation_result(results, postpone_show=True)

    genx_axis, genx_values = create_real_data()

    plt.semilogy(genx_axis, genx_values, 'ko', markevery=300)
    plt.legend(['BornAgain', 'GenX'], loc='upper right')

    plt.show()
Beispiel #5
0
    simulation.setSample(sample)
    # set region of interest in mm
    simulation.setRegionOfInterest(150.0, 390.0, 520.0, 650.0)
    # uncomment lines below to add the beam divergence
    # beware: this will increase the simulation time a lot!
    # wavelength_distr = ba.DistributionLogNormal(wavelength*angstrom, 0.2*wavelength*angstrom)
    # alpha_distr = ba.DistributionGaussian(ai * deg, 0.05 * deg)
    # phi_distr = ba.DistributionGaussian(0.0 * deg, 0.15 * deg)
    # simulation.addParameterDistribution("*/Beam/Wavelength", wavelength_distr, 5)
    # simulation.addParameterDistribution("*/Beam/InclinationAngle", alpha_distr, 3)
    # simulation.addParameterDistribution("*/Beam/AzimuthalAngle", phi_distr, 5)
    # options
    # simulation.getOptions().setUseAvgMaterials(True)   # does not work for the microgel FF in 1.11
    simulation.getOptions().setIncludeSpecular(True)  # include specular peak
    simulation.getOptions().setNumberOfThreads(
        -1)  # custom FF can be calculaten only in a single thread
    simulation.setTerminalProgressMonitor()  # show progress

    simulation.runSimulation()  # run simulation
    return simulation.result()  # return result


if __name__ == '__main__':
    result = run_simulation()
    # to save the simulated matrix to a file, uncomment the line below
    # np.savetxt(sim_datafile, result.histogram2d(ba.AxesUnits.QSPACE).getArray())
    ba.plot_simulation_result(result,
                              units=ba.AxesUnits.QSPACE,
                              intensity_min=1.0e-05,
                              intensity_max=0.2)
Beispiel #6
0
    multilayer = ba.MultiLayer()
    multilayer.addLayer(l_air)
    multilayer.addLayer(l_substrate)
    # print(multilayer.parametersToString())
    return multilayer


def get_simulation():
    simulation = ba.GISASSimulation()
    simulation.setDetectorParameters(400, -2.0 * deg, 2.0 * deg, 400,
                                     0.0 * deg, 3.0 * deg)

    simulation.setBeamParameters(0.1 * nm, 0.2 * deg, 0.0 * deg)
    simulation.setBeamIntensity(1.0e+06)
    # simulation.getOptions().setMonteCarloIntegration(True, 20)  # uncomment for large mesocrystals
    simulation.setTerminalProgressMonitor()
    return simulation


def run_simulation():
    sample = get_sample()
    simulation = get_simulation()
    simulation.setSample(sample)
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__':
    result = run_simulation()
    ba.plot_simulation_result(result, intensity_max=1e+06)
    Returns an off-specular simulation with beam and detector defined.
    """
    simulation = ba.OffSpecSimulation()
    simulation.setDetectorParameters(20, phi_f_min * deg, phi_f_max * deg, 200,
                                     alpha_f_min * deg, alpha_f_max * deg)
    # define the beam with alpha_i varied between alpha_i_min and alpha_i_max
    alpha_i_axis = ba.FixedBinAxis("alpha_i", 200, alpha_i_min * deg,
                                   alpha_i_max * deg)
    simulation.setBeamParameters(1.0 * angstrom, alpha_i_axis, 0.0 * deg)
    simulation.setBeamIntensity(1e9)
    return simulation


def run_simulation():
    """
    Runs simulation and returns intensity map.
    """
    sample = get_sample()
    simulation = get_simulation()
    simulation.setSample(sample)
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__':
    result = run_simulation()
    ba.plot_simulation_result(result,
                              intensity_min=1.0,
                              cmap='jet',
                              aspect='auto')
        multi_layer.addLayer(ni_layer)
    multi_layer.addLayer(substrate_layer)

    return multi_layer


def get_simulation(scan_size=500):
    """
    Defines and returns a specular simulation.
    """
    simulation = ba.SpecularSimulation()
    scan = ba.AngularSpecScan(1.54 * angstrom, scan_size, 0.0 * deg, 2.0 * deg)
    simulation.setScan(scan)
    return simulation


def run_simulation():
    """
    Runs simulation and returns its result.
    """
    sample = get_sample()
    simulation = get_simulation()
    simulation.setSample(sample)
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__':
    results = run_simulation()
    ba.plot_simulation_result(results, c='k')
Beispiel #9
0
    multi_layer.addLayer(substrate_layer)
    return multi_layer


def get_simulation():
    """
    Create and return GISAXS simulation with beam and detector defined
    """
    simulation = ba.GISASSimulation()
    simulation.setDetectorParameters(200, -1.0*deg, 1.0*deg,
                                     200, 0.0*deg, 2.0*deg)
    simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg)
    simulation.getOptions().setMonteCarloIntegration(True, 100)
    return simulation


def run_simulation():
    """
    Runs simulation and returns intensity map.
    """
    simulation = get_simulation()
    simulation.setSample(get_sample())
    simulation.setTerminalProgressMonitor()
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__':
    result = run_simulation()
    ba.plot_simulation_result(result, 1e-03)
Beispiel #10
0
    """
    simulation = ba.GISASSimulation()
    simulation.setBeamParameters(wl * ba.angstrom, alpha_i * ba.deg,
                                 0.0 * ba.deg)
    simulation.setDetector(create_detector())
    simulation.setBeamIntensity(beam_intensity)
    return simulation


def run_simulation():
    """
    Runs simulation and returns resulting intensity map.
    """
    sample = get_sample()
    simulation = get_simulation(wavelength)
    simulation.setDetectorResolutionFunction(
        ba.ResolutionFunction2DGaussian(2.0 * psize, 1.0 * psize))
    simulation.setSample(sample)
    simulation.setRegionOfInterest(20, 400, 650, 650)
    # options
    simulation.getOptions().setUseAvgMaterials(True)
    #simulation.getOptions().setIncludeSpecular(True)
    simulation.setTerminalProgressMonitor()
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__':
    result = run_simulation()
    ba.plot_simulation_result(result, units=ba.AxesUnits.QSPACE)
Beispiel #11
0
        roughness = ba.LayerRoughness(sigma, 0.5, 10.0*nm)
        multiLayer_1.addLayerWithTopRoughness(layer_2, roughness)
        multiLayer_1.addLayer(layer_3)
    multiLayer_1.addLayerWithTopRoughness(layer_4, layerRoughness_1)
    return multiLayer_1


def get_simulation():
    simulation = ba.OffSpecSimulation()
    simulation.setDetectorParameters(10, -1.0*deg, 1.0*deg, 100, 0.0*deg, 5*deg)
    
    simulation.setDetectorResolutionFunction(ba.ResolutionFunction2DGaussian(0.005*deg, 0.005*deg))
    alpha_i_axis = ba.FixedBinAxis("alpha_i", 100, 0.0*deg, 5*deg)
    simulation.setBeamParameters(0.154*nm, alpha_i_axis, 0.0*deg)
    simulation.setBeamIntensity(1.0e+08)
    simulation.getOptions().setIncludeSpecular(True)
    return simulation


def run_simulation():
    sample = get_sample()
    simulation = get_simulation()
    simulation.setSample(sample)
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__': 
    result = run_simulation()
    ba.plot_simulation_result(result, intensity_max=10.0)
Beispiel #12
0
    # Defining detector
    simulation.setDetectorParameters(200, -3.0*deg, 3.0*deg, 200, -3.0*deg, 3.0*deg)

    # Defining beam parameters
    simulation.setBeamParameters(0.5*nm, 0.0*deg, 0.0*deg)
    simulation.setBeamIntensity(1e12)

    # Defining beam polarization and polarization analysis for spin-flip channel
    analyzer_dir = kvector_t(0.0, 0.0, -1.0)
    beampol = kvector_t(0.0, 0.0, 1.0)
    simulation.setBeamPolarization(beampol)
    simulation.setAnalyzerProperties(analyzer_dir, 1.0, 0.5)

    return simulation


def run_simulation():
    """
    Runs simulation and returns intensity map.
    """
    simulation = get_simulation()
    simulation.setSample(get_sample())
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__': 
    result = run_simulation()
    ba.plot_simulation_result(result, cmap='jet', units=ba.AxesUnits.QSPACE,
                              aspect='auto')
Beispiel #13
0
    n_scan_points, alpha_i_min, alpha_i_max = n_alpha, alpha_min, alpha_max
    alpha_i_axis = ba.FixedBinAxis("alpha_i", n_scan_points, alpha_i_min,
                                   alpha_i_max)
    simulation.setBeamParameters(5.0 * angstrom, alpha_i_axis, 0.0)

    simulation.setBeamIntensity(1e9)
    simulation.getOptions().setIncludeSpecular(True)

    # define detector resolution function with smearing depending on bin size
    d_alpha = (alpha_max - alpha_min) / n_alpha
    d_phi = (phi_max - phi_min) / n_phi
    sigma_factor = 1.0
    simulation.setDetectorResolutionFunction(
        ba.ResolutionFunction2DGaussian(sigma_factor * d_alpha,
                                        sigma_factor * d_phi))

    return simulation


def run_simulation():
    sample = get_sample(nlayers=3)
    simulation = get_offspec_simulation()
    simulation.setSample(sample)
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__':
    result = run_simulation()
    ba.plot_simulation_result(result, intensity_min=1e-03)
Beispiel #14
0
    n_scan_points, alpha_i_min, alpha_i_max = n_alpha, alpha_min, alpha_max
    alpha_i_axis = ba.FixedBinAxis("alpha_i", n_scan_points, alpha_i_min,
                                   alpha_i_max)
    simulation.setBeamParameters(5.0 * angstrom, alpha_i_axis, 0.0)

    simulation.setBeamIntensity(1e9)
    simulation.getOptions().setIncludeSpecular(True)

    # define detector resolution function with smearing depending on bin size
    d_alpha = (alpha_max - alpha_min) / n_alpha
    d_phi = (phi_max - phi_min) / n_phi
    sigma_factor = 1.0
    simulation.setDetectorResolutionFunction(
        ba.ResolutionFunction2DGaussian(sigma_factor * d_alpha,
                                        sigma_factor * d_phi))

    return simulation


def run_simulation():
    sample = get_sample(nlayers=3)
    simulation = get_offspec_simulation()
    simulation.setSample(sample)
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__':
    result = run_simulation()
    ba.plot_simulation_result(result, zmin=1e-03)
Beispiel #15
0
    multi_layer.addLayer(substrate_layer)
    print(multi_layer.treeToString())
    return multi_layer


def get_simulation():
    """
    Returns a GISAXS simulation with beam and detector defined.
    """
    simulation = ba.GISASSimulation()
    simulation.setDetectorParameters(100, -1.0 * deg, 1.0 * deg, 100,
                                     0.0 * deg, 2.0 * deg)
    simulation.setBeamParameters(1.0 * angstrom, 0.2 * deg, 0.0 * deg)
    simulation.setBeamIntensity(1.0e+08)
    return simulation


def run_simulation():
    """
    Runs simulation and returns resulting intensity map.
    """
    simulation = get_simulation()
    simulation.setSample(get_sample())
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__':
    result = run_simulation()
    ba.plot_simulation_result(result, cmap='jet', aspect='auto')
Beispiel #16
0
                                     alpha_f_min * deg, alpha_f_max * deg)
    # define the beam with alpha_i varied between alpha_i_min and alpha_i_max
    alpha_i_axis = ba.FixedBinAxis("alpha_i", 400, alpha_i_min * deg,
                                   alpha_i_max * deg)
    simulation.setBeamParameters(5.23 * angstrom, alpha_i_axis, 0.0 * deg)
    # setBeamParameters(wavelength, alpha_i, phi_i)
    simulation.setBeamIntensity(1e11)
    return simulation


def run_simulation(bilayers, interfacewidth, crosscorrlength, lattcorrlength):
    """
    Runs simulation and returns intensity map.
    """
    sample = get_sample(bilayers, interfacewidth, crosscorrlength,
                        lattcorrlength)
    print("Running simulation")
    simulation = get_simulation()
    simulation.setSample(sample)
    simulation.runSimulation()
    arr = simulation.result().array()
    #    numpy.savetxt("crossinf_Latt10000_H080_N52_s08.txt", arr)
    #   ba.plot_simulation_result(result, intensity_min=0.1)
    return simulation.result()


if __name__ == '__main__':
    result = run_simulation()
    print(result)
    ba.plot_simulation_result(result, intensity_min=0.1)
    qzs = np.linspace(0.01, 1.0, scan_size)  # qz-values
    dq = 0.03 * qzs
    n_sig = 2.0
    n_samples = 25

    distr = ba.RangedDistributionGaussian(n_samples, n_sig)

    scan = ba.QSpecScan(qzs)
    scan.setAbsoluteQResolution(distr, dq)

    simulation = ba.SpecularSimulation()
    simulation.setScan(scan)

    return simulation


def run_simulation():
    """
    Runs simulation and returns its result.
    """
    sample = get_sample()
    simulation = get_simulation()
    simulation.setSample(sample)
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__':
    result = run_simulation()
    ba.plot_simulation_result(result)
Beispiel #18
0
def get_simulation():
    """
    Returns an off-specular simulation with beam and detector defined.
    """
    simulation = ba.OffSpecSimulation()
    simulation.setDetectorParameters(20, phi_f_min * deg, phi_f_max * deg, 200,
                                     alpha_f_min * deg, alpha_f_max * deg)
    # define the beam with alpha_i varied between alpha_i_min and alpha_i_max
    alpha_i_axis = ba.FixedBinAxis("alpha_i", 200, alpha_i_min * deg,
                                   alpha_i_max * deg)
    simulation.setBeamParameters(1.0 * angstrom, alpha_i_axis, 0.0 * deg)
    simulation.setBeamIntensity(1e9)
    return simulation


def run_simulation():
    """
    Runs simulation and returns intensity map.
    """
    sample = get_sample()
    simulation = get_simulation()
    simulation.setSample(sample)
    simulation.runSimulation()
    return simulation.result()


if __name__ == '__main__':
    result = run_simulation()
    ba.plot_simulation_result(result, zmin=1.0)