PPM

Pythonic Programming for Multilayers

Alessandro MIRONE

ESRF



Download and installation

This ftp link points to a download zone where you can find the binary packages you need and instruction to install easily PPM

Description of the packages

Once you have installed the packages, following the instruction found in the download zone, you can use the scalar and the magnetic version

of the PPM packages by running


/scisoft/ESRF_sw/linux_i386/PACKAGES/PPM/WRAPPERS/ppm


and


/scisoft/ESRF_sw/linux_i386/PACKAGES/PPM/WRAPPERS/ppmtens


respectively.


PPM is written in C for the low level, numerically time consuming, part, and in Python for the high level part.

It is possible to use PPM as a Library, describing syntactically your model with a set of high level python instruction, and this

methodology allows the most advanced use of PPM.

However the most common use of PPM is through the graphical interface.


This manual explains the utilisation of such a graphical interface for the newbyes.


The graphical interface used for PPM is a really original one. I have create such an interface to manipulate

graphically the Classes and Methods provided by the PPM library.


More in general, my original graphical interface ( that I called pyguibeans ), allows to manipulate graphically the functionalities of a

generic Python library, once a short description of classes and methods is provided to the interface in a suited format.


Of course I have already done the work for you, of exporting PPM library to pyguibeans, and the result is summarized by this screenshot .


Presentation of the interface

Click on this link todownload a very simple example. Open the examples ex1.bean with the Load Bean option of the File menu, using the scalar version ppm.


What you see now on the interface panel is:

The use of Variables

You describe your model creating objects and assembling them together. Objects are created giving them different kinds of parameters like filenames, float numbers or even previously defined objects . Float number parameters may be things like thicknesses, densities, energies and so on.

When you pass a float parameter to an object, you have the possibility, and a very useful one indeed, to give, instead of a float, an object of the class Variable.

Objects of such a class have a current value, a minimum and a maximum. They can enter in the definition of a model and can be given to the optimizing routines to be optimised

Following this link you can download a very simple example involving variables. Open the examples ex1.bean using the Load Bean option of the File menu, using the scalar version ppm.

The first line defines a Variable object. It is associate with the name a. ( Now go to the variables list panel , third window in first row, select the variable a, press <Enter>, and see what happens, you might need to tear to the left the columns of the panel to see the value of the variable that is shown on the right )

The second line is a dependent variable. See how it is defined. Read the help of its Class and that for its parameters. Go to the variable list panel, select the associated variable, press <Enter> and see what happens.

The remaining lines show how to create correlated variables like the partial densities of two different elements in a given compound. When you vary the compound density, the partial densities vary dependently, according to stechiometry.

Simulating Multilayers

This is after all a manual on a multilayer program, and you are eager to see a simulated scan. So let's pass to a concrete example without to much feedling about Classes, objects and other things.

I have prepared for you this beautiful example, ex2.bean that you can load using the Load Bean option of the File menu, using the scalar version ppm.

In the middle row, you can see, from top to bottom, the items composing the model :



t0=Dabax_f0_Table("f0_WaasKirf.dat",)

t12=Dabax_f1f2_Table("f1f2_Henke.dat",)

What is shown here are just the corresponding lines of code. However you dont have to deal with such lines. You can play with the interface, in particular you can get help clicking on the parameter entry forms. These lines are just an handy way to show you what is happening without producing screenshots. The same applies to the rest of this manual.

Dabax tables are in /scisoft/ESRF_sw/os_arch/PACKAGES/PPM/DATA.

Os_arch depends on what system you are working on( if you have the chance to get the suited distribution of PPM for you system)

fo_ind=IndexFromTable(t0,t12,"Fe",4.0,"O",2.0,)

alo_ind=IndexFromTable(t0,t12,"Al",2.0,"O",3.0,)

subst_ind=IndexFromTable(t0,t12,"Al",2.0,"O",3.0,)

As you see, the element names begin in upper-case. That depends on the naming scheme used in DATA directory ( Manolo's dabax files ) and you can check there in case of doubts.

feo_layer=PPM_SimpleLayer(thickness=10.0,roughness=5.0,material=fo_ind,)

alo_layer=PPM_SimpleLayer(thickness=10.0,roughness=6.0,material=alo_ind,)

subst_layer=PPM_SimpleLayer(thickness=0.0,roughness=6.0,material=alo_ind,)



bilayer=SumThings(alo_layer,feo_layer,)

NXbilayers=MultiplyAThing(10,bilayer,)

stack=SumThings(subst_layer,NXbilayers,)



scan0=ScanReader(wavelenghts_col=15.0,angles_col=[10.0,40,0.01 ],angle_factor=math.pi/180,)

scan1=ScanReader(wavelenghts_col=20.0,angles_col=[10.0,40,0.01 ],angle_factor=math.pi/180,)

A scan is alway a sequance of points, each one having a wavelenght, an angle (theta), a data,a statistical weight. These can be read from a file, weights are optional, but you can also synthetise scans as shown above. Data values dont matter in this case.

More scans can be specified like in this example.

In the next section we'll optimise fits. By now click the Just View button, see what happens, play with graph widgets using right mouse button to get a pop-up menu , and save the data to files. We'll use such files as experimental data to be fitted in the nex section.