需要自取,欢迎讨论,不喜勿喷。
详细设定可见官网python API
输入卡说明:
#==============================================================================
# program: openmc input card description
# author: liusy
# email: liusongyang@hrbeu.edu.cn
# date: 2022-05-23
# part: main
# description:
#
# a brief introduction to openmc input card
# &
# several simple cases
#
#==============================================================================
#==============================================================================
# abbreviation
#==============================================================================
<...> - optional place
/.../ - addtional place
rho - density
BC - boundary condition
#==============================================================================
#==============================================================================
# TIPS
#==============================================================================
I. The center of GEO better at origin.
II. "region in -> cell" can be repeated applied, but "cell in -> uni" only once.
III.surf -> region: surf must be pointed out <+ or ->, but region not.
IV.
V.
VI.
#==============================================================================
#==============================================================================
# MAT
#==============================================================================
* structure
elements---|
|---> material---> Materials---> export_to_xml()
nuclides---| |
| |
| |
mixture------|
* syntax:
* step 1:
* material general define
<mat name> = openmc.Material()
* compositions setting
* a. nuclide (for certain [ISO][A]):
<mat name>.add_nuclide('<nuclide name>', <value>, '<fraction option>')
- ao * atom fraction
- wo * weight fraction
* b. element (call data library component):
<mat name>.add_element('<element name>',
<value>,
/enrichment = <enrich value *unit: %>/,
/enrichmnet_target = '<target nuclide>'/,
/enrichment_type = '<fraction type *ao, wo>'/)
/* ********************************* *\
1. nuclide
fuel = openmc.Material()
fuel.add_nuclide('U235', 0.03, 'ao')
fuel.add_nuclide('U238', 0.97, 'ao')
fuel.add_nuclide('016', 2.00, 'ao')
...
2. element
fuel = openmc.Material()
fuel.add_element('U', 1, enrichment = 0.03, enrichment_target = 'U235', enrichment_type = 'wo')
fuel.add_nuclide('016', 0.118581, 'wo')
...
\* ********************************* */
* temperature
<mat name>.temperature = <temperature value> *unit: K
/* ********************************* *\
temperature setting priority
cell | high
|
material | priority
|
global | low
↓
\* ********************************* */
<mat name>.set_density('<unit>', <rho value>)
- g/cm3
- kg/m3
- atom/b-cm
* !!! thermal scattering for isotope H
<only constant water mat name>.add_s_alpha_beta('c_H_in_H2O')
* mixture
<mix name> = openmc.Material.mix_materials([<mat list>, <frac list>, '<frac option>'])
- wo
- ao
* !!! c_H_in_H2O can not work for mat which only including in mix, but work for mix
* step 2
* Mats list
<mats name> = openmc.Materials([<mat 1>, <mat 2> ...])
or
<mats name> = openmc.Materials() * mats is a python list
<mats name>.append(<mat 1>)
<mats name> += [<mat 2>, <mat 3>, ...]
* export
<mats name>.export_to_xml()
#==============================================================================
#==============================================================================
# GEO
#==============================================================================
* structure:
surface---> cell---|
| |
uni----|---> openmc.Geometry([<uni a>, <uni b>, ...])---> export_to_xml()
| |
lat----|
* syntax:
* surf:
* plane
<pl name> = openmc.XPlane(x0=<num>, /boundary_type='<BC>'/)
<pl name> = openmc.YPlane(y0=<num>, /boundary_type='<BC>'/)
<pl name> = openmc.ZPlane(z0=<num>, /boundary_type='<BC>'/)
<pl name> = openmc.Plane(..., /boundary_type='<BC>'/)
* cylinder
<cyl name> = openmc.XCylinder(y0=<num>, z0=<num>, r=<num>)
<cyl name> = openmc.YCylinder(x0=<num>, z0=<num>, r=<num>)
<cyl name> = openmc.ZCylinder(x0=<num>, y0=<num>, r=<num>)
* sphere
<sph name> = openmc.Sphere(x0=<num>, y0=<num>, z0=<num>, r=<num>, /boundary_type='<BC>'/)
* cone /圆锥
<con name> = openmc.Xcone()
<con name> = openmc.Ycone()
<con name> = openmc.Zcone()
* Quadric /自由面
<qua name> = openmc.Quadric()
* !!! BC -reflective
-vaccum
-periodic *see following details
* periodic boundary condition:
<periodic surface 1> = openmc.<surf>(<parameters>, boundary_type='periodic')
<periodic surface 2> = openmc.<surf>(<parameters>, boundary_type='periodic')
<periodic surface 1>.periodic_surface = <periodic surface 2>
* region:
* prism: --> region, not surface !!!
* Rect
<prism region name> = openmc.rectangular_prism(
width=<value>,
height=<value>,
\boundary_type='<BC>'\
\origin = (<x0>, <y0>)\
\corner_radius = <r0>\
)
* Hex
<prism region name> = openmc.hexagonal_prism(
edge_length=<value>,
\boundary_type='<BC>'\
\origin = (<x0>, <y0>)\
\orientation = '<x or y>' *default is y\
)
/* ********************************* *\
edge_length
|-----------|-> corner ↑
| | /--+--\ / \
| | / | \ / \
| |height / | \ | |
| | \ / | |
| | \ / \ /
|-----------| \-----/ \ /
width orientation = x orientation = y
\* ********************************* */
* region define
<region name> = <+ or -><surf name>
&
<region name> = <& or | or ~ *交 并 补><region name>
* universe:
<universe name> = openmc.Universe(cells=[<cell1>, <cell2> ,,,])
or
<universe name> = openmc.Universe()
<universe name>.add_cells([<cell1, cell2 ,,,>])
<universe name>.add_cell(cell3)
* lattice:
* 1. Rec/四边形
<lat name> = openmc.RectLattice()
* lower left point location
* 2D:
<lat name>.lower_left = (<x>, <y>)
<lat name>.pitch = (<x pitch>, <y pitch>)
<lat name>.universes = [[<u>, <u>, ...],[<u>, <u>, ...],[<u>, <u>, ...], ...]
or
import numpy as np
<lat name>.universes = np.tile(<u>, (n, n))
or
<lat name>.universe = [[pin] * <num lat line pin>] * <num lat line pin>
* 3D:
<lat name>.lower_left = (<x>, <y>, <z>)
<lat name>.pitch = (<x pitch>, <y pitch>, <z pitch>)
<lat name>.universes = [[[<u>, <u>, ...],[<u>, <u>, ...],[<u>, <u>, ...], ...]]
or
<lat name>.universes = np.empty((n,n,n), dtype=openmc.Universe)
<lat name>.universes[0, ...] = <uni a>
<lat name>.universes[1, ...] = <uni b>
<lat name>.universes[2, ...] = <uni c>
* 2. Hex/六边形
<lat name> = openmc.HexLattice()
<lat name>.center = (<x>, <y>)
<lat name>.pitch = [<pitch value>]
<ring name 1> = [<uni a>]
<ring name 2> = [<uni b>, <uni b>, ...]
....
<lat name>.universes = [<ring name 1>, <ring name 2>, ...]
* cell:
* cell general define
<cell name> = openmc.Cell(fill=<mat or universe or lat name or None>, region=<region name>)
* !!! None - void/真空
or
<cell name> = openmc.Cell()
<cell name>.fill = <mat or universe or lat name or None>
<cell name>.region = <region name>
* cell temperature
<cell name>.temperature = <temperature value> *unit: K
* export
* define universe as root
<uni name> = openmc.Universe(cells = [list - all cell name])
<geo name> = openmc.Geometry(<root uni>)
or
<geo name> = openmc.Geometry()
<geo name>.root_universe = (<root uni>)
* export_to_xml()
<geo name>.export_to_xml()
# * no need to point out cell name if including in lat part
#==============================================================================
#==============================================================================
# PLOT
#==============================================================================
* two plot methods:
* I. export to xml & openmc -p
* structure:
openmc.Plot1-|
. |
. |---> openmc.Plots---> Plots.export_to_xml()
. |
openmc.PlotN-|
* syntax:
* step 1:
* define plot command:
<plot name> = openmc.Plot()
* refine the command - axis
<plot name>.basis = '<axis>'
1.xy
2.xz
3.yz
4.voxel
* refine the command - center
<plot name>.origin = (x, y, z)
or
[x, y, z]
* refine the command - width and height
<plot name>.width = (width, height)
or
[width, height]
* refine the command - pixels (clearity)
<plot name>.pixels = (x pixels, y pixels)
or
[x pixels, y pixels]
* refine the command - color as material (default is colored by cell unit)
<plot name>.color_by = '<option>'
material
cell
* refine the command - assign the color /元组
<plot name>.colors = {<material name 1>: <option 1>, ....}
1. 'color name (like blue, red, yellow)'
2. rgb value
* refine the command - PPM name
<plot name>.filename = '<output file name>'
* step 2:
* combine plot commands together
* !!! <plots name> is a python list
<plots name> = openmc.Plots([<plot name 1>, <plot name 2>, ...])
* output plots
<plots name>.export_to_xml()
* step 3:
* run openmc plot in system:
* 1. add in input card (after plots.export_to_xml())
openmc.plot_geometry()
or
* 2. by command line
openmc -p
or
openmc --plot
* II. command 'to_ipython_image()' in input card
* define plot command:
<plot name> = openmc.Plot.from_geometry(<geo name which to export>)
* cross section
<plot name>.basis = '<axis>'
1.xy
2.xz
3.yz
4.voxel
* refine the command - center
<plot name>.origin = (x, y, z)
or
[x, y, z]
* refine the command - width and height
<plot name>.width = (width, height)
or
[width, height]
* refine the command - pixels (clearity)
<plot name>.pixels = (x pixels, y pixels)
or
[x pixels, y pixels]
* refine the command - color as material (default is colored by cell unit)
<plot name>.color_by = '<option>'
material
cell
* refine the command - assign the color /元组
<plot name>.colors = {<material name n>: (<option n>), ....}
1. 'color name (like blue, red, yellow)'
2. rgb value (like 51,161,201 )
* refine the command - PNG name
<plot name>.filename = '<output file name>'
* plot by ipython
<plot name>.to_ipython_image()
#==============================================================================
#==============================================================================
# TALLY
#==============================================================================
#==============================================================================
#==============================================================================
# SET
#==============================================================================
* structure:
running model----|
|
neutron cycle----|
|---> export_to_xml
external Source--|
|
photon transport-|
. |
.
* syntax
<set name> = openmc.Settings()
* 1.run model
<set name>.run_mode = '<run model option>'
- eigenvalue * keff calculation (default)
- fixed source * external source
- volume
- plot
- particle restart
* 2.run strategy
<set name>.batches = <total cycles number>
<set name>.particles = <neutrons per cycles>
<set name>.inactive = <skip cycles number>
* !!! fixed source is no need to set inactive cycles
<set name>.generations_per_batch = <generation number per cycle>
* 3.Source
* a.internal source
<src location> = openmc.states.Point((0, 0, 0))
<src name> = openmc.Source(space = <src location>)
* b.external source
<source name> = openmc.Source()
/* ********************* *\
|-- space
|
sources ----|-- angle
|
|-- energy
\* ********************* */
<source name>.space = openmc.stats.Box((x0,y0,z0),(x1,y1,z1))
Point
CartesianIndependent
SphericalIndependent
CyclindricalIndependent
Uniform(<func>,<value>)???
<source name>.angle = openmc.stats.Isotropic()
UnitSphere
Monodirectional
PolarAzimuthal
<source name>.energy = openmc.stats.Discrete([energy in eV list],[frac list])
Watt(???)
Tabular(???) * 表格化
* source strength
<source name 1>.strength = <frac value>
<source name 2>.strength = <frac value>
* particle
<source name>.particle = '<particle option>'
- photon
- neutron
* conbine together
<set name>.Source = <source name>
* 4.photon transport
<set name>.photon_transport = <True or False>
* 5.temperature
<set name>.temperature = {'multipole': <option>, 'method': '<option>', 'range': [<Tmin>, <Tmax>]}
-True -interpolation
-False -
#==============================================================================
#==============================================================================
# RUN
#==============================================================================
* OMP model:
# default threads is full/默认全线程
openmc.run()
# openmc.run(threads = N)
openmc.run(threads = N)
openmc -s N
openmc -threads N
* MPI model:
# by mpiexec wrapper
mpiexec -n <N> openmc
# by python API
openmc.run(mpi_args = ['mpiexec', '-n', '<N>'])
#==============================================================================
case pin model
#==============================================================================
# IMPORT
#==============================================================================
import openmc
#==============================================================================
#==============================================================================
# MAT
#==============================================================================
# fuel
M_fuel = openmc.Material()
M_fuel.set_density('g/cm3', 10.00)
M_fuel.add_nuclide('U235', 0.03 , 'ao')
M_fuel.add_nuclide('U238', 0.97 , 'ao')
M_fuel.add_nuclide('O16', 2.00 , 'ao')
# gap
M_gap = openmc.Material()
M_gap.set_density('g/cm3', 6.53)
M_gap.add_element('He', 1.00, 'wo')
# clad
M_clad = openmc.Material()
M_clad.set_density('g/cm3', 6.60)
M_clad.add_element('Zr', 0.9793, 'wo')
M_clad.add_element('Sn', 0.0092, 'wo')
M_clad.add_element('Zr', 0.0103, 'wo')
M_clad.add_element('Fe', 0.0012, 'wo')
# cool
M_cool = openmc.Material()
M_cool.set_density('g/cm3', 0.729)
M_cool.add_element('H', 2.00, 'ao')
M_cool.add_element('O', 1.00, 'ao')
M_cool.add_s_alpha_beta('c_H_in_H2O')
# export
list_mats = [M_fuel, M_gap, M_clad, M_cool]
M_mats = openmc.Materials(list_mats)
M_mats.export_to_xml()
#==============================================================================
#==============================================================================
# GEO
#==============================================================================
pitch = 1.26
# surf
Scy_fuelout = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = 0.39)
Scy_cladin = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = 0.40)
Scy_cladout = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = 0.46)
Spx_front = openmc.XPlane( pitch/2, boundary_type = 'reflective')
Spx_back = openmc.XPlane(-pitch/2, boundary_type = 'reflective')
Spy_right = openmc.YPlane( pitch/2, boundary_type = 'reflective')
Spy_left = openmc.YPlane(-pitch/2, boundary_type = 'reflective')
Sqc_BC = -Spx_front & +Spx_back & -Spy_right & +Spy_left
# region
R_fuel = -Scy_fuelout
R_gap = -Scy_cladin & +Scy_fuelout
R_clad = -Scy_cladout & +Scy_cladin
R_cool = Sqc_BC & +Scy_cladout
# cell
C_fuel = openmc.Cell()
C_fuel.fill = M_fuel
C_fuel.region = R_fuel
C_fuel.temperature = 1200
C_gap = openmc.Cell()
C_gap.fill = M_gap
C_gap.region = R_gap
C_clad = openmc.Cell()
C_clad.fill = M_clad
C_clad.region = R_clad
C_cool = openmc.Cell()
C_cool.fill = M_cool
C_cool.region = R_cool
# export
U_root = openmc.Universe(cells = (C_fuel, C_gap, C_clad, C_cool))
U_geo = openmc.Geometry(U_root)
U_geo.export_to_xml()
#==============================================================================
#==============================================================================
# SET
#==============================================================================
Set_point = openmc.stats.Point((0,0,0))
Set_src = openmc.Source(space = Set_point)
Set_set = openmc.Settings()
Set_set.Source = Set_src
Set_set.batches = 100
Set_set.inactive = 10
Set_set.particles = 10000
Set_set.export_to_xml()
#==============================================================================
#==============================================================================
# PLOT
#==============================================================================
# method 1
length = 1.26
plot_xy = openmc.Plot()
plot_xy.basis = 'xy'
plot_xy.origin = (0, 0, 0)
plot_xy.width = (length, length)
plot_xy.pixels = (1000, 1000)
plot_xy.color_by = 'material'
plot_yz = openmc.Plot()
plot_yz.basis = 'xy'
plot_yz.origin = (0, 0, 0)
plot_yz.width = (length, length)
plot_yz.pixels = (1000, 1000)
plot_yz.color_by = 'material'
list_plots = [plot_xy, plot_yz]
plots = openmc.Plots(list_plots)
plots.export_to_xml
# method 2
plot_geoxy = openmc.Plot.from_geometry(U_geo)
plot_geoxy.basis = 'xy'
plot_geoxy.origin = (0,0,0)
plot_geoxy.width = (length, length)
plot_geoxy.pixels = (1000, 1000)
plot_geoxy.color_by = 'material'
plot_geoxy.filename = 'plot_xy'
plot_geoxy.to_ipython_image()
plot_geoyz = openmc.Plot.from_geometry(U_geo)
plot_geoyz.basis = 'yz'
plot_geoyz.origin = [0,0,0]
plot_geoyz.width = [length, length]
plot_geoyz.pixels = [1000, 1000]
plot_geoyz.color_by = 'material'
plot_geoyz.filename = 'plot_yz'
plot_geoyz.to_ipython_image()
#==============================================================================
#==============================================================================
# TALLY
#==============================================================================
mesh = openmc.RegularMesh()
mesh.dimension = [10, 10]
mesh.lower_left = [-pitch/2, -pitch/2]
mesh.upper_right = [pitch/2, pitch/2]
mesh_filter = openmc.MeshFilter(mesh)
tally_E = openmc.Tally()
tally_E.filters = [mesh_filter]
tally_E.scores = ['flux']
tally_E = openmc.EnergyFilter([0.0, 1.0e5, 1.0e7])
list_tally = [tally_E]
tally = openmc.Tallies(list_tally)
tally.export_to_xml()
#==============================================================================
#==============================================================================
# RUN
#==============================================================================
openmc.run()
#==============================================================================
case lat model
#==============================================================================
# IMPORT
#==============================================================================
import openmc
#==============================================================================
#==============================================================================
# MAT
#==============================================================================
# fuel
M_fuel = openmc.Material()
M_fuel.set_density('g/cm3', 10.00)
M_fuel.add_nuclide('U235', 0.03 , 'ao')
M_fuel.add_nuclide('U238', 0.97 , 'ao')
M_fuel.add_nuclide('O16', 2.00 , 'ao')
# gap
M_gap = openmc.Material()
M_gap.set_density('g/cm3', 6.53)
M_gap.add_element('He', 1.00, 'wo')
# clad
M_clad = openmc.Material()
M_clad.set_density('g/cm3', 6.60)
M_clad.add_element('Zr', 0.9793, 'wo')
M_clad.add_element('Sn', 0.0092, 'wo')
M_clad.add_element('Zr', 0.0103, 'wo')
M_clad.add_element('Fe', 0.0012, 'wo')
# cool
M_cool = openmc.Material()
M_cool.set_density('g/cm3', 0.729)
M_cool.add_element('H', 2.00, 'ao')
M_cool.add_element('O', 1.00, 'ao')
M_cool.add_s_alpha_beta('c_H_in_H2O')
# export
list_mats = [M_fuel, M_gap, M_clad, M_cool]
M_mats = openmc.Materials(list_mats)
M_mats.export_to_xml()
#==============================================================================
#==============================================================================
# GEO
#==============================================================================
pitch_pin = 1.26
num_linepin = 17
pitch_lat = pitch_pin * num_linepin
height_pin = 350.0
height_core = 450.0
# surf
Scy_fuelout = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = 0.39)
Scy_cladin = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = 0.40)
Scy_cladout = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = 0.46)
Spx_front = openmc.XPlane( pitch_pin/2, boundary_type = 'reflective')
Spx_back = openmc.XPlane(-pitch_pin/2, boundary_type = 'reflective')
Spy_right = openmc.YPlane( pitch_pin/2, boundary_type = 'reflective')
Spy_left = openmc.YPlane(-pitch_pin/2, boundary_type = 'reflective')
Spx_1 = openmc.XPlane( pitch_lat/2, boundary_type = 'reflective')
Spx_2 = openmc.XPlane(-pitch_lat/2, boundary_type = 'reflective')
Spy_3 = openmc.YPlane( pitch_lat/2, boundary_type = 'reflective')
Spy_4 = openmc.YPlane(-pitch_lat/2, boundary_type = 'reflective')
Spz_top = openmc.ZPlane( height_pin/2)
Spz_bot = openmc.ZPlane(-height_pin/2)
Spz_coretop = openmc.ZPlane( height_core/2, boundary_type = 'vacuum')
Spz_corebot = openmc.ZPlane(-height_core/2, boundary_type = 'vacuum')
# region
R_fuel = -Scy_fuelout & +Spz_bot & -Spz_top
R_gap = -Scy_cladin & +Scy_fuelout & +Spz_bot & -Spz_top
R_clad = -Scy_cladout & +Scy_cladin & +Spz_bot & -Spz_top
R_cool = -Spx_front & +Spx_back & -Spy_right & +Spy_left & +Scy_cladout & +Spz_bot & -Spz_top
R_bot = -Spx_front & +Spx_back & -Spy_right & +Spy_left & -Spz_bot & +Spz_corebot
R_top = -Spx_front & +Spx_back & -Spy_right & +Spy_left & +Spz_top & -Spz_coretop
# cell
C_fuel = openmc.Cell()
C_fuel.fill = M_fuel
C_fuel.region = R_fuel
C_fuel.temperature = 1200
C_gap = openmc.Cell()
C_gap.fill = M_gap
C_gap.region = R_gap
C_clad = openmc.Cell()
C_clad.fill = M_clad
C_clad.region = R_clad
C_cool = openmc.Cell()
C_cool.fill = M_cool
C_cool.region = R_cool
C_bot = openmc.Cell()
C_bot.fill = M_cool
C_bot.region = R_bot
C_top = openmc.Cell()
C_top.fill = M_cool
C_top.region = R_top
# lat
list_region_pin = [C_fuel, C_gap ,C_clad, C_cool, C_bot, C_top]
FR = openmc.Universe(cells = list_region_pin)
lat = openmc.RectLattice()
lat.lower_left = (-pitch_lat/2, -pitch_lat/2)
lat.pitch = (pitch_pin, p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z_coretop
C_lat.fill = lat
# export
U_root = openmc.Universe(cells = [C_lat])
U_geo = openmc.Geometry(U_root)
U_geo.export_to_xml()
#==============================================================================
#==============================================================================
# SET
#==============================================================================
Set_point = openmc.stats.Point((0,0,0))
Set_src = openmc.Source(space = Set_point)
Set_set = openmc.Settings()
Set_set.Source = Set_src
Set_set.batches = 100
Set_set.inactive = 10
Set_set.particles = 10000
Set_set.export_to_xml()
#==============================================================================
#==============================================================================
# PLOT
#==============================================================================
length = pitch_pin * num_linepin
# method 1
plot_xy = openmc.Plot()
plot_xy.basis = 'xy'
plot_xy.origin = (0, 0, 0)
plot_xy.width = (length, length)
plot_xy.pixels = (1000, 1000)
plot_xy.color_by = 'material'
plot_xy.colors = {M_fuel:('yellow'),M_gap:('green'),M_clad:('gray'),M_cool:('blue')}
plot_yz = openmc.Plot()
plot_yz.basis = 'yz'
plot_yz.origin = (0, 0, 0)
plot_yz.width = (length, height_core)
plot_yz.pixels = (1000, 10000)
plot_yz.color_by = 'material'
plot_yz.colors = {M_fuel:'yellow',M_gap:'green',M_clad:'gray',M_cool:'blue'}
list_plots = [plot_xy, plot_yz]
plots = openmc.Plots(list_plots)
plots.export_to_xml()
openmc.plot_geometry()
# method 2
'''
plot_geoxy = openmc.Plot.from_geometry(U_geo)
plot_geoxy.basis = 'xy'
plot_geoxy.origin = (0,0,0)
plot_geoxy.width = (length, length)
plot_geoxy.pixels = (5000, 5000)
plot_geoxy.color_by = 'material'
plot_geoxy.filename = 'plot_xy'
plot_geoxy.colors = {M_fuel:('yellow'),M_gap:('green'),M_clad:('gray'),M_cool:('blue')}
plot_geoxy.to_ipython_image()
'''
'''
plot_geoyz = openmc.Plot.from_geometry(U_geo)
plot_geoyz.basis = 'yz'
plot_geoyz.origin = [0,0,0]
plot_geoyz.width = [length, height_core]
plot_geoyz.pixels = [1000, 1000]
plot_geoyz.color_by = 'material'
plot_geoyz.filename = 'plot_yz'
plot_geoyz.to_ipython_image()
'''
plot_pinxy = openmc.Plot.from_geometry(U_geo)
plot_pinxy.basis = 'xy'
plot_pinxy.origin = (0,0,0)
plot_pinxy.width = (pitch_pin/2, pitch_pin/2)
plot_pinxy.pixels = (500, 500)
plot_pinxy.color_by = 'material'
plot_pinxy.filename = 'plot_pinxy'
plot_pinxy.to_ipython_image()
#==============================================================================
#==============================================================================
# RUN
#==============================================================================
openmc.run()
#==============================================================================
case core model
#==============================================================================
# IMPORT
#==============================================================================
import openmc
#==============================================================================
#==============================================================================
'''
Abbr
UL UO2 fuel with LOW enrichment
UH UO2 fuel with HIGH enrichment
RB ROD LBANK
RG ROD GUIDE
LL LATTICE with LOW enrichment
LH LATTICE with HEIGH enrichment
LB LATTICE LBANK
'''
#==============================================================================
#==============================================================================
# MAT
#==============================================================================
# UO2
M_UO2L = openmc.Material()
M_UO2L.set_density('g/cm3', 10.96)
M_UO2L.add_nuclide('U235', 0.0365, 'ao')
M_UO2L.add_nuclide('U238', 0.9635, 'ao')
M_UO2L.add_nuclide('O16', 2.00 , 'ao')
M_UO2H = openmc.Material()
M_UO2H.set_density('g/cm3', 10.96)
M_UO2H.add_nuclide('U235', 0.0495, 'ao')
M_UO2H.add_nuclide('U238', 0.9505, 'ao')
M_UO2H.add_nuclide('O16' , 2.00 , 'ao')
# Gd2O3 fuel
M_GdFL = openmc.Material()
M_GdFL.set_density('g/cm3', 10.64)
M_GdFL.add_element('Gd' , 0.078442, 'wo')
M_GdFL.add_nuclide('U235', 0.005695, 'wo')
M_GdFL.add_nuclide('U238', 0.796453, 'wo')
M_GdFL.add_nuclide('O16' , 0.119785, 'wo')
M_GdFH = openmc.Material()
M_GdFH.set_density('g/cm3', 10.64)
M_GdFH.add_element('Gd' , 0.078442, 'wo')
M_GdFH.add_nuclide('U235', 0.020053, 'wo')
M_GdFH.add_nuclide('U238', 0.782094, 'wo')
M_GdFH.add_nuclide('O16' , 0.119785, 'wo')
# gap
M_gap = openmc.Material()
M_gap.set_density('g/cm3', 1.347E-4)
M_gap.add_element('He', 1.00, 'wo')
# clad
M_clad = openmc.Material()
M_clad.set_density('g/cm3', 6.53)
M_clad.add_element('Sn', 0.0092, 'wo')
M_clad.add_element('Nb', 0.0103, 'wo')
M_clad.add_element('Fe', 0.0012, 'wo')
M_clad.add_element('Zr', 0.9793, 'wo')
# cool
M_cool = openmc.Material()
M_cool.set_density('g/cm3', 0.729)
M_cool.add_element('H', 2.00, 'ao')
M_cool.add_element('O', 1.00, 'ao')
M_cool.add_s_alpha_beta('c_H_in_H2O')
# vessel
M_vess = openmc.Material()
M_vess.set_density('g/cm3', 6.616)
M_vess.add_element('C' , 0.0018, 'wo')
M_vess.add_element('Si', 0.0015, 'wo')
M_vess.add_element('Mn', 0.0147, 'wo')
M_vess.add_element('Mo', 0.0049, 'wo')
M_vess.add_element('Ni', 0.0074, 'wo')
M_vess.add_element('Cr', 0.0013, 'wo')
M_vess.add_element('Fe', 0.9684, 'wo')
# export
list_mats = [M_UO2L, M_UO2H, M_GdFL, M_GdFH, M_gap, M_clad, M_cool, M_vess]
M_mats = openmc.Materials(list_mats)
M_mats.export_to_xml()
#==============================================================================
#==============================================================================
# GEO
#==============================================================================
# assemLBy
num_linepin = 17
num_corelat = 11
# pitch cm
num_pitch_pin = 1.26
num_pitch_lat = num_pitch_pin * num_linepin
num_pitch_core= num_pitch_lat * num_corelat
# R cm
num_R_fuelout = 0.39
num_R_gapout = 0.40
num_R_cladout = 0.46
num_R_coreout = 115.
num_R_flanout = 120.
num_R_vessin = 128.
num_R_vessout = 148.
# H cm
num_Z_pinbot =-150.
num_Z_pintop = 150.
num_Z_corebot =-170.
num_Z_coretop = 170.
num_Z_vessbot =-180.
num_Z_vesstop = 180.
# surf
# Z
Spz_vessbot = openmc.ZPlane(num_Z_vessbot, boundary_type = 'vacuum')
Spz_corebot = openmc.ZPlane(num_Z_corebot, boundary_type = 'vacuum')
Spz_pinbot = openmc.ZPlane(num_Z_pinbot)
Spz_pintop = openmc.ZPlane(num_Z_pintop)
Spz_coretop = openmc.ZPlane(num_Z_coretop, boundary_type = 'vacuum')
Spz_vesstop = openmc.ZPlane(num_Z_vesstop, boundary_type = 'vacuum')
# cyl
Scy_fuelout = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = num_R_fuelout)
Scy_cladin = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = num_R_gapout )
Scy_cladout = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = num_R_cladout)
Scy_coreout = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = num_R_coreout)
Scy_flanout = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = num_R_flanout)
Scy_vessin = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = num_R_vessin )
Scy_vessout = openmc.ZCylinder(x0 = 0.0, y0 = 0.0, r = num_R_vessout, boundary_type = 'vacuum')
# region
Pri_pin = openmc.rectangular_prism(num_pitch_pin,num_pitch_pin)
Pri_lat = openmc.rectangular_prism(num_pitch_lat,num_pitch_lat)
R_fuel = -Scy_fuelout & +Spz_pinbot & -Spz_pintop
R_gap = -Scy_cladin & +Scy_fuelout & +Spz_pinbot & -Spz_pintop
R_clad = -Scy_cladout & +Scy_cladin & +Spz_pinbot & -Spz_pintop
R_cool = +Scy_cladout & +Spz_pinbot & -Spz_pintop & Pri_pin
R_pinbot = +Spz_corebot & -Spz_pinbot & Pri_pin
R_pintop = -Spz_coretop & +Spz_pintop & Pri_pin
# cell
C_UO2L = openmc.Cell(fill = M_UO2L, region = R_fuel)
C_UO2H = openmc.Cell(fill = M_UO2H, region = R_fuel)
#---------------------
C_GdFL = openmc.Cell()
C_GdFL.fill = M_GdFL
C_GdFL.region = R_fuel
C_GdFH = openmc.Cell()
C_GdFH.fill = M_GdFH
C_GdFH.region = R_fuel
#---------------------
C_gapL = openmc.Cell(fill = M_gap, region = R_gap)
C_gapH = openmc.Cell(fill = M_gap, region = R_gap)
C_cladL = openmc.Cell(fill = M_clad, region = R_clad)
C_cladH = openmc.Cell(fill = M_clad, region = R_clad)
C_coolL = openmc.Cell(fill = M_cool, region = R_cool)
C_coolH = openmc.Cell(fill = M_cool, region = R_cool)
C_pinbotL = openmc.Cell(fill = M_cool, region = R_pinbot)
C_pinbotH = openmc.Cell(fill = M_cool, region = R_pinbot)
C_pintopL = openmc.Cell(fill = M_cool, region = R_pintop)
C_pintopH = openmc.Cell(fill = M_cool, region = R_pintop)
C_LBank = openmc.Cell(fill = M_cool, region = Pri_pin)
C_empty = openmc.Cell(fill = M_cool, region = Pri_lat)
# uni
list_RodUO2L = [C_UO2L, C_gapL, C_cladL, C_coolL, C_pinbotL, C_pintopL]
list_RodUO2H = [C_UO2H, C_gapH, C_cladH, C_coolH, C_pinbotH, C_pintopH]
U_RodUO2L = openmc.Universe(cells = list_RodUO2L)
U_RodUO2H = openmc.Universe(cells = list_RodUO2H)
'''
U_RodGdFL = openmc.Universe(cells = list_RodGdFL)
U_RodGdFH = openmc.Universe(cells = list_RodGdFH)
'''
U_RodCool = openmc.Universe(cells = [C_LBank])
UL = U_RodUO2L
UH = U_RodUO2H
'''
GL = U_RodGdFL
GH = U_RodGdFH
'''
RB = U_RodCool
# lat
LB =openmc.Universe(cells = [C_empty])
L_UO2L = openmc.RectLattice()
L_UO2L.lower_left = (-num_pitch_lat/2, -num_pitch_lat/2)
L_UO2L.pitch = (num_pitch_pin, num_pitch_pin)
L_UO2L.universes = [
[UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL],
[UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL],
[UL,UL,UL,UL,UL,RB,UL,UL,RB,UL,UL,RB,UL,UL,UL,UL,UL],
[UL,UL,UL,RB,UL,UL,UL,UL,UL,UL,UL,UL,UL,RB,UL,UL,UL],
[UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL],
[UL,UL,RB,UL,UL,RB,UL,UL,RB,UL,UL,RB,UL,UL,RB,UL,UL],
[UL,UL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
[UL,UL,RB,UL,UL,RB,UL,UL,RB,UL,UL,RB,UL,UL,RB,UL,UL],
[UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL],
[UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL],
[UL,UL,RB,UL,UL,RB,UL,UL,RG,UL,UL,RB,UL,UL,RB,UL,UL],
[UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL],
[UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL],
[UL,UL,RB,UL,UL,RB,UL,UL,RB,UL,UL,RB,UL,UL,RB,UL,UL],
[UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL],
[UL,UL,UL,RB,UL,UL,UL,UL,UL,UL,UL,UL,UL,RB,UL,UL,UL],
[UL,UL,UL,UL,UL,RB,UL,UL,RB,UL,UL,RB,UL,UL,UL,UL,UL],
[UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL],
[UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL,UL]
]
C_LLA = openmc.Cell()
C_LLA.fill = L_UO2H
LA = openmc.Universe(cells = [C_LLA])
L_core = openmc.RectLattice()
L_core.lower_left = (-num_pitch_core/2, -num_pitch_core/2)
L_core.pitch = (num_pitch_lat, num_pitch_lat)
#L_core.universes = [[LL]*11]*11
L_core.universes = [[LB,LB,LB,LB,LB,LB,LB,LB,LB,LB,LB],
[LB,LB,LB,LH,LH,LH,LH,LH,LB,LB,LB],
[LB,LB,LH,LH,LH,LH,LH,LH,LH,LB,LB],
[LB,LH,LH,LH,LH,LL,LH,LH,LH,LH,LB],
[LB,LH,LH,LH,LL,LL,LL,LH,LH,LH,LB],
[LB,LH,LH,LL,LL,LL,LL,LL,LH,LH,LB],
[LB,LH,LH,LH,LL,LL,LL,LH,LH,LH,LB],
[LB,LH,LH,LH,LH,LL,LH,LH,LH,LH,LB],
[LB,LB,LH,LH,LH,LH,LH,LH,LH,LB,LB],
[LB,LB,LB,LH,LH,LH,LH,LH,LB,LB,LB],
[LB,LB,LB,LB,LB,LB,LB,LB,LB,LB,LB]]
C_core = openmc.Cell()
C_core.region = -Scy_coreout & +Spz_corebot & -Spz_coretop
C_core.fill = L_core
R_flan = +Scy_coreout & -Scy_flanout & +Spz_corebot & -Spz_coretop
C_flan = openmc.Cell(fill = M_vess, region = R_flan)
R_downChannel = +Scy_flanout & -Scy_vessin & +Spz_corebot & -Spz_coretop
C_downChannel= openmc.Cell(fill = M_cool, region = R_downChannel)
R_vess = +Scy_vessin & -Scy_vessout & +Spz_corebot & -Spz_coretop
C_vess = openmc.Cell(fill = M_vess, region = R_vess)
# export
list_cells = [C_core, C_flan, C_downChannel, C_vess]
U_root = openmc.Universe(cells = list_cells)
U_geo = openmc.Geometry(U_root)
U_geo.export_to_xml()
#==============================================================================
#==============================================================================
# SET
#==============================================================================
Set_point = openmc.stats.Point((0.,0.,0.))
Set_src = openmc.Source(space = Set_point)
Set_set = openmc.Settings()
Set_set.Source = Set_src
Set_set.batches = 100
Set_set.inactive = 10
Set_set.particles = 10000
Set_set.export_to_xml()
#==============================================================================
#==============================================================================
# PLOT
#==============================================================================
# method 1
plot_xy = openmc.Plot()
plot_xy.basis = 'xy'
plot_xy.origin = (0, 0, (num_Z_coretop+num_Z_corebot)/2)
plot_xy.width = (num_R_vessout*2, num_R_vessout*2)
plot_xy.pixels = (5000, 5000)
plot_xy.color_by = 'material'
plot_xy.colors = { M_UO2L:(255,153,18 ),
M_UO2H:(255,97 ,0 ),
M_gap:('green'),
M_clad:('gray'),
M_cool:('Blue'),
M_vess:('gray')}
plot_yz = openmc.Plot()
plot_yz.basis = 'yz'
plot_yz.origin = (0, 0, (num_Z_coretop+num_Z_corebot)/2)
plot_yz.width = (num_R_vessout*2, num_Z_coretop-num_Z_corebot)
plot_yz.pixels = (8000, 10000)
plot_yz.color_by = 'material'
plot_yz.colors = { M_UO2L:(255,153,18 ),
M_UO2H:(255,97 ,0 ),
M_gap:('green'),
M_clad:('gray'),
M_cool:('Blue'),
M_vess:('gray')}
list_plots = [plot_xy, plot_yz]
plots = openmc.Plots(list_plots)
plots.export_to_xml()
openmc.plot_geometry()
# method 2
'''
plot_geoxy = openmc.Plot.from_geometry(U_geo)
plot_geoxy.basis = 'xy'
plot_geoxy.origin = (0,0,0)
plot_geoxy.width = (length, length)
plot_geoxy.pixels = (5000, 5000)
plot_geoxy.color_by = 'material'
plot_geoxy.filename = 'plot_xy'
plot_geoxy.colors = {M_fuel:('yellow'),M_gap:('green'),M_clad:('gray'),M_cool:('LBue')}
plot_geoxy.to_ipython_image()
'''
'''
plot_geoyz = openmc.Plot.from_geometry(U_geo)
plot_geoyz.basis = 'yz'
plot_geoyz.origin = [0,0,0]
plot_geoyz.width = [length, height_core]
plot_geoyz.pixels = [1000, 1000]
plot_geoyz.color_by = 'material'
plot_geoyz.filename = 'plot_yz'
plot_geoyz.to_ipython_image()
plot_pinxy = openmc.Plot.from_geometry(U_geo)
plot_pinxy.basis = 'xy'
plot_pinxy.origin = (0,0,)
plot_pinxy.width = (num_pitch_pin/2, num_pitch_pin/2)
plot_pinxy.pixels = (500, 500)
plot_pinxy.color_by = 'material'
plot_pinxy.filename = 'plot_pinxy'
plot_pinxy.to_ipython_image()
'''
#==============================================================================
#==============================================================================
# RUN
#==============================================================================
openmc.run()
#==============================================================================