<jupyter_start><jupyter_text>The sedimentation drift velocity for a spherical particle in bulk writes:\begin{equation}v_\mathrm{sed} = \frac{2}{9} \frac{\Delta \rho a^2 g}{\eta}\end{equation}<jupyter_code>a = 1.45e-6
v_th = 2/9 * 50 * a ** 2 * 9.81 / 0.001 * 1e6
v_th
def msd(x, Dt):
	"""Function that returns the MSD for a list of time indices Dt for a trajectory x"""
	_msd = lambda x, Dt: np.mean((x[:-Dt] - x[Dt:]) ** 2)
	return [_msd(x, i) for i in Dt]
Dt = np.arange(1,1000,5)
MSD = msd(z, Dt)

def msd_th(x, d, v, n):
    return 2*d*x + v**2 * x**2 + n**2

def msd_log(x, d, v, n):
    return np.log( 2*d*x + v**2 * x**2 + n**2)
plt.plot(np.log(Dt/100),np.log(MSD), "o")
popt, pcov = curve_fit(msd_log, Dt/100, np.log(MSD), p0 = [0.13, 0.22, 4e-2], maxfev=2000, ftol=1e-2)
popt
perr = np.sqrt(np.diag(pcov))
perr
Dt = np.array([*np.arange(1,10,1), *np.arange(10,100,10), *np.arange(100,1000,100)])
MSD = msd(z, Dt)

plt.figure(figsize=( cm2inch(6*1.68),cm2inch(6)))
plt.loglog(Dt/100,MSD, "o")
t_th=np.linspace(0.7e-2, 20,10000)
plt.plot(t_th, msd_th(t_th, *popt), color = "k", linewidth=2)
plt.xlim((0.8e-2, 15))
plt.ylim((None, 10))
plt.xlabel("$\Delta t$ (s)")
plt.ylabel("MSD ($\mathrm{\mu m^2}$)")
plt.tight_layout(pad=0.1)
plt.savefig("msd_sedimentation.svg")
relat_err_D = abs(0.144 - 0.146)/0.146
relat_err_D*100
relat_err_v = abs(222 - 229)/229
relat_err_v*100
popt[1]
popt[0]
9/2 * 222e-9 * 0.001 / (1.45e-6 ** 2) / 9.81 
(50 - 48.5) / 50 * 100<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22468142186452045, 'fraction_numerical': 0.11133467471495641, 'mean_word_length': 4.328571428571428, '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': '186047', 'license': 'MIT', 'n_tokens_mistral': 859, 'n_tokens_neox': 752, 'n_words': 153, 'path': 'Preparation_talk/sedimenting/Sedimenting_particle.ipynb', 'repo_name': 'eXpensia/Confined-Brownian-Motion', 'size': '1491'}