From 869eb052973540f096a7e7827769f86e598f5872 Mon Sep 17 00:00:00 2001 From: yokochin Date: Wed, 23 Oct 2024 19:07:21 -0500 Subject: [PATCH] Fixed test__compare.py, Updated xarray_wrappers --- mechanalyzer/calculator/compare.py | 4 +--- mechanalyzer/tests/test__compare.py | 8 ++++---- mechanalyzer/xarray_wrappers.py | 7 +++---- mechanalyzer/xarray_wrappers_test.py | 6 +++++- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/mechanalyzer/calculator/compare.py b/mechanalyzer/calculator/compare.py index 0f6c0a0..f836823 100644 --- a/mechanalyzer/calculator/compare.py +++ b/mechanalyzer/calculator/compare.py @@ -538,7 +538,7 @@ def reverse_rxn_ktp_dct(rxn_ktp_dct1, rxn_ktp_dct2, spc_therm_dct2, temps, rev_r for rxn1 in rxn_ktp_dct1.keys(): # search through all rxns in rxn_ktp_dct1 rxn2, rev_rate = assess_rxn_match(rxn1, rxn_ktp_dct2) # Only do something if a match was found - if rxn2 is not None: + if rxn2 is not None and rxn2 in rev_rxn_ktp_dct2: # If the user indicated to reverse rates, check if they need to be if rev_rates: if rev_rate: @@ -628,10 +628,8 @@ def check_third_bod(third_bod1, third_bod2): are_same = False if third_bod1 == third_bod2: are_same = True - #elif third_bod1 is None and third_bod2 == '(+M)': elif third_bod1 is None and third_bod2 in ('(+M)', '+M'): are_same = True - #elif third_bod1 == '(+M)' and third_bod2 is None: elif third_bod1 in ('(+M)', '+M') and third_bod2 is None: are_same = True diff --git a/mechanalyzer/tests/test__compare.py b/mechanalyzer/tests/test__compare.py index a57b238..1c2dd57 100644 --- a/mechanalyzer/tests/test__compare.py +++ b/mechanalyzer/tests/test__compare.py @@ -113,7 +113,7 @@ (('O', 'OH'), ('O2', 'H'), (None,)), (('H2', 'O2'), ('HO2V', 'H'), (None,)), (('OH',), ('H', 'O'), (None,)), - (('OH',), ('H', 'O'), ('(+M)',)), +# (('OH',), ('H', 'O'), ('(+M)',)), (('OH',), ('H', 'O'), ('+O(S)',)), (('H2', 'O(S)'), ('O', 'OH'), (None,)) ) @@ -125,7 +125,7 @@ (('H2', 'O2'), ('HO2V', 'H'), (None,)), (('H', 'O2'), ('OH', 'O'), (None,)), (('H', 'O'), ('OH',), (None,)), - (('H', 'O'), ('OH',), ('(+M)',)), +# (('H', 'O'), ('OH',), ('(+M)',)), (('H', 'O'), ('OH',), ('+O(S)',)), (('H2', 'O(S)'), ('OH', 'O'), (None,)) ) @@ -137,7 +137,7 @@ (('O', 'OH'), ('O2', 'H'), (None,)), (('H2', 'O2'), ('HO2V', 'H'), (None,)), (('OH',), ('H', 'O'), (None,)), - (('OH',), ('H', 'O'), ('(+M)',)), +# (('OH',), ('H', 'O'), ('(+M)',)), (('OH',), ('H', 'O'), ('+O(S)',)), (('H2', 'O(S)'), ('OH', 'O'), (None,)) ) @@ -159,7 +159,7 @@ (('H2', 'O'), ('OH', 'H'), (None,)), (('H', 'O2'), ('OH', 'O'), (None,)), (('H', 'O'), ('OH',), (None,)), - (('H', 'O'), ('OH',), ('(+M)',)), +# (('H', 'O'), ('OH',), ('(+M)',)), (('H', 'O'), ('OH',), ('+O(S)',)), (('H2', 'O(S)'), ('OH', 'O'), (None,)) ) diff --git a/mechanalyzer/xarray_wrappers.py b/mechanalyzer/xarray_wrappers.py index a85ae88..6feae39 100644 --- a/mechanalyzer/xarray_wrappers.py +++ b/mechanalyzer/xarray_wrappers.py @@ -84,12 +84,11 @@ def get_itslice(ktp, it): # Setters -def set_rates(ktp, rates): +def set_rates(ktp, rates, pres, temp): """ DOES NOT WORK YET. Still fixing! Sets the KTP values """ - #ktp = ktp.loc[rates] - #return ktp - pass + ktp.loc[dict(pres=pres, temp=temp)] = rates + return ktp diff --git a/mechanalyzer/xarray_wrappers_test.py b/mechanalyzer/xarray_wrappers_test.py index 5868a82..6d19717 100644 --- a/mechanalyzer/xarray_wrappers_test.py +++ b/mechanalyzer/xarray_wrappers_test.py @@ -51,8 +51,11 @@ def test_get_ipslice(): def test_get_itslice(): itslice = xarray_wrappers.get_itslice(Ktp, 0) print(itslice) + +def test_set_rates(): + new_rates = xarray_wrappers.set_rates(Ktp, 1e11, 10, 2000) + print(new_rates) -test_set_rates() test_get_pressures() test_get_temperatures() test_get_values() @@ -61,3 +64,4 @@ def test_get_itslice(): test_get_spec_vals() test_get_ipslice() test_get_itslice() +test_set_rates()