<jupyter_start><jupyter_text>langevin.cppundef ENABLE_HISTundef ENABLE_HARMONIC_WELL<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import scipy.optimize
import pysimul
import time
from math import *
π = np.pi
simul = pysimul.PySimul()
simul['t_pause'] = simul_time = 10000
simul['T'] = kBT = 10
simul['gamma'] = γ = 1000
simul['part_m'] = m = 1
simul.start()
while not simul['pause']:
    simul.sfml_event_poll()
    time.sleep(0.01)
D = kBT / γ
κ = sqrt( simul["reset_rate"] / D )
(acc, samples) = simul["xdist"]
xdist = acc/samples
xdist_max = simul["xdist_max"]
(acc, samples) = simul["rdist"]
rdist = acc/samples
simul.end()
x = np.linspace(-xdist_max,xdist_max,len(xdist))
Δx = x[1]-x[0]
plt.plot(x, Δx*κ/2*np.exp(-κ*np.abs(x)), label="theoretical $\operatorname{e}^{-\kappa|x|}$", color='black', linestyle='dashed', lw=3)
plt.plot(x, xdist, label="measured")
plt.ylim(0,np.max(xdist)*1.05)
plt.xlabel(r"$x$")
plt.title(r"free diffusion with reset ($\kappa={:.1f}$) 1D position distribution".format(κ))
plt.legend()
plt.savefig("langevin-reset-xdist.pdf")
r = np.linspace(0,xdist_max,len(rdist))+1e-100
plt.plot(r, rdist, label="measured")
plt.plot(r, Δx*κ**2*r*scipy.special.kn(0,κ*r), label="theoretical $r\cdot\operatorname{K}_0(\kappa r)$", color='black', linestyle='dashed', lw=3)
plt.xlabel(r"$r$")
plt.title(r"free diffusion with reset ($\kappa={:.1f}$) 2D position distribution".format(κ))
plt.legend()
plt.savefig("langevin-reset-rdist.pdf")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19827012641383898, 'fraction_numerical': 0.023952095808383235, 'mean_word_length': 6.482587064676617, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '277554', 'license': 'MIT', 'n_tokens_mistral': 677, 'n_tokens_neox': 632, 'n_words': 111, 'path': 'langevin-reset/langevin-reset.ipynb', 'repo_name': 'xif-fr/BrownianMotion', 'size': '1503'}