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.

Sunday, March 9, 2025

Physics problem: acceleration of water level in a container due to draining from an opening in its bottom

Problem statement

From an opening at the bottom of a tall container, water drains out. The cross-section area of the container is $S$, and the cross-section area of the draining stream of water is $\sigma$. The water level in the vessel moves downward with constant acceleration. Determine this acceleration.

Solution

I'll describe two methods to solve the problem: the first one is the one I used and it is based on Bernoulli's law (energy conservation) and the second one is using the Toricelli's formula and accompanying assumptions from the get go. The second one I would guess a more experimented physicist would use and be done with it (see the approach 2). If I were to think about the second approach right away, this post would not happen.

Approach 1

Let's denote the speed of the water at the surface of the container and at the draining hole as $v_0$ and $v_1$ respectively. Then we can write energy and mass conservation expressions for the two cross-sections as follows:

\begin{align*} \begin{cases} \frac{v_0^2}{2} + gh = \frac{v_1^2}{2} \\ v_1\sigma = v_0 S \end{cases} \end{align*}

where $h$ is the current water level in the container, ang $g$ is the acceleration due to gravity.

Now, if we eliminate $v_1$ from the energy conservation equation and apply a time derivative to the both sides of the equation we will obtain the following relation (we use an upper dot to denote a time derivative, $\dot{x}=\frac{dx}{dt}$):

\begin{equation*} 2 v_0 \dot{v_0} + 2g\dot{h}=\left(\frac{S}{\sigma}\right)^2 2 v_0 \dot{v_0} \end{equation*}

Let's denote the acceleration of the water level as $a=\dot{v_0}$, and also note that $v_0 = -\dot{h}$ (the minus sign here is added because the level $h$ is decreasing with time and I prefer to consider $v_0$ as speed value without direction). Using this notation, the previous equation can be written as:

\begin{equation*} 2 v_0 a - 2gv_0=\left(\frac{S}{\sigma}\right)^2 2 v_0 a \end{equation*}

Simplifying we get the following expression for the water level acceleration in the container:

\begin{equation*} a = \frac{g}{1 - \left(\frac{S}{\sigma}\right)^2} \end{equation*}

Now we could consider that the conditions given in the problem statement imply $S\gg\sigma \rightarrow S/\sigma \gg 1$, therefore we can approximate the above expression as:

\begin{equation*} a \approx -g\left(\frac{\sigma}{S}\right)^2 \end{equation*}

Note that $a = \dot{v_0} < 0$, meaning that the water level descent in the container is slowing down with time.

Approach 2

For this approach we recognize right away that the problem conditions allow the use of Toricelli's formula for the speed $v_1$ of draining water from a large container with the water level at $h$:

\begin{equation*} v_1=\sqrt{2gh} \end{equation*}

The draining water will cause the change to the water level as follows: \begin{align*} \dot{h}=-v_1\sigma/S=-\frac{\sigma}{S}\sqrt{2gh} \end{align*}

If we apply a time derivative to the above equation and substitute $\dot{h}$, we obtain:

\begin{align*} \ddot{h} & =-\frac{\sigma}{S}\sqrt{2g}\frac{1}{2\sqrt{h}}\dot{h} \\ & = g\left(\frac{\sigma}{S}\right)^2 \end{align*}

Since the water level acceleration is $a = \dot{v_0} = d_t \left( -\dot{h} \right) = -\ddot{h}$, we obtain the final expression using the above relation for the second derivative of the water level as:

\begin{align*} a = -g\left(\frac{\sigma}{S}\right)^2 \end{align*}

Note that in this case we did not have to make any approximations as they were already applied for the Toricelli's formula to be valid (mainly that the speed of the water level $v_0$ is much lower than the draining speed $v_1$).