diff --git a/saltproc/depcode.py b/saltproc/depcode.py index 16cf83776..65e1dd691 100644 --- a/saltproc/depcode.py +++ b/saltproc/depcode.py @@ -212,6 +212,8 @@ def __init__(self, active_cycles, inactive_cycles) + self.fix_dict = {} + def change_sim_par(self, template_data): """Finds simulation parameters (neutron population, cycles) in the Serpent2 template file and change them to the parameters from the @@ -246,6 +248,20 @@ def change_sim_par(self, template_data): self.inactive_cycles) return [s.replace(sim_param[0], args) for s in template_data] + def create_fix_dict(self): + """ Creates dictionary of material names to the value of their 'fix' card as well as + library information for decay-only nuclides""" + mat_data = self.read_plaintext_file(self.iter_matfile) + mat_cards = [s for s in mat_data if s.startswith("mat ")] + for mat_card in mat_cards: + mat_name = mat_card.split()[1] + fix_regex = "\s+fix\s+[a-zA-Z0-9]+\s+[0-9]+(\.[0-9]+)?" + fix_match = re.search(fix_regex, mat_card) + if bool(fix_match): + fix_params = fix_match.group(0).split()[1:] + fix_params[1] = float(fix_params[1]) + self.fix_dict.update({mat_name: fix_params}) + def create_iter_matfile(self, template_data): """Finds ``include`` line with path to material file, copies content of this file to iteration material file, changes path in ``include`` line @@ -441,6 +457,7 @@ def read_dep_comp(self, read_at_end=False): mats[m].density = dep['MAT_' + m + '_MDENS'][-1, moment] mats[m].mass = mats[m].density * volume mats[m].vol = volume + mats[m].temp = self.fix_dict[m][1] mats[m].burnup = dep['MAT_' + m + '_BURNUP'][moment] self.create_nuclide_name_map_zam_to_serpent() return mats @@ -670,6 +687,7 @@ def write_depcode_input( data = self.insert_path_to_geometry(data) data = self.change_sim_par(data) data = self.create_iter_matfile(data) + self.create_fix_dict() else: data = self.read_plaintext_file(self.iter_inputfile) data = self.replace_burnup_parameters(data, reactor, dep_step) @@ -705,8 +723,8 @@ def write_mat_file(self, dep_dict, dep_end_time): matf.write('mat %s %5.9E burn 1 fix %3s %4i vol %7.5E\n' % (key, -dep_dict[key].density, - '09c', - dep_dict[key].temp, + self.fix_dict[key][0], + self.fix_dict[key][1], dep_dict[key].vol)) for nuc_code, wt_frac in dep_dict[key].comp.items(): # Transforms iso name from zas to zzaaam and then to SERPENT