Skip to content

Instantly share code, notes, and snippets.

@paulromano
Created May 17, 2016 14:36
Show Gist options
  • Save paulromano/8ea9ee0b566df154774a5d8725ef0728 to your computer and use it in GitHub Desktop.
Save paulromano/8ea9ee0b566df154774a5d8725ef0728 to your computer and use it in GitHub Desktop.
Example of openmc.make_hexagon_region()
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import openmc\n",
"from IPython.display import Image"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"m = openmc.Material()\n",
"m.add_nuclide('U-235', 1.0)\n",
"m.set_density('g/cm3', 1.0)\n",
"mats = openmc.Materials([m])\n",
"mats.default_xs = '71c'\n",
"mats.export_to_xml()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"hex = openmc.make_hexagon_region(orientation='y')\n",
"inside_hex = openmc.Cell(fill=m, region=hex)\n",
"\n",
"sph = openmc.Sphere(R=1., boundary_type='vacuum')\n",
"outside_hex = openmc.Cell(fill=m, region=~hex & -sph)\n",
"\n",
"geom = openmc.Geometry()\n",
"geom.root_universe = openmc.Universe(0, cells=(inside_hex, outside_hex))\n",
"geom.export_to_xml()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsAgMAAAAEE2bmAAAABGdBTUEAALGPC/xhBQAAACBjSFJN\nAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACVBMVEX///9yEhJNv8RfnfQs\nAAAAAWJLR0QAiAUdSAAAAAd0SU1FB+AFEQ4jNRhRkOAAAAQYSURBVHja7ZxBkpswEEWtRR9BmzlC\nTsERWCAvOALniY/ghXXKGDNIAiMktT5JTwxVqUkWfvX0rYyxrf6Xy9+8tDFm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xPg87NEUcsMs/3YoHmDJHzj8i5TOi8\n6Csw0Bwrcr4WOfcLnUeeWJg56Sl8zPw2cq4cOe8OncOnArFUPwCytwDZpwDteUD2TyB7MaB9HZQn\nltUjguw3QfauQPtgkD01qeaihVaqvcgtEtDrg+wbQvYgQfuZkL1R0D4rZM8Wsv8L2kuG7EuD9rgh\n++WQvXfQPj5kTyC0vxDZqwjte4T2UCL7MaG9ncg+UWjPqX8uFxui4bGQvbDQvlpojy603/dS0jv8\nB4ZwtMI9TqS3AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE2LTA1LTE3VDA5OjM1OjUzLTA1OjAwLIwb\nuAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNi0wNS0xN1QwOTozNTo1My0wNTowMF3RowQAAAAASUVO\nRK5CYII=\n",
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p = openmc.Plot()\n",
"p.origin = (0., 0., 0.)\n",
"p.width = (2., 2.)\n",
"p.pixels = (300, 300)\n",
"openmc.Plots([p]).export_to_xml()\n",
"\n",
"openmc.plot_geometry(output=False)\n",
"!convert plot.ppm plot.png\n",
"Image('plot.png')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(-10000 10001 -10002 -10003 10004 10005)\n"
]
}
],
"source": [
"print(hex)"
]
}
],
"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.5.1"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment