{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Extract trajectories from Set1ext for PPN single-zone processing\n", "This notebook shows how to extract notebooks from Set1ext models, anywhere. These methods should be used to create trajectories for the OZoNe project\n", "\n", "FH (170621)\n", "\n", "This notebook lives in this repo: https://github.com/NuGrid/wendi-examples\n", "\n", "### How ipython notebooks work\n", "\n", "If you have never used an ipython notebook, then here are the few basic rules you need to know:\n", "\n", "* each cell is a block of code or comments (in markdown, see pull-down menu above)\n", "* in each cell you can edit code, several lines using the `Return` key to create a newline\n", "* once you are happy with a block of code use the _play_ button above, or just hit `Shift`-`Return` to execute the block of code\n", "* in this notebook you use the [NuGridPy tools](http://nugridpy.phys.uvic.ca) to analyze data, [latest version on Github](https://github.com/NuGrid/NuGridPy) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Initialize session" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%pylab \n", "from nugridpy import nugridse as mp\n", "from nugridpy import mesa as ms\n", "\n", "data_dir=\"/data/nugrid_apod2/\" \n", "\n", "ms.set_nugrid_path(data_dir)\n", "mp.set_nugrid_path(data_dir)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Select the model you would like to etract a trajectory from\n", "\n", "Create MESA instance, plot Kippenhahn diagrams and select location of the trajectory to be extracted." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "s=ms.star_log(mass=12,Z=0.006)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ifig=111;close(ifig);figure(ifig)\n", "s.kippenhahn(111,'model')\n", "xlim(100,1500)\n", "ylim(0, 6)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "ifig=107;close(ifig);figure(ifig)\n", "s.kip_cont(ifig=ifig)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We extract the thermodynamic trajectory from the mppnp output se files:\n", "\n", "### The NuGrid post-processing model\n", "Initialise:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pt=mp.se(mass=12,Z=0.006)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Two ways of writing the trajectory\n", "\n", "### nugridse method \"trajectory\" \n", "This method writes a trajectory at constant mass. The docstring says it interpolates to the given mass coordinate. The output format does not have any headers and creates a blank file, which is not good." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m_coor = 0.15\n", "model_start = 235\n", "r,rho,temperature, time = pt.trajectory(model_start, 1306, 10,\\\n", " m_coor, age_in_sec=True, online=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "%less traj_0.15.dat" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ascii_table method \n", "The `ascii_table.writeTraj` method of the `ascii_table` module of NuGridPy is meant to produce a standard trajectory format with header. \n", "\n", "**Task A1:** Use `ascii_table.writeTraj` in `nugridse.trajectory` for writing the actual trajectory.\n", "\n", "**Task A2:** Make sure that `ascii_table.writeTraj` trajectory is a valid nsource option in `ppn`.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from nugridpy import ascii_table as at" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%rm trajectory.input\n", "at.writeTraj(filename='trajectory.input', data=[time,temperature,rho], \\\n", " ageunit=1, tunit=1, rhounit=0, idNum=0)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "%less trajectory.input" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Extract initial abundance at beginning of trajectory\n", "This method produces an initial abundance file in some odd format, it does have a header, however, we have maybe other formats for this, such as the `iniab.dat` format?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pt.abund_at_masscoordinate(model_start,m_coor,online=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "%less massf_0.15.dat" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Task B1:** Review the output format of `nugridse.abund_at_masscoordinate` method. Is there a better format for initial abundances already supported in `ppn`? \n", "\n", "Initial response: now, this is a good format.\n", "\n", "**Task B2:** Make sure that whatever the adopted output of `nugridse.abund_at_masscoordinate` is, it can be read correctly by `ppn`.\n", "\n", "**Task B3:** `nugridse.abund_at_masscoordinate` method takes the nearest mass on grid point, but does not interpolate. This is inconsistent with what `nugridse.trajectory` is doing. This needs to be fixed in `nugridse.abund_at_masscoordinate` so that it is interpolating to the exact mass coordinate." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Extract Set1 trajectories\n", "\n", "With this capability in hand we can extract trajectories from all environments to be found in Set1Ext. \n", "\n", "Trajectory name | comment | lead\n", "------------------|---------------|-----\n", "MS burn low-mass | M=2, Z=0.01 |\n", "MS burn massives | M=12, Z=0.006 | Falk\n", "PDCZ | .... | Adria\n", "CC explosion | .... | Syndey?\n", "C-shell | | \n", "\n", "**Task C1:** add to this table\n", "\n", "**Task C2:** extract a trajectory, setup a ppn RUN" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.12" } }, "nbformat": 4, "nbformat_minor": 1 }