benchmarks.wiki / Public workspace

SciCode / 47.4 / Write a function to use Markov Chain Monte Carlo simulation to generate samples…

Problem

Answer published by the source. Consult the official source to check your work against its answer.

step background

Background: In the canonical ensemble, we have to sample distribution. This can be done using the following scheme: Select a particle at random and calculate the energy of this configuration U(0)\mathcal{U}(0). 2. Give this particle a random displacement, r(o)r(0)+Δ(Ranf0.5), \mathbf{r}(\mathbf{o}) \rightarrow \mathbf{r}(\mathbf{0})+\Delta(\operatorname{Ranf}-0.5), where Δ/2\Delta / 2 is the maximum displacement. The value of Δ\Delta should be chosen such that the sampling scheme is optimal. The new configuration is denoted nn and its energy U(n)\mathcal{U}(n). 3. The move is accepted with a probability acc(on)=min(1,exp{β[U(n)U(o)]}) \operatorname{acc}(o \rightarrow \mathfrak{n})=\min (1, \exp \{-\beta[\mathcal{U}(\mathfrak{n})-\mathcal{U}(o)]\}) If rejected, the old configuration is kept.
Plain-text mathematical notation (without MathML)
Background:

In the canonical ensemble, we have to sample distribution. This can be done using the following scheme:
Select a particle at random and calculate the energy of this configuration U(0).
2. Give this particle a random displacement,
r(o)→r(0)+Δ(Ranf−0.5),
where Δ/2 is the maximum displacement. The value of Δ should be chosen such that the sampling scheme is optimal. The new configuration is denoted n and its energy U(n).

3. The move is accepted with a probability
acc(o→n)=min(1,exp{−β[U(n)−U(o)]})
If rejected, the old configuration is kept.
Original LaTeX notation
Background:

In the canonical ensemble, we have to sample distribution. This can be done using the following scheme:
Select a particle at random and calculate the energy of this configuration $\mathcal{U}(0)$.
2. Give this particle a random displacement,
$$
\mathbf{r}(\mathbf{o}) \rightarrow \mathbf{r}(\mathbf{0})+\Delta(\operatorname{Ranf}-0.5),
$$
where $\Delta / 2$ is the maximum displacement. The value of $\Delta$ should be chosen such that the sampling scheme is optimal. The new configuration is denoted $n$ and its energy $\mathcal{U}(n)$.

3. The move is accepted with a probability
$$
\operatorname{acc}(o \rightarrow \mathfrak{n})=\min (1, \exp \{-\beta[\mathcal{U}(\mathfrak{n})-\mathcal{U}(o)]\})
$$
If rejected, the old configuration is kept.

step description prompt

Write a function to use Markov Chain Monte Carlo simulation to generate samples energy of system of atoms interacting through Lennard Jones potential at temperature T, using Metropolis-Hasting Algorithm with Gaussian trial move. Assume that "U_i" is given, and it computes the total energy on a single stom. Also assume that "U_system" is given, and it computes the total energy of the entire system. The inputs of the resultant function contain a N by 3 float array init_posistion, a float sigma, a float epsilon, a float T, an integer MC_steps and a float dispSize. The output is a MC_steps by 1 float array.

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import