{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Set, add, remove\n", "\n", "The user needs to link materials, absorbers and detectors to Experiment() objects and pins to Assembly() objects. The syntax is very similar to create all this linking for each of these class types. Below one can find some basic examples, which are not covered in the other tutorials (there only the set functions are used).\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from feign.blocks import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting materials" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Material(matID=1), '2': Material(matID=2)}" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "uo2=Material('1')\n", "h2o=Material('2')\n", "zr=Material('3')\n", "ss=Material('4')\n", "lead=Material('5')\n", "ex=Experiment()\n", "ex.set_materials(uo2,h2o)\n", "ex.materials" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Material(matID=1), '2': Material(matID=2), '3': Material(matID=3)}" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.add_material(zr)\n", "ex.materials" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Material(matID=1),\n", " '2': Material(matID=2),\n", " '3': Material(matID=3),\n", " '4': Material(matID=4),\n", " '5': Material(matID=5)}" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.add_material(ss,lead)\n", "ex.materials" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Material(matID=1),\n", " '3': Material(matID=3),\n", " '4': Material(matID=4),\n", " '5': Material(matID=5)}" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.remove_material(h2o)\n", "ex.materials" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'4': Material(matID=4), '5': Material(matID=5)}" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.remove_material(zr,uo2)\n", "ex.materials" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ID 1 is not in dict yet\n" ] } ], "source": [ "ex.remove_material(uo2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting pins" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Pin(pinID=1), '2': Pin(pinID=2)}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fuel1=Pin('1')\n", "fuel2=Pin('2')\n", "fuel3=Pin('3')\n", "fuel4=Pin('4')\n", "fuel5=Pin('5')\n", "assy=Assembly(17,17)\n", "assy.set_pins(fuel1,fuel2)\n", "assy.pins" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Pin(pinID=1), '2': Pin(pinID=2), '3': Pin(pinID=3)}" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "assy.add_pin(fuel3)\n", "assy.pins" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Pin(pinID=1),\n", " '2': Pin(pinID=2),\n", " '3': Pin(pinID=3),\n", " '4': Pin(pinID=4),\n", " '5': Pin(pinID=5)}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "assy.add_pin(fuel4,fuel5)\n", "assy.pins" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Pin(pinID=1), '3': Pin(pinID=3), '4': Pin(pinID=4), '5': Pin(pinID=5)}" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "assy.remove_pin(fuel2)\n", "assy.pins" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'4': Pin(pinID=4), '5': Pin(pinID=5)}" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "assy.remove_pin(fuel1,fuel3)\n", "assy.pins" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ID 1 is not in dict yet\n" ] } ], "source": [ "assy.remove_pin(fuel1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting detectors" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Detector(detID=1), '2': Detector(detID=2)}" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "d1=Detector('1')\n", "d2=Detector('2')\n", "d3=Detector('3')\n", "d4=Detector('4')\n", "d5=Detector('5')\n", "ex=Experiment()\n", "ex.set_detectors(d1,d2)\n", "ex.detectors" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Detector(detID=1), '2': Detector(detID=2), '3': Detector(detID=3)}" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.add_detector(d3)\n", "ex.detectors" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Detector(detID=1),\n", " '2': Detector(detID=2),\n", " '3': Detector(detID=3),\n", " '4': Detector(detID=4),\n", " '5': Detector(detID=5)}" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.add_detector(d4,d5)\n", "ex.detectors" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Detector(detID=1),\n", " '3': Detector(detID=3),\n", " '4': Detector(detID=4),\n", " '5': Detector(detID=5)}" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.remove_detector(d2)\n", "ex.detectors" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'4': Detector(detID=4), '5': Detector(detID=5)}" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.remove_detector(d1,d3)\n", "ex.detectors" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ID 1 is not in dict yet\n" ] } ], "source": [ "ex.remove_detector(d1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting absorbers" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Absorber(absID=1), '2': Absorber(absID=2)}" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a1=Absorber('1')\n", "a2=Absorber('2')\n", "a3=Absorber('3')\n", "a4=Absorber('4')\n", "a5=Absorber('5')\n", "ex=Experiment()\n", "ex.set_absorbers(a1,a2)\n", "ex.absorbers" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Absorber(absID=1), '2': Absorber(absID=2), '3': Absorber(absID=3)}" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.add_absorber(a3)\n", "ex.absorbers" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Absorber(absID=1),\n", " '2': Absorber(absID=2),\n", " '3': Absorber(absID=3),\n", " '4': Absorber(absID=4),\n", " '5': Absorber(absID=5)}" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.add_absorber(a4,a5)\n", "ex.absorbers" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'1': Absorber(absID=1),\n", " '3': Absorber(absID=3),\n", " '4': Absorber(absID=4),\n", " '5': Absorber(absID=5)}" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.remove_absorber(a2)\n", "ex.absorbers" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'4': Absorber(absID=4), '5': Absorber(absID=5)}" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ex.remove_absorber(a1,a3)\n", "ex.absorbers" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ID 1 is not in dict yet\n" ] } ], "source": [ "ex.remove_absorber(a1)" ] } ], "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 }