Commit 29b26210 authored by Antoine RAVETTA's avatar Antoine RAVETTA

fonctional notebooks for CCCN - augment the box size !

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.
......@@ -3,11 +3,36 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
"source": [
"%matplotlib inline\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"data_path = '../data/CN_cylindric_complex_'\n",
"\n",
"\n",
"def import_data(path):\n",
" data_array = np.loadtxt(path + 'E.dat', dtype=float)\n",
" r_pts = np.loadtxt(path + 'r_pts.dat', dtype=float)\n",
" z_pts = np.loadtxt(path + 'z_pts.dat', dtype=float)\n",
" return data_array, r_pts, z_pts\n",
"\n",
"\n",
"def plot_data(z_pts, r_pts, E_matrix):\n",
" fig, ax = plt.subplots()\n",
" mesh = ax.pcolormesh(r_pts, z_pts, E_matrix.T)\n",
" ax.set_xlabel('z')\n",
" ax.set_ylabel('r')\n",
" plt.colorbar(mesh, ax=ax)\n",
" fig.show()\n",
"\n",
"\n",
"data_ary, r_pts, z_pts = import_data(data_path)\n",
"plot_data(r_pts, z_pts, data_ary)"
]
}
],
"metadata": {
......@@ -26,7 +51,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.7.3"
}
},
"nbformat": 4,
......
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": 49,
"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"
"/home/antoine/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:10: RuntimeWarning: divide by zero encountered in true_divide\n",
" # Remove the CWD from sys.path while we load stuff.\n",
"/home/antoine/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:10: RuntimeWarning: invalid value encountered in true_divide\n",
" # Remove the CWD from sys.path while we load stuff.\n",
"/home/antoine/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:29: RuntimeWarning: invalid value encountered in multiply\n"
]
}
],
"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=10000, z_min=0, z_max=20, n_z=2000)\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