Using lattiece modeling, the following appears: error:more than 95% of the external source sites sampled were rejected。
What’s the reason for this, I wonder? thanks!
The size of a cuboid is 22.420.817.6 cm, and the small cuboid with the size of 5.65.24.4 is filled according to the 444 array. The cuboid is then placed between the spheres。
# Materials definitions
m1= openmc.Material() #空气
m1.add_element('C',2)
m1.add_element('N',1)
m1.set_density('g/cm3', 1.13)
m2 = openmc.Material(material_id=1, name='fuel')
m2.set_density('g/cc', 4.5)
m2.add_nuclide('U235', 1.)
m3 = openmc.Material(material_id=2, name='moderator')
m3.set_density('g/cc', 1.0)
m3.add_element('H', 2.)
m3.add_element('O', 1.)
# Instantiate a Materials collection and export to xml
materials = openmc.Materials([m1,m2,m3])
materials.export_to_xml()
# Geometry definitions
# surface
r1=50
sphere1 = openmc.Sphere(x0=0,y0=0,z0=0,r=r1, boundary_type='vacuum')
xplane1 = openmc.XPlane(x0=-11.2)
xplane2 = openmc.XPlane(x0=-5.60)
xplane3 = openmc.XPlane(x0=11.20)
yplane1 = openmc.YPlane(y0=-10.4)
yplane2 = openmc.YPlane(y0=-5.20)
yplane3 = openmc.YPlane(y0=10.40)
zplane1 = openmc.ZPlane(z0=-8.80)
zplane2 = openmc.ZPlane(z0=-4.4)
zplane3 = openmc.ZPlane(z0=8.800)
# regions
region1= +xplane1 & -xplane2 & +yplane1 & -yplane2 & +zplane1 & -zplane2
region2= +xplane1 & -xplane3 & +yplane1 & -yplane3 & +zplane1 & -zplane3
region3= -sphere1 &(~(+xplane1 & -xplane3 & +yplane1 & -yplane3 & +zplane1 & -zplane3 ))
# cell
cell1 = openmc.Cell(fill =m1,region=+xplane1 & -xplane2 & +yplane1 & -yplane2 & +zplane1 & -zplane2)
cell2 = openmc.Cell(fill =m2,region=+xplane1 & -xplane2 & +yplane1 & -yplane2 & +zplane1 & -zplane2)
cell3 = openmc.Cell(fill =m3,region=+xplane1 & -xplane2 & +yplane1 & -yplane2 & +zplane1 & -zplane2)
cell4 = openmc.Cell()
cell4.region = region3
cell4.fill =m3
cell5 = openmc.Cell()
cell5.region = region2
# universe
u1 = openmc.Universe()
u1.add_cell(cell1)
u2 = openmc.Universe()
u2.add_cell(cell2)
u3 = openmc.Universe()
u3.add_cell(cell3)
u4 = openmc.Universe()
u4.add_cell(cell4)
root = openmc.Universe()
root.add_cell(cell5)
# Instantiate a Lattice
# Create Lattice
lat3d = openmc.RectLattice(name='Head mold') #长方形的格子,长方形矩阵
lat3d.pitch = (5.6, 5.2, 4.4)
lat3d.lower_left = (-11.2, -10.4,-8.8)
lat3d.universes = [[[u1, u2, u1, u2],
[u2, u3, u2, u3],
[u1, u2, u1, u2],
[u2, u3, u2, u3]],
[[u1, u2, u2, u2],
[u3, u3, u2, u3],
[u1, u2, u2, u2],
[u2, u1, u2, u3]],
[[u1, u2, u3, u2],
[u2, u1, u2, u3],
[u1, u2, u3, u2],
[u2, u3, u2, u3]],
[[u1, u1, u1, u2],
[u3, u3, u2, u3],
[u1, u2, u2, u2],
[u1, u3, u2, u3]]]
# Fill Cell with the Lattice
cell5.fill = lat3d
# Instantiate a geometry collection and export to xml
geometry = openmc.Geometry([cell4,cell5])
geometry.export_to_xml()
#画二维图
root.plot(width=(25, 25))
plt.show()
# Define source 各向同性的点源
source = openmc.Source()
source.particle = 'neutron'
source.space = openmc.stats.Point((0, 0, 0))
source.angle = openmc.stats.Isotropic()
# source.dist = openmc.stats.Tabular([
#20个能量点
source.energy = openmc.stats.Tabular([
0,
0.001,0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.009,0.010,
0.011,0.012,0.013,0.014,0.015,0.016,0.017,0.018,0.019,0.020,
0.021,0.022,0.023,0.024,0.025,0.026,0.027,0.028,0.029,0.030,
0.031,0.032,0.033,0.034,0.035,0.036,0.037,0.038,0.039,0.040,
0.041,0.042,0.043,0.044,0.045,0.046,0.047,0.048,0.049,0.050,
0.051,0.052,0.053,0.054,0.055,0.056,0.057,0.058,0.059,0.060,
0.061,0.062,0.063,0.064,0.065,0.066,0.067,0.068,0.069,0.070,
0.071,0.072,0.073,0.074,0.075,0.076,0.077,0.078,0.079,0.080,
0.081,0.082,0.083,0.084,0.085,0.086,0.087,0.088,0.089,0.090,
0.091,0.092,0.093,0.094,0.095,0.096,0.097,0.098,0.099,0.100],
[0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,0.01/0.001,
0],'histogram') #histogram
# 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()
# Instantiate a tally mesh
mesh = openmc.RegularMesh(mesh_id=1)
mesh.dimension = [4, 4, 4]
mesh.lower_left = [-11.2,-10.4, -8.8]
mesh.upper_right = [11.2, 10.4, 8.8]
particle_filter = openmc.ParticleFilter(['neutron'])
filter = openmc.MeshFilter(mesh)
# Instantiate tally Filter
tally = openmc.Tally()
tally.filters = [filter, particle_filter]
tally.scores = ['flux']
#
tallies = openmc.Tallies()
tallies.append(tally)
tallies.export_to_xml()
openmc.run(tracks=True)
B01.ipynb (9.3 KB)