Skip to main content


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 [1] 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. [2] 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. [1] 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. [1], GitHub pages depends on certain version of packages (a link can be found there in Ref. [1] 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. [1], 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. [9]. 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


根据热力学第二定律的开尔文表述,不可能从单一热源吸热并全部用来做功而不引起其他变化,从这个角度完全可以说明为什么不能以海水为单一热源,从它获取源源不断的能量并用来做功。到这里似乎问题就已经结束了,但是如果海水并不是体系当中唯一的热源,除此之外还存在另外一个高温热源,如下图所示, 在这种情况下是否能实现通过让海水不断降温将热量传向高温热源从而源源不断的向外输出功?同理可以问类似的一个问题,能否将冰箱在制冷的过程中放出的热量收集起来然后带动热机对外做功,或者干脆带动冰箱自己来实现下一轮的制冷过程,从而实现冰箱自己带动自己制冷进而无限循环下去而不需要外界提供任何能量?两个问题的答案显然都是,不能。如图所示,左半部分代表的是冰箱制冷的过程(也可以代表海水降温向外放热的过程),这里实际上就是热力学第二定律的克劳修斯表述,要想实现热量从低温热源传向高温热源,外界是必须要做功的(图中\(W_1\)),右半部分对应的是从高温热源收集热量再用来驱动热机对外做功的过程,这里对应的是热力学第二定律的开尔文表述,在驱动热机做功的过程中,是必须要向低温热源(冰箱,或者海水)放出一定的热量的。如果想要实现上面所说的两个永动机,整个图示的过程综合起来最终要满足一个关系:\(W_2 > W_1\),因为只有这样才有有效的对外净输出。换句话说,如果这里提到的两个永动机能够对外输出的功还不够让低温热源降温所需要做的功(或者刚好能够提供低温热源降温所需要做的功),那么这个时候此类永动机根本不是“永动”的(因为它无法向外界输出有用功)。针对\(W_1=W_2\)的情况需要一点特殊说明,这个时候,上面提到的两个永动机理论上是可以“永动”的,只是无法向外界输出功。但是实际上这也是不可能的,因为热机在运转的过程中总是存在各种能量损耗,如果\(W_1 = W_2\),那么体系是没有多余的输出来抵消哪怕是丝毫的损耗的,这时永动机也就无法“永动”了。这有点类似于说物体在水平方向不受外力的情况下可以在水平绝对光滑的平面上一直运动下去的,但是实际上绝对光滑的平面是不存在的。同理,没有损耗的热机也是不存在的,因而\(W_1=W_2\)也是无法保证永动机“永动”的。 要满足\(W_2 > W_1\),总体上看,如图所示,这就相当于从高温热源放出了\((Q_2^{'} - Q_2) - (Q_1^{'

Notes on temperature

📌 Introduction - What is temperature? By temperature (\(T\)), we could mean simply the 'hotness' of something, i. e. as always the case in our daily life, the higher \(T\) of an object, the hotter it is. But in physics, when we say temperature, we could also mean a parameter that is shared between systems when they reach equilibrium, in terms of heat flow. Quite often, these two specific meanings of temperature agree with each other. For example, in terms of heat flow, the natural  (by which we mean no extra work needs to be done for it to happen, naturally ) direction of heat flow will always be from hotter object (thus with higher \(T\)) to colder (thus with lower \(T\)) one. As heat flows out of the hotter object, its temperature (now, we mean 'temperature' by its first definition as given above) will decrease, and vice versa for the colder object. This process will continue until these two objects in question reach equilibrium ‒ they now share the same temperature

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. [1]). Detailed theoretical description about SRO can be found in Refs. [1-3] - the early paper by J. M. Cowley [2] gives the definition of SRO for binary systems; the one by D.De Fontaine [3] 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