Skip to content

Commit 1b5d749

Browse files
NellyMitnikalongd
authored andcommitted
added an option to insert exp_data with sim_data for IDT vs. 1000/K plot.
Also changed style to scatter plot with 100 points of simulations.
1 parent ece7493 commit 1b5d749

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

t3/simulate/cantera_IDT.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
from arc.common import save_yaml_file
1616

17+
from rmgpy.chemkin import load_chemkin_file
18+
1719
from t3.common import determine_concentrations_by_equivalence_ratios
1820
from t3.logger import Logger
1921
from t3.simulate.adapter import SimulateAdapter
@@ -315,7 +317,7 @@ def compute_idt(time_history: ct.SolutionArray,
315317
return None
316318
try:
317319
plt.plot(times, concentration)
318-
plt.plot(times[idt_index_dc_dt], concentration[idt_index_dc_dt], 'ro')
320+
plt.plot(times[idt_index_dc_dt], concentration[idt_index_dc_dt], 'o')
319321
plt.xlabel('Time (s)')
320322
plt.ylabel(f'[{radical_label}]')
321323
plt.title(f'IDT = {idt:.2e} s')
@@ -349,7 +351,7 @@ def get_t_and_p_lists(reactor: dict) -> Tuple[List[float], List[float]]:
349351
T_list = [reactor['T']]
350352
else:
351353
inverse_ts = np.linspace(1 / reactor['T'][1],
352-
1 / reactor['T'][0], num=15) # 15 inverse T points
354+
1 / reactor['T'][0], num=100) # 15 inverse T points
353355
T_list = [1 / inverse_t for inverse_t in inverse_ts[::-1]]
354356
if isinstance(reactor['P'], (int, float)):
355357
P_list = [reactor['P']]
@@ -364,6 +366,7 @@ def get_t_and_p_lists(reactor: dict) -> Tuple[List[float], List[float]]:
364366
def plot_idt_vs_temperature(idt_dict: dict,
365367
figs_path: str,
366368
reactor_index: int = 0,
369+
exp_data: tuple = None,
367370
) -> None:
368371
"""
369372
Plot IDT vs. 1000/T per phi and P condition combination.
@@ -374,11 +377,13 @@ def plot_idt_vs_temperature(idt_dict: dict,
374377
idt_dict (dict): A dictionary containing IDT values.
375378
figs_path (str): The path to the figures' directory.
376379
reactor_index (int, optional): The reactor index.
380+
exp_data (tuple): Experimental data in lists for IDT [sec] and 1000/T [K]
377381
"""
378382
figs_path = os.path.join(figs_path, 'IDT_vs_T')
379383
if not os.path.isdir(figs_path):
380384
os.makedirs(figs_path)
381385
data = get_idt_per_phi_p_condition(idt_dict)
386+
382387
for phi, phi_data in data.items():
383388
for p, phi_p_data in phi_data.items():
384389
fig_name = f'R{reactor_index}_{phi}_{round(p,2)}_bar.png'
@@ -387,7 +392,13 @@ def plot_idt_vs_temperature(idt_dict: dict,
387392
ax.set_xlabel('1000/T (1/K)')
388393
ax.set_ylabel('IDT (s)')
389394
ax.set_title(f'IDT vs. 1000/T, phi = {phi}, P = {p} bar')
390-
ax.semilogy(phi_p_data.keys(), phi_p_data.values())
395+
ax.scatter(phi_p_data.keys(), phi_p_data.values(),label='simulation', color='blue',marker="o")
396+
ax.set_yscale('log')
397+
#Add experimental data specified by the user
398+
if exp_data is not None:
399+
ax.scatter(exp_data[0], exp_data[1], label='experiment', color='orange',marker="D")
400+
ax.set_yscale('log')
401+
ax.legend(loc='lower right')
391402
fig.savefig(os.path.join(figs_path, fig_name))
392403
except (AttributeError, ValueError):
393404
pass

0 commit comments

Comments
 (0)