## Posts

Showing posts from 2020

### Notes on magnetism III - Various physical quantities describing magnetic field

Talking about magnetic field, we have three relevant physical quantities - magnetic field $$\vec{H}$$, magnetic induction field $$\vec{B}$$ and magnetization field $$\vec{M}$$. It is straightforward to understand $$\vec{M}$$ - when applying magnetic field (here, by 'magnetic field', we mean something in general, but not specifically refer to $$\vec{H}$$), we use $$\vec{M}$$ to characterize how much the matter in question is magnetized. However, concerning $$\vec{H}$$ and $$\vec{B}$$, it seems that both are describing some sort of 'strength' of magnetic field (again, we mean 'magnetic field' in general. The same applies below until we become specific about what we mean by 'magnetic field'). But why do we have two quantities here to describe the 'same' thing? The answer is - they are not the same thing, as described by $$\vec{H}$$ and $$\vec{B}$$, respectively. Fundamentally, this goes back to the foundation of the electromagnetic theory - specific

### Why do we have spin half for electrons?

Illustration for Stern-Glach experiment  Angular moment means rotation - this applies to electron as well. For electrons, any movement is associated with current and therefore angular moment naturally is tightly linked to current as well. Furthermore, current means magnetic field, as originated by Orsted. Mathematically, starting from expressing the current with the angular moment of rotating electrons, followed by detailed mathematics based on Biot-Savart law (induction $$\vec{B}$$ as the function of current), one can arrive at the expression of magnetic induction in terms of magnetic (dipole) moment $$\vec{m}_l$$. In another word, it can be shown that the magnetic field generated by electron rotation current is equivalent to that generated by magnetic dipole, with the equivalent dipole moment defined as (see Ref.  for detailed derivation), $\vec{m}_l = -\frac{1}{2}eR^2\vec{\omega}$ Given that the angular moment can be written as $$\vec{l} = m_eR^2\vec{\omega}$$, we can obtain

### Notes on building site with Jekyll locally

One can follow Ref.  to build up site with Jekyll - it contains quite a few steps concerning the set-up of sites through GitHub pages. However, this is not necessary if one just wants to set up site locally and test. Therefore, after installing Ruby and Bundle, one can directly create a local folder and go into it. From there, one needs to follow the steps given below, Run bundle init  - this will create the Gemfile . According to Ref. , GitHub pages depends on certain version of packages (a link can be found there in Ref.  about details) and therefore one may need to install certain version of Jekyll with Bundle (though, again this may not be necessary if one only wants to do it locally). To install a certain version of Jekyll with Bundle, one need to put in the following line into Gemfile , gem 'jekyll', '3.9.0'  Then one needs to execute bundle install  to install the required version of Jekyll. At this stage if one continues, as instructed in Ref. , to e

### Notes on kernel density estimation (KDE)

With a collection of data, we may want to extract or estimate the underlying distribution model. For example, we have the collection of house price in a certain area, we want to have an idea about how the house price in that area is distributed. However, without a priori knowledge about what the model that distribution should follow, we cannot follow the so-called parameterized way for estimating the distribution. In that way, we know beforehand about what the distribution model should be and it's just some parameters yet need to be determined. Then we can do the commonly used least-square fitting to obtain those unknown parameters. However, it is usually the case where we have no knowledge about what the distribution model should look like, in which case we need a non-parameterized approach to estimate the underlying distribution, e.g. the histogram method and the one we are going to focus here: kernel density estimation (KDE). Here is the formulation of KDE, \[\hat{f}(x_0) = \fra

### Notes on setting up web host with Python Flask

☝Introduction We follow the tutorial given in Ref. [1, 2] for setting up the web host using Python Flask module. Details will not be reproduced in current blog step by step. Instead, we will focus on 1) some key aspects to make step description clearer and 2) steps where error can easily occur. First, we give all the necessary recipes, as follows, Flask - Python web server uWSGI - Sitting in the middle between Flask and Nginx for connection purpose. Nginx - Facing outwards to receive request. and we will configure the web host on CentOS 7. Traditionally, we have the web server hosts files in specific location on the server (e.g. /var/www) and then we will have, e.g. the Apache HTTP server to listen to user request (through a certain port, e.g. 80) and fetch certain files stored in specific location on the server and then send back to users' browser. When using Python to set up web host, we have one more layer for the connection between files on the server to be visited and users. T

### Notes on RSA algorithm

Image reproduced from Ref. . In this post, i will note down my learning and understanding for the RSA algorithm. This will not go into deep details about RSA. Instead, only basics will be covered. In fact, most of the discussion presented here has already been covered in the relevant Wiki page: Click Me ! Basically, I will just follow the Wiki page and put in my understanding along the way. Specially, when we go into the working example of RSA algorithm, detailed explanation about how the algorithm is realized in practice will be presented, with reference to some outstanding external resources. Finally, a bit understanding will be presented for why encryption and decryption through RSA algorithm is difficult or even impossible to decipher in practice and thus considered to be secure enough nowadays. ☝ Keys generation

### On occupational short-range ordering in crystal

When multiple atomic species (including vacancies) coexist on the same crystallographic site, it immediately brings up a question - say, we have species A and B sharing the same site, then do we have clustering of A and B in separate domains, or do we have A and B preferring to stay together, or do we have random distribution of A and B? This is usually what we mean by short-range order (SRO) and what we have mentioned here is specifically the occupational SRO (one can find introduction about more types of SRO in Chapter-10 in Ref. ). Detailed theoretical description about SRO can be found in Refs. [1-3] - the early paper by J. M. Cowley  gives the definition of SRO for binary systems; the one by D.De Fontaine  extends the definition to multi-component system (to give the so-called pairwise multi-component SRO, i. e. PM-SRO); the book by R. B. Neder and T. Proffen presents in details practical implementation and calculation of SRO, in DISCUS framework. Here I am not going to

### Sublime Text 3 - Key binding configuration issue

For many packages installed in Sublime Text 3, either we can configure the key bindings for executing available commands by going to 'Preferences' →'Key Bindings', or we can go to the package specific key binding setting section. However, sometimes, we don't have a dedicated key binding setting section for some of the installed package, e. g. 'Google Search' package. In this case, it becomes a headache to set the key binding since we don't even know what commands are actually available there. To get an idea about what commands are available for such types of packages, we can go to '%APPDATA%\Sublime Text 3\Installed Packages' directory (taking Windows OS as an example) and find the package file, e. g. 'Google Search.sublime-package'. This file is just a zip file which contains all the necessary stuff of the installed package. Therefore, we can copy it to somewhere and change the file name extension to '.zip' and open the package w

### When Fourier transform meets total scattering

In this article, I am going to note down my bits of understanding for the role that Fourier transform is playing in total scattering regime. Quite often we hear people talking about real space or reciprocal space representation of the total scattering signal. Also, it's probably a common sense that the two spaces are coupled by Fourier transform. But if pulling ourselves out of those technical details for the moment and think about why Fourier transform comes into play in total scattering regime in the first place, sometimes we may find ourselves in a situation like 'um...but...why?' Before diving into the specific total scattering topic, I will first mention a little bit background about Fourier transform. Here I will not try to reproduce details about it from head to toe, since obviously a simple Googling will guide us to tons of available resources about such a topic. Therefore, there is no need at all to reinvent the wheel. Instead, I will pick up a very interesting vis