From bf55368a4efa7c3f4ff4e9698fbc33e31ee3f905 Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Thu, 31 Oct 2024 04:09:49 +0200 Subject: [PATCH] TMP --- t3/common.py | 5 +- t3/schema.py | 2 +- t3/simulate/cantera_IDT.py | 97 +++++++------- tests/test_common.py | 1 + .../test_cantera_IDT.py | 124 +++++++++--------- 5 files changed, 116 insertions(+), 113 deletions(-) diff --git a/t3/common.py b/t3/common.py index 0df734a7..17f8ae3f 100644 --- a/t3/common.py +++ b/t3/common.py @@ -284,7 +284,9 @@ def determine_concentrations_by_equivalence_ratios(species: List[dict]): inchi=objects['fuel']['inchi'] if 'inchi' in objects['fuel'].keys() else None ) objects['oxygen']['concentration'] = [eq_ratio * o2_stoichiometry for eq_ratio in objects['fuel']['equivalence_ratios']] - if objects['nitrogen'] is not None and objects['nitrogen']['concentration'] == 0: + if objects['nitrogen'] is not None and not ('concentration' in objects['nitrogen'] + and isinstance(objects['nitrogen']['concentration'], list) + and len(objects['nitrogen']['concentration']) > 1): objects['nitrogen']['concentration'] = [o2 * 3.76 for o2 in objects['oxygen']['concentration']] return objects @@ -337,5 +339,6 @@ def remove_numeric_parentheses(input_string: str) -> str: Returns: str: The string without numeric parentheses. """ + print(input_string, type(input_string)) result = re.sub(r'\(\d+\)$', '', input_string) return result diff --git a/t3/schema.py b/t3/schema.py index 1973c193..5e9c305f 100644 --- a/t3/schema.py +++ b/t3/schema.py @@ -198,7 +198,7 @@ def check_ranged_concentration_not_constant(cls, value, values): return value @validator('role') - def check_species_role(cls, value, values): + def check_species_role(cls, value): """RMGSpecies.role validator""" if value not in ['fuel', 'oxygen', 'nitrogen', None]: raise ValueError(f'The species role must be either "fuel", "oxygen", or "nitrogen".\nGot: {value}') diff --git a/t3/simulate/cantera_IDT.py b/t3/simulate/cantera_IDT.py index 70cc766d..ecfd0ae0 100644 --- a/t3/simulate/cantera_IDT.py +++ b/t3/simulate/cantera_IDT.py @@ -14,7 +14,7 @@ from arc.common import save_yaml_file -from t3.common import determine_concentrations_by_equivalence_ratios +from t3.common import determine_concentrations_by_equivalence_ratios, remove_numeric_parentheses from t3.logger import Logger from t3.simulate.adapter import SimulateAdapter from t3.simulate.factory import register_simulate_adapter @@ -84,12 +84,11 @@ def __init__(self, self.spc_identifier_lookup, self.rxn_identifier_lookup = dict(), dict() self.num_ct_reactions = None self.num_ct_species = None - self.T_list, self.P_list, self.reaction_time_list = list(), list(), list() + self.T_list, self.P_list, self.reaction_time_list, self.species_names_without_indices = list(), list(), list(), list() self.idt_dict = dict() self.set_up() self.radical_label = self.determine_radical_label() - print(f'radical label: {self.radical_label}') def set_up(self): """ @@ -106,7 +105,8 @@ def set_up(self): self.spc_identifier_lookup[spc.name] = i for i, rxn in enumerate(self.model.reactions()): self.rxn_identifier_lookup[rxn.equation] = i - self.species_names_without_indices = [self.model.species()[i].name.split('(')[0] for i in range(self.num_ct_species)] # Todo: what about HNO(T)(21)? make more robust + self.species_names_without_indices = [remove_numeric_parentheses(self.model.species()[i].name) + for i in range(self.num_ct_species)] self.T_list = ([self.rmg['reactors'][0]['T']], 'K') self.P_list = ([self.rmg['reactors'][0]['P']], 'bar') @@ -119,17 +119,22 @@ def simulate(self): self.logger.info('Running a simulation using CanteraIDT...') equivalence_ratios, concentration_combinations = self.get_concentration_combinations() + print(f'equivalence_ratios: {equivalence_ratios}\nconcentration_combinations: {concentration_combinations}') reactor_idt_dict = dict() for r, reactor in enumerate(self.rmg['reactors']): T_list, P_list = get_t_and_p_lists(reactor) if equivalence_ratios is not None and concentration_combinations is not None: for i, X in enumerate(concentration_combinations): + if self.idt_dict.get(equivalence_ratios[i]) is None: + self.idt_dict[equivalence_ratios[i]] = dict() for P in P_list: + if self.idt_dict[equivalence_ratios[i]].get(P) is None: + self.idt_dict[equivalence_ratios[i]][P] = dict() for T in T_list: print(f'T: {T}, P: {P},\nX: {X}') self.model.TPX = T, P * 1e5, X - self.idt_dict[(equivalence_ratios[i], P, T)] = \ - self.simulate_idt(fig_name=f'R{r}_{equivalence_ratios[i]}_{round(P,2)}_bar_{round(T,2)}_K.png') + self.idt_dict[equivalence_ratios[i]][P][T] = \ + self.simulate_idt(fig_name=f'R{r}_{equivalence_ratios[i]}_{P:.2f}_bar_{round(T,2)}_K.png') else: X = {spc['label']: spc['concentration'] for spc in self.rmg['species'] if spc['concentration']} for P in P_list: @@ -137,11 +142,11 @@ def simulate(self): print(f'T: {T}, P: {P},\nX: {X}') self.model.TPX = T, P * 1e5, X if equivalence_ratios is None: - self.idt_dict[(0, P, T)] = \ - self.simulate_idt(fig_name=f'R{r}_{round(P,2)}_bar_{round(T,2)}_K.png') + self.idt_dict[0][P][T] = \ + self.simulate_idt(fig_name=f'R{r}_{round(P,2)}_bar_{T:.2f}_K.png') else: - self.idt_dict[(equivalence_ratios[i], P, T)] = \ - self.simulate_idt(fig_name=f'R{r}_{equivalence_ratios[i]}_{round(P,2)}_bar_{round(T,2)}_K.png') + self.idt_dict[equivalence_ratios[i]][P][T] = \ + self.simulate_idt(fig_name=f'R{r}_{equivalence_ratios[i]}_{P:.2f}_bar_{T:.2f}_K.png') if len(T_list) >= 3: plot_idt_vs_temperature(self.idt_dict, figs_path=self.paths['figs'], reactor_index=r) reactor_idt_dict[r] = self.idt_dict @@ -212,6 +217,8 @@ def get_cantera_species_label(self, rmg_label: str) -> Optional[str]: for i, label in enumerate(self.species_names_without_indices): if label == rmg_label: return self.model.species()[i].name + if label == remove_numeric_parentheses(rmg_label): + return self.model.species()[i].name return None def get_concentration_combinations(self) -> Tuple[Optional[List[float]], Optional[List[dict]]]: @@ -236,8 +243,8 @@ def get_concentration_combinations(self) -> Tuple[Optional[List[float]], Optiona concentration_dict = dict() for spc in self.rmg['species']: if spc['role'] is None: - cantera_label = self.get_cantera_species_label(spc['label']) - if cantera_label is not None: + cantera_label = self.get_cantera_species_label(spc['label']) # can take out of loop + if cantera_label is not None and spc['concentration'] != 0: concentration_dict[cantera_label] = spc['concentration'] if spc['role'] == 'fuel': cantera_label = self.get_cantera_species_label(spc['label']) @@ -307,7 +314,7 @@ def compute_idt(time_history: ct.SolutionArray, Optional[float]: The IDT in seconds. Todo: - - solve possible noice in dc/dt. ** add IDT(1000/T) figure. + - solve possible noise in dc/dt. ** add IDT(1000/T) figure. """ figs_path = os.path.join(figs_path, 'IDTs') if not os.path.isdir(figs_path): @@ -317,7 +324,7 @@ def compute_idt(time_history: ct.SolutionArray, dc_dt = np.diff(concentration) / np.diff(times) idt_index_dc_dt = np.argmax(dc_dt) idt_index_c = np.argmax(concentration) - idt = times[idt_index_dc_dt] + idt = float(times[idt_index_dc_dt]) if idt_index_dc_dt > len(times) - 10 or idt < 1e-12 or max(concentration) < concentration[0] * 100: return None try: @@ -354,80 +361,72 @@ def get_t_and_p_lists(reactor: dict) -> Tuple[List[float], List[float]]: """ if isinstance(reactor['T'], (int, float)): T_list = [reactor['T']] - else: + elif len(reactor['T']) == 2: inverse_ts = np.linspace(1 / reactor['T'][1], - 1 / reactor['T'][0], num=100) # 15 inverse T points + 1 / reactor['T'][0], num=min(int(abs(reactor['T'][1] - reactor['T'][0]) / 10), 50)) T_list = [1 / inverse_t for inverse_t in inverse_ts[::-1]] + else: + T_list = [float(t) for t in reactor['T']] if isinstance(reactor['P'], (int, float)): P_list = [reactor['P']] - else: + elif len(reactor['P']) == 2: base = 10 log_p = np.linspace(math.log(reactor['P'][0], base), math.log(reactor['P'][1], base), num=3) # 3 pressure in log10 space P_list = [base ** p for p in log_p] + else: + P_list = [float(p) for p in reactor['P']] + T_list = [float(t) for t in T_list] + P_list = [float(p) for p in P_list] return T_list, P_list def plot_idt_vs_temperature(idt_dict: dict, figs_path: str, reactor_index: int = 0, - exp_data: tuple = None, + exp_data: dict = None, ) -> None: """ Plot IDT vs. 1000/T per phi and P condition combination. + If exp_data is provided, plot the experimental data as well and only consider phi and P values that appear in it. - idt_dict[(equivalence_ratios[i], P, T)] + idt_dict[equivalence_ratios[i]][P][T] Args: idt_dict (dict): A dictionary containing IDT values. figs_path (str): The path to the figures' directory. reactor_index (int, optional): The reactor index. - exp_data (tuple): Experimental data in lists for IDT [sec] and 1000/T [K] + exp_data (dict): Experimental data in the same format as idt_dict, IDT units are in s. """ figs_path = os.path.join(figs_path, 'IDT_vs_T') if not os.path.isdir(figs_path): os.makedirs(figs_path) - data = get_idt_per_phi_p_condition(idt_dict) - - for phi, phi_data in data.items(): + for phi, phi_data in idt_dict.items(): + print(f'phi: {phi}') + if exp_data is not None and phi not in exp_data: + print(f'phi {phi} not in exp_data') + continue for p, phi_p_data in phi_data.items(): - fig_name = f'R{reactor_index}_{phi}_{round(p,2)}_bar.png' + if exp_data is not None and p not in exp_data[phi]: + print(f'p {p} not in exp_data') + continue + fig_name = f'R{reactor_index}_{phi}_{p:.2f}_bar.png' + print(f'fig_name: {fig_name}') try: fig, ax = plt.subplots() ax.set_xlabel('1000/T (1/K)') ax.set_ylabel('IDT (s)') - ax.set_title(f'IDT vs. 1000/T, phi = {phi}, P = {p} bar') - ax.scatter(phi_p_data.keys(), phi_p_data.values(), label='simulation', color='blue', marker="o") + ax.set_title(f'IDT vs. 1000/T, phi = {phi}, P = {p:.2f} bar') + ax.scatter([1000 / t for t in phi_p_data.keys()], phi_p_data.values(), label='simulation', color='blue', marker='o', linestyle='-') ax.set_yscale('log') if exp_data is not None: - ax.scatter(exp_data[0], exp_data[1], label='experiment', color='orange', marker="D") + ax.scatter([1000 / t for t in exp_data[phi][p].keys()], [e * 1e-6 for e in exp_data[phi][p].values()], label='experiment', color='orange', marker="D") ax.set_yscale('log') ax.legend(loc='lower right') fig.savefig(os.path.join(figs_path, fig_name)) except (AttributeError, ValueError): + raise pass -def get_idt_per_phi_p_condition(idt_dict: dict) -> dict: - """ - Get IDT values per phi, P, and 1000/T condition combination. - - Args: - idt_dict (dict): A dictionary containing IDT values. - - Returns: - dict: A dictionary containing IDT values per phi and P condition combination corresponding to the 1000/T list. - """ - data = dict() - for triple_key in idt_dict.keys(): - phi, p, _ = triple_key - if phi not in data.keys(): - data[phi] = dict() - if p not in data[phi].keys(): - data[phi][p] = dict() - for triple_key, value in idt_dict.items(): - data[triple_key[0]][triple_key[1]][1000 / triple_key[2]] = value - return data - - register_simulate_adapter("CanteraIDT", CanteraIDT) diff --git a/tests/test_common.py b/tests/test_common.py index 4638fd4d..025fb32a 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -180,4 +180,5 @@ def test_remove_numeric_parentheses(): assert common.remove_numeric_parentheses('CH2(S)') == 'CH2(S)' assert common.remove_numeric_parentheses('C2H5(547)') == 'C2H5' assert common.remove_numeric_parentheses('C2H5(547)H') == 'C2H5(547)H' + assert common.remove_numeric_parentheses('HNO(T)(21)') == 'HNO(T)' diff --git a/tests/test_simulate_adapters/test_cantera_IDT.py b/tests/test_simulate_adapters/test_cantera_IDT.py index 10b50da1..4ba82e48 100644 --- a/tests/test_simulate_adapters/test_cantera_IDT.py +++ b/tests/test_simulate_adapters/test_cantera_IDT.py @@ -12,7 +12,7 @@ from t3.common import SIMULATE_DATA_BASE_PATH from tests.common import almost_equal, run_minimal -from t3.simulate.cantera_IDT import CanteraIDT, get_t_and_p_lists, get_idt_per_phi_p_condition, plot_idt_vs_temperature +from t3.simulate.cantera_IDT import CanteraIDT, get_t_and_p_lists, plot_idt_vs_temperature from t3.utils.fix_cantera import fix_cantera @@ -263,67 +263,67 @@ def test_get_concentration_combinations(): {'NH3(1)': 1, 'O2(3)': 1.125, 'N2(2)': 4.2299999999999995}] -def test_get_idt_per_phi_p_condition(): - """ - Test the ``get_idt_per_phi_p_condition()`` and ``plot_idt_vs_temperature()`` functions. - """ - idt_dict = {(0.5, 1.0, 700.0): 0.2225226476740191, (0.5, 1.0, 734.0823970037453): 0.16708573916474148, (0.5, 1.0, 771.6535433070866): 5.02356740178409, - (0.5, 1.0, 813.278008298755): 2.6993671480891055, (0.5, 1.0, 859.6491228070174): 1.356443738133375, (0.5, 1.0, 911.627906976744): 0.6983581107939171, - (0.5, 1.0, 970.2970297029701): 0.33755656449282906, (0.5, 1.0, 1037.037037037037): 0.14535334628842056, (0.5, 1.0, 1113.6363636363637): 2.736494028032103e-07, - (0.5, 1.0, 1202.4539877300613): 1.000961330460136e-06, (0.5, 1.0, 1306.6666666666665): 7.12259225172802e-07, (0.5, 1.0, 1430.6569343065692): 4.5459640244849895e-07, - (0.5, 1.0, 1580.6451612903224): 2.3022666857319686e-07, (0.5, 1.0, 1765.7657657657658): 9.206394695035107e-08, (0.5, 1.0, 2000.0): 3.573432315120674e-08, - (0.5, 10.0, 700.0): 0.017890482771101373, (0.5, 10.0, 734.0823970037453): 0.006983386498803974, (0.5, 10.0, 771.6535433070866): 0.0030995373885993618, - (0.5, 10.0, 813.278008298755): 0.0016907682247677828, (0.5, 10.0, 859.6491228070174): 0.0014290458277037052, (0.5, 10.0, 911.627906976744): 0.024839673682728793, - (0.5, 10.0, 970.2970297029701): 0.016377405433457032, (0.5, 10.0, 1037.037037037037): 0.009061116852517204, (0.5, 10.0, 1113.6363636363637): 0.004355537823553577, - (0.5, 10.0, 1202.4539877300613): 0.001813773431235719, (0.5, 10.0, 1306.6666666666665): 8.913654979267154e-08, (0.5, 10.0, 1430.6569343065692): 6.880894219736608e-08, - (0.5, 10.0, 1580.6451612903224): 4.144278144671478e-08, (0.5, 10.0, 1765.7657657657658): 2.0488968735319567e-08, (0.5, 10.0, 2000.0): 8.503011014429142e-09, - (0.5, 100.0, 700.0): 0.005435488034345394, (0.5, 100.0, 734.0823970037453): 0.001787188448355339, (0.5, 100.0, 771.6535433070866): 0.0006347140607608446, - (0.5, 100.0, 813.278008298755): 0.00021190487623380018, (0.5, 100.0, 859.6491228070174): 7.987901887938693e-05, (0.5, 100.0, 911.627906976744): 3.263051659337995e-05, - (0.5, 100.0, 970.2970297029701): 1.4849422053893114e-05, (0.5, 100.0, 1037.037037037037): 9.24871858161717e-06, (0.5, 100.0, 1113.6363636363637): 8.351115423339925e-06, - (0.5, 100.0, 1202.4539877300613): 4.19701181841529e-05, (0.5, 100.0, 1306.6666666666665): 1.715836447277912e-05, (0.5, 100.0, 1430.6569343065692): 5.90026803036469e-09, - (0.5, 100.0, 1580.6451612903224): 6.255138391856596e-09, (0.5, 100.0, 1765.7657657657658): 4.26627737099569e-09, (0.5, 100.0, 2000.0): 2.0875416305454136e-09, - (1.0, 1.0, 700.0): 0.5920046195114103, (1.0, 1.0, 734.0823970037453): 25.20627885398315, (1.0, 1.0, 771.6535433070866): 12.767585163653209, (1.0, 1.0, 813.278008298755): 5.716485074891581, - (1.0, 1.0, 859.6491228070174): 2.553180004265852, (1.0, 1.0, 911.627906976744): 1.1231722696550877, (1.0, 1.0, 970.2970297029701): 0.43615510429279186, - (1.0, 1.0, 1037.037037037037): 0.14620000787049678, (1.0, 1.0, 1113.6363636363637): 5.307835695537308e-07, (1.0, 1.0, 1202.4539877300613): 1.7086621427001015e-06, - (1.0, 1.0, 1306.6666666666665): 1.190123704797599e-06, (1.0, 1.0, 1430.6569343065692): 7.666609861364305e-07, (1.0, 1.0, 1580.6451612903224): 3.7957780648719297e-07, - (1.0, 1.0, 1765.7657657657658): 1.4873205857608197e-07, (1.0, 1.0, 2000.0): 3.410869675993873e-06, (1.0, 10.0, 700.0): 0.030141236107045628, (1.0, 10.0, 734.0823970037453): 0.012789805640634989, - (1.0, 10.0, 771.6535433070866): 0.006691030606197884, (1.0, 10.0, 813.278008298755): 0.005425145384644125, (1.0, 10.0, 859.6491228070174): 0.10662963089066134, - (1.0, 10.0, 911.627906976744): 0.06638081223291674, (1.0, 10.0, 970.2970297029701): 0.0338779727293199, (1.0, 10.0, 1037.037037037037): 0.015278921977995857, - (1.0, 10.0, 1113.6363636363637): 0.0057515533254156636, (1.0, 10.0, 1202.4539877300613): 0.001860322307495681, (1.0, 10.0, 1306.6666666666665): 1.582033035671788e-07, - (1.0, 10.0, 1430.6569343065692): 1.1051229608250778e-07, (1.0, 10.0, 1580.6451612903224): 6.788645792555125e-08, (1.0, 10.0, 1765.7657657657658): 3.347974272493323e-08, - (1.0, 10.0, 2000.0): 1.320029247792099e-08, (1.0, 100.0, 700.0): 0.00920847613468232, (1.0, 100.0, 734.0823970037453): 0.003319939713013387, (1.0, 100.0, 771.6535433070866): 0.0009346034377021333, - (1.0, 100.0, 813.278008298755): 0.0003364813695425258, (1.0, 100.0, 859.6491228070174): 0.00013188187589578053, (1.0, 100.0, 911.627906976744): 5.8877410092406586e-05, - (1.0, 100.0, 970.2970297029701): 3.3877254067224806e-05, (1.0, 100.0, 1037.037037037037): 3.6256347086780324e-05, (1.0, 100.0, 1113.6363636363637): 0.00036025425555191536, - (1.0, 100.0, 1202.4539877300613): 1.5950943566673704e-08, (1.0, 100.0, 1306.6666666666665): 9.913445948190319e-09, (1.0, 100.0, 1430.6569343065692): 9.533288504711534e-09, - (1.0, 100.0, 1580.6451612903224): 9.776005620375751e-09, (1.0, 100.0, 1765.7657657657658): 7.170974648131883e-09, (1.0, 100.0, 2000.0): 3.3249820396549518e-09, (2.0, 1.0, 700.0): 153.42627889517567, - (2.0, 1.0, 734.0823970037453): 72.07801439138305, (2.0, 1.0, 771.6535433070866): 29.858800758367142, (2.0, 1.0, 813.278008298755): 12.19350991294148, (2.0, 1.0, 859.6491228070174): 4.981464061860932, - (2.0, 1.0, 911.627906976744): 1.9009892918050009, (2.0, 1.0, 970.2970297029701): 0.6050619278279298, (2.0, 1.0, 1037.037037037037): 0.15977101588655185, (2.0, 1.0, 1113.6363636363637): 3.554181280297076e-06, - (2.0, 1.0, 1202.4539877300613): 2.692532328166398e-06, (2.0, 1.0, 1306.6666666666665): 2.0742127776023104e-06, (2.0, 1.0, 1430.6569343065692): 1.5257400932247982e-06, - (2.0, 1.0, 1580.6451612903224): 6.4898453340595e-07, (2.0, 1.0, 1765.7657657657658): 2.276317066246901e-07, (2.0, 1.0, 2000.0): 9.141443099145247e-08, (2.0, 10.0, 700.0): 0.05446218706560296, - (2.0, 10.0, 734.0823970037453): 0.026925447558953746, (2.0, 10.0, 771.6535433070866): 0.02026453438020286, (2.0, 10.0, 813.278008298755): 0.3121168817399508, - (2.0, 10.0, 859.6491228070174): 0.2855186343870682, (2.0, 10.0, 911.627906976744): 0.16722258168806528, (2.0, 10.0, 970.2970297029701): 0.07008781204858813, - (2.0, 10.0, 1037.037037037037): 0.026701006033165515, (2.0, 10.0, 1113.6363636363637): 0.008178628130578134, (2.0, 10.0, 1202.4539877300613): 0.002104845434600624, - (2.0, 10.0, 1306.6666666666665): 2.429411770965833e-07, (2.0, 10.0, 1430.6569343065692): 1.8684140375699375e-07, (2.0, 10.0, 1580.6451612903224): 1.326022435725622e-07, - (2.0, 10.0, 1765.7657657657658): 5.4793403682451235e-08, (2.0, 10.0, 2000.0): 1.9529689210357182e-08, (2.0, 100.0, 700.0): 0.01345974259908484, (2.0, 100.0, 734.0823970037453): 0.004332708238713801, - (2.0, 100.0, 771.6535433070866): 0.0014875458039001063, (2.0, 100.0, 813.278008298755): 0.0005568658354940749, (2.0, 100.0, 859.6491228070174): 0.00023782156661448042, - (2.0, 100.0, 911.627906976744): 0.00013024762221742106, (2.0, 100.0, 970.2970297029701): 0.0003654164224997926, (2.0, 100.0, 1037.037037037037): 0.00047137250311130507, - (2.0, 100.0, 1113.6363636363637): 0.0011588590661409058, (2.0, 100.0, 1202.4539877300613): 1.9886722119469843e-08, (2.0, 100.0, 1306.6666666666665): 1.2862135863448915e-08, - (2.0, 100.0, 1430.6569343065692): 1.5833393881133795e-08, (2.0, 100.0, 1580.6451612903224): 1.538084118885189e-08, (2.0, 100.0, 1765.7657657657658): 1.5502875986669263e-08, - (2.0, 100.0, 2000.0): 5.251911799476016e-09} - - data = get_idt_per_phi_p_condition(idt_dict=idt_dict) - assert data == {0.5: {1.0: {1.4285714285714286: 0.2225226476740191, 1.3622448979591837: 0.16708573916474148, 1.2959183673469388: 5.02356740178409, 1.229591836734694: 2.6993671480891055, 1.1632653061224492: 1.356443738133375, 1.0969387755102042: 0.6983581107939171, 1.0306122448979593: 0.33755656449282906, 0.9642857142857144: 0.14535334628842056, 0.8979591836734693: 2.736494028032103e-07, 0.8316326530612246: 1.000961330460136e-06, 0.7653061224489797: 7.12259225172802e-07, 0.6989795918367347: 4.5459640244849895e-07, 0.6326530612244898: 2.3022666857319686e-07, 0.5663265306122449: 9.206394695035107e-08, 0.5: 3.573432315120674e-08}, - 10.0: {1.4285714285714286: 0.017890482771101373, 1.3622448979591837: 0.006983386498803974, 1.2959183673469388: 0.0030995373885993618, 1.229591836734694: 0.0016907682247677828, 1.1632653061224492: 0.0014290458277037052, 1.0969387755102042: 0.024839673682728793, 1.0306122448979593: 0.016377405433457032, 0.9642857142857144: 0.009061116852517204, 0.8979591836734693: 0.004355537823553577, 0.8316326530612246: 0.001813773431235719, 0.7653061224489797: 8.913654979267154e-08, 0.6989795918367347: 6.880894219736608e-08, 0.6326530612244898: 4.144278144671478e-08, 0.5663265306122449: 2.0488968735319567e-08, 0.5: 8.503011014429142e-09}, - 100.0: {1.4285714285714286: 0.005435488034345394, 1.3622448979591837: 0.001787188448355339, 1.2959183673469388: 0.0006347140607608446, 1.229591836734694: 0.00021190487623380018, 1.1632653061224492: 7.987901887938693e-05, 1.0969387755102042: 3.263051659337995e-05, 1.0306122448979593: 1.4849422053893114e-05, 0.9642857142857144: 9.24871858161717e-06, 0.8979591836734693: 8.351115423339925e-06, 0.8316326530612246: 4.19701181841529e-05, 0.7653061224489797: 1.715836447277912e-05, 0.6989795918367347: 5.90026803036469e-09, 0.6326530612244898: 6.255138391856596e-09, 0.5663265306122449: 4.26627737099569e-09, 0.5: 2.0875416305454136e-09}}, - 1.0: {1.0: {1.4285714285714286: 0.5920046195114103, 1.3622448979591837: 25.20627885398315, 1.2959183673469388: 12.767585163653209, 1.229591836734694: 5.716485074891581, 1.1632653061224492: 2.553180004265852, 1.0969387755102042: 1.1231722696550877, 1.0306122448979593: 0.43615510429279186, 0.9642857142857144: 0.14620000787049678, 0.8979591836734693: 5.307835695537308e-07, 0.8316326530612246: 1.7086621427001015e-06, 0.7653061224489797: 1.190123704797599e-06, 0.6989795918367347: 7.666609861364305e-07, 0.6326530612244898: 3.7957780648719297e-07, 0.5663265306122449: 1.4873205857608197e-07, 0.5: 3.410869675993873e-06}, - 10.0: {1.4285714285714286: 0.030141236107045628, 1.3622448979591837: 0.012789805640634989, 1.2959183673469388: 0.006691030606197884, 1.229591836734694: 0.005425145384644125, 1.1632653061224492: 0.10662963089066134, 1.0969387755102042: 0.06638081223291674, 1.0306122448979593: 0.0338779727293199, 0.9642857142857144: 0.015278921977995857, 0.8979591836734693: 0.0057515533254156636, 0.8316326530612246: 0.001860322307495681, 0.7653061224489797: 1.582033035671788e-07, 0.6989795918367347: 1.1051229608250778e-07, 0.6326530612244898: 6.788645792555125e-08, 0.5663265306122449: 3.347974272493323e-08, 0.5: 1.320029247792099e-08}, - 100.0: {1.4285714285714286: 0.00920847613468232, 1.3622448979591837: 0.003319939713013387, 1.2959183673469388: 0.0009346034377021333, 1.229591836734694: 0.0003364813695425258, 1.1632653061224492: 0.00013188187589578053, 1.0969387755102042: 5.8877410092406586e-05, 1.0306122448979593: 3.3877254067224806e-05, 0.9642857142857144: 3.6256347086780324e-05, 0.8979591836734693: 0.00036025425555191536, 0.8316326530612246: 1.5950943566673704e-08, 0.7653061224489797: 9.913445948190319e-09, 0.6989795918367347: 9.533288504711534e-09, 0.6326530612244898: 9.776005620375751e-09, 0.5663265306122449: 7.170974648131883e-09, 0.5: 3.3249820396549518e-09}}, - 2.0: {1.0: {1.4285714285714286: 153.42627889517567, 1.3622448979591837: 72.07801439138305, 1.2959183673469388: 29.858800758367142, 1.229591836734694: 12.19350991294148, 1.1632653061224492: 4.981464061860932, 1.0969387755102042: 1.9009892918050009, 1.0306122448979593: 0.6050619278279298, 0.9642857142857144: 0.15977101588655185, 0.8979591836734693: 3.554181280297076e-06, 0.8316326530612246: 2.692532328166398e-06, 0.7653061224489797: 2.0742127776023104e-06, 0.6989795918367347: 1.5257400932247982e-06, 0.6326530612244898: 6.4898453340595e-07, 0.5663265306122449: 2.276317066246901e-07, 0.5: 9.141443099145247e-08}, - 10.0: {1.4285714285714286: 0.05446218706560296, 1.3622448979591837: 0.026925447558953746, 1.2959183673469388: 0.02026453438020286, 1.229591836734694: 0.3121168817399508, 1.1632653061224492: 0.2855186343870682, 1.0969387755102042: 0.16722258168806528, 1.0306122448979593: 0.07008781204858813, 0.9642857142857144: 0.026701006033165515, 0.8979591836734693: 0.008178628130578134, 0.8316326530612246: 0.002104845434600624, 0.7653061224489797: 2.429411770965833e-07, 0.6989795918367347: 1.8684140375699375e-07, 0.6326530612244898: 1.326022435725622e-07, 0.5663265306122449: 5.4793403682451235e-08, 0.5: 1.9529689210357182e-08}, - 100.0: {1.4285714285714286: 0.01345974259908484, 1.3622448979591837: 0.004332708238713801, 1.2959183673469388: 0.0014875458039001063, 1.229591836734694: 0.0005568658354940749, 1.1632653061224492: 0.00023782156661448042, 1.0969387755102042: 0.00013024762221742106, 1.0306122448979593: 0.0003654164224997926, 0.9642857142857144: 0.00047137250311130507, 0.8979591836734693: 0.0011588590661409058, 0.8316326530612246: 1.9886722119469843e-08, 0.7653061224489797: 1.2862135863448915e-08, 0.6989795918367347: 1.5833393881133795e-08, 0.6326530612244898: 1.538084118885189e-08, 0.5663265306122449: 1.5502875986669263e-08, 0.5: 5.251911799476016e-09}}} - assert len(data[0.5][1.0].keys()) == len(data[1.0][10.0].keys()) == len(data[2.0][100.0].keys()) == 15 - - plot_idt_vs_temperature(idt_dict=idt_dict, figs_path=os.path.join(TEST_DIR_IDT, 'iteration_3', 'Figures')) +# def test_get_idt_per_phi_p_condition(): +# """ +# Test the ``get_idt_per_phi_p_condition()`` and ``plot_idt_vs_temperature()`` functions. +# """ +# idt_dict = {(0.5, 1.0, 700.0): 0.2225226476740191, (0.5, 1.0, 734.0823970037453): 0.16708573916474148, (0.5, 1.0, 771.6535433070866): 5.02356740178409, +# (0.5, 1.0, 813.278008298755): 2.6993671480891055, (0.5, 1.0, 859.6491228070174): 1.356443738133375, (0.5, 1.0, 911.627906976744): 0.6983581107939171, +# (0.5, 1.0, 970.2970297029701): 0.33755656449282906, (0.5, 1.0, 1037.037037037037): 0.14535334628842056, (0.5, 1.0, 1113.6363636363637): 2.736494028032103e-07, +# (0.5, 1.0, 1202.4539877300613): 1.000961330460136e-06, (0.5, 1.0, 1306.6666666666665): 7.12259225172802e-07, (0.5, 1.0, 1430.6569343065692): 4.5459640244849895e-07, +# (0.5, 1.0, 1580.6451612903224): 2.3022666857319686e-07, (0.5, 1.0, 1765.7657657657658): 9.206394695035107e-08, (0.5, 1.0, 2000.0): 3.573432315120674e-08, +# (0.5, 10.0, 700.0): 0.017890482771101373, (0.5, 10.0, 734.0823970037453): 0.006983386498803974, (0.5, 10.0, 771.6535433070866): 0.0030995373885993618, +# (0.5, 10.0, 813.278008298755): 0.0016907682247677828, (0.5, 10.0, 859.6491228070174): 0.0014290458277037052, (0.5, 10.0, 911.627906976744): 0.024839673682728793, +# (0.5, 10.0, 970.2970297029701): 0.016377405433457032, (0.5, 10.0, 1037.037037037037): 0.009061116852517204, (0.5, 10.0, 1113.6363636363637): 0.004355537823553577, +# (0.5, 10.0, 1202.4539877300613): 0.001813773431235719, (0.5, 10.0, 1306.6666666666665): 8.913654979267154e-08, (0.5, 10.0, 1430.6569343065692): 6.880894219736608e-08, +# (0.5, 10.0, 1580.6451612903224): 4.144278144671478e-08, (0.5, 10.0, 1765.7657657657658): 2.0488968735319567e-08, (0.5, 10.0, 2000.0): 8.503011014429142e-09, +# (0.5, 100.0, 700.0): 0.005435488034345394, (0.5, 100.0, 734.0823970037453): 0.001787188448355339, (0.5, 100.0, 771.6535433070866): 0.0006347140607608446, +# (0.5, 100.0, 813.278008298755): 0.00021190487623380018, (0.5, 100.0, 859.6491228070174): 7.987901887938693e-05, (0.5, 100.0, 911.627906976744): 3.263051659337995e-05, +# (0.5, 100.0, 970.2970297029701): 1.4849422053893114e-05, (0.5, 100.0, 1037.037037037037): 9.24871858161717e-06, (0.5, 100.0, 1113.6363636363637): 8.351115423339925e-06, +# (0.5, 100.0, 1202.4539877300613): 4.19701181841529e-05, (0.5, 100.0, 1306.6666666666665): 1.715836447277912e-05, (0.5, 100.0, 1430.6569343065692): 5.90026803036469e-09, +# (0.5, 100.0, 1580.6451612903224): 6.255138391856596e-09, (0.5, 100.0, 1765.7657657657658): 4.26627737099569e-09, (0.5, 100.0, 2000.0): 2.0875416305454136e-09, +# (1.0, 1.0, 700.0): 0.5920046195114103, (1.0, 1.0, 734.0823970037453): 25.20627885398315, (1.0, 1.0, 771.6535433070866): 12.767585163653209, (1.0, 1.0, 813.278008298755): 5.716485074891581, +# (1.0, 1.0, 859.6491228070174): 2.553180004265852, (1.0, 1.0, 911.627906976744): 1.1231722696550877, (1.0, 1.0, 970.2970297029701): 0.43615510429279186, +# (1.0, 1.0, 1037.037037037037): 0.14620000787049678, (1.0, 1.0, 1113.6363636363637): 5.307835695537308e-07, (1.0, 1.0, 1202.4539877300613): 1.7086621427001015e-06, +# (1.0, 1.0, 1306.6666666666665): 1.190123704797599e-06, (1.0, 1.0, 1430.6569343065692): 7.666609861364305e-07, (1.0, 1.0, 1580.6451612903224): 3.7957780648719297e-07, +# (1.0, 1.0, 1765.7657657657658): 1.4873205857608197e-07, (1.0, 1.0, 2000.0): 3.410869675993873e-06, (1.0, 10.0, 700.0): 0.030141236107045628, (1.0, 10.0, 734.0823970037453): 0.012789805640634989, +# (1.0, 10.0, 771.6535433070866): 0.006691030606197884, (1.0, 10.0, 813.278008298755): 0.005425145384644125, (1.0, 10.0, 859.6491228070174): 0.10662963089066134, +# (1.0, 10.0, 911.627906976744): 0.06638081223291674, (1.0, 10.0, 970.2970297029701): 0.0338779727293199, (1.0, 10.0, 1037.037037037037): 0.015278921977995857, +# (1.0, 10.0, 1113.6363636363637): 0.0057515533254156636, (1.0, 10.0, 1202.4539877300613): 0.001860322307495681, (1.0, 10.0, 1306.6666666666665): 1.582033035671788e-07, +# (1.0, 10.0, 1430.6569343065692): 1.1051229608250778e-07, (1.0, 10.0, 1580.6451612903224): 6.788645792555125e-08, (1.0, 10.0, 1765.7657657657658): 3.347974272493323e-08, +# (1.0, 10.0, 2000.0): 1.320029247792099e-08, (1.0, 100.0, 700.0): 0.00920847613468232, (1.0, 100.0, 734.0823970037453): 0.003319939713013387, (1.0, 100.0, 771.6535433070866): 0.0009346034377021333, +# (1.0, 100.0, 813.278008298755): 0.0003364813695425258, (1.0, 100.0, 859.6491228070174): 0.00013188187589578053, (1.0, 100.0, 911.627906976744): 5.8877410092406586e-05, +# (1.0, 100.0, 970.2970297029701): 3.3877254067224806e-05, (1.0, 100.0, 1037.037037037037): 3.6256347086780324e-05, (1.0, 100.0, 1113.6363636363637): 0.00036025425555191536, +# (1.0, 100.0, 1202.4539877300613): 1.5950943566673704e-08, (1.0, 100.0, 1306.6666666666665): 9.913445948190319e-09, (1.0, 100.0, 1430.6569343065692): 9.533288504711534e-09, +# (1.0, 100.0, 1580.6451612903224): 9.776005620375751e-09, (1.0, 100.0, 1765.7657657657658): 7.170974648131883e-09, (1.0, 100.0, 2000.0): 3.3249820396549518e-09, (2.0, 1.0, 700.0): 153.42627889517567, +# (2.0, 1.0, 734.0823970037453): 72.07801439138305, (2.0, 1.0, 771.6535433070866): 29.858800758367142, (2.0, 1.0, 813.278008298755): 12.19350991294148, (2.0, 1.0, 859.6491228070174): 4.981464061860932, +# (2.0, 1.0, 911.627906976744): 1.9009892918050009, (2.0, 1.0, 970.2970297029701): 0.6050619278279298, (2.0, 1.0, 1037.037037037037): 0.15977101588655185, (2.0, 1.0, 1113.6363636363637): 3.554181280297076e-06, +# (2.0, 1.0, 1202.4539877300613): 2.692532328166398e-06, (2.0, 1.0, 1306.6666666666665): 2.0742127776023104e-06, (2.0, 1.0, 1430.6569343065692): 1.5257400932247982e-06, +# (2.0, 1.0, 1580.6451612903224): 6.4898453340595e-07, (2.0, 1.0, 1765.7657657657658): 2.276317066246901e-07, (2.0, 1.0, 2000.0): 9.141443099145247e-08, (2.0, 10.0, 700.0): 0.05446218706560296, +# (2.0, 10.0, 734.0823970037453): 0.026925447558953746, (2.0, 10.0, 771.6535433070866): 0.02026453438020286, (2.0, 10.0, 813.278008298755): 0.3121168817399508, +# (2.0, 10.0, 859.6491228070174): 0.2855186343870682, (2.0, 10.0, 911.627906976744): 0.16722258168806528, (2.0, 10.0, 970.2970297029701): 0.07008781204858813, +# (2.0, 10.0, 1037.037037037037): 0.026701006033165515, (2.0, 10.0, 1113.6363636363637): 0.008178628130578134, (2.0, 10.0, 1202.4539877300613): 0.002104845434600624, +# (2.0, 10.0, 1306.6666666666665): 2.429411770965833e-07, (2.0, 10.0, 1430.6569343065692): 1.8684140375699375e-07, (2.0, 10.0, 1580.6451612903224): 1.326022435725622e-07, +# (2.0, 10.0, 1765.7657657657658): 5.4793403682451235e-08, (2.0, 10.0, 2000.0): 1.9529689210357182e-08, (2.0, 100.0, 700.0): 0.01345974259908484, (2.0, 100.0, 734.0823970037453): 0.004332708238713801, +# (2.0, 100.0, 771.6535433070866): 0.0014875458039001063, (2.0, 100.0, 813.278008298755): 0.0005568658354940749, (2.0, 100.0, 859.6491228070174): 0.00023782156661448042, +# (2.0, 100.0, 911.627906976744): 0.00013024762221742106, (2.0, 100.0, 970.2970297029701): 0.0003654164224997926, (2.0, 100.0, 1037.037037037037): 0.00047137250311130507, +# (2.0, 100.0, 1113.6363636363637): 0.0011588590661409058, (2.0, 100.0, 1202.4539877300613): 1.9886722119469843e-08, (2.0, 100.0, 1306.6666666666665): 1.2862135863448915e-08, +# (2.0, 100.0, 1430.6569343065692): 1.5833393881133795e-08, (2.0, 100.0, 1580.6451612903224): 1.538084118885189e-08, (2.0, 100.0, 1765.7657657657658): 1.5502875986669263e-08, +# (2.0, 100.0, 2000.0): 5.251911799476016e-09} +# +# data = get_idt_per_phi_p_condition(idt_dict=idt_dict) +# assert data == {0.5: {1.0: {1.4285714285714286: 0.2225226476740191, 1.3622448979591837: 0.16708573916474148, 1.2959183673469388: 5.02356740178409, 1.229591836734694: 2.6993671480891055, 1.1632653061224492: 1.356443738133375, 1.0969387755102042: 0.6983581107939171, 1.0306122448979593: 0.33755656449282906, 0.9642857142857144: 0.14535334628842056, 0.8979591836734693: 2.736494028032103e-07, 0.8316326530612246: 1.000961330460136e-06, 0.7653061224489797: 7.12259225172802e-07, 0.6989795918367347: 4.5459640244849895e-07, 0.6326530612244898: 2.3022666857319686e-07, 0.5663265306122449: 9.206394695035107e-08, 0.5: 3.573432315120674e-08}, +# 10.0: {1.4285714285714286: 0.017890482771101373, 1.3622448979591837: 0.006983386498803974, 1.2959183673469388: 0.0030995373885993618, 1.229591836734694: 0.0016907682247677828, 1.1632653061224492: 0.0014290458277037052, 1.0969387755102042: 0.024839673682728793, 1.0306122448979593: 0.016377405433457032, 0.9642857142857144: 0.009061116852517204, 0.8979591836734693: 0.004355537823553577, 0.8316326530612246: 0.001813773431235719, 0.7653061224489797: 8.913654979267154e-08, 0.6989795918367347: 6.880894219736608e-08, 0.6326530612244898: 4.144278144671478e-08, 0.5663265306122449: 2.0488968735319567e-08, 0.5: 8.503011014429142e-09}, +# 100.0: {1.4285714285714286: 0.005435488034345394, 1.3622448979591837: 0.001787188448355339, 1.2959183673469388: 0.0006347140607608446, 1.229591836734694: 0.00021190487623380018, 1.1632653061224492: 7.987901887938693e-05, 1.0969387755102042: 3.263051659337995e-05, 1.0306122448979593: 1.4849422053893114e-05, 0.9642857142857144: 9.24871858161717e-06, 0.8979591836734693: 8.351115423339925e-06, 0.8316326530612246: 4.19701181841529e-05, 0.7653061224489797: 1.715836447277912e-05, 0.6989795918367347: 5.90026803036469e-09, 0.6326530612244898: 6.255138391856596e-09, 0.5663265306122449: 4.26627737099569e-09, 0.5: 2.0875416305454136e-09}}, +# 1.0: {1.0: {1.4285714285714286: 0.5920046195114103, 1.3622448979591837: 25.20627885398315, 1.2959183673469388: 12.767585163653209, 1.229591836734694: 5.716485074891581, 1.1632653061224492: 2.553180004265852, 1.0969387755102042: 1.1231722696550877, 1.0306122448979593: 0.43615510429279186, 0.9642857142857144: 0.14620000787049678, 0.8979591836734693: 5.307835695537308e-07, 0.8316326530612246: 1.7086621427001015e-06, 0.7653061224489797: 1.190123704797599e-06, 0.6989795918367347: 7.666609861364305e-07, 0.6326530612244898: 3.7957780648719297e-07, 0.5663265306122449: 1.4873205857608197e-07, 0.5: 3.410869675993873e-06}, +# 10.0: {1.4285714285714286: 0.030141236107045628, 1.3622448979591837: 0.012789805640634989, 1.2959183673469388: 0.006691030606197884, 1.229591836734694: 0.005425145384644125, 1.1632653061224492: 0.10662963089066134, 1.0969387755102042: 0.06638081223291674, 1.0306122448979593: 0.0338779727293199, 0.9642857142857144: 0.015278921977995857, 0.8979591836734693: 0.0057515533254156636, 0.8316326530612246: 0.001860322307495681, 0.7653061224489797: 1.582033035671788e-07, 0.6989795918367347: 1.1051229608250778e-07, 0.6326530612244898: 6.788645792555125e-08, 0.5663265306122449: 3.347974272493323e-08, 0.5: 1.320029247792099e-08}, +# 100.0: {1.4285714285714286: 0.00920847613468232, 1.3622448979591837: 0.003319939713013387, 1.2959183673469388: 0.0009346034377021333, 1.229591836734694: 0.0003364813695425258, 1.1632653061224492: 0.00013188187589578053, 1.0969387755102042: 5.8877410092406586e-05, 1.0306122448979593: 3.3877254067224806e-05, 0.9642857142857144: 3.6256347086780324e-05, 0.8979591836734693: 0.00036025425555191536, 0.8316326530612246: 1.5950943566673704e-08, 0.7653061224489797: 9.913445948190319e-09, 0.6989795918367347: 9.533288504711534e-09, 0.6326530612244898: 9.776005620375751e-09, 0.5663265306122449: 7.170974648131883e-09, 0.5: 3.3249820396549518e-09}}, +# 2.0: {1.0: {1.4285714285714286: 153.42627889517567, 1.3622448979591837: 72.07801439138305, 1.2959183673469388: 29.858800758367142, 1.229591836734694: 12.19350991294148, 1.1632653061224492: 4.981464061860932, 1.0969387755102042: 1.9009892918050009, 1.0306122448979593: 0.6050619278279298, 0.9642857142857144: 0.15977101588655185, 0.8979591836734693: 3.554181280297076e-06, 0.8316326530612246: 2.692532328166398e-06, 0.7653061224489797: 2.0742127776023104e-06, 0.6989795918367347: 1.5257400932247982e-06, 0.6326530612244898: 6.4898453340595e-07, 0.5663265306122449: 2.276317066246901e-07, 0.5: 9.141443099145247e-08}, +# 10.0: {1.4285714285714286: 0.05446218706560296, 1.3622448979591837: 0.026925447558953746, 1.2959183673469388: 0.02026453438020286, 1.229591836734694: 0.3121168817399508, 1.1632653061224492: 0.2855186343870682, 1.0969387755102042: 0.16722258168806528, 1.0306122448979593: 0.07008781204858813, 0.9642857142857144: 0.026701006033165515, 0.8979591836734693: 0.008178628130578134, 0.8316326530612246: 0.002104845434600624, 0.7653061224489797: 2.429411770965833e-07, 0.6989795918367347: 1.8684140375699375e-07, 0.6326530612244898: 1.326022435725622e-07, 0.5663265306122449: 5.4793403682451235e-08, 0.5: 1.9529689210357182e-08}, +# 100.0: {1.4285714285714286: 0.01345974259908484, 1.3622448979591837: 0.004332708238713801, 1.2959183673469388: 0.0014875458039001063, 1.229591836734694: 0.0005568658354940749, 1.1632653061224492: 0.00023782156661448042, 1.0969387755102042: 0.00013024762221742106, 1.0306122448979593: 0.0003654164224997926, 0.9642857142857144: 0.00047137250311130507, 0.8979591836734693: 0.0011588590661409058, 0.8316326530612246: 1.9886722119469843e-08, 0.7653061224489797: 1.2862135863448915e-08, 0.6989795918367347: 1.5833393881133795e-08, 0.6326530612244898: 1.538084118885189e-08, 0.5663265306122449: 1.5502875986669263e-08, 0.5: 5.251911799476016e-09}}} +# assert len(data[0.5][1.0].keys()) == len(data[1.0][10.0].keys()) == len(data[2.0][100.0].keys()) == 15 +# +# plot_idt_vs_temperature(idt_dict=idt_dict, figs_path=os.path.join(TEST_DIR_IDT, 'iteration_3', 'Figures')) def teardown_module():