mirror of
https://github.com/smyalygames/FiniteVolumeGPU.git
synced 2025-05-18 06:24:13 +02:00
578 lines
31 KiB
Plaintext
578 lines
31 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#Lets have matplotlib \"inline\"\n",
|
|
"%matplotlib inline\n",
|
|
"\n",
|
|
"# Add line profiler\n",
|
|
"%load_ext line_profiler\n",
|
|
"\n",
|
|
"#Import packages we need\n",
|
|
"import numpy as np\n",
|
|
"from matplotlib import animation, rc\n",
|
|
"from matplotlib import pyplot as plt\n",
|
|
"from matplotlib.colorbar import ColorbarBase\n",
|
|
"\n",
|
|
"from IPython.display import display, HTML\n",
|
|
"\n",
|
|
"from enum import Enum\n",
|
|
"import subprocess\n",
|
|
"import time\n",
|
|
"import os\n",
|
|
"import gc\n",
|
|
"import datetime\n",
|
|
"import importlib\n",
|
|
"import logging\n",
|
|
"import netCDF4\n",
|
|
"import json\n",
|
|
"\n",
|
|
"import pycuda.driver as cuda\n",
|
|
"import pycuda.compiler\n",
|
|
"\n",
|
|
"try:\n",
|
|
" from StringIO import StringIO\n",
|
|
"except ImportError:\n",
|
|
" from io import StringIO\n",
|
|
"\n",
|
|
"from GPUSimulators import Common, IPythonMagic\n",
|
|
"from GPUSimulators.EE2D_KP07_dimsplit import EE2D_KP07_dimsplit\n",
|
|
"from GPUSimulators.helpers import InitialConditions, Visualization"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Console logger using level INFO\n",
|
|
"File logger using level DEBUG to test_schemes.log\n",
|
|
"Python version 3.6.7 |Anaconda custom (64-bit)| (default, Oct 28 2018, 19:44:12) [MSC v.1915 64 bit (AMD64)]\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"%setup_logging --out test_schemes.log"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Registering my_context in user workspace\n",
|
|
"PyCUDA version 2018.1.1\n",
|
|
"CUDA version (10, 0, 0)\n",
|
|
"Driver version 10000\n",
|
|
"Using 'GeForce 840M' GPU\n",
|
|
"Created context handle <306858187648>\n",
|
|
"Using CUDA cache dir c:\\Users\\anbro\\Documents\\projects\\GPUSimulators\\GPUSimulators\\cuda_cache\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"%cuda_context_handler --no_autotuning my_context "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#Set large figure sizes as default\n",
|
|
"rc('figure', figsize=(16.0, 12.0))\n",
|
|
"rc('animation', html='html5')\n",
|
|
"rc('animation', bitrate=1800)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"def plotVars(rho, rho_u, rho_v, E):\n",
|
|
" plt.figure()\n",
|
|
" plt.subplot(1,4,1)\n",
|
|
" plt.imshow(rho, origin='bottom')\n",
|
|
" plt.colorbar(orientation='horizontal', pad=0.02, shrink=0.9)\n",
|
|
"\n",
|
|
" plt.subplot(1,4,2)\n",
|
|
" plt.imshow(rho_u, origin='bottom')\n",
|
|
" plt.colorbar(orientation='horizontal', pad=0.02, shrink=0.9)\n",
|
|
"\n",
|
|
" plt.subplot(1,4,3)\n",
|
|
" plt.imshow(rho_v, origin='bottom')\n",
|
|
" plt.colorbar(orientation='horizontal', pad=0.02, shrink=0.9)\n",
|
|
"\n",
|
|
" plt.subplot(1,4,4)\n",
|
|
" plt.imshow(E, origin='bottom')\n",
|
|
" plt.colorbar(orientation='horizontal', pad=0.02, shrink=0.9)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"def runSimulation(outfile, t_end, sim_args):\n",
|
|
" with Common.Timer(\"construct\") as t:\n",
|
|
" sim = EE2D_KP07_dimsplit(**sim_args)\n",
|
|
" print(\"Constructed in \" + str(t.secs) + \" seconds\")\n",
|
|
"\n",
|
|
" #Create netcdf file and simulate\n",
|
|
" with Common.DataDumper(outfile, mode='w', clobber=False) as outdata:\n",
|
|
" outdata.ncfile.createDimension('time', None)\n",
|
|
" outdata.ncfile.createDimension('x', sim.nx)\n",
|
|
" outdata.ncfile.createDimension('y', sim.ny)\n",
|
|
"\n",
|
|
" #Create variables\n",
|
|
" outdata.time_var = outdata.ncfile.createVariable('time', np.dtype('float32').char, 'time')\n",
|
|
" outdata.x_var = outdata.ncfile.createVariable('x', np.dtype('float32').char, 'x')\n",
|
|
" outdata.y_var = outdata.ncfile.createVariable('y', np.dtype('float32').char, 'y')\n",
|
|
" outdata.rho_var = outdata.ncfile.createVariable('rho', np.dtype('float32').char, ('time', 'y', 'x'), zlib=True, least_significant_digit=3)\n",
|
|
" outdata.rho_u_var = outdata.ncfile.createVariable('rho_u', np.dtype('float32').char, ('time', 'y', 'x'), zlib=True, least_significant_digit=3)\n",
|
|
" outdata.rho_v_var = outdata.ncfile.createVariable('rho_v', np.dtype('float32').char, ('time', 'y', 'x'), zlib=True, least_significant_digit=3)\n",
|
|
" outdata.E_var = outdata.ncfile.createVariable('E', np.dtype('float32').char, ('time', 'y', 'x'), zlib=True, least_significant_digit=3)\n",
|
|
" \n",
|
|
" #Create attributes\n",
|
|
" def toJson(in_dict):\n",
|
|
" out_dict = in_dict.copy()\n",
|
|
"\n",
|
|
" for key in out_dict:\n",
|
|
" if isinstance(out_dict[key], np.ndarray):\n",
|
|
" out_dict[key] = out_dict[key].tolist()\n",
|
|
" else:\n",
|
|
" try:\n",
|
|
" json.dumps(out_dict[key])\n",
|
|
" except:\n",
|
|
" out_dict[key] = str(out_dict[key])\n",
|
|
"\n",
|
|
" return json.dumps(out_dict)\n",
|
|
" outdata.ncfile.created = time.ctime(time.time())\n",
|
|
" outdata.ncfile.sim_args = toJson(sim_args)\n",
|
|
"\n",
|
|
" outdata.x_var[:] = np.linspace(0, sim.nx*sim.dx, sim.nx)\n",
|
|
" outdata.y_var[:] = np.linspace(0, sim.ny*sim.dy, sim.ny)\n",
|
|
"\n",
|
|
" progress_printer = Common.ProgressPrinter(n_save, print_every=10)\n",
|
|
" print(\"Simulating to t={:f}. Estimated {:d} timesteps (dt={:f})\".format(t_end, int(t_end / sim.dt), sim.dt))\n",
|
|
" for i in range(n_save+1):\n",
|
|
" #Sanity check simulator\n",
|
|
" try:\n",
|
|
" sim.check()\n",
|
|
" except AssertionError as e:\n",
|
|
" print(\"Error after {:d} steps (t={:f}: {:s}\".format(sim.simSteps(), sim.simTime(), str(e)))\n",
|
|
" return outdata.filename\n",
|
|
"\n",
|
|
" #Simulate\n",
|
|
" if (i > 0):\n",
|
|
" sim.simulate(t_end/n_save)\n",
|
|
"\n",
|
|
" #Save to file\n",
|
|
" #rho = sim.u0[0].download(sim.stream)\n",
|
|
" rho, rho_u, rho_v, E = sim.download()\n",
|
|
" outdata.time_var[i] = sim.simTime()\n",
|
|
" outdata.rho_var[i, :] = rho\n",
|
|
" outdata.rho_u_var[i, :] = rho_u\n",
|
|
" outdata.rho_v_var[i, :] = rho_v\n",
|
|
" outdata.E_var[i, :] = E\n",
|
|
"\n",
|
|
" #Write progress to screen\n",
|
|
" print_string = progress_printer.getPrintString(i)\n",
|
|
" if (print_string):\n",
|
|
" print(print_string)\n",
|
|
"\n",
|
|
" return outdata.filename "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"class VisType(Enum):\n",
|
|
" Schlieren = 0\n",
|
|
" Density = 1\n",
|
|
"\n",
|
|
"def createAnimation(infile, vis_type, vmin, vmax, save_anim=False, cmap=plt.cm.coolwarm, fig_args=None):\n",
|
|
" fig = plt.figure(**fig_args)\n",
|
|
" \n",
|
|
" with Common.DataDumper(infile, 'r') as indata:\n",
|
|
" time = indata.ncfile.variables['time'][:]\n",
|
|
" x = indata.ncfile.variables['x'][:]\n",
|
|
" y = indata.ncfile.variables['y'][:]\n",
|
|
" rho = indata.ncfile.variables['rho'][0]\n",
|
|
" rho_u = indata.ncfile.variables['rho_u'][0]\n",
|
|
" rho_v = indata.ncfile.variables['rho_v'][0]\n",
|
|
" \n",
|
|
" created = indata.ncfile.created\n",
|
|
" sim_args = json.loads(indata.ncfile.sim_args)\n",
|
|
" for key in sim_args:\n",
|
|
" if isinstance(sim_args[key], list):\n",
|
|
" sim_args[key] = \"[...]\"\n",
|
|
" num_frames = len(time)\n",
|
|
" print(\"{:s} created {:s} contains {:d} timesteps\".format(infile, created, num_frames))\n",
|
|
" print(\"Simulator arguments: \\n\", sim_args)\n",
|
|
"\n",
|
|
" ax1 = fig.gca()\n",
|
|
" extents = [0, x.max(), 0, y.max()]\n",
|
|
" \n",
|
|
" if (vis_type == VisType.Schlieren):\n",
|
|
" im = ax1.imshow(Visualization.genColors(rho, rho_u, rho_v, cmap, vmax, vmin), origin='bottom', extent=extents, cmap='gray', vmin=0.0, vmax=1.0)\n",
|
|
" fig.suptitle(\"Schlieren / vorticity at t={:.2f}\".format(time[0]))\n",
|
|
" elif (vis_type == VisType.Density):\n",
|
|
" im = ax1.imshow(rho, origin='bottom', extent=extents, cmap=cmap, vmin=vmin, vmax=vmax)\n",
|
|
" fig.suptitle(\"Density at t={:.2f}\".format(time[0]))\n",
|
|
" else:\n",
|
|
" assert False, \"Wrong vis_type\"\n",
|
|
"\n",
|
|
" #Create colorbar\n",
|
|
" from matplotlib.colors import Normalize\n",
|
|
" from mpl_toolkits.axes_grid1 import make_axes_locatable\n",
|
|
" divider = make_axes_locatable(ax1)\n",
|
|
" ax2 = divider.append_axes(\"right\", size=0.1, pad=0.05)\n",
|
|
" cb1 = ColorbarBase(ax2, cmap=cmap,\n",
|
|
" norm=Normalize(vmin=vmin, vmax=vmax),\n",
|
|
" orientation='vertical')\n",
|
|
" \n",
|
|
" #Label colorbar\n",
|
|
" if (vis_type == VisType.Schlieren):\n",
|
|
" cb1.set_label('Vorticity')\n",
|
|
" elif (vis_type == VisType.Density):\n",
|
|
" cb1.set_label('Density')\n",
|
|
"\n",
|
|
" progress_printer = Common.ProgressPrinter(num_frames, print_every=5)\n",
|
|
" \n",
|
|
" def animate(i):\n",
|
|
" rho = indata.ncfile.variables['rho'][i]\n",
|
|
" rho_u = indata.ncfile.variables['rho_u'][i]\n",
|
|
" rho_v = indata.ncfile.variables['rho_v'][i]\n",
|
|
" \n",
|
|
" if (vis_type == VisType.Schlieren):\n",
|
|
" im.set_data(Visualization.genColors(rho, rho_u, rho_v, cmap, vmax, vmin))\n",
|
|
" fig.suptitle(\"Schlieren / vorticity at t={:.2f}\".format(time[i]))\n",
|
|
" elif (vis_type == VisType.Density):\n",
|
|
" im.set_data(rho) \n",
|
|
" fig.suptitle(\"Density at t={:.2f}\".format(time[i]))\n",
|
|
" \n",
|
|
" #Write progress to screen\n",
|
|
" print_string = progress_printer.getPrintString(i)\n",
|
|
" if (print_string):\n",
|
|
" print(print_string)\n",
|
|
"\n",
|
|
" anim = animation.FuncAnimation(fig, animate, interval=50, frames=range(num_frames))\n",
|
|
" plt.close()\n",
|
|
"\n",
|
|
" if (save_anim):\n",
|
|
" root, _ = os.path.splitext(infile)\n",
|
|
" movie_outpath = os.path.abspath(root + \".mp4\")\n",
|
|
" if (os.path.isfile(movie_outpath)):\n",
|
|
" print(\"Reusing previously created movie \" + movie_outpath)\n",
|
|
" else:\n",
|
|
" print(\"Creating movie \" + movie_outpath)\n",
|
|
" #from matplotlib.animation import FFMpegFileWriter\n",
|
|
" #writer = FFMpegFileWriter(fps=25)\n",
|
|
" from matplotlib.animation import FFMpegWriter\n",
|
|
" writer = FFMpegWriter(fps=25)\n",
|
|
" anim.save(movie_outpath, writer=writer)\n",
|
|
" display(HTML(\"\"\"\n",
|
|
" <div align=\"middle\">\n",
|
|
" <video width=\"80%\" controls>\n",
|
|
" <source src=\"{:s}\" type=\"video/mp4\">\n",
|
|
" </video>\n",
|
|
" </div>\n",
|
|
" \"\"\".format(movie_outpath)))\n",
|
|
" else:\n",
|
|
" #plt.rcParams[\"animation.html\"] = \"html5\"\n",
|
|
" plt.rcParams[\"animation.html\"] = \"jshtml\"\n",
|
|
" display(anim)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Shock-bubble"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"<matplotlib.colorbar.Colorbar at 0x4777bb5128>"
|
|
]
|
|
},
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
},
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAzkAAADhCAYAAADrl3vGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAGFVJREFUeJzt3XGsZOV53/Hvj8XECXaC7V1bFHCyTdbF1GrAvsW0SCkB0i60YqmEK0jrEIt2WwkSJzipcVrhlDZSnLahjUTcbgyBRI4xIU5ZWVsTi4CiVoXsrqG2dwlis0awZuvdjYGkcTHZ7NM/5lyYHWbuzNw7d+7Mud+PdHTnnDnznndeXmbPM+/zvpOqQpIkSZLa4pS1roAkSZIkTZJBjiRJkqRWMciRJEmS1CoGOZIkSZJaxSBHkiRJUqsY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1IvAInflQZ6SzchOc3K5jr+yk/rrae2uTqllV9W3g17GPa4KmFeSMsmqCVijJ6UnevPgY+LvAVzl5RYrrgQfWpoatNqiNdwI/1qwUcxHw0mK6j5avJzf7H9Lp59Bp72ublZA205m0+ofTrt+8a+Ya3Ak8WVW/3PWU/XwVDGpv+/nqSbIpyRnN4+8ELqczF+phOis3wev7+FgrO+k1A9r7j7q+NAmd+U/dfdzPFK3IVH4MtKqOJ1lcNWEDcFdV7ZvGtdeZdwC/28yFPBX4rar6QpLdwH1JbgCeBT6whnWce0k+A1wCbExyCPg48Iv0b+NdwJV0JgZ/C/jQ1Cs85wa09yXNUqMFPAP8c4BmNZb7gP10Vqy6sar+ci3qPecuBj4IfKXJoQf4Oeznq2VQe19nP181ZwL3NKvSnUJnNafPJ9kP3Jvk3wGP0wk+af7+ZrOy0zfpfFmr0Q1q799PsolOetoTwL9ozvczRSsWv4iQJEmS1CZT+zFQSZIkSZoGgxxJkiRJrWKQI0mSJKlVDHIkSZIktYpBjiRJkqRWMciRJEmS1CoGOZIkSZJa5f8DL+rH19igU4QAAAAASUVORK5CYII=\n",
|
|
"text/plain": [
|
|
"<Figure size 1152x864 with 2 Axes>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"nx = 400\n",
|
|
"arguments = InitialConditions.genShockBubble(nx, nx//4, 1.4)\n",
|
|
"plt.figure()\n",
|
|
"plt.imshow(Visualization.genSchlieren(arguments['rho']), cmap='gray')\n",
|
|
"plt.colorbar(orientation='vertical', aspect=20, pad=0.02, shrink=0.3)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Writing output to c:\\Users\\anbro\\Documents\\projects\\GPUSimulators\\data\\euler_shock-bubble_0006.nc\n",
|
|
"Opening c:\\Users\\anbro\\Documents\\projects\\GPUSimulators\\data\\euler_shock-bubble_0006.nc\n",
|
|
"Keyword arguments: {'mode': 'w', 'clobber': False}\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Constructed in 1.875434160232544 seconds\n",
|
|
"Simulating to t=0.500000. Estimated 1699 timesteps (dt=0.000294)\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Closing c:\\Users\\anbro\\Documents\\projects\\GPUSimulators\\data\\euler_shock-bubble_0006.nc\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"nx = 800#1600\n",
|
|
"ny = nx//4\n",
|
|
"g = 0.0\n",
|
|
"gamma = 1.4\n",
|
|
"t_end = 0.5#3.0\n",
|
|
"n_save = 20#500\n",
|
|
"outfile = \"data/euler_shock-bubble.nc\"\n",
|
|
"outdata = None\n",
|
|
"\n",
|
|
"arguments = InitialConditions.genShockBubble(nx, ny, gamma)\n",
|
|
"arguments['context'] = my_context\n",
|
|
"outfile = runSimulation(outfile, t_end, arguments)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Writing output to c:\\Users\\anbro\\Documents\\projects\\GPUSimulators\\data\\euler_shock-bubble_0006.nc\n",
|
|
"Opening c:\\Users\\anbro\\Documents\\projects\\GPUSimulators\\data\\euler_shock-bubble_0006.nc\n",
|
|
"Arguments: ('r',)\n",
|
|
"Closing c:\\Users\\anbro\\Documents\\projects\\GPUSimulators\\data\\euler_shock-bubble_0006.nc\n",
|
|
"Exception caught: Resetting to CUDA context my_context\n",
|
|
"Traceback (most recent call last):\n",
|
|
" File \"c:\\Users\\anbro\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\IPython\\core\\interactiveshell.py\", line 3267, in run_code\n",
|
|
" exec(code_obj, self.user_global_ns, self.user_ns)\n",
|
|
" File \"<ipython-input-10-ddea935f97e0>\", line 2, in <module>\n",
|
|
" createAnimation(outfile, vis_type=VisType.Schlieren, vmin=-0.2, vmax=0.2, cmap=plt.cm.RdBu, save_anim=False, fig_args={'figsize':(16, 5)})\n",
|
|
" File \"<ipython-input-7-4893a31896f1>\", line 18, in createAnimation\n",
|
|
" for key in sim_args:\n",
|
|
"RuntimeError: dictionary changed size during iteration\n",
|
|
"Popping <306858187648>\n",
|
|
"Pushing <306858187648>\n"
|
|
]
|
|
},
|
|
{
|
|
"ename": "RuntimeError",
|
|
"evalue": "dictionary changed size during iteration",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[1;31mRuntimeError\u001b[0m Traceback (most recent call last)",
|
|
"\u001b[1;32m<ipython-input-10-ddea935f97e0>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m#outfile = 'data/euler_shock-bubble_0008.nc'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mcreateAnimation\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0moutfile\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvis_type\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mVisType\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mSchlieren\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvmin\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m0.2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvmax\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0.2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcmap\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mplt\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcm\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mRdBu\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msave_anim\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mFalse\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfig_args\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m{\u001b[0m\u001b[1;34m'figsize'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m16\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
"\u001b[1;32m<ipython-input-7-4893a31896f1>\u001b[0m in \u001b[0;36mcreateAnimation\u001b[1;34m(infile, vis_type, vmin, vmax, save_anim, cmap, fig_args)\u001b[0m\n\u001b[0;32m 16\u001b[0m \u001b[0mcreated\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mindata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mncfile\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcreated\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 17\u001b[0m \u001b[0msim_args\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mjson\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloads\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mncfile\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msim_args\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 18\u001b[1;33m \u001b[1;32mfor\u001b[0m \u001b[0mkey\u001b[0m \u001b[1;32min\u001b[0m \u001b[0msim_args\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 19\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msim_args\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlist\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 20\u001b[0m \u001b[0msim_args\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|
"\u001b[1;31mRuntimeError\u001b[0m: dictionary changed size during iteration"
|
|
]
|
|
},
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"<Figure size 1152x360 with 0 Axes>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"#outfile = 'data/euler_shock-bubble_0008.nc'\n",
|
|
"createAnimation(outfile, vis_type=VisType.Schlieren, vmin=-0.2, vmax=0.2, cmap=plt.cm.RdBu, save_anim=False, fig_args={'figsize':(16, 5)})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Kelvin-Helmholtz"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"nx = 400\n",
|
|
"arguments = InitialConditions.genKelvinHelmholtz(nx, nx//4, 1.4)\n",
|
|
"\n",
|
|
"plt.figure()\n",
|
|
"plt.imshow(arguments['rho'])\n",
|
|
"plt.colorbar(orientation='vertical', aspect=20, pad=0.02, shrink=0.3)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"nx = 400\n",
|
|
"ny = nx//2\n",
|
|
"roughness = 0.125\n",
|
|
"t_end = 10.0\n",
|
|
"n_save = 100#1000\n",
|
|
"outfile = \"data/euler_kelvin_helmholtz.nc\"\n",
|
|
"outdata = None\n",
|
|
"\n",
|
|
"arguments = InitialConditions.genKelvinHelmholtz(nx, ny, gamma, roughness)\n",
|
|
"arguments['context'] = my_context\n",
|
|
"outfile = runSimulation(outfile, t_end, arguments)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#outfile='data/euler_kelvin_helmholtz_0012.nc'\n",
|
|
"createAnimation(outfile, vis_type=VisType.Density, vmin=1.0, vmax=2.0, save_anim=False, fig_args={'figsize':(16, 9)})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Rayleigh-Taylor\n",
|
|
"\n",
|
|
"* Liska and Wendroff, COMPARISON OF SEVERAL DIFFERENCE SCHEMES ON 1D AND 2D TEST PROBLEMS FOR THE EULER EQUATIONS, http://www-troja.fjfi.cvut.cz/~liska/CompareEuler/compare8.pdf\n",
|
|
"* https://www.astro.princeton.edu/~jstone/Athena/tests/rt/rt.html\n",
|
|
"* "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"nx = 400\n",
|
|
"arguments = InitialConditions.genRayleighTaylor(nx, nx*3, 1.4, version=0)\n",
|
|
"plotVars(arguments['rho'], arguments['rho_u'], arguments['rho_v'], arguments['E'])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"nx = 151\n",
|
|
"ny = nx*3\n",
|
|
"g = 0.1\n",
|
|
"gamma = 1.4\n",
|
|
"t_end = 30\n",
|
|
"n_save = 300\n",
|
|
"outfile = \"data/euler_rayleigh-taylor.nc\"\n",
|
|
"outdata = None\n",
|
|
"\n",
|
|
"arguments = InitialConditions.genRayleighTaylor(nx, ny, gamma)\n",
|
|
"arguments['context'] = my_context\n",
|
|
"outfile = runSimulation(outfile, t_end, arguments)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#outfile = 'data/euler_rayleigh-taylor_0007.nc'\n",
|
|
"createAnimation(outfile, vis_type=VisType.Density, vmin=1, vmax=2, cmap=plt.cm.coolwarm, save_anim=False, fig_args={'figsize':(3.4, 8)})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python [conda env:anaconda3]",
|
|
"language": "python",
|
|
"name": "conda-env-anaconda3-py"
|
|
},
|
|
"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.6.7"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|