Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R2S Config/Step1 #25

Merged
merged 7 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added DAGMC_Geometry.h5m
Binary file not shown.
36 changes: 36 additions & 0 deletions WC_Layers/Conversion_h5m.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import openmc
import numpy as np
import pymoab
from pymoab import core, types, rng
import matplotlib.pyplot as plt

# Load the statepoint file
sp = openmc.StatePoint("statepoint.10.h5")

mb = core.Core()
mb.load_file('OpenMC_Mesh.h5m')

# Retrieve the tally
tally = sp.get_tally(id=2)

# Load the mesh
mesh = sp.meshes[1]

tally_data = tally.get_reshaped_data(value='mean')

#Summing over cell filter:
flux_spectra_on_mesh = tally_data.sum(axis=0)

ebounds = tally.find_filter(openmc.EnergyFilter).bins

plt.xlabel('Energy [eV]')
plt.ylabel('Flux [n/cm^2-s]')
plt.loglog(ebounds[:,0],flux_sum_en[0,:,0,0])
plt.savefig("Flux_Graph.png")

# get all tets from the MOAB mesh
all_tets = mb.get_entities_by_type(0, types.MBTET)
n_flux_tag = mb.tag_get_handle('FLUX_MESH', 175, types.MB_TYPE_DOUBLE, types.MB_TAG_DENSE, create_if_missing=True)
mb.tag_set_data(n_flux_tag, all_tets, flux_spectra_on_mesh[:,:,0,0]) # the shape of the data will need to be checked here

mb.write_file('Mesh_with_Tally.h5m')
19 changes: 19 additions & 0 deletions WC_Layers/PyNE_Lib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 2 01:08:06 2024

@author: Anupama Rajendra
"""

from pyne.material import Material
from pyne.material_library import MaterialLibrary

W=Material({"W":1})
W.density=19.3
Graphite=Material({"C":1})
Graphite.density=2.62

MatLib = MaterialLibrary()
MatLib["W"]=W
MatLib["Graphite"]=Graphite
MatLib.write_hdf5("PyNE_Lib_WC.h5", h5_overwrite=True)
43 changes: 43 additions & 0 deletions WC_Layers/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[general]
# Specify whether this problem uses structured or unstructured mesh
structured: False
# Specify whether this problem uses sub-voxel r2s
sub_voxel: False

[step1]
# Path to MCNP MESHTAL file containing neutron fluxes or a DAG-MCNP5
# unstructured mesh tally .h5m file.
meshtal: Mesh_with_Tally.h5m
# Tally number within the meshtal file containing the fluxes for activation.
tally_num: 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this relevant for an unstructured mesh? It doesn't seem like your script to convert from OpenMC to H5M preserves any tally number (which is fine if we don't actually need it).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not relevant here--only data from one tally is written to h5m, so the same ALARA input file is printed regardless of which number is chosen here

# The name of the tag used to store flux data on the mesh. For unstructured
# mesh this tag must already exist within the file specified in <meshtal>.
flux_tag: FLUX_MESH
# Path to the DAGMC material-laden geometry file (.h5m).
geom: DAGMC_Geometry.h5m
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this geometry have materials in it? Where is the script that does that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is material laden. PyNE_Lib.py creates a PyNE material library which is then assigned to the DAG-MC geometry using the uwuw_preproc tool (done inside a terminal).

# If True the fluxes in the fluxin file will be printed in the reverse
# order of how they appear within the flux vector tag. Since MCNP and
# the Meshtal class order fluxes from low energy to high energy, this
# option should be true if the transmutation data being used is
# ordered from high-energy to low-energy.
reverse: True
# Number of rays to fire down each mesh row in each direction to calculate
# cell volume fractions.
num_rays: 100
# If true, rays will be fired down mesh rows in evenly spaced intervals.
# In this case <num_rays> must be a perfect square. If false, rays are fired
# down mesh rows in random intervals.
grid: False

[step2]
# List of decays times, seperated by commas. These strings much match exactly
# with their counterparts in the phtn_src file produced in step1. No spaces
# should appear in this line except the space between the time and the time unit
# for each entry.
decay_times:24 h,2.6864e+6 s
# The prefix of the .h5m files containing the source density distributations for
# each decay time.
output: source
# The name of the output files containing the total photon source intensities for
# each decay time
tot_phtn_src_intensities : total_photon_source_intensities.txt