Skip to content

Motivation

canrong qiu edited this page May 22, 2021 · 1 revision

I have been dreaming of a user-friendly and powerful software for CTR fitting since 2010 when I embarked on CTR work as a PhD student at University of Alaska Fairbanks. Unlike many other X-ray techniques, eg. X-ray absorption spectroscopy, GISAXS, for which there are already numerous nice software from which you can pick to do the modeling work, the available software to fit CTR data are very limited. I started my PhD program with Prof. Tom Trainor in Alaska in 2010. My PhD project involved resolving metal binding mechanism on hematite(1-102) surface using CTR technique. To start with my CTR modeling, I first used ROD, which is written in C language. It runs fast, and it is still used by some groups nowadays, but the limitations of ROD are apparent. Firstly, it doesn’t have a GUI interface but works with a bunch of commands in terminal, which makes things obscure especially for beginners. In addition, it is cumbersome to start a model fit with ROD. Furthermore, it does not support constraints, eg. bond valence constraints, during the fit. The biggest drawback, in my opinion, is the fit algorithm that is based on non-linear least square routine, which comes up with solutions probably representing local minimum. After a while of using ROD, I learned of GenX software, which was first developed for fitting both X-ray/neutron reflectivity data. The functionality of the software had been extended to also fit CTR data afterwards. GenX was developed in Python scripting language by Matts Björck, who is now working for Swedish Nuclear and Fuel Management Company. Once I started using GenX, I could not leave it. The software is user-friendly with a wxPython-based GUI frame. It becomes very easy to get a good hand on it. In addition, GenX is equipped with a powerful fitting engine based on differential evolution algorithm, a global optimization algorithm aiming to find solutions of global minimum. The software is well written with highly modularizable functionalities, which can be extended and/or customized easily. GenX is fit for users of different levels. For beginners, you can always follow the logics while playing with the GUI widgets; for advanced users, you can customize the functionality accordingly to live up to your full potentials to accomplish different purpose. The transition from beginner to advanced user is a matter of time, which should be relatively short for a heavy user. The popularity of GenX is also represented in the citation of the first GenX paper (https://doi.org/10.1107/S0021889807045086). As of the date I wrote this manual, the paper had been cited by 492 times. It should be noted that the majority of those citing papers had focused on the modeling work relating to X-ray/neutron reflectivity data using GenX, while only a few papers reported their surface diffraction work that was assisted by GenX for model fitting.

I have been a heavy user of GenX until the end of my first postdoc position in HZDR in Dresden, Germany. Five CTR papers have been published, where I used GenX for CTR modeling work. Since I started my postdoc position in Kiel, I have been getting involved in several projects, which required a wealth of scripting work. Not long ago, I started playing with GUI programming based on PyQt5. Three GUI applications (CTR, XRV, PXRD, all shipped with DaFy) have been developed for processing synchrotron X-ray data. Having accumulated some GUI programing experience, I was amazed by the fact that how much better you feel when you use a program with a nice GUI compared to working with pure plain Python code files. GUI programming with PyQt5 is much simpler than I thought, and the signal/slot protocol employed in PyQt5 is not only simpler but also more efficient for signal transfer among GUI widgets compared to “callback” functions used in wxPython. I don’t intent to make detailed comparisons between PyQt5 and wxPython in terms of the performance for GUI programing, but there is a nice article if you want to learn more (https://opensource.com/article/17/4/pyqt-versus-wxpython). As said in the article, both have pros and cons, but I myself prefer the advantages PyQt5 has to those coming with wxPython. I can endure the disadvantages of PyQt5 without pain.

I realized the speed issue of wxPython-based GUI program when I was using GenX. That’s also the reason why I developed the mpi code to speed up the model running with GenX. I think the speed issue is partially due to the matplotlib widget, which is used in GenX for displaying meta-data during model fit. Matplotlib is good for its maturity having lots of API functions for plotting, and thus it is definitely a good choice when you want to produce high-quality figures. However, it is not the best choice when performance matters in applications like model fitting. In SuperRod, pyqtgraph package is used instead of matplotlib for displaying data. Except for the speed, I do like all the MVC (model-viewer-controller) concepts of GenX software design and also the powerful fitting engine. Realizing these, a glimpse of idea came to my mind one day, “How about equipping GenX’s powerful heart with a PyQt5-GUI shell to improve the performance?”. Since the fit engine is already hard coded in GenX, I only need to pull the program apart into pieces of modules, and re-assemble them into the new GUI shell. After around a few month of coding work, I made a brand new SuPerRod application with a PyQt5-based GUI, where all nice concepts found in GenX are maintained. More than just making a new skin, I optimized some central modules from bottom in SuPerRod, and some new features are implemented during the software development. Upon comparing the performance between SuPerRod and GenX, I have a strong feeling that SuPerRod runs much faster than GenX(>10 times faster). In a word, not only has SuPerRod inherited GenX’s central fitting engine, but also has it introduced a bunch of new features using new GUI frames based on PyQt5.

Clone this wiki locally