hi,I I wanted to partition the geometry by a tetrahedral grid and then perform the fuel depletion calculation, so I created a geometry and drew the tetrahedral grid, exported its grid nodes, and converted it into a h5m file by the vertices to h5m plug-in. Each small volume has defined the geometry but how to give the boundaries of each volume grid。when i run the model,it appare error:No boundary conditions were applied to any surfaces!
import numpy as np
import re
import os
from vertices_to_h5m import vertices_to_h5m
from itertools import combinations
import linecache
from math import log10
import openmc
import math
from matplotlib import pyplot
import dagmc_h5m_file_inspector as di
import openmc.lib
import openmc.lib
import copy
from time import sleep
from PySide2 import QtCore, QtGui
import openmc.model
def cell():
model = openmc.model.Model()
with open('twist.txt', "r", encoding="UTF-8") as r:
alltxt=r.read()
alltxt=alltxt.replace('%', '')
a = alltxt.find('Coordinates')
b = alltxt.find('Elements (tetrahedra)')
c=alltxt[a:b]
d=alltxt[b:]
f1 = open("./vertices.txt", "w+")
f1.write(c)
f1.close()
f2 = open("./triangle.txt", "w+")
f2.write(d)
f2.close()
vertices = np.loadtxt('vertices.txt', skiprows=1, dtype=float)
#print(vertices)
triangles1=np.loadtxt('triangle.txt', skiprows=1, dtype=int)
#print(triangles1)
triangles2=[]
count = len(open("triangle.txt").readlines())
for data in triangles1:
c = list(combinations(data,3))# pai lie zu he
#print(c)
cc=np.array(c)-1
triangles2.append(cc)
#print(triangles2)
count = len(open("triangle.txt").readlines())-1
print("count=",count)
mat_list=[]
fuel_material = openmc.Material(material_id=0)
fuel_material.set_density('g/cm3', 9.7012)
fuel_material.add_nuclide('Zr90', 0.255449, 'wo')
fuel_material.add_nuclide('Zr91', 0.055707, 'wo')
fuel_material.add_nuclide('Zr92', 0.085150, 'wo')
fuel_material.add_nuclide('Zr94', 0.086292, 'wo')
fuel_material.add_nuclide('Zr96', 0.013902, 'wo')
fuel_material.add_nuclide('U235', 0.097811, 'wo')
fuel_material.temperature=800
fuel_material.name= "mat0"
mat_list.append(fuel_material)
for i in range(1,count):
mat = fuel_material.clone()
mat.name= "mat"+str(i)
mat_list.append(mat)
# Instantiate a Materials collection and export to XML
model.material = openmc.Materials(mat_list)
mats=[]
for i in range(0,count ):
mats.append( "mat"+str(i))
vertices_to_h5m(
vertices= vertices,
triangles=triangles2,
material_tags=mats,
h5m_filename="dagmc.h5m",
)
dagunv=openmc.DAGMCUniverse(filename="dagmc.h5m")
fuel_pin = openmc.Cell(name='Fuel', fill=dagunv)
model.geometry.root_universe = openmc.DAGMCUniverse(filename="dagmc.h5m")
model.geometry.root_universe.add_cells(fuel_pin)
print(di.get_volumes_from_h5m("dagmc.h5m"))
print(di.get_materials_from_h5m("dagmc.h5m"))
###############################################################################
# Exporting to OpenMC plots.xml file
###############################################################################
plot_xy = openmc.Plot(plot_id=1)
plot_xy.filename = 'plot_xy'
plot_xy.origin = [0, 0, 0]
plot_xy.basis = "xy"
plot_xy.width = [1.3, 1.3]
plot_xy.pixels = [400, 400]
plot_xy.color_by = 'material'
plot_xz = openmc.Plot(plot_id=2)
plot_xz.filename = 'plot_xz'
plot_xz.origin = [0, 0, 0]
plot_xz.basis = "xz"
plot_xz.width = [1.3, 0.2]
plot_xz.pixels = [400, 400]
plot_xz.color_by = 'material'
# Instantiate a Plots object and export to XML
model.plots= openmc.Plots([plot_xy, plot_xz])
###############################################################################
# Exporting to OpenMC settings.xml file
###############################################################################
# Instantiate a Settings object, set all runtime parameters, and export to XML
model.settings.particles = 100
model.settings.batches = 10
model.settings.inactive = 2
model.settings.output = {'summary' : False}
return model
model=openmc.cell()
surfaces = model.geometry.get_all_surfaces()
# modify the boundary condition of the
# planar surfaces bounding the assembly
for surface in surfaces.values():
surface.boundary_type = 'reflective'
model.run()
Sincerely hope to get your answer
this is the plot of dagmc.h5m