Commit 6d64ba7e authored by Antoine RAVETTA's avatar Antoine RAVETTA

cleaning from last session

parent 2edecd00
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"\n",
"def import_data():\n",
" # TODO\n",
" data_array = np.loadtxt('../data/CN_cylindric_data.dat', dtype=complex)\n",
" return data_array\n",
"\n",
"\n",
"def plot_data(crank):\n",
" fig, ax = plt.subplots()\n",
" # TODO\n",
" mesh = ax.pcolormesh(crank.z_pts, np.concatenate(crank.r_pts, -crank.r_pts[::-1]),\n",
" np.concatenate(crank.u_matrix, -crank.u_matrix[::-1]))\n",
" ax.set_xlabel('z')\n",
" ax.set_ylabel('r')\n",
" plt.colorbar(mesh, ax=ax)\n",
" fig.show()\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -169,10 +169,8 @@
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": true
},
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
......@@ -285,16 +283,13 @@
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": true
},
"execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"c = 299792458\n",
"lambd = 700 * 10 ** -9\n",
"lambd = 628 * 10 ** -9\n",
"\n",
"k = c * 2 * np.pi / lambd\n",
"k = 2 * np.pi / lambd\n",
"\n",
"diff_coeff = 1j/(2 * k)\n",
"\n",
......@@ -306,7 +301,7 @@
" return 0\n",
"\n",
"\n",
"def gaussian(r, mu=0, sigma=1, amplitude=1):\n",
"def gaussian(r, mu=0, sigma=1e-3, amplitude=1):\n",
" return amplitude * np.exp(-(r - mu) ** 2 / (2 * sigma ** 2))\n",
"\n",
"\n",
......@@ -323,25 +318,25 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/anaconda3-5.0.0/lib/python3.6/site-packages/ipykernel_launcher.py:11: RuntimeWarning: divide by zero encountered in true_divide\n",
" # This is added back by InteractiveShellApp.init_path()\n",
"/usr/local/anaconda3-5.0.0/lib/python3.6/site-packages/ipykernel_launcher.py:11: RuntimeWarning: invalid value encountered in true_divide\n",
" # This is added back by InteractiveShellApp.init_path()\n",
"/usr/local/anaconda3-5.0.0/lib/python3.6/site-packages/ipykernel_launcher.py:29: RuntimeWarning: invalid value encountered in multiply\n"
"ename": "NameError",
"evalue": "name 'CrankNicolson' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-e251e79e49fb>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mcrank\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mCrankNicolson\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mcrank\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_grid\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mr_max\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0.005\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mn_r\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m100\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mz_min\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mz_max\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m20\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mn_z\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m200\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mcrank\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_parameters\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mD\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdiff_coeff\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mV\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpotential\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mlambda\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'CrankNicolson' is not defined"
]
}
],
"source": [
"crank = CrankNicolson()\n",
"\n",
"crank.set_grid(r_max=5, n_r=50, z_min=0, z_max=10, n_z=100)\n",
"crank.set_grid(r_max=0.005, n_r=100, z_min=0, z_max=20, n_z=200)\n",
"crank.set_parameters(D=diff_coeff, V=potential, f=lambda x:0)\n",
"\n",
"crank.solve(initial_enveloppe(crank.r_pts))"
......@@ -356,23 +351,14 @@
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": true
},
"execution_count": 50,
"metadata": {},
"outputs": [],
"source": [
"np.savetxt(\"CN_cylindric_complex.dat\", crank.E_matrix)"
"np.savetxt(\"../data/CN_cylindric_complex_E.dat\", np.abs(crank.E_matrix))\n",
"np.savetxt(\"../data/CN_cylindric_complex_r_pts.dat\", crank.r_pts)\n",
"np.savetxt(\"../data/CN_cylindric_complex_z_pts.dat\", crank.z_pts)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
......@@ -391,7 +377,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.7.3"
}
},
"nbformat": 4,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment