How to subdivide a cylinder 10 times and fill with 2 meterials by using function(model.pin)?

I want to use this method to divide a cylinder named div_surfs_1 into 10 regions, and the outermost zone is water(material_id=3) and the inner 10 zones are fuel(material_id=1) .
like this :

import math
import openmc
from openmc import geometry

fuel = openmc.Material(material_id=1, name="uo2")
fuel.add_element("U", 1, percent_type="ao", enrichment=4.25)
fuel.add_element("O", 2)
fuel.set_density("g/cc", 10.4)

clad = openmc.Material(material_id=2, name="clad")
clad.add_element("Zr", 1)
clad.set_density("g/cc", 6)
water = openmc.Material(name=material_id=3, "water")
water.add_element("O", 1)
water.add_element("H", 2)
water.set_density("g/cc", 1.0)
water.add_s_alpha_beta("c_H_in_H2O")
materials = openmc.Materials([fuel, clad, water])
materials.export_to_xml()

div_surfs_1 = [openmc.ZCylinder(r=1)]
div_1 = openmc.model.pin (div_surfs_1, [fuel,water], subdivisions={0: 10})
box=openmc.rectangular_prism(3,3,boundary_type='reflective')
root_cell=openmc.Cell(fill=div_1)
root_cell.region=box
root_universe=openmc.Universe(cells=[root_cell])
geometry=openmc.Geometry(root_universe)
geometry.export_to_xml()

settings = openmc.Settings()
settings.particles = 100
settings.inactive = 10
settings.batches = 50
settings.export_to_xml()
root_universe.plot(width=(4,4))

As a result, there are many material ids in the geometry.xml file that I have not defined:

help me please :sob:
thank you.

@Jason_Chen when you use the subdivisions option in openmc.model.pin, it will “clone” the material that is used, i.e., create a copy of it that is equivalent for each of the subdivisions. If you want to use the same material in each of the subdivisions, a quick hack would be as follows:

div_1 = openmc.model.pin(div_surfs_1, [fuel,water], subdivisions={0: 10})
fuel_cells = list(div_1.cells.values())[:10]
for cell in fuel_cells:
    cell.fill = fuel

This will overwrite the cloned materials with the original one that you had.

1 Like

Thanks for your help,I’m already using the method to solve problem. :kissing_heart: