Rounders theme of blogspot

Rounders is a great and classic theme of blogspot (my first blogspot site), it was born in year 2004

Blogger Template Style
Name:     Rounders
Date:     27 Feb 2004
Updated by: Blogger Team

and it's earlier than the birth of border-radius (2005?) property. Therefore the Rounders theme uses background images (cap rails and bottom) therefore multiple <div>s are used to wrap the the contents in order to draw the rounder borders. In this blog, I slightly modified the CSS and use border-radius property to replace the background images in their first wrappers.

Notes about training GAN

  • Try more complex generator
  • simpler the discriminator
  • A "stronger" dataset: the style of the distribution should be more highlighted

G' and G''

Exercises 7.41 and 8.14 from Rubinstein's book Polymer Physics. From Boltzmann superposition principle, we have $$\sigma(t)=\int_{-\infty}^t G(t-t^\prime)\dot{\gamma}(t^\prime)\mathrm{d}t^\prime$$ $$ \gamma(t) = \gamma_0 \exp(I \omega t)$$ $$\begin{align} \sigma(t)&=I\omega \gamma_0 \int_{-\infty}^t G(t-t^\prime)\exp(I \omega t^\prime)\mathrm{d}t^\prime\\ &=I \omega \gamma_0\exp(I \omega t)\int_0^\infty G(\tau)\exp(-I\omega \tau)\mathrm{d}\tau \\ &:=\gamma(t)I \omega \hat{G}(\omega)\end{align}$$ We therefore have $$I\omega\hat{G}=I\omega \mathcal{F}^{\cos}\lbrace G\rbrace+\omega \mathcal{F}^{\sin}\lbrace G\rbrace\equiv I G^{\prime\prime}+G^\prime$$ $\mathcal{F}^{\cos}$ and $\mathcal{F}^{\sin}$ represent Fourier cosine and sine transform. Take $\mathcal{F}^{\cos}(1)=\delta(\omega)$ and $\mathcal{F}^{\sin}(1)=1/\omega$ (note the normalization factor of $\mathcal{F}$), let $G(t)=G_{eq}+G_1(t)$: $$\begin{align} G^\prime &= \omega\mathcal{F}^{\sin}(G_1+G_{eq}) = G_{eq}+\omega\mathcal{F}^{\sin}(G_1(t))\\G^{\prime\prime}&=\omega\mathcal{F}^{\cos}(G_1+G_{eq})=\omega\mathcal{F}^{\cos}(G_1(t))+\omega\delta(\omega)=\omega\mathcal{F}^{\cos}(G_1(t))\end{align}$$ $G'$ and $G''$ are defined as the Fourier sine and cosine transform of stress relaxation function $G(t)$: $$ \begin{align} G^\prime &:= \omega\int_0^\infty G(t) \sin\omega t\mathrm{d}t\\ G^{\prime\prime} &:= \omega\int_0^\infty G(t) \cos\omega t\mathrm{d}t \end{align}$$ Let $G(t)$ be $$G(t)\sim \left(\frac{t}{\tau_0}\right)^{-\frac{1}{2}} \exp\left(-\frac{t}{\tau_R}\right)$$ G' i.e., the cosine transform is thus $$G^{\prime\prime}/\omega=\int_0^\infty \mathrm{d}t \left(\frac{t}{\tau_0}\right)^{-\frac{1}{2}} \exp\left(-\frac{t}{\tau_R}\right)\cos\omega t$$ Since $\tau_R = N^2\tau_0$, we have (let ${t^\prime}^2\tau_R = t$) $$\begin{align} G^{\prime\prime}/\omega &= 2\frac{\tau_R}{N} \int_0^\infty \mathrm{d}t^\prime \exp\left(-{t^\prime}^2\right)\cos\omega\tau_R {t^\prime}^2\\ &=2\frac{\tau_R}{N} \mathrm{Re} \int_0^\infty \mathrm{d}t^\prime \exp\left(-{t^\prime}^2\right)\exp\left(I \omega \tau_R {t^\prime}^2\right)\\ &=2\frac{\tau_R}{N} \mathrm{Re} \int_0^\infty \mathrm{d}t^\prime \exp\left(-(1-I \omega \tau_R){t^\prime}^2\right) \end{align} $$ Since $t^2=(-t)^2$, extending the range of last integral to $(-\infty, \infty)$ yields a Gaussian integral with complex argument, the result is straightforward:
$$ \begin{align}G^{\prime\prime}/\omega &=\frac{\tau_R}{N}\mathrm{Re}\sqrt{\frac{\pi}{1-I \omega \tau_R}}\\ &=\frac{\tau_R}{N}\mathrm{Re}\sqrt{\pi}\frac{\sqrt{1+I\omega\tau_R}}{1+(\omega\tau_R)^2}\\ &=\frac{\tau_R}{N}\mathrm{Re}\sqrt{\pi}\frac{1}{1+(\omega\tau_R)^2}\sqrt{\sqrt{1+(\omega\tau_R)^2}}\times&\\ &\left(\cos\left(\frac{1}{2}\arctan\omega\tau_R\right)+I \sin\left(\frac{1}{2}\arctan\omega\tau_R\right)\right)\\ &= \frac{\tau_R}{N}\sqrt{\pi}\frac{1}{1+(\omega\tau_R)^2}\sqrt{\sqrt{1+(\omega\tau_R)^2}}\cos\left(\frac{1}{2}\arctan\omega\tau_R\right)\end{align} $$ With $\cos(\arctan(x)) = \frac{1}{1+x^2}$ and $2\cos(x/2)^2-1=\cos(x)$, we finally have $$G^{\prime\prime} = \omega\tau_R\sqrt{\frac{\pi}{2}} \sqrt{\frac{\sqrt{1+(\omega\tau_R)^2}+1}{1+(\omega\tau_R)^2}}$$ The factor $\frac{\pi}{2}$ comes from the definition of Fourier cosine transform.
P.S. It is more convinient (non-restrictively) to treat the integral $$t^{-\alpha} \exp(-t) \exp(I w t)$$ with $0\lt \alpha \lt 1$ as Gamma function with (complex) coefficient in $\exp$: $$\int_0^\infty \mathrm{d}t t^{-\alpha}\exp(-(1-I \omega) t) = (1-I\omega t)^{\alpha-1} \Gamma(1-\alpha)$$ We may use Hypergeometric function $_pF_q$ for more genernal cases, i.e., $t^{-\alpha}\exp(-t^\beta)\exp(I w t)$

FEniCS: Read mesh from msh (XDMF) with subdomains

The overall procedure is generating Mesh(), MeshValueCollection objects first, and reading information into them. Then generating MeshFunctionSizet accordingly to define dx, ds... for subdomains.

Step 0. Open corresponding XDMF files; e.g., 

with XDMFFile(MPI.comm_world, "mesh.xdmf") as xdmf_infile:

Step 1. Create Mesh object, using

mesh = dolfin.cpp.mesh.Mesh()

Step 2. Read Mesh from XDMF file, e.g.,

Step 3. Create MeshValueCollection object as container of subdomain information;

mvc_subdomain = dolfin.MeshValueCollection("size_t", mesh, mesh.topology().dim())

Step 4. Read subdomain information,, "name-to-read")

The "name-to-read" here is the name given in XDMF file generated by meshio.

Step 5. Using step 3, 4 to read boundaries (open another file if necessary):

mvc_boundaries = dolfin.MeshValueCollection("size_t", mesh, mesh.topology().dim()-1), "name-to-read")

Step 6. Generate MeshFunctionSizet object, this is crucial for the latter solving process:

domains = dolfin.cpp.mesh.MeshFunctionSizet(mesh, mvc_subdomain)
boundaries = dolfin.cpp.mesh.MeshFunctionSizet(mesh, mvc_boundaries)

Step 7. Define dx, ds for subdomains and boundaries:

dx = Measure('dx', domain=mesh, subdomain_data=domains)
ds = Measure('ds', domain=mesh, subdomain_data=boundaries)

Then we could use dx(1), dx(2)... to define problem in specific sub-domains. The index of sub-domains must be consistent with domains.array(), and same for ds. One other thing notable, the default is to have a unique subdomain with value 0. For example, if domains.array() gives [5,5,5,6,6,6], an error would be raised

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***     [email protected]
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
*** -------------------------------------------------------------------------
*** Error:   Unable to set given (local) rows to identity matrix.
*** Reason:  some diagonal elements not preallocated (try assembler option keep_diagonal).
*** Where:   This error was encountered inside PETScMatrix.cpp.
*** Process: 0
*** DOLFIN version: 2019.2.0.dev0
*** Git changeset:  unknown
*** -------------------------------------------------------------------------
To fix the error, just re-set the domain values: domains.set_values([0,0,0,1,1,1]).

Step 8. Give the variational problem for each sub-domain, e.g., for poisson problem:

F = inner(a0 * grad(u), grad(v)) * dx(0) + \
    inner(a1 * grad(u), grad(v)) * dx(1) + \
    inner(g_L, v) * ds(1) - \
    inner(g_R, v) * ds(3) - \
    inner(f, v) * dx(0)  - \
    inner(f, v) * dx(1)

Bending energy and persistence length

Persistence length $L_p$ is a basic mechanical property quantifying the bending stiffness of a polymer and is defined as the relaxation of $\langle\cos(\theta)\rangle$ of bond angles of the polymer chain:

$$ \langle\cos(\theta(s))\rangle = \exp(-sl/L_p) $$

The problem of calculating $L_p$ becomes calculating $\langle\cos(\theta(s))\rangle$, if we choose the $\theta$ as the angle of adjacent bonds, i.e., $s=1$, we have:

$$ \langle\cos(\theta)\rangle = \exp(-l/L_p) $$

in simulations, the stiffness constant is given by a bending energy $U_b$, when $U_b$ is large, where excluded volume effect is negligible, we can calculate $\langle\cos(\theta)\rangle$ as

$$\langle\cos(\theta)\rangle=\frac{\int_0^\pi \cos(\theta)\sin(\theta)\exp(-\beta U_b)\mathrm{d}\theta}{\int_0^\pi\sin(\theta)\exp(-\beta U_b)\mathrm{d}\theta}$$

the $\sin(\theta)$ is a geometric weight that when 2 bonds are at an angle of $\theta$, then in 3-D space, the number of bonds is proportion to $\sin(\theta)$.

Here is an example of harmonic bending energy:

$$U_b(\theta)=-\frac{1}{2}k \theta^2$$

where $k$ is the stiffness constant in unit of $k_BT$, the $\langle\cos(\theta)\rangle$ is simply

$$\frac{e^{\frac{3}{4 k}} \left(-2 \text{erf}\left(\frac{1}{\sqrt{k}}\right)+\text{erf}\left(\frac{1+i \pi  k}{\sqrt{k}}\right)+\text{erf}\left(\frac{1-i \pi  k}{\sqrt{k}}\right)\right)}{2 \left(-2 \text{erf}\left(\frac{1}{2 \sqrt{k}}\right)+\text{erf}\left(\frac{1+2 i \pi  k}{2 \sqrt{k}}\right)+\text{erf}\left(\frac{1-2 i \pi  k}{2 \sqrt{k}}\right)\right)}$$

For large $k$ ($k\ge 6$), $\langle\cos(\theta)\rangle\simeq L(k)$, with $L(k)$ being the Langevin function.

Steady compliance (Linear viscoelasty)

Boltzmann superposition: assume that there is no stress when $t\le 0$, so the integral starts from $0$ and $\sigma(0^{-})=0$:

$$\begin{equation} \gamma(t)=\int_0^t J(t-t^\prime)\dot{\sigma}(t^\prime)\mathrm{d}t^\prime \end{equation}$$

 Performing Laplace Transform yields: 

$$\begin{align} \hat{\gamma}(s)&=\hat{J}(s)\hat{\dot{\sigma}}(s)\\ &=\hat{J}(s)\left(s\hat{\sigma}(s)-\sigma(0^{-})\right) \\ &=\hat{J}(s)\left(s\hat{G}(s)\hat{\dot{\gamma}}(s)-\sigma(0^{-})\right)\\ &=\hat{J}(s)\left(s\hat{G}(s)(s\hat{\gamma}(s)-\gamma(0^-))-\sigma(0^{-})\right)\\ &=s^2\hat{J}(s)\hat{\gamma}(s)\hat{G}(s)  \end{align}$$

Here we let $\hat{f}(s):=\mathcal{L}\lbrace f(t)\rbrace(s)$ be the Laplace transformation and since the stress starts at time $0$, $\gamma(0^-)$ and $\sigma(0^-)$ are simply $0$. The 2nd to 3rd step is derived from the convolution relation $\sigma(t)=\int_0^t G(t-t^\prime)\dot{\gamma}(t^\prime)\mathrm{d}t^\prime$. Cancelling out the $\hat{\gamma}(s)$ and rearranging the last equation give

$$\begin{equation} \frac{1}{s^2}=\hat{J}(s)\hat{G}(s) \end{equation}$$

The inverse Laplace of above equation gives the convolution relation

$$\begin{equation} t=\int_0^{t}J(t-t^\prime)G(t^\prime)\mathrm{d}t^\prime \end{equation}$$

The last step is substituting $J(t)=J_e + t/\eta$ into above convolution relation and making $t\to\infty$: 

$$\begin{equation} \begin{aligned} \color{blue}{t} &=\int_0^{t}\left(J_e+\frac{t-t^\prime}{\eta}\right)G(t^\prime)\mathrm{d}t^\prime\\ &= J_e\int_0^\infty G(t^\prime)\mathrm{d}t^\prime + {\color{blue}{\frac{t}{\eta}\int_0^\infty G(t^\prime)\mathrm{d}t^\prime}} - \int_0^\infty G(t^\prime)\frac{t^\prime}{\eta}\mathrm{d}t^\prime \end{aligned} \end{equation}$$

Since $\eta:=\int_0^\infty G(t^\prime)\mathrm{d}t^\prime$, the blue terms cancelled out, which gives \begin{equation} J_e\int_0^\infty G(t^\prime)\mathrm{d}t^\prime = J_e\eta= \int_0^\infty G(t^\prime)\frac{t^\prime}{\eta}\mathrm{d}t^\prime = \frac{1}{\eta} \int_0^\infty G(t^\prime)t^\prime\mathrm{d}t^\prime \end{equation} Therefore we have 

$$J_e = \frac{1}{\eta^2}\int_0^\infty tG(t)\mathrm{d}t$$


Saddle point method and end-to-end distribution of polymer models

Saddle point methods are widely used in estimation of integrals with form
$$ I = \int \exp\left(-f(x)\right)\mathrm{d}x $$
where function $f$ can be approximated by first 2 terms of its Taylor series around some $x_0$, i.e.
$$ f(x)\approx f(x_0) + f^\prime (x_0)(x-x_0) + \frac{1}{2}f^{\prime\prime}(x_0)(x-x_0)^2 $$
The integral is thus approximated by its saddle point, where $f^\prime (x_0)=0$ and $f^{\prime\prime}(x_0)>0$:
$$ \begin{align} I&\approx \int \exp\left(-f(x_0) - \frac{1}{2}f^{\prime\prime}(x_0)(x-x_0)^2\right) \mathrm{d}x\\ &=\exp(-f(x_0))\sqrt{\frac{2\pi}{f^{\prime\prime}(x_0)}} \end{align}$$

  • Stirling's formula:
With the knowledge of $\Gamma$ function we know that
$$N!=\int_0^\infty \exp(-x)x^N\mathrm{d}x$$
let $f(x):=x-N\ln(x)$, with large $N$, the negative part is negligible, solving $f^\prime (x) = 0$, we have:
  • Partition function:

$$Z = \int \exp(-\beta U(\mathbf{x})) \mathrm{d}\mathbf{x}$$
$$U(\mathbf{x})\approx U(\mathbf{x}_0) + \frac{1}{2}(\mathbf{x}-\mathbf{x}_0)^T H[U](\mathbf{x}-\mathbf{x}_0)$$
where $H$ represents hessian matrix.

End-to-end distribution function of random walk model of polymer chains
For an $N$-step random walk model, the exact end-to-end vector distribution is
$$ \begin{align} P(\mathbf{Y})&=\frac{1}{(2\pi)^3}\int \mathrm{d}\mathbf{k} \exp(-i\mathbf{k}\cdot\mathbf{Y})\tilde{\phi}^N\\ &=\int_{0}^{\infty} k\sin(kY) \left(\frac{\sin(kb)}{kb}\right)^N \mathrm{d}k \end{align} $$
with $\phi(\mathbf{x})=\frac{1}{4\pi b^2}\delta(|\mathbf{x}|-b)$ is the distribution of one step vector (length=$b$) and $\tilde{\phi}$ is the characteristic function of $\phi$; $\mathbf{Y}:=\sum_{i=1}^N \mathbf{x}_i$ is the end-to-end vector. Let $s=kb$ and $f(s):=i\frac{Y}{Nb}s -\ln\frac{\sin(s)}{s}$ then we have:
$$ \begin{align} P&=\frac{i}{4\pi^2 b^2 Y}\int_{-\infty}^{+\infty} s \exp\left(-is\frac{Y}{b}\right)\left(\frac{\sin(s)}{s}\right)^N\mathrm{d}s\\ &=\frac{i}{4\pi^2 b^2 Y} \int s \exp(-Nf(s)) \mathrm{d} s\end{align}$$
in this step, the integral is extened to $(-\infty, +\infty)$ due to the symmetry of sin/cos function: the first sin function is replaced with form of $\exp(-ix)$ by Eular's equation: $\exp(ix)=\cos(x)+i\sin(x)$.

Solving for $f^\prime(s)=0$, one could find that $is$ satisfies
i.e. the Langevin function, $is_0=L^{-1}(\frac{Y}{Nb})$. We therefore have:
$$\begin{align} P &\approx\frac{s_0}{4\pi^2b^2Y}\sqrt{\frac{2\pi}{Nf^{\prime\prime}(s_0)}}e^{-Nf(s_0)}\\ &=\frac{1}{(2\pi{}Nb^2)^{3/2}}\frac{L^{-1}(x)^2}{x(1-(L^{-1}(x)\csc\left(L^{-1}(x)\right))^2)^{1/2}}\\&\times\left(\frac{\sinh\left(L^{-1}(x)\right)}{L^{-1}(x)\exp\left(xL^{-1}(x)\right)}\right)^N\end{align}$$
with $x:=\frac{Y}{Nb}$.

Back2Top ^