<jupyter_start><jupyter_text>Begining of LifeThe purpose of this notebook is to establish basic beginning of life parameters of this concept including $k_{eff}$ and neutron energy spectrum.<jupyter_code>import openmc
import openmc.deplete
import matplotlib.pyplot as plt

%matplotlib inline
import numpy as np
fuel = openmc.Material(name="fuel_compact")
fuel.set_density('atom/b-cm',8.2679e-2) # To Do: implement a better method for adjusting triso fuel parameters
fuel.add_nuclide('U235',3.5287e-4)
fuel.add_nuclide('U238',1.4203e-3)
fuel.add_element('C',7.3047e-2)
fuel.add_element('O',3.5464e-3)
fuel.add_element('S',4.3125e-3)
fuel.add_s_alpha_beta('c_Graphite')

coolant = openmc.Material(name='He')
coolant.set_density('g/cm3',1.86e-3) # at 3MPa, 500 C (need to fix)
coolant.add_element('He',1.0)
 # no s_alpha_beta for Helium??
    
    
mod = openmc.Material(name='Graphite')
mod.set_density('g/cm3',1.7)
mod.add_element('C',1)
mod.add_s_alpha_beta('c_Graphite')

materials = openmc.Materials([fuel,coolant,mod]);<jupyter_output><empty_output><jupyter_text>Pin Cell GeometryThe goal is to establish a pin-cell to provide a simplified representation of the basic criticality and (especially) neutron energy spectrum for this concept.<jupyter_code>h_core = 300.; 
h_fuel = 200.;

r_fuel = 0.6; #cm, radius of fuel compact
r_channel = 0.8;#cm, radius of fuel channel 

P_D = 1.55

pitch = P_D*(2*r_channel);

fuel_temp = 1200; # K, representative fuel temperature (?)
mod_temp = 800; # K, representative moderator temperature (?)

# fuel cylinder:
fuel_cyl = openmc.model.RightCircularCylinder([0.,0.,-h_fuel/2.],
                                             h_fuel, r_fuel);

fuel.volume = np.pi*(r_fuel**2)*h_fuel;

# channel cylinder
channel_cyl = openmc.model.RightCircularCylinder([0.,0.,-h_core/2+1.],
                                            h_core-2.,r_channel);
# avoid coincident boundaries with the core cell

# core cell container
core_cell = openmc.model.RectangularParallelepiped(-pitch/2.,pitch/2.,
                                                  -pitch/2.,pitch/2.,
                                                  -h_core/2.,h_core/2.,
                                                  boundary_type='reflective');

fuel_cell = openmc.Cell();
fuel_cell.region = -fuel_cyl
fuel_cell.fill = fuel;
fuel_cell.temperature = fuel_temp;


channel_cell = openmc.Cell();
channel_cell.region = +fuel_cyl & -channel_cyl;
channel_cell.fill = coolant;

mod_cell = openmc.Cell();
mod_cell.region = +channel_cyl & -core_cell;
mod_cell.fill = mod
mod_cell.temperature = mod_temp;

root_univ = openmc.Universe();
root_univ.add_cells([fuel_cell,channel_cell,mod_cell]);

geometry = openmc.Geometry();
geometry.root_universe = root_univ;



materials.export_to_xml();
geometry.export_to_xml();

colors = {}
colors[fuel]='yellow'
colors[mod]='grey'
colors[coolant]='green'


settings = openmc.Settings();
settings.run_mode = 'eigenvalue';
settings.particles = 20000;
settings.batches = 200;
settings.inactive = 50

box = openmc.stats.Box(lower_left = (-r_fuel,-r_fuel,-h_fuel/2.),
                      upper_right = (r_fuel,r_fuel,h_fuel/2.),
                      only_fissionable=True);
src = openmc.Source(space=box);

settings.source = src;

settings.temperature['method']='interpolation';

settings.export_to_xml();
root_univ.plot(width=(pitch,pitch),pixels=[200,200],color_by='material',colors=colors);
plot = openmc.Plot()
plot.filename = 'model3'
plot.width = (pitch, pitch)
plot.pixels = (400, 400)
plot.color_by = 'material'
plot.colors = {fuel: 'yellow', coolant: 'blue', mod: 'grey'}

plots = openmc.Plots([plot])
plots.export_to_xml()
openmc.plot_geometry()
!convert model3.ppm model3.png
from IPython.display import Image
Image("model3.png")
# get flux energy spectrum in the fuel

# filter for the fuel cell
cell_filter = openmc.CellFilter(fuel_cell)

# set up energy bins
N = 1001
energy_bins = np.logspace(-3,7,num=N)
energy_filter = openmc.EnergyFilter(values=energy_bins)

# establish flux tally
flux = openmc.Tally(name='flux')
flux.scores = ['flux']
flux.filters = [cell_filter,energy_filter]

tallies = openmc.Tallies([flux])

tallies.export_to_xml()

openmc.run();
sp = openmc.StatePoint('statepoint.200.h5')
sp.tallies

flux_t = sp.get_tally(name='flux')
flux_df = flux_t.get_pandas_dataframe()
flux_vals = flux_df['mean'].to_numpy()

energy_x = 0.5*(energy_bins[0:-1]+energy_bins[1:])

plt.loglog(energy_x,flux_vals)
plt.grid()
plt.xlabel('Energy [eV]')
plt.ylabel('flux [n/cm**2-s]')
sp_lpwr = openmc.StatePoint('../leu_pwr/statepoint.200.h5')
flux_lpwr = sp_lpwr.get_tally(name='flux')
flux_lpwr_df = flux_lpwr.get_pandas_dataframe()
flux_lpwr_vals = flux_lpwr_df['mean'].to_numpy()

sp_hpwr = openmc.StatePoint('../haleu_pwr/statepoint.200.h5')
flux_hpwr = sp_hpwr.get_tally(name='flux')
flux_hpwr_df = flux_hpwr.get_pandas_dataframe()
flux_hpwr_vals = flux_hpwr_df['mean'].to_numpy()

plt.loglog(energy_x,flux_vals,label='HALEU GCR')
plt.loglog(energy_x,flux_lpwr_vals,label='LEU PWR')
plt.loglog(energy_x,flux_hpwr_vals,label='HALEU PWR')
plt.title('Neutron Energy Spectra in Fuel Region')
plt.legend()
plt.grid()
plt.xlabel('Energy [eV]')
plt.ylabel('flux [n/cm^2-s]')
plt.savefig("Fuel Neutron Energy Spectra.png")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14228949858088932, 'fraction_numerical': 0.02762535477767266, 'mean_word_length': 4.51199165797706, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '140887', 'license': 'MIT', 'n_tokens_mistral': 2118, 'n_tokens_neox': 1915, 'n_words': 347, 'path': 'examples/micro_reactor/haleu_gcr/BOL_haleu_grc.ipynb', 'repo_name': 'stu314159/er362_omc', 'size': '5285'}