Skip to content

Commit

Permalink
Merge pull request #5 from ryanstwrt/Variable_Input
Browse files Browse the repository at this point in the history
Variable Input
  • Loading branch information
ryanstwrt committed Oct 15, 2019
2 parents 574686d + e32e19c commit dee7ab5
Show file tree
Hide file tree
Showing 35 changed files with 1,526 additions and 23 deletions.
6 changes: 6 additions & 0 deletions fridge/Assembly/Assembly.py
Expand Up @@ -67,6 +67,12 @@ def update_global_identifiers(self, universe_test):
if universe_test:
self.universe += 1

def update_perturbations(self):
"""Update the variables for any perturbations in the input file"""
for a, perts in self.globalVars.assembly_perturbations.items():
if a == self.assembly_file_name:
for k, v in perts.items():
self.__setattr__(k, v)

def read_assembly_type(assembly_file_name):
"""Reads in the assembly type to determine what type of assembly to build and return it."""
Expand Down
4 changes: 4 additions & 0 deletions fridge/Assembly/FuelAssembly.py
Expand Up @@ -82,6 +82,10 @@ def get_fuel_assembly_data(self):
self.read_plenum_region_data(self.inputs)
self.read_reflector_region_data(self.inputs)

# Update for perturbations
if bool(self.globalVars.assembly_perturbations):
self.update_perturbations()

def build_fuel_assembly(self):
"""Create the cell, surface, and material cards for the fuel assembly."""
self.fuel_height_with_bond = self.fuelHeight + self.bondAboveFuel
Expand Down
4 changes: 4 additions & 0 deletions fridge/Assembly/SmearAssembly.py
Expand Up @@ -41,6 +41,10 @@ def get_smear_assembly_data(self):
self.smearMaterial = self.inputs['Smear Materials']
self.smearRegionHeight = self.inputs['Smear Height']

# Update for perturbations
if bool(self.globalVars.assembly_perturbations):
self.update_perturbations()

def build_smear_assembly(self):
"""Build the cell, surface, and material cards for the smear assembly."""
self.assemblyUniverse = self.universe
Expand Down
30 changes: 24 additions & 6 deletions fridge/Material/Material.py
Expand Up @@ -30,6 +30,7 @@ def __init__(self):
self.enrichmentZaids = []
self.enrichmentIsotopes = []
self.enrichmentVector = []
self.isotopicAtomPercents = []

def set_material(self, material):
self.name = material
Expand All @@ -49,6 +50,7 @@ def read_material_data(self, material):
self.enrichmentZaids = inputs['Elemental Adjustment ZAIDs'] if 'Elemental Adjustment ZAIDs' in inputs else []
self.enrichmentIsotopes = inputs['Isotopic Adjustment ZAIDs'] if 'Isotopic Adjustment ZAIDs' in inputs else []
self.enrichmentVector = inputs['Isotopic Weight Percents'] if 'Isotopic Weight Percents' in inputs else []
self.isotopicAtomPercents = inputs['Isotopic Atom Percents'] if 'Isotopic Atom Percents' in inputs else []
self.density = inputs['Density']
self.linearCoeffExpansion = inputs['Linear Coefficient of Expansion']

Expand All @@ -61,9 +63,14 @@ def create_material_data(self):
self.enrichmentDict[zaid] = enriched_isotope_dict
for num, element in enumerate(self.elements):
self.elementDict[self.zaids[num]] = Element.Element(element)
self.set_elemental_enrichment()
self.set_weight_percent()
self.atomDensity, self.atomPercent = set_atom_percent(self.weightPercent, self.density,

if self.isotopicAtomPercents:
self.atomDensity = self.density
self.set_atom_fractions()
else:
self.set_elemental_enrichment()
self.set_weight_percent()
self.atomDensity, self.atomPercent = set_atom_percent(self.weightPercent, self.density,
self.elementDict)

def set_elemental_enrichment(self):
Expand All @@ -88,8 +95,19 @@ def set_weight_percent(self, void_percent=1.0):
def set_void(self, void_percent):
"""Adjust the atom density/atom percent of a material to account for voiding."""
self.set_weight_percent(void_percent)
self.atomDensity, self.atomPercent = set_atom_percent(self.weightPercent, self.density,
self.elementDict)
self.atomDensity, self.atomPercent = set_atom_percent(self.weightPercent, self.density, self.elementDict)

def set_atom_fractions(self, void_percent=1.0):
"""Calculates the atom density of a material given a material with atom densities defined."""
for zaidNum, zaid in enumerate(self.zaids):
for isotope, isotopeFraction in self.elementDict[zaid].atomPercentDict.items():
if zaid in self.isotopicAtomPercents:
print(self.elementDict[zaid].weightPercentDict[isotope])
self.atomPercent[isotope] = self.elementDict[zaid].atomPercentDict[isotope] * \
self.isotopicAtomPercents[zaid] * void_percent
elif isotope in self.isotopicAtomPercents:
self.atomPercent[isotope] = self.isotopicAtomPercents[isotope] * void_percent
assert np.allclose(sum(self.atomPercent.values()), self.density, 3)


def set_atom_percent(weight_percents, density, element_dict):
Expand All @@ -102,7 +120,7 @@ def set_atom_percent(weight_percents, density, element_dict):
current_element = int(element[:1] + '000')
else:
current_element = int(element[:2] + '000')
atom_densities[zaid] = weight*density * AVOGADROS_NUMBER / element_dict[current_element].molecularMassDict[zaid]
atom_densities[zaid] = weight*density*AVOGADROS_NUMBER / element_dict[current_element].molecularMassDict[zaid]
atom_density = sum(atom_densities.values())

for zaid, atomicDensity in atom_densities.items():
Expand Down
7 changes: 7 additions & 0 deletions fridge/data/CotN/Co.yaml
@@ -0,0 +1,7 @@
Name: Cobolt
Elemental ZAIDs: 27000
Isotopic ZAID: [27059]
Abundance: [1.0]
Mass: [58.933193]
Density: 8.86
Linear Coefficient of Expansion: 0.0
7 changes: 7 additions & 0 deletions fridge/data/CotN/Cu.yaml
@@ -0,0 +1,7 @@
Name: Copper
Elemental ZAIDs: 29000
Isotopic ZAID: [29063, 29065]
Abundance: [0.6915,0.3085 ]
Mass: [62.929597, 64.927789]
Density: 8.96
Linear Coefficient of Expansion: 0.0
6 changes: 6 additions & 0 deletions fridge/data/materials/FFTF_B4C.yaml
@@ -0,0 +1,6 @@
Name: FFTF Stainless Steel 316
Elements: [B, C]
Elemental ZAIDs: [5000, 6000]
IsIsotopic Atom Percents: {5010: 2.0297E-2, 5011: 8.1700E-2, 6000: 2.3699E-2}
Density: 1.2570E-1
Linear Coefficient of Expansion: 0.0
10 changes: 10 additions & 0 deletions fridge/data/materials/FFTF_IF.yaml
@@ -0,0 +1,10 @@
Name: FFTF Inner Fuel
Elements: ['U', 'Np', 'Pu', 'Am', 'O']
Elemental ZAIDs: [92000, 93000, 94000, 95000, 8000]
Isotopic Atom Percents: {92234: 9.9319E-7, 92235: 1.1417E-4, 92238: 1.5764E-2,
93237: 1.6063E-5,
94238: 3.1181E-6, 94239: 5.1998E-3, 94240: 7.0298E-4, 94241: 6.9284E-5, 94242: 1.2825E-5,
95241: 1.1744E-5,
8016: 4.2690E-2}
Density: 6.4584E-2
Linear Coefficient of Expansion: 0.0
9 changes: 9 additions & 0 deletions fridge/data/materials/FFTF_IP.yaml
@@ -0,0 +1,9 @@
Name: FFTF_IP
Elements: ['U', 'O']
Elemental ZAIDs: [92000, 8000]
Isotopic ZAIDs: [[92234, 92235, 92236, 92238],
[8016, 8017, 8018]]
Isotopic Atom Percents: [[1.2746E-6, 1.6686E-4, 0.0, 2.3007E-2],
[4.6351E-2]]
Density: 6.9526E-2
Linear Coefficient of Expansion: 0.0
7 changes: 7 additions & 0 deletions fridge/data/materials/FFTF_Inconel600.yaml
@@ -0,0 +1,7 @@
Name: FFTF Inconel 600
Elements: [C, Si, S, Cr, Mn, Fe, Co, Ni, Cu]
Elemental ZAIDs: [6000, 14000, 16000, 24000, 25000, 26000, 27000, 28000, 29000]
Isotopic Atom Percents: {6000: 2.0908E-3, 14000: 4.4707E-4, 16000: 1.1747E-5, 24000: 1.4972E-2, 25000: 1.5998E-3,
26000: 7.1948E-3, 27000: 8.5222E-5, 28000: 6.3016E-2, 29000: 1.9759E-4}
Density: 8.9615E-2
Linear Coefficient of Expansion: 0.0
7 changes: 7 additions & 0 deletions fridge/data/materials/FFTF_LiquidNa.yaml
@@ -0,0 +1,7 @@
Name: FFTF Liquid Sodium
Elements: [Na]
Elemental ZAIDs: [11000]
Isotopic ZAIDs: [11000]]
Isotopic Weight Percents: [[2.3620E-2]]
Density: 3.3620E-2
Linear Coefficient of Expansion: 0.0
7 changes: 7 additions & 0 deletions fridge/data/materials/FFTF_LowerAxialShieldMat.yaml
@@ -0,0 +1,7 @@
Name: FFTF Stainless Steel 316
Elements: [B, C, N, Na, Al, Si, P, S, V, Cr, Mn, Fe, Co, Ni, Cu, As, Nb, Mo, Ta]
Elemental ZAIDs: [5000, 6000, 7000, 11000, 13000, 14000, 15000, 16000, 23000, 24000, 25000, 26000, 27000, 28000, 29000, 33000, 41000, 42000, 73000]
Isotopic ZAIDs: [[5010, 5011], [6000], [7000], [11000], [13000], [14000], [15000], [16000], [23000], [24000], [25000], [26000], [27000], [28000], [29000], [33000], [41000], [42000], [73000]]
Isotopic Weight Percents: [[3.2491E-7, 1.3078E-6], [1.4696E-4], [1.2602E-5], [6.1160E-3], [3.2710E-5], [4.7136E-4], [1.11398E-5], [5.55048E-6], [6.9300E-5], [1.1882E-2], [1.1245E-3], [4.0495E-2], [1.4976E-5], [8.1199E-3], [2.7777E-5], [7.0679E-6], [9.4995E-6], [9.1991E-4], [9.7549E-7]]
Density: 6.9469E-2
Linear Coefficient of Expansion: 0.0
15 changes: 15 additions & 0 deletions fridge/data/materials/FFTF_OF.yaml
@@ -0,0 +1,15 @@
Name: FFTF_OF
Elements: ['U', 'Np', 'Pu', 'Am', 'O']
Elemental ZAIDs: [92000, 93000, 94000, 95000, 8000]
Isotopic ZAIDs: [[92234, 92235, 92236, 92238],
[93273],
[94238, 94239, 94240, 94241, 94242],
[95241],
[8016, 8017, 8018]]
Isotopic Atom Percents: [[1.0327E-6, 1.2127E-4, 0.0, 1.6744E-2],
[1.3313E-5],
[2.6497E-6, 4.2072E-3, 5.6618E-4, 5.7297E-5, 9.2450E-6],
[1.4025E-5],
[4.3372E-2]]
Density: 6.5108E-2
Linear Coefficient of Expansion: 0.0
7 changes: 7 additions & 0 deletions fridge/data/materials/FFTF_PlenumMat.yaml
@@ -0,0 +1,7 @@
Name: FFTF Plenum Material
Elements: [B, C, N, Na, Al, Si, P, S, V, Cr, Mn, Fe, Co, Ni, Cu, As, Nb, Mo, Ta]
Elemental ZAIDs: [5000, 6000, 7000, 11000, 13000, 14000, 15000, 16000, 23000, 24000, 25000, 26000, 27000, 28000, 29000, 33000, 41000, 42000, 73000]
Isotopic ZAIDs: [[5010, 5011], [6000], [7000], [11000], [13000], [14000], [15000], [16000], [23000], [24000], [25000], [26000], [27000], [28000], [29000], [33000], [41000], [42000], [73000]]
Isotopic Weight Percents: [[1.2816E-7, 5.1585E-7], [5.7968E-5], [4.9707E-6], [9.6390E-3], [1.2902E-5], [1.8592E-4], [4.4957E-6], [2.1713E-6], [2.7335E-5], [4.6866E-3], [4.4356E-4], [1.5973E-2], [5.9070E-6], [3.2028E-3], [1.0956E-5], [2.7879E-6], [3.7470E-6], [3.6285E-4], [3.8477E-7]]
Density: 3.4628E-2
Linear Coefficient of Expansion: 0.0
7 changes: 7 additions & 0 deletions fridge/data/materials/FFTF_ReflectorMat7.yaml
@@ -0,0 +1,7 @@
Name: FFTF Reflector Block Region
Elements: [B, C, N, Na, Al, Si, P, S, V, Cr, Mn, Fe, Co, Ni, Cu, As, Nb, Mo, Ta]
Elemental ZAIDs: [5000, 6000, 7000, 11000, 13000, 14000, 15000, 16000, 23000, 24000, 25000, 26000, 27000, 28000, 29000, 33000, 41000, 42000, 73000]
Isotopic ZAIDs: [[5010, 5011], [6000], [7000], [11000], [13000], [14000], [15000], [16000], [23000], [24000], [25000], [26000], [27000], [28000], [29000], [33000], [41000], [42000], [73000]]
Isotopic Weight Percents: [[9.6514E-8, 3.8848E-7], [1.3432E-3], [3.7434E-6], [3.4400E-3], [9.7165E-6], [4.1789E-4], [3.3856E-6], [8.9367E-6], [2.0586E-5], [1.2835E-2], [1.3248E-3], [1.6501E-2], [5.7417E-5], [4.1579E-2], [1.3106E-6], [2.0995E-6], [2.8218E-6], [2.7326E-4], [2.8977E-7]]
Density: 7.7958E-2
Linear Coefficient of Expansion: 0.0
7 changes: 7 additions & 0 deletions fridge/data/materials/FFTF_SS316.yaml
@@ -0,0 +1,7 @@
Name: FFTF Stainless Steel 316
Elements: [B, C, N, Al, Si, P, S, V, Cr, Mn, Fe, Co, Ni, Cu, As, Nb, Mo, Ta]
Elemental ZAIDs: [5000, 6000, 7000, 13000, 14000, 15000, 16000, 23000, 24000, 25000, 26000, 27000, 28000, 29000, 33000, 41000, 42000, 73000]
Isotopic ZAIDs: [[5010, 5011], [6000], [7000], [13000], [14000], [15000], [16000], [23000], [24000], [25000], [26000], [27000], [28000], [29000], [33000], [41000], [42000], [73000]]
Isotopic Weight Percents: [[4.3730E-7, 1.7602E-6], [1.9780E-4], [1.6961E-5], [4.4025E-5], [6.3442E-4], [1.5340E-5], [7.4091E-6], [9.3272E-5], [1.5992E-2], [1.5135E-3], [5.4503E-2], [2.0156E-5], [1.0929E-2], [3.7386E-5], [9.5128E-6], [1.2786E-5], [1.2381E-3], [1.3129E-6]]
Density: 8.5268E-2
Linear Coefficient of Expansion: 0.0
7 changes: 7 additions & 0 deletions fridge/data/materials/SS316_AtomDensity.yaml
@@ -0,0 +1,7 @@
Name: Stainless Steel 316
Elements: [C, Si, P, S, Cr, Mn, Fe, Ni, Mo]
Elemental ZAIDs: [6000, 14000, 15000, 16000, 24000, 25000, 26000, 28000, 42000]
Isotopic Atom Percents: {6000: 0.000164, 14000: 0.000870, 15000: 0.000036, 16000: 0.000023, 24000: 0.015751,
25000: 0.000889, 26000: 0.057714, 28000: 0.009850, 42000: 0.001255}
Density: 0.086553
Linear Coefficient of Expansion: 0.0
4 changes: 2 additions & 2 deletions fridge/driver/fridge_driver.py
Expand Up @@ -11,10 +11,10 @@
# TODO utilize an avogadro's number from somewhere


def main(file_name):
def main(file_name, **kwargs):
print('Welcome to FRIDGe, the Fast Reactor Input Deck Generator!')
global_vars = gb.GlobalVariables()
global_vars.read_input_file(file_name)
global_vars.read_input_file(file_name, **kwargs)
print(global_vars.input_type)
if global_vars.input_type == 'Single':
print('Creating assembly: {}... Please Wait'.format(global_vars.file_name))
Expand Down
16 changes: 12 additions & 4 deletions fridge/driver/global_variables.py
Expand Up @@ -27,17 +27,19 @@ def __init__(self):
self.number_particles_generation = 0
self.kopts = False
self.ksens = False
self.assembly_perturbations = {}
self.output_name = ''
self.input_type = ''

def read_input_file(self, assembly_name):
def read_input_file(self, assembly_name, **perturbations):
"""Reads the yaml file for a FRIDGE input file and assigns any variables found."""
self.assembly_file_name = assembly_name

cur_dir = os.path.dirname(__file__)
input_dir = os.path.join(cur_dir, "../fridge_input_file")
assembly_file = glob.glob(os.path.join(input_dir, self.assembly_file_name + '.yaml'))

assembly_path = os.path.join(input_dir, self.assembly_file_name + '.yaml')
assembly_file = glob.glob(assembly_path)
print(assembly_name, assembly_file)
print(assembly_path)
with open(assembly_file[0], "r") as file:
inputs = yaml.safe_load(file)

Expand Down Expand Up @@ -69,6 +71,12 @@ def read_input_file(self, assembly_name):
if 'ksens' in inputs else False
self.void_per = float(inputs["Void Percent"]) \
if "Void Percent" in inputs else 1.0
self.assembly_perturbations = inputs["Assembly Perturbations"] \
if "Assembly Perturbations" in inputs else {}

# Update for perturbations
for k, v in perturbations.items():
self.__setattr__(k, v)

# Set the XC set depending on the temperature
if self.temperature == 600:
Expand Down
4 changes: 4 additions & 0 deletions fridge/driver/reactorMaker.py
Expand Up @@ -38,5 +38,9 @@ def core_maker(global_vars):
print('Building reactor core and coolant.')
core.build_core(global_vars)
print('Creating MCNP input file.')
for a, perts in global_vars.assembly_perturbations.items():
print('Perturbations For Assembly {}'.format(a))
for k, v in perts.items():
print(' {}: {}'.format(k, v))
k_card = mcnpCF.make_mcnp_problem(global_vars, core=core)
mcnpCF.mcnp_input_deck_maker_core(core, k_card, global_vars)

0 comments on commit dee7ab5

Please sign in to comment.