From 86af0c493ba3677e31379fe9aace34952345ee43 Mon Sep 17 00:00:00 2001 From: yardasol Date: Fri, 22 Apr 2022 16:12:10 -0500 Subject: [PATCH 1/6] added machinery to preserve 'fix' option parameters in mat card across iteration material files; fix the material temperature not being preseved --- saltproc/depcode.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/saltproc/depcode.py b/saltproc/depcode.py index 16cf83776..c1235317a 100644 --- a/saltproc/depcode.py +++ b/saltproc/depcode.py @@ -246,6 +246,33 @@ def change_sim_par(self, template_data): self.inactive_cycles) return [s.replace(sim_param[0], args) for s in template_data] + def create_temperature_dicts(self): + """ Creates dictionary of material names to temperatures as well as + library information for decay-only nuclides""" + temperature_dict = {} + fix_dict = {} + 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 = "\+fix\s+[a-zA-Z0-9]+\s+[0-9]+(\.[0-9]+)?" + tmp_regex = "\+tmp\s+[0-9]+(\.[0-9]+)?" + fix_match = re.search(fix_regex, mat_card) + tmp_match = re.search(tmp_regex, mat_card) + if bool(fix_match): + fix_params = fix_match.group(0) + fix_params = fix_card.split()[1:] + fix_params[-1] = float(fix_params[-1]) + fix_dict.update({mat_name: fix_params]}) + if bool(tmp_match): + tmp_params = tmp_match.group(0) + temperature = float(tmp_params.split()[-1]) + temperature_dict.update({mat_name: temperature}) + + self.temperature_dict = temperature_dict + self.fix_dict = fix_dict + + 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 +468,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.temperature_dict[m] mats[m].burnup = dep['MAT_' + m + '_BURNUP'][moment] self.create_nuclide_name_map_zam_to_serpent() return mats @@ -670,6 +698,7 @@ def write_depcode_input( data = self.insert_path_to_geometry(data) data = self.change_sim_par(data) data = self.create_iter_matfile(data) + create_fix_dict() else: data = self.read_plaintext_file(self.iter_inputfile) data = self.replace_burnup_parameters(data, reactor, dep_step) @@ -705,7 +734,7 @@ 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', + self.fix_dict[key][0], dep_dict[key].temp, dep_dict[key].vol)) for nuc_code, wt_frac in dep_dict[key].comp.items(): From 84056de96c6b782e93f86c25c0eef59289a07164 Mon Sep 17 00:00:00 2001 From: yardasol Date: Fri, 22 Apr 2022 16:15:49 -0500 Subject: [PATCH 2/6] minor consistency fix --- saltproc/depcode.py | 1 + 1 file changed, 1 insertion(+) diff --git a/saltproc/depcode.py b/saltproc/depcode.py index c1235317a..3c79b688e 100644 --- a/saltproc/depcode.py +++ b/saltproc/depcode.py @@ -264,6 +264,7 @@ def create_temperature_dicts(self): fix_params = fix_card.split()[1:] fix_params[-1] = float(fix_params[-1]) fix_dict.update({mat_name: fix_params]}) + temp_dict.update({mat_name: fix_params[-1]}) if bool(tmp_match): tmp_params = tmp_match.group(0) temperature = float(tmp_params.split()[-1]) From f166b340102e90c3e9bbbb9955ca15b99a6ad0b7 Mon Sep 17 00:00:00 2001 From: yardasol Date: Fri, 22 Apr 2022 16:24:02 -0500 Subject: [PATCH 3/6] minor consistency fix --- saltproc/depcode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saltproc/depcode.py b/saltproc/depcode.py index 3c79b688e..8cd84468f 100644 --- a/saltproc/depcode.py +++ b/saltproc/depcode.py @@ -699,7 +699,7 @@ def write_depcode_input( data = self.insert_path_to_geometry(data) data = self.change_sim_par(data) data = self.create_iter_matfile(data) - create_fix_dict() + create_temperatures_dict() else: data = self.read_plaintext_file(self.iter_inputfile) data = self.replace_burnup_parameters(data, reactor, dep_step) From dde318423303fbff0458886e35537e9ab294f4c5 Mon Sep 17 00:00:00 2001 From: yardasol Date: Mon, 25 Apr 2022 11:07:43 -0500 Subject: [PATCH 4/6] typo fix --- saltproc/depcode.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/saltproc/depcode.py b/saltproc/depcode.py index 8cd84468f..756cc6609 100644 --- a/saltproc/depcode.py +++ b/saltproc/depcode.py @@ -65,6 +65,8 @@ def __init__(self, self.active_cycles = active_cycles self.inactive_cycles = inactive_cycles self.param = {} + self.temperature_dict = {} + self.fix_dict = {} self.sim_info = {} @abstractmethod @@ -249,8 +251,6 @@ def change_sim_par(self, template_data): def create_temperature_dicts(self): """ Creates dictionary of material names to temperatures as well as library information for decay-only nuclides""" - temperature_dict = {} - fix_dict = {} 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: @@ -263,12 +263,12 @@ def create_temperature_dicts(self): fix_params = fix_match.group(0) fix_params = fix_card.split()[1:] fix_params[-1] = float(fix_params[-1]) - fix_dict.update({mat_name: fix_params]}) - temp_dict.update({mat_name: fix_params[-1]}) + self.fix_dict.update({mat_name: fix_params}) + self.temperature_dict.update({mat_name: fix_params[-1]}) if bool(tmp_match): tmp_params = tmp_match.group(0) temperature = float(tmp_params.split()[-1]) - temperature_dict.update({mat_name: temperature}) + self.temperature_dict.update({mat_name: temperature}) self.temperature_dict = temperature_dict self.fix_dict = fix_dict From aa6f8615cfc18404a23de779b9167365c5e90970 Mon Sep 17 00:00:00 2001 From: yardasol Date: Mon, 25 Apr 2022 11:50:24 -0500 Subject: [PATCH 5/6] move temperatuer_dict and fix_dict to be attirbutes of DepcodeSerpent --- saltproc/depcode.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/saltproc/depcode.py b/saltproc/depcode.py index 756cc6609..db31f5b69 100644 --- a/saltproc/depcode.py +++ b/saltproc/depcode.py @@ -65,8 +65,6 @@ def __init__(self, self.active_cycles = active_cycles self.inactive_cycles = inactive_cycles self.param = {} - self.temperature_dict = {} - self.fix_dict = {} self.sim_info = {} @abstractmethod @@ -214,6 +212,9 @@ def __init__(self, active_cycles, inactive_cycles) + self.temperature_dict = {} + 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 From ef912d927c1a767b2b775e1c96e825e4fbf92bf4 Mon Sep 17 00:00:00 2001 From: yardasol Date: Wed, 27 Jul 2022 14:21:59 -0500 Subject: [PATCH 6/6] create_temperature_dicts -> create_fix_dict --- saltproc/depcode.py | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/saltproc/depcode.py b/saltproc/depcode.py index db31f5b69..65e1dd691 100644 --- a/saltproc/depcode.py +++ b/saltproc/depcode.py @@ -212,7 +212,6 @@ def __init__(self, active_cycles, inactive_cycles) - self.temperature_dict = {} self.fix_dict = {} def change_sim_par(self, template_data): @@ -249,31 +248,19 @@ def change_sim_par(self, template_data): self.inactive_cycles) return [s.replace(sim_param[0], args) for s in template_data] - def create_temperature_dicts(self): - """ Creates dictionary of material names to temperatures as well as + 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 = "\+fix\s+[a-zA-Z0-9]+\s+[0-9]+(\.[0-9]+)?" - tmp_regex = "\+tmp\s+[0-9]+(\.[0-9]+)?" + fix_regex = "\s+fix\s+[a-zA-Z0-9]+\s+[0-9]+(\.[0-9]+)?" fix_match = re.search(fix_regex, mat_card) - tmp_match = re.search(tmp_regex, mat_card) if bool(fix_match): - fix_params = fix_match.group(0) - fix_params = fix_card.split()[1:] - fix_params[-1] = float(fix_params[-1]) + fix_params = fix_match.group(0).split()[1:] + fix_params[1] = float(fix_params[1]) self.fix_dict.update({mat_name: fix_params}) - self.temperature_dict.update({mat_name: fix_params[-1]}) - if bool(tmp_match): - tmp_params = tmp_match.group(0) - temperature = float(tmp_params.split()[-1]) - self.temperature_dict.update({mat_name: temperature}) - - self.temperature_dict = temperature_dict - self.fix_dict = fix_dict - def create_iter_matfile(self, template_data): """Finds ``include`` line with path to material file, copies content of @@ -470,7 +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.temperature_dict[m] + 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 @@ -700,7 +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) - create_temperatures_dict() + self.create_fix_dict() else: data = self.read_plaintext_file(self.iter_inputfile) data = self.replace_burnup_parameters(data, reactor, dep_step) @@ -737,7 +724,7 @@ def write_mat_file(self, dep_dict, dep_end_time): (key, -dep_dict[key].density, self.fix_dict[key][0], - dep_dict[key].temp, + 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