Stand With Ukraine

Wednesday, April 2, 2025

Setting up a screen lock with i3 on lightdm

As you might know there are many basic things, which are done automatically for you by GNOME and KDE, you have to do with i3 window manager yourself. One such thing is the screen locking functionality. If you are using lightdm login manager then there is a nice way to make it in the following manner:

# install the light locker (for arch-based distros)
yay light-locker
  
# add the following lines to your ~/.config/i3/config
exec_always --no-startup-id /usr/bin/light-locker
bindsym $mod+l exec --no-startup-id light-locker-command --lock
The last line is needed to be able to lock the screen with $mod+l combination. My $mod=Win, so I get to lock my screen with Win+l.

What I like about this approach is that it brings you to the lightdm login window, which is how I expected the locking to behave before I started using i3.

Wednesday, March 26, 2025

Physics problem: Collapsing spherical cavity (bubble) in a water pond

Consider a collapsing spherical cavity in a large pond of water. The initial pressure of water in the pond is $P_0$, the initial radius of the cavity is $R_0$. Determine the speed of the edge of the cavity when its radius reaches $r_0$ ($r_0 < R_0$). The water density is $\rho$.

Note: The problem statement is translated (and slightly modified) from the original text in Savchenko et al 1981.

Discussion

I did not plan on writing up this problem as it seemed trivial to me at first. I thought, ok there is some kind of differential equation to compose and solve.

I tried to use the Newton's law and the energy conservation equation approaches but could not really get it.

I asked ChatGPT, and it came up with a solution based on the energy balance equation, the solution did resemble the correct one but it was off by a constant factor. ChatGPT mentioned the Rayleigh-Plesset equation which helped me to come up with my solution below. But here I decided to base the solution on the Newton's equation of motion to be able to present a self-contained solution, at least from my stand point.

Solution

Let's consider a water parcel at a distance $x$ from the center of the cavity $C$ (see the figure below).

No description has been provided for this image
Figure 1: Cross-section of collapsing cavity in a large pond. Dashed circles show positions of the cavity's edge when its sizes are $R_0, r, r_0$.

The pressure gradient will act to accelerate the parcel towards the point $C$.

\begin{equation} \rho \frac{dv}{dt} = -\frac{\partial P}{\partial x} \end{equation}

where $v=v(x, t)$ - is velocity of the water parcel at the distance $x$ from the center of the collapsing hollow cavity at time $t$.

We can express the derivative of $v(x(t), t)$ in the above equation by assuming that the parcell travels along a tragectory $x(t)$ and employing the compound function differentiation formula:

\begin{align*} \frac{dv}{dt} &= \frac{\partial v}{\partial t} + \frac{\partial v}{\partial x} \frac{d x}{d t} \\ &= \frac{\partial v}{\partial t} + v\frac{\partial v}{\partial x} \end{align*}

Therefore, the equation of motion takes the following form (this is also known as an Euler form of the equation of motion): \begin{align} \boxed{\frac{\partial v}{\partial t} + v\frac{\partial v}{\partial x} = -\frac{1}{\rho}\frac{\partial P}{\partial x}} \end{align}

Let's consider the continuity equation for the spheres with radii $x$ and $R_0$ and centered around the point $C$:

\begin{align*} & v(x, t) \cdot 4\pi x^2 = v(R_0, t) \cdot 4\pi R_0^2 & \Rightarrow \\ & v(x, t) \cdot x^2 = v(R_0, t) \cdot R_0^2 = F(t) & \Rightarrow \\ & \boxed{v(x, t) = \frac{F(t)}{x^2}} & \end{align*}

Now let's plug the above expression for $v(x, t)$ into the equation of motion:

\begin{align*} & \frac{1}{x^2} \frac{d F(t)}{d t} + \frac{F(t)^2}{x^2}\left(-\frac{2}{x^3} \right) = -\frac{1}{\rho}\frac{\partial P}{\partial x} & \Rightarrow \\ & \frac{1}{x^2} \frac{d F(t)}{d t} - \frac{2F(t)^2}{x^5} = -\frac{1}{\rho}\frac{\partial P}{\partial x} \end{align*}

Let's consider the above equation at a fixed moment in time when the radius of the hollow cavity is $r(t)$. Then integrating the above equation from $r(t)$ to $+\infty$ and using that $P(r) = 0$ and $P(+\infty)=P_0$ we get:

\begin{align*} & \frac{d F(t)}{d t}\int\limits_r^{+\infty}\frac{dx}{x^2} - 2F(t)^2\int\limits_r^{+\infty}\frac{dx}{x^5} = -\frac{1}{\rho}\int\limits_r^{+\infty}\frac{\partial P}{\partial x} dx & \Rightarrow \\ & \frac{1}{r}\frac{d F(t)}{d t} - \frac{1}{2} \frac{F(t)^2}{r^4} = -\frac{P_0}{\rho} & \end{align*}

We can express $F(t)$ using flux continuity at the edge of the cavity as follows:

\begin{align*} F(t) = u(t)r^2 \end{align*}

where $u(t) = dr/dt=\dot{r}$ - is the speed of the edge of the cavity at time $t$ when its radius is $r=r(t)$.

After plugging in the above expression for $F(t)$ into the integrated equation of motion, we get:

\begin{align*} \boxed{\dot{u}r + \frac{3}{2} u^2 = -\frac{P_0}{\rho}} \end{align*}

The above is a particular case of an existing named equation (Rayleigh-Plesset equation: $\ddot{r} r + \frac{3}{2} \dot{r}^2 = -P_0/\rho$, where $\dot{r}=u$).

Finally, to solve the equation we will invert the $r(t)$ function and will consider the speed of the edge of the cavity as a function of the radius of the cavity.

\begin{align*} \dot{u} = \frac{d u}{d r} \frac{1}{\dot{r}} \end{align*}

Replacing the temporal derivative $\dot{u}$, using the above formula, in the initial differential equation we get an easily separable first order differential equation with respect to $u=u(r)$:

\begin{align*} \frac{du}{dr}ur + \frac{3}{2} u^2 = -\frac{P_0}{\rho} \end{align*}

Further, we can separate $du$ and $dr$ and integrate the equation from $R_0$ to $r_0$, taking into account that $u(R_0) = 0$ (i.e. the velocity of the cavity edge was 0 in the beginning when its radius was $R_0$):

\begin{align*} & -\int\limits_{u(R_0)}^{u(r_0)} \frac{u du}{\frac{P_0}{\rho} + \frac{3}{2}u^2} = \int\limits_{R_0}^{r_0}\frac{dr}{r} & \Rightarrow \\ & \ln\left(\frac{\frac{P_0}{\rho} + \frac{3}{2}u_(r_0)^2}{\frac{P_0}{\rho}}\right) = -3 \ln\left(\frac{r_0}{R_0}\right) & \Rightarrow \\ & \frac{P_0}{\rho} + \frac{3}{2}u(r_0)^2 = \frac{P_0}{\rho}\left(\frac{R_0}{r_0}\right)^3 & \Rightarrow \\ & \boxed{\left| u(r_0)\right| = \sqrt{\frac{2}{3}\frac{P_0}{\rho}\frac{R_0^3 - r_0^3}{r_0^3}} } & \end{align*}

So the above expression is the formula for the speed of the edge of the collapsing cavity at the moment when its radius reaches $r_0$ from $R_0$. It is interesting to note that there is a singularity at $r_0 \rightarrow 0$, the speed of the cavity edge increases to infinity.