hello,Developer!
I am new to openmc。I Refer to:Energy distribution in OPENMC fixed source ,。
A simple sphere is written using openmc, however, in calculating the neutron flux through the sphere, the results are inconsistent with those calculated by MCNP。
This is the openmc input file:
import glob
from IPython.display import Image
import matplotlib.pyplot as plt
import scipy.stats
import numpy as np
import pandas as pd
import openmc
from math import pi, cos
import os
%matplotlib inline
# Materials definitions
m286 = openmc.Material() #空气
m286.add_element('C',0.00012,'wo')
m286.add_element('N',0.7552927,'wo')
m286.add_element('O',0.231787,'wo')
m286.add_element('Ca',0.0128004,'wo')
m286.set_density('g/cm3', 0.00000013)
# Instantiate a Materials collection and export to xml
materials = openmc.Materials([m286])
materials.export_to_xml()
# Geometry definitions
# surface
r1=50
r2=10
sphere1 = openmc.Sphere(x0=0,y0=0,z0=0,r=r1, boundary_type='vacuum')
sphere2 = openmc.Sphere(x0=0,y0=0,z0=0,r=r2)
# regions
region1= -sphere2
region2= -sphere1 & +sphere2
# cell
cell1 = openmc.Cell()
cell1.fill =m286
cell1.region = region1
cell2 = openmc.Cell()
cell2.fill =m286
cell2.region = region2
# Instantiate a geometry collection and export to xml
root_universe = openmc.Universe(cells=(cell1, cell2))
geometry = openmc.Geometry(root_universe)
geometry.export_to_xml()
root_universe.plot(origin=(0, 0, 0),basis = 'xy',width=(100, 100),color_by = 'material')
plt.show()
# Define source 各向同性的点源
source = openmc.Source()
source.particle = 'neutron'
source.space = openmc.stats.Point((0, 0, 0))
source.angle = openmc.stats.Isotropic()
source.dist5 = openmc.stats.Tabular([
0.001,
1.06412E-03,
1.13235E-03,
1.20495E-03,
1.28221E-03,
1.36442E-03,
1.4519E-03,
1.545E-03,
1.64406E-03,
1.74947E-03,
1.86165E-03,
1.98101E-03,
2.10803E-03,
2.24319E-03,
2.38702E-03,
2.54007E-03,
2.70293E-03,
2.87624E-03,
3.06066E-03,
3.2569E-03,
3.46572E-03,
3.68794E-03,
3.9244E-03,
4.17603E-03,
4.44378E-03,
4.72871E-03,
5.0319E-03,
5.35454E-03,
5.69786E-03,
6.06319E-03,
6.45195E-03,
6.86563E-03,
7.30584E-03,
7.77428E-03,
8.27275E-03,
8.80318E-03,
9.36762E-03,
9.96825E-03,
1.06074E-02,
1.12875E-02,
1.20112E-02,
1.27814E-02,
1.36009E-02,
1.4473E-02,
1.54009E-02,
1.63884E-02,
1.74392E-02,
1.85573E-02,
1.97472E-02,
2.10134E-02,
2.23607E-02,
2.37944E-02,
2.532E-02,
2.69435E-02,
2.86711E-02,
3.05094E-02,
3.24656E-02,
3.45472E-02,
3.67623E-02,
3.91194E-02,
4.16277E-02,
4.42967E-02,
4.71369E-02,
5.01593E-02,
5.33754E-02,
5.67977E-02,
6.04394E-02,
6.43146E-02,
6.84384E-02,
7.28265E-02,
7.74959E-02,
8.24648E-02,
8.77523E-02,
9.33788E-02,
9.9366E-02,
1.05737E-01,
1.12517E-01,
1.19731E-01,
1.27408E-01,
1.35577E-01,
1.4427E-01,
1.5352E-01,
1.63364E-01,
1.73838E-01,
1.84984E-01,
1.96845E-01,
2.09466E-01,
2.22897E-01,
2.37188E-01,
2.52396E-01,
2.6858E-01,
2.858E-01,
3.04125E-01,
3.23625E-01,
3.44375E-01,
3.66456E-01,
3.89952E-01,
4.14955E-01,
4.41561E-01,
4.69873E-01,
5.0000000E-01],
[0,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01])
source.dist6 = openmc.stats.Tabular([
5.0000000E-01,
5.5205240E-01,
6.0952371E-01,
6.7297806E-01,
7.4303831E-01,
8.2039217E-01,
9.0579893E-01,
1.0000970,
1.1042119,
1.2191656,
1.3460866,
1.4862207,
1.6409434,
1.8117735,
2.0003878,
2.2086378,
2.4385676,
2.6924342,
2.9727296,
3.2822050,
3.6238983,
4.0011636,
4.4177039,
4.8776081,
5.3853906,
5.9460356,
6.5650465,
7.2484994,
8.0031030,
8.8362645,
9.7561621,
1.0771825E+01,
1.1893224E+01,
1.3131366E+01,
1.4498404E+01,
1.6007758E+01,
1.7674242E+01,
1.9514216E+01,
2.1545740E+01,
2.3788755E+01,
2.6265278E+01,
2.8999620E+01,
3.2018620E+01,
3.5351912E+01,
3.9032216E+01,
4.3095657E+01,
4.7582122E+01,
5.2535650E+01,
5.8004864E+01,
6.4043449E+01,
7.0710679E+01,
7.8072001E+01,
8.6199671E+01,
9.5173471E+01,
1.0508149E+02,
1.1602097E+02,
1.2809932E+02,
1.4143507E+02,
1.5615914E+02,
1.7241606E+02,
1.9036540E+02,
2.1018335E+02,
2.3206445E+02,
2.5622347E+02,
2.8289757E+02,
3.1234856E+02,
3.4486555E+02,
3.8076771E+02,
4.2040746E+02,
4.6417389E+02,
5.1249663E+02,
5.6584999E+02,
6.2475769E+02,
6.8979797E+02,
7.6160925E+02,
8.4089644E+02,
9.2843780E+02,
1.0250926E+03,
1.1318097E+03,
1.2496365E+03,
1.3797297E+03,
1.5233662E+03,
1.6819559E+03,
1.8570556E+03,
2.0503840E+03,
2.2638389E+03,
2.4995154E+03,
2.7597269E+03,
3.0470278E+03,
3.3642380E+03,
3.7144714E+03,
4.1011657E+03,
4.5281167E+03,
4.9995154E+03,
5.5199890E+03,
6.0946464E+03,
6.7291284E+03,
7.4296630E+03,
8.2031266E+03,
9.0571115E+03,
1.0000000E+04],
[0,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01])
source.dist7 = openmc.stats.Tabular([
1.0000000E+04,
1.0544119E+04,
1.1117845E+04,
1.1722788E+04,
1.2360647E+04,
1.3033213E+04,
1.3742375E+04,
1.4490124E+04,
1.5278559E+04,
1.6109895E+04,
1.6986465E+04,
1.7910730E+04,
1.8885287E+04,
1.9912872E+04,
2.0996369E+04,
2.2138822E+04,
2.3343437E+04,
2.4613598E+04,
2.5952870E+04,
2.7365016E+04,
2.8853998E+04,
3.0423999E+04,
3.2079427E+04,
3.3824929E+04,
3.5665408E+04,
3.7606031E+04,
3.9652247E+04,
4.1809801E+04,
4.4084752E+04,
4.6483487E+04,
4.9012742E+04,
5.1679618E+04,
5.4491605E+04,
5.7456597E+04,
6.0582919E+04,
6.3879351E+04,
6.7355148E+04,
7.1020070E+04,
7.4884407E+04,
7.8959010E+04,
8.3255320E+04,
8.7785401E+04,
9.2561972E+04,
9.7598445E+04,
1.0290896E+05,
1.0850843E+05,
1.1441258E+05,
1.2063799E+05,
1.2720213E+05,
1.3412344E+05,
1.4142136E+05,
1.4911636E+05,
1.5723007E+05,
1.6578525E+05,
1.7480594E+05,
1.8431747E+05,
1.9434653E+05,
2.0492130E+05,
2.1607145E+05,
2.2782831E+05,
2.4022489E+05,
2.5329598E+05,
2.6707830E+05,
2.8161053E+05,
2.9693350E+05,
3.1309022E+05,
3.3012605E+05,
3.4808884E+05,
3.6702901E+05,
3.8699976E+05,
4.0805715E+05,
4.3026032E+05,
4.5367160E+05,
4.7835674E+05,
5.0438504E+05,
5.3182959E+05,
5.6076745E+05,
5.9127987E+05,
6.2345253E+05,
6.5737577E+05,
6.9314484E+05,
7.3086017E+05,
7.7062766E+05,
8.1255898E+05,
8.5677186E+05,
9.0339045E+05,
9.5254564E+05,
1.0043755E+06,
1.0590254E+06,
1.1166490E+06,
1.1774080E+06,
1.2414730E+06,
1.3090240E+06,
1.3802504E+06,
1.4553525E+06,
1.5345410E+06,
1.6180383E+06,
1.7060788E+06,
1.7989098E+06,
1.8967919E+06,
2.0000000E+06],
[0,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,
0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01])
source.dist = openmc.stats.Mixture([0.1, 0.89, 0.01], [source.dist5, source.dist6, source.dist7])
# Define problem settings
settings = openmc.Settings()
settings.source = source
settings.run_mode = 'fixed source'
settings.batches = 110
settings.inactive = 10
settings.particles = 1000000
settings.export_to_xml()
# Define tallies
energy_filter = openmc.EnergyFilter([
0.001,
1.06412E-03,
1.13235E-03,
1.20495E-03,
1.28221E-03,
1.36442E-03,
1.4519E-03,
1.545E-03,
1.64406E-03,
1.74947E-03,
1.86165E-03,
1.98101E-03,
2.10803E-03,
2.24319E-03,
2.38702E-03,
2.54007E-03,
2.70293E-03,
2.87624E-03,
3.06066E-03,
3.2569E-03,
3.46572E-03,
3.68794E-03,
3.9244E-03,
4.17603E-03,
4.44378E-03,
4.72871E-03,
5.0319E-03,
5.35454E-03,
5.69786E-03,
6.06319E-03,
6.45195E-03,
6.86563E-03,
7.30584E-03,
7.77428E-03,
8.27275E-03,
8.80318E-03,
9.36762E-03,
9.96825E-03,
1.06074E-02,
1.12875E-02,
1.20112E-02,
1.27814E-02,
1.36009E-02,
1.4473E-02,
1.54009E-02,
1.63884E-02,
1.74392E-02,
1.85573E-02,
1.97472E-02,
2.10134E-02,
2.23607E-02,
2.37944E-02,
2.532E-02,
2.69435E-02,
2.86711E-02,
3.05094E-02,
3.24656E-02,
3.45472E-02,
3.67623E-02,
3.91194E-02,
4.16277E-02,
4.42967E-02,
4.71369E-02,
5.01593E-02,
5.33754E-02,
5.67977E-02,
6.04394E-02,
6.43146E-02,
6.84384E-02,
7.28265E-02,
7.74959E-02,
8.24648E-02,
8.77523E-02,
9.33788E-02,
9.9366E-02,
1.05737E-01,
1.12517E-01,
1.19731E-01,
1.27408E-01,
1.35577E-01,
1.4427E-01,
1.5352E-01,
1.63364E-01,
1.73838E-01,
1.84984E-01,
1.96845E-01,
2.09466E-01,
2.22897E-01,
2.37188E-01,
2.52396E-01,
2.6858E-01,
2.858E-01,
3.04125E-01,
3.23625E-01,
3.44375E-01,
3.66456E-01,
3.89952E-01,
4.14955E-01,
4.41561E-01,
4.69873E-01,
5.0000000E-01,
5.5205240E-01,
6.0952371E-01,
6.7297806E-01,
7.4303831E-01,
8.2039217E-01,
9.0579893E-01,
1.0000970,
1.1042119,
1.2191656,
1.3460866,
1.4862207,
1.6409434,
1.8117735,
2.0003878,
2.2086378,
2.4385676,
2.6924342,
2.9727296,
3.2822050,
3.6238983,
4.0011636,
4.4177039,
4.8776081,
5.3853906,
5.9460356,
6.5650465,
7.2484994,
8.0031030,
8.8362645,
9.7561621,
1.0771825E+01,
1.1893224E+01,
1.3131366E+01,
1.4498404E+01,
1.6007758E+01,
1.7674242E+01,
1.9514216E+01,
2.1545740E+01,
2.3788755E+01,
2.6265278E+01,
2.8999620E+01,
3.2018620E+01,
3.5351912E+01,
3.9032216E+01,
4.3095657E+01,
4.7582122E+01,
5.2535650E+01,
5.8004864E+01,
6.4043449E+01,
7.0710679E+01,
7.8072001E+01,
8.6199671E+01,
9.5173471E+01,
1.0508149E+02,
1.1602097E+02,
1.2809932E+02,
1.4143507E+02,
1.5615914E+02,
1.7241606E+02,
1.9036540E+02,
2.1018335E+02,
2.3206445E+02,
2.5622347E+02,
2.8289757E+02,
3.1234856E+02,
3.4486555E+02,
3.8076771E+02,
4.2040746E+02,
4.6417389E+02,
5.1249663E+02,
5.6584999E+02,
6.2475769E+02,
6.8979797E+02,
7.6160925E+02,
8.4089644E+02,
9.2843780E+02,
1.0250926E+03,
1.1318097E+03,
1.2496365E+03,
1.3797297E+03,
1.5233662E+03,
1.6819559E+03,
1.8570556E+03,
2.0503840E+03,
2.2638389E+03,
2.4995154E+03,
2.7597269E+03,
3.0470278E+03,
3.3642380E+03,
3.7144714E+03,
4.1011657E+03,
4.5281167E+03,
4.9995154E+03,
5.5199890E+03,
6.0946464E+03,
6.7291284E+03,
7.4296630E+03,
8.2031266E+03,
9.0571115E+03,
1.0000000E+04,
1.0544119E+04,
1.1117845E+04,
1.1722788E+04,
1.2360647E+04,
1.3033213E+04,
1.3742375E+04,
1.4490124E+04,
1.5278559E+04,
1.6109895E+04,
1.6986465E+04,
1.7910730E+04,
1.8885287E+04,
1.9912872E+04,
2.0996369E+04,
2.2138822E+04,
2.3343437E+04,
2.4613598E+04,
2.5952870E+04,
2.7365016E+04,
2.8853998E+04,
3.0423999E+04,
3.2079427E+04,
3.3824929E+04,
3.5665408E+04,
3.7606031E+04,
3.9652247E+04,
4.1809801E+04,
4.4084752E+04,
4.6483487E+04,
4.9012742E+04,
5.1679618E+04,
5.4491605E+04,
5.7456597E+04,
6.0582919E+04,
6.3879351E+04,
6.7355148E+04,
7.1020070E+04,
7.4884407E+04,
7.8959010E+04,
8.3255320E+04,
8.7785401E+04,
9.2561972E+04,
9.7598445E+04,
1.0290896E+05,
1.0850843E+05,
1.1441258E+05,
1.2063799E+05,
1.2720213E+05,
1.3412344E+05,
1.4142136E+05,
1.4911636E+05,
1.5723007E+05,
1.6578525E+05,
1.7480594E+05,
1.8431747E+05,
1.9434653E+05,
2.0492130E+05,
2.1607145E+05,
2.2782831E+05,
2.4022489E+05,
2.5329598E+05,
2.6707830E+05,
2.8161053E+05,
2.9693350E+05,
3.1309022E+05,
3.3012605E+05,
3.4808884E+05,
3.6702901E+05,
3.8699976E+05,
4.0805715E+05,
4.3026032E+05,
4.5367160E+05,
4.7835674E+05,
5.0438504E+05,
5.3182959E+05,
5.6076745E+05,
5.9127987E+05,
6.2345253E+05,
6.5737577E+05,
6.9314484E+05,
7.3086017E+05,
7.7062766E+05,
8.1255898E+05,
8.5677186E+05,
9.0339045E+05,
9.5254564E+05,
1.0043755E+06,
1.0590254E+06,
1.1166490E+06,
1.1774080E+06,
1.2414730E+06,
1.3090240E+06,
1.3802504E+06,
1.4553525E+06,
1.5345410E+06,
1.6180383E+06,
1.7060788E+06,
1.7989098E+06,
1.8967919E+06,
2.0000000E+06 ])
#面通量
filter = openmc.SurfaceFilter(bins=sphere2 )
particle_filter = openmc.ParticleFilter(['neutron'])
tally = openmc.Tally()
tally.filters = [filter, particle_filter,energy_filter]
tally.scores = ['current']
#体通量
#particle_filter = openmc.ParticleFilter(['neutron'])
#filter_water_cell = openmc.CellFilter(cell1)
#tally = openmc.Tally(name='体通量')
#tally.filters = [filter_water_cell, particle_filter,energy_filter]
#tally.scores = ['flux'] #通常单位:[particle-cm/source]. 若单位改为[particle/cm2 .source],需要除以体积
#
tallies = openmc.Tallies()
tallies.append(tally)
tallies.export_to_xml()
openmc.run(tracks=True)
but,The result is :
The result is wrong。
(mcnp:The energy range is 1896791.9~200000 eV, and the probability is 0.0001)