Final: Remove weird edge case from atomic_basis

I realized that the case of matching x[i] to mu[i] does not make any
sense.
This commit is contained in:
2022-04-03 22:28:10 +02:00
parent e7497fd6ed
commit e0145285fe

View File

@ -232,7 +232,7 @@
}
],
"source": [
"def atomic_basis(x, mu, sigma, outer=False):\n",
"def atomic_basis(x, mu, sigma):\n",
" \"\"\"\n",
" Calculates the atomic basis functions for the 1D chain of atoms.\n",
" \n",
@ -240,19 +240,13 @@
" x: array of positions to calculate the wavefunction at\n",
" mu: atomic position(s) to center Gaussian wavefunction at\n",
" sigma: broadening constant for Gaussian function(s)\n",
" outer: if mu is an array: whether to calculate the atomic basis\n",
" on a len(x) by len(mu) grid instead of the pairs x[i]\n",
" and mu[i]\n",
"\n",
" Returns:\n",
" An array of values for the wavefunction over the positions\n",
" as given by x with shape len(x) by len(mu) if outer is False\n",
" as given by x with shape len(x) by len(mu)\n",
" \"\"\"\n",
" \n",
" if outer:\n",
" return np.pi**(-1/4)*sigma**(-1/2)*np.exp(-1/2*(np.subtract.outer(x, mu)/sigma)**2)\n",
" \n",
" return np.pi**(-1/4)*sigma**(-1/2)*np.exp(-1/2*((x - mu)/sigma)**2)\n",
" return np.pi**(-1/4)*sigma**(-1/2)*np.exp(-1/2*(np.subtract.outer(x, mu)/sigma)**2)\n",
"\n",
"n = 10\n",
"sigma = .25\n",
@ -270,28 +264,6 @@
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(10000, 2)"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = np.linspace(-1, 1, 10000)\n",
"mu = np.array([1,2])\n",
"atomic_basis(x, mu, .25, True).shape"
]
},
{
"cell_type": "markdown",
"metadata": {
@ -1109,7 +1081,7 @@
" \n",
" # Luckily, the function is built in such a way it can also\n",
" # handle an array input as its first argument.\n",
" delta = atomic_basis(w, Ei, sigma, True)\n",
" delta = atomic_basis(w, Ei, sigma)\n",
" \n",
" rho = np.sum(delta, axis=1)\n",
" \n",