{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Populating the interactive namespace from numpy and matplotlib\n" ] } ], "source": [ "# %pylab\n", "# %matplotlib inline\n", "%pylab ipympl\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import matplotlib.tri as tri\n", "import matplotlib.ticker as tick\n", "import scipy.integrate\n", "import scipy.stats\n", "import nugridpy.utils as utils\n", "import nugridpy.astronomy as ast\n", "import sys\n", "import os\n", "import time\n", "import logging\n", "import collections\n", "import shutil\n", "\n", "# my modules\n", "sys.path.insert(0,'/home/user/home/advection-streams/')\n", "import hydromixing.mixer as mixer\n", "import hydromixing.run as run\n", "\n", "sys.path.insert(0,'/home/user/home/PyPPM/')\n", "from ppmpy import ppm\n", "\n", "cb = utils.linestylecb # colours\n", "\n", "# plot things\n", "ifig = 0\n", "ptrack = {}\n", "\n", "# turn off matplotlib messages\n", "logging.getLogger(\"matplotlib\").setLevel(logging.ERROR)\n", "\n", "# define a named tuple Hcore\n", "Hcore = collections.namedtuple('Hcore', 'momsdata rprof')" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3556 rprof files found in '/user/cedar_scratch_djstephe/N15-LowZRAWD-768-10x-burn-moms/prfs/.\n", "Dump numbers range from 0 to 3555.\n" ] } ], "source": [ "rprof_dir = '/user/cedar_scratch_djstephe/N15-LowZRAWD-768-10x-burn-moms/prfs/'\n", "\n", "var_list = ['xc','ux','uy','uz','|ut|','|ur|','|w|','P','rho','fv']\n", "n15 = Hcore(10,ppm.RprofSet(rprof_dir))\n", "n15_history = n15.rprof.get_history()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "12.091567661547378 14.0 10.0\n", "(array([], dtype=int64),)\n" ] } ], "source": [ "# the run is...\n", "dumpStart = 100\n", "dumpEnd = 3550\n", "dumps = list(range(dumpStart, dumpEnd+1))\n", "\n", "# create stream object\n", "initbase_base = './N15-standard/N15-standard'\n", "stream = mixer.Stream(initbase_base, 'advection',initdump=dumpStart)\n", "advect = mixer.Advection(initbase_base,Cmax=0.5,initdump=dumpStart)\n", "\n", "# # I need to modify the central file as well\n", "stream.readFile(initbase_base, 'advection', 'shell', dumpStart)\n", "stream.readFile(initbase_base, 'advection', 'central', dumpStart)\n", "\n", "# when not using subtime steps, how many steps per dump? Set to 1 if subtime steps\n", "steps_per_dump = 1\n", "\n", "# data for appropriate mass fractions from central\n", "stop = len(stream.shellData['v'])\n", "lcli = np.max(np.where(stream.shellData['v'][0:int(stop/2)] <= 0))\n", "ucli = np.min(np.where(stream.shellData['v'][(lcli+1):] <= 0)) + lcli\n", "\n", "stream.X = stream.X[:,lcli:ucli+1]\n", "# stream.X = stream.X[:, 0:stop-1]\n", "data_dict = {'X':stream.X[0,:], '(1-X)':stream.X[1,:]}\n", "\n", "# write to file\n", "initbase_change = './N15-standard-mppnp/N15-standard-mppnp'\n", "stream.writeFile(initbase_change, dumpStart, data_dict, stream.burnHeaders, fileExt='central')\n", "\n", "# save number of subtime steps that would be done\n", "all_subtimesteps = np.zeros(len(dumps))\n", "entr_rate = np.zeros(len(dumps))\n", "\n", "# cycle counter\n", "cycle = dumpStart - 1\n", "\n", "for idump, dump in enumerate(dumps):\n", " \n", " # remove base dump for reading\n", " dump = dump - dumps[0]\n", "\n", " # read in data\n", " stream.readFile(initbase_base, 'advection', 'shell', dump + dumps[0])\n", " advect.newDump(dump + dumps[0])\n", " \n", " dumpstep = (n15.rprof.get('t',fname=dump+dumps[0]+1) - n15.rprof.get('t',fname=dump+dumps[0]))\n", " dtmax_dump = advect.dtmax\n", " all_subtimesteps[idump] = int(np.ceil(dumpstep / dtmax_dump))\n", " entr_rate[idump] = stream.shellHeaders['entrainmentRate']\n", " \n", " # since this is for mppnp, cut out the excess boundaries\n", " stop = len(stream.shellData['v'])\n", " lsli = np.max(np.where(stream.shellData['v'][0:int(stop/2)] <= 0))\n", " usli = np.min(np.where(stream.shellData['v'][(lsli+1):] <= 0)) + lsli + 1\n", "\n", " for key in stream.shellData.keys():\n", " stream.shellData[key] = stream.shellData[key][lcli:usli+1]\n", " \n", " # for every step per dump\n", " for counter in range(steps_per_dump):\n", " \n", " # what file cycle are we?\n", " cycle += 1\n", " \n", " # if no subtime steps, I must write files explicitly\n", " if steps_per_dump > 1:\n", " \n", " # add new headers for mppnp, timestep and subtimesteps\n", " stream.shellHeaders['timestep'] = dumpstep / dtmax_dump \n", " stream.shellHeaders['subtimesteps'] = 1\n", " \n", " else:\n", "\n", " # add new headers for mppnp, timestep and subtimesteps\n", " stream.shellHeaders['timestep'] = dumpstep\n", " stream.shellHeaders['subtimesteps'] = int(np.ceil(stream.shellHeaders['timestep'] / dtmax_dump))\n", "\n", " # rewrite file\n", " stream.writeFile(initbase_change, cycle, stream.shellData, stream.shellHeaders, if6d=False)\n", " \n", "print(all_subtimesteps.mean(), all_subtimesteps.max(), all_subtimesteps.min())\n", "print(np.where(entr_rate < 0))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.6.8" } }, "nbformat": 4, "nbformat_minor": 4 }