Пример #1
0
import math
import numpy
import timeit
import time
from matplotlib import pyplot as plt
import scipy.optimize

from PyXMRTool import SampleRepresentation
from PyXMRTool import Parameters
from PyXMRTool import Experiment
from PyXMRTool import Fitters

### ALL LENGTHES ARE MEASURED IN Angstroem!!!!

#### create ParameterPool #####################################################################
pp = Parameters.ParameterPool("parameters.txt")
#pp=Parameters.ParameterPool()

#some Parameters which are used later on
mdensity_SrTiO3 = pp.newParameter(
    "mdensity_SrTiO3")  #mass density of the material in g/cm^3
mdensity_SrRuO3 = pp.newParameter("mdensity_SrRuO3")
mdensity_LSMO = pp.newParameter("mdensity_LSMO")
#mdensity_MnO2=pp.newParameter("mdensity_MnO2")
mdensity_C = pp.newParameter(
    "mdensity_C")  #number density of C atoms in mol/cm^3

#some numbers
mol_mass_Sr = 87.62  #molar mass of elements  g/mol
mol_mass_Ti = 47.867
mol_mass_Ru = 101.07

base_energies = numpy.arange(500, 600, 2)


def ff_tensor(energy, *coeffs):
    """
    Model funtion for the formfactor tensor. Sum of ff_real and ff_imag on the diagonal elements.
    """
    ff = ff_real(energy, coeffs,
                 base_energies) + 1j * ff_imag(energy, coeffs, base_energies)
    return numpy.array([ff, 0, 0, 0, ff, 0, 0, 0, ff])


#generate parameters as coefficients
pp = Parameters.ParameterPool()
suffix = "ff_coeff_"
coeff_pars_list = [
    pp.newParameter(suffix + str(i)) for i in range(len(base_energies))
]

#generate parametrized Function
ff_tensor_parfunc = Parameters.ParametrizedFunction(ff_tensor,
                                                    *coeff_pars_list)

#generate Formfactor object with parametrized funtion
FF_Mn_fit = SampleRepresentation.FFfromFitableModel(ff_tensor_parfunc,
                                                    min(base_energies),
                                                    max(base_energies))

#generate parameter values for coeffients
Пример #3
0
from time import time
from scipy import constants 
import math
import numpy as np
from matplotlib import pyplot as plt

import Pythonreflectivity


from PyXMRTool import SampleRepresentation
from PyXMRTool import Parameters




pp=Parameters.ParameterPool("partest-samplerep.txt")


#one LayerObject

l=SampleRepresentation.LayerObject([pp.newParameter("chi_xx"),pp.newParameter("chi_xy"),pp.newParameter("chi_xz"),pp.newParameter("chi_yx"),pp.newParameter("chi_yy"),pp.newParameter("chi_yz"),pp.newParameter("chi_zx"),pp.newParameter("chi_zy"),pp.newParameter("chi_zz")],pp.newParameter("d"),Parameters.Parameter(0))




print("One Layer")
ar,lower,upper=pp.getStartLowerUpper()

print("Sigma: " +str(l.getSigma(ar)))

print("D: "+str(l.getD(ar)))
Пример #4
0
        0] * scipy.constants.physical_constants["speed of light in vacuum"][
            0] / 1e-10  #ev times Angstroem


#helper functions
def Lorentzian(a, s, t, x):
    return a * s / (s * s + (t - x)**2)


##This one here is important if you want to parallelize python in windows.
##This code will only be executed in the mother process.
if __name__ == '__main__':

    #####################################################################################
    #create a pool which handles all fitparameters (and connect it to a Parameter File)
    pp = Parameters.ParameterPool("parameters.txt")

    #####################################################################################
    ####  set up the MODEL for the sample
    # it should consist of three layers: substrate, layer and cap
    # substrate has a fixed susceptibility, the layers suscept is energy-dependent and fitted and cap has a constant but fitted suscept. For further paramters see below.

    #create a Heterostructur object as sample representation, with 3 layers
    hs = SampleRepresentation.Heterostructure(3)

    ##substrate
    chi_substrate = Parameters.Parameter(
        -0.0005 + 0.0005j
    )  #set fixed,isotropic and constant chi as instance of the Parameter class
    substrate_roughness = pp.newParameter(
        "substrate_roughness"
Пример #5
0
from PyXMRTool import Parameters
from PyXMRTool import SampleRepresentation




#############################
#Model Parameters (not fitted!!)
#############################
#all lengths in nm
transzone_thickness = 100     #thickness of the transition zone
lattice_const = 0.52            #assume cubic
#############################


pp=Parameters.ParameterPool("partest_experiment_dens.txt")
#pp=Parameters.ParameterPool()
fitpararray, lower, upper = pp.getStartLowerUpper()
#############################
#create fitparameters
#############################
total_thickness=pp.newParameter("total_thickness")
transition_pos=pp.newParameter("transition_pos")     #position of transition from Sr to Co measured in nm from top
transition_width=pp.newParameter("transition_width")  #width of transition (sigma in error function erf(z/sqrt(2)/sigma)
decay_depth=pp.newParameter("decay_depth")              #position at which the O density starts to decay, measured in nm from top
decay_rel_gradient=pp.newParameter("decay_rel_gradient")        #gradient of the decay (defined as positiv number)


#############################

#some calculations
Пример #6
0
import numpy
import scipy
import time
import types

from PyXMRTool import Experiment
from PyXMRTool import Parameters
from PyXMRTool import SampleRepresentation
from PyXMRTool import Fitters

if __name__ == '__main__':

    pp = Parameters.ParameterPool("partest.txt")

    #set up layer system
    #l=SampleRepresentation.LayerObject([pp.newParameter("chi_xx"),pp.newParameter("chi_xy"),pp.newParameter("chi_xz"),pp.newParameter("chi_yx"),pp.newParameter("chi_yy"),pp.newParameter("chi_yz"),pp.newParameter("chi_zx"),pp.newParameter("chi_zy"),pp.newParameter("chi_zz")],pp.newParameter("d"),Parameters.Parameter(0))
    l = SampleRepresentation.LayerObject([
        pp.newParameter("chi_xx"),
        pp.newParameter("chi_yy"),
        pp.newParameter("chi_zz")
    ], pp.newParameter("d"), Parameters.Parameter(0))

    ar = [33, 0.0094, -0.444]
    ar += list(range(36))

    hs = SampleRepresentation.Heterostructure(
        9, [0, 1, 2, [10, [3, 4, 5, 6]], 7, 8])

    for i in range(7):
        hs.setLayer(
            i,
Пример #7
0
import time
import math

from PyXMRTool import Parameters

pp = Parameters.ParameterPool("partest.txt")

parh = pp.newParameter("h", False, 56, 10, 100)

#pp.writeToFile("partest2.txt")

(s, l, u) = pp.getStartLowerUpper()

starttime = time.clock()
for i in range(1000):
    pp.newParameter("real" + str(i), False, i * 0.3, -5000, 5000)
for i in range(1000):
    pp.newParameter("complex" + str(i), False, i * 0.3j, -5000 * (1 + 1j),
                    5000 * (1 + 1j))
print("Creating paramters took " + str((time.clock() - starttime) / 5000) +
      " per parameter.")

#pp.writeToFile("partest3.txt")

starttime = time.clock()
(s, l, u) = pp.getStartLowerUpper()

print("Reading took " + str(time.clock() - starttime))

fitpararray = [i * 0.1 for i in range(3023)]
Пример #8
0
import timeit
import time
from matplotlib import pyplot as plt
import scipy.optimize


from PyXMRTool import SampleRepresentation
from PyXMRTool import Parameters
from PyXMRTool import Experiment
from PyXMRTool import Fitters

### ALL LENGTHES ARE MEASURED IN Angstroem!!!! 
    
#### create ParameterPool #####################################################################
#pp=Parameters.ParameterPool("parameters.txt")
pp=Parameters.ParameterPool()


#some Parameters which are used later on
mdensity_LSMO=pp.newParameter("mdensity_LSMO",fixed=True,start_val=6.5)    #mass density of the material in g/cm^3



#some numbers
mol_mass_Sr=87.62               #molar mass of elements  g/mol
mol_mass_Ti=47.867
mol_mass_Ru=101.07
mol_mass_O=15.999
mol_mass_Mn=54.938
mol_mass_C=12.011
mol_mass_La=138.91
Пример #9
0
import math
import numpy
import timeit
import time
from matplotlib import pyplot as plt
import scipy.optimize

from PyXMRTool import SampleRepresentation
from PyXMRTool import Parameters
from PyXMRTool import Experiment
from PyXMRTool import Fitters

#### create ParameterPool #####################################################################
pp = Parameters.ParameterPool("simplified-parameters.txt")
#pp=Parameters.ParameterPool()

#some Parameters which are used later on

suscept_SrTiO3 = pp.newParameter(
    "suscept_SrTiO3")  #mass density of the material in g/cm^3
suscept_SrRuO3 = pp.newParameter("suscept_SrRuO3")
suscept_LSMO = pp.newParameter("suscept_LSMO")
suscept_MnO2 = pp.newParameter("suscept_MnO2")
suscept_C = pp.newParameter(
    "suscept_C")  #number density of C atoms in mol/cm^3

#pp.writeToFile("simplified-parameters.txt")            #write parameter file to get nice layout after changing values
start, l, u = pp.getStartLowerUpper(
)  #read start values etc. to check for errors at beginnning of script

#####################################################################################################################################
import timeit
import time
from matplotlib import pyplot as plt
import scipy.optimize
import pickle


from PyXMRTool import SampleRepresentation
from PyXMRTool import Parameters
from PyXMRTool import Experiment
from PyXMRTool import Fitters

### ALL LENGTHES ARE MEASURED IN Angstroem!!!! 
    
#### create ParameterPool #####################################################################
pp=Parameters.ParameterPool("parameters.txt")
#pp=Parameters.ParameterPool()


#some Parameters which are used later on
mdensity_SrTiO3=pp.newParameter("mdensity_SrTiO3")    #mass density of the material in g/cm^3
mdensity_SrRuO3=pp.newParameter("mdensity_SrRuO3")
mdensity_LSMO=pp.newParameter("mdensity_LSMO")
mdensity_C=pp.newParameter("mdensity_C")      #number density of C atoms in mol/cm^3

#some numbers
mol_mass_Sr=87.62               #molar mass of elements  g/mol
mol_mass_Ti=47.867
mol_mass_Ru=101.07
mol_mass_O=15.999
mol_mass_Mn=54.938
Пример #11
0
from matplotlib import pyplot as plt

import Pythonreflectivity

from PyXMRTool import SampleRepresentation
from PyXMRTool import Parameters

#############################
#Model Parameters (not fitted!!)
#############################
#all lengths in nm
transzone_thickness = 100  #thickness of the transition zone
lattice_const = 0.52  #assume cubic
#############################

pp = Parameters.ParameterPool("fitparameters.txt")
#############################
#create fitparameters
#############################
total_thickness = pp.newParameter("total_thickness")
transition_pos = pp.newParameter(
    "transition_pos"
)  #position of transition from Sr to Co measured in nm from top
transition_width = pp.newParameter(
    "transition_width"
)  #width of transition (sigma in error function erf(z/sqrt(2)/sigma)
decay_depth = pp.newParameter(
    "decay_depth"
)  #position at which the O density starts to decay, measured in nm from top
decay_rel_gradient = pp.newParameter(
    "decay_rel_gradient")  #gradient of the decay (defined as positiv number)