diff --git a/streamlit/app_scripts/app_view.py b/streamlit/app_scripts/app_view.py index 84b0003..48565b6 100644 --- a/streamlit/app_scripts/app_view.py +++ b/streamlit/app_scripts/app_view.py @@ -4919,24 +4919,49 @@ def find_max_length_array_y_axis(self,arrays): return arrays - def find_closest_value_index(self,array, value): """Find the index of the value in the array that is closest to the specified value.""" - if isinstance(array, np.ndarray): - diff = np.abs(array - value) - idx = np.where(diff <= np.diff(array).min())[0] - if idx.size > 0: - return idx[diff[idx].argmin()] - elif isinstance(array, list): - min_diff = float('inf') - closest_index = None - for i, elem in enumerate(array): - diff = abs(elem - value) - if diff <= min_diff: - min_diff = diff - closest_index = i + if isinstance(array, (np.ndarray, list)): + # Convert the array to a numpy array for uniform handling + array = np.array(array) + mask = ~np.isnan(array) + + # Filter the array to exclude NaN values + valid_array = array[mask] + + # Compute the absolute difference with the valid array + diff = np.abs(valid_array - value) + + # Find the index of the minimum difference in the valid array + closest_index_in_valid_array = np.argmin(diff) + + # Map the index back to the original array + closest_index = np.where(mask)[0][closest_index_in_valid_array] + return closest_index - return None + else: + st.write("Type not handled:", type(array)) + return None + + # def find_closest_value_index(self,array, value): + # """Find the index of the value in the array that is closest to the specified value.""" + # if isinstance(array, np.ndarray): + # diff = np.abs(array - value) + # idx = np.where(diff <= np.diff(array).min())[0] + # if idx.size > 0: + # return idx[diff[idx].argmin()] + # elif isinstance(array, list): + # min_diff = float('inf') + # closest_index = None + # for i, elem in enumerate(array): + # diff = abs(elem - value) + # if diff <= min_diff: + # min_diff = diff + # closest_index = i + # return closest_index + # else: + # st.write("type " + type(array)+"not handled") + # return None def view_plots_static(_self,time,state): @@ -5588,7 +5613,6 @@ def create_subplot(_self,x_data, y_data, title, x_label, y_label, x_min=None, y_ fig = go.Figure(layout=go.Layout( autosize=True )) - if isinstance(_self.selected_data_sets, list) and len(_self.selected_data_sets) > 1: for i,x in enumerate(x_data): diff --git a/streamlit/input_files/battmo_formatted_input.json b/streamlit/input_files/battmo_formatted_input.json index f65ff33..211a0a8 100644 --- a/streamlit/input_files/battmo_formatted_input.json +++ b/streamlit/input_files/battmo_formatted_input.json @@ -36,7 +36,7 @@ }, "diffusionModelType": "full", "SolidDiffusion": { - "activationEnergyOfDiffusion": 5000.0, + "activationEnergyOfDiffusion": 70000.0, "referenceDiffusionCoefficient": 3.9e-14, "particleRadius": 1e-06, "N": 10 @@ -133,7 +133,7 @@ "bruggemanCoefficient": 1.5 }, "Electrolyte": { - "initialConcentration": 1000.0, + "initialConcentration": 1800.0, "specificHeatCapacity": 1518.0, "thermalConductivity": 0.099, "density": 1200, @@ -170,7 +170,7 @@ "Control": { "controlPolicy": "CCCV", "initialControl": "charging", - "numberOfCycles": 1, + "numberOfCycles": 10, "CRate": 1.0, "DRate": 1.0, "lowerCutoffVoltage": 2.4, diff --git a/streamlit/input_files/linked_data_input.json b/streamlit/input_files/linked_data_input.json index 94a8561..8eb49b8 100644 --- a/streamlit/input_files/linked_data_input.json +++ b/streamlit/input_files/linked_data_input.json @@ -1929,7 +1929,7 @@ "@type": "emmo:Energy", "value": { "@type": "emmo:Numerical", - "hasNumericalData": 5000.0 + "hasNumericalData": 70000.0 }, "unit": { "label": "JoulePerMole", @@ -5961,7 +5961,7 @@ "@type": "string", "value": { "@type": "emmo:Numerical", - "hasNumericalData": 1000.0 + "hasNumericalData": 1800.0 }, "unit": { "label": "MolPerLiter", @@ -6357,7 +6357,7 @@ "@type": "emmo:NumberOfEntities", "value": { "@type": "emmo:Numerical", - "hasNumericalData": 1 + "hasNumericalData": 10 }, "unit": { "label": "UnitOne", diff --git a/streamlit/output_files/battmo_results.hdf5 b/streamlit/output_files/battmo_results.hdf5 index d812d9d..d52183b 100644 Binary files a/streamlit/output_files/battmo_results.hdf5 and b/streamlit/output_files/battmo_results.hdf5 differ