Skip to content

Commit

Permalink
fixed succes message bug
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenaH84 committed Jun 16, 2024
1 parent f53141c commit 3885fd9
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 47 deletions.
23 changes: 11 additions & 12 deletions streamlit/app_scripts/app_parameter_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ def __init__(self):
self.type_function = "function"
self.user_defined_id = 0

st.cache_data
def get_index(_self,list, id):
def get_index(self,list, id):

for list_index, value in enumerate(list):
if value == id:
Expand All @@ -253,11 +252,11 @@ def get_index(_self,list, id):
assert index is not None, "id={} not found in list".format(id)
return index

@st.cache_data
def format_parameter_sets(_self,material_component,materials, parameter_sets,material_parameter_sets_name_by_id, raw_template_parameters,raw_parameters,material_component_id):

def format_parameter_sets(self,material_component,materials, parameter_sets,material_parameter_sets_name_by_id, raw_template_parameters,raw_parameters,material_component_id):
# initialize from template parameters
formatted_materials = _self.initialize_parameter_set(material_component)
formatted_parameters = _self.initialize_parameters(raw_template_parameters)
formatted_materials = self.initialize_parameter_set(material_component)
formatted_parameters = self.initialize_parameters(raw_template_parameters)


#if np.ndim(parameter_sets)> 1:
Expand Down Expand Up @@ -398,13 +397,13 @@ def custom_number_input(_self,value):
format_str = "{:.2f}" # Normal notation with 2 decimal places
return format_str.format(value)

@st.cache_data
def format_parameters(_self, raw_parameters, raw_template_parameters, parameter_sets_name_by_id):

def format_parameters(self, raw_parameters, raw_template_parameters, parameter_sets_name_by_id):

if np.ndim(raw_parameters) > 1:

# initialize from template parameters
formatted_parameters = _self.initialize_parameters(raw_template_parameters)
formatted_parameters = self.initialize_parameters(raw_template_parameters)


for parameter in raw_parameters:
Expand Down Expand Up @@ -459,7 +458,7 @@ def format_parameters(_self, raw_parameters, raw_template_parameters, parameter_

else:
# initialize from template parameters
formatted_parameters = _self.initialize_parameters(raw_template_parameters)
formatted_parameters = self.initialize_parameters(raw_template_parameters)

parameter_id, \
name, \
Expand Down Expand Up @@ -516,7 +515,7 @@ def format_parameters(_self, raw_parameters, raw_template_parameters, parameter_


return formatted_parameters
@st.cache_data

def initialize_parameter_set(_self, materials):
initialized_materials = {}

Expand Down Expand Up @@ -588,7 +587,7 @@ def initialize_parameter_set(_self, materials):
)
return initialized_materials

@st.cache_data

def initialize_parameters(_self, raw_template_parameters):
initialized_parameters = {}
if np.ndim(raw_template_parameters) > 1:
Expand Down
12 changes: 7 additions & 5 deletions streamlit/app_scripts/app_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,7 @@ def fill_material_components(self,component_name,component_parameters,component_
key_input_number = "input_number_{}_{}".format(material_component_id, id)

if key_select not in st.session_state:
st.session_state[key_select] = material_display_names[-1]
st.session_state[key_select] = "Default"

if key_input_number not in st.session_state:
st.session_state[key_input_number] = None
Expand Down Expand Up @@ -2416,7 +2416,7 @@ def execute_api_on_click(self, save_run,file_name):

if response_start.status_code == 200:

st.session_state.reponse = True
st.session_state.response = True

with open(app_access.get_path_to_battmo_results(), "wb") as f:
f.write(response_start.content)
Expand All @@ -2437,13 +2437,14 @@ def execute_api_on_click(self, save_run,file_name):


else:
st.session_state.reponse = False

# st.error("The data has not been retrieved succesfully, most probably due to an unsuccesful simulation")
# st.session_state.success = False
# self.success = False

self.success = DivergenceCheck(save_run,False).success

st.session_state.response = False

# with open("BattMo_results.pkl", "rb") as f:
# data = pickle.load(f)
Expand Down Expand Up @@ -2604,7 +2605,7 @@ def add_indicators_to_results(self, indicators, response):

def divergence_check_logging(self,N, number_of_states,log_messages,results):

if self.response == False and st.session_state.success == None or self.response == False and st.session_state.success == False:
if self.response == False and st.session_state.success == False and st.session_state.response != None:
self.save_run.error("The data has not been retrieved succesfully, most probably due to an unsuccesful simulation")
st.session_state.success = False
st.session_state.transfer_results = False
Expand Down Expand Up @@ -2666,7 +2667,8 @@ def divergence_check_logging(self,N, number_of_states,log_messages,results):
# except:
# pass


elif st.session_state.response == None:
pass



Expand Down
16 changes: 8 additions & 8 deletions streamlit/input_files/battmo_formatted_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"Coating": {
"thickness": 8.499999999999999e-05,
"N": 20,
"effectiveDensity": 1726.14,
"effectiveDensity": 1770.4,
"bruggemanCoefficient": 1.5,
"ActiveMaterial": {
"massFraction": 0.9,
"density": 2260.0,
"electronicConductivity": 0.8,
"electronicConductivity": 100.0,
"specificHeatCapacity": 632.0,
"thermalConductivity": 1.04,
"Interface": {
Expand All @@ -36,9 +36,9 @@
},
"diffusionModelType": "full",
"SolidDiffusion": {
"activationEnergyOfDiffusion": 80000.0,
"activationEnergyOfDiffusion": 5000.0,
"referenceDiffusionCoefficient": 3.9e-14,
"particleRadius": 5e-07,
"particleRadius": 1e-06,
"N": 10
}
},
Expand Down Expand Up @@ -72,7 +72,7 @@
"ActiveMaterial": {
"massFraction": 0.9,
"density": 4950.0,
"electronicConductivity": 0.8,
"electronicConductivity": 100.0,
"specificHeatCapacity": 632.0,
"thermalConductivity": 2.1,
"Interface": {
Expand All @@ -96,9 +96,9 @@
},
"diffusionModelType": "full",
"SolidDiffusion": {
"activationEnergyOfDiffusion": 80000.0,
"activationEnergyOfDiffusion": 5000.0,
"referenceDiffusionCoefficient": 3.9e-14,
"particleRadius": 5e-07,
"particleRadius": 1e-06,
"N": 10
}
},
Expand Down Expand Up @@ -170,7 +170,7 @@
"Control": {
"controlPolicy": "CCCV",
"initialControl": "charging",
"numberOfCycles": 1,
"numberOfCycles": 2,
"CRate": 1.0,
"DRate": 1.0,
"lowerCutoffVoltage": 2.4,
Expand Down
24 changes: 12 additions & 12 deletions streamlit/input_files/linked_data_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,7 @@
"@type": "emmo:ElectricConductivity",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 0.8
"hasNumericalData": 100.0
},
"unit": {
"label": "SiemensPerMetre",
Expand All @@ -1929,7 +1929,7 @@
"@type": "emmo:Energy",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 80000.0
"hasNumericalData": 5000.0
},
"unit": {
"label": "JoulePerMole",
Expand All @@ -1955,7 +1955,7 @@
"@type": "emmo:Radius",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 5e-07
"hasNumericalData": 1e-06
},
"unit": {
"label": "Metre",
Expand Down Expand Up @@ -2337,7 +2337,7 @@
"@type": "emmo:Porosity",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 0.22000000000000003
"hasNumericalData": 0.2
},
"unit": {
"label": "UnitOne",
Expand All @@ -2350,7 +2350,7 @@
"@type": "emmo:MassLoading",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 14.67219
"hasNumericalData": 15.0484
},
"unit": {
"label": "MiliGramPerCubicCentiMeter",
Expand Down Expand Up @@ -2402,7 +2402,7 @@
"@type": "emmo:Capacity",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 1092.5690615494264
"hasNumericalData": 1120.5836528712066
},
"unit": {
"label": "MiliAmpereHour",
Expand Down Expand Up @@ -4104,7 +4104,7 @@
"@type": "emmo:ElectricConductivity",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 0.8
"hasNumericalData": 100.0
},
"unit": {
"label": "SiemensPerMetre",
Expand All @@ -4117,7 +4117,7 @@
"@type": "emmo:Energy",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 80000.0
"hasNumericalData": 5000.0
},
"unit": {
"label": "JoulePerMole",
Expand All @@ -4143,7 +4143,7 @@
"@type": "emmo:Radius",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 5e-07
"hasNumericalData": 1e-06
},
"unit": {
"label": "Metre",
Expand Down Expand Up @@ -6233,7 +6233,7 @@
"@type": "emmo:N/PRatio",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 1.04
"hasNumericalData": 1.07
},
"unit": {
"label": "UnitOne",
Expand All @@ -6246,7 +6246,7 @@
"@type": "emmo:CellMass",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 31.6742860172
"hasNumericalData": 31.7796972032
},
"unit": {
"label": "Gram",
Expand Down Expand Up @@ -6357,7 +6357,7 @@
"@type": "emmo:NumberOfEntities",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 1
"hasNumericalData": 2
},
"unit": {
"label": "UnitOne",
Expand Down
Binary file modified streamlit/output_files/battmo_results.hdf5
Binary file not shown.
4 changes: 2 additions & 2 deletions streamlit/output_files/calculated_values.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"calculatedParameters": {
"effective_density": {
"negative_electrode": 1726.14,
"negative_electrode": 1770.4,
"positive_electrode": 3151.12
},
"mass_loadings": {
"negative_electrode": 14.67219,
"negative_electrode": 15.0484,
"positive_electrode": 23.948511999999994
}
}
Expand Down
12 changes: 6 additions & 6 deletions streamlit/output_files/indicator_values.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"Cell": {
"cellMass": {
"value": 31.7532588032,
"value": 31.7796972032,
"unit": "g"
},
"roundTripEfficiency": {
"unit": "1"
},
"nominalCellCapacity": {
"value": 984.6814862555711,
"value": 1047.6223333812661,
"unit": "mAh"
},
"NPRatio": {
"value": 0.94,
"value": 1.07,
"unit": "1"
}
},
"NegativeElectrode": {
"massLoading": {
"value": 14.926,
"value": 15.0484,
"unit": "mg\u00b7cm\u207b\u00b2"
},
"thickness": {
Expand All @@ -30,12 +30,12 @@
"unit": "1"
},
"specificCapacity": {
"value": 984.6814862555711,
"value": 1120.5836528712066,
"unit": "mAh"
},
"ActiveMaterial": {
"specificCapacity": {
"value": 271.48513910203127,
"value": 306.44157263296455,
"unit": "mAh\u00b7g\u207b\u00b9"
}
}
Expand Down
5 changes: 3 additions & 2 deletions streamlit/pages/1_Simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def run_page():
model_id = app.set_model_choice().selected_model

if st.session_state.success and st.session_state.transfer_results:
st.session_state["toast"](":green-background[Gattering the results!]", icon='💤')
st.session_state["toast"](":green-background[Gathering the results!]", icon='💤')

gui_parameters = app.set_tabs(model_id).user_input

Expand All @@ -121,9 +121,10 @@ def run_page():
app.divergence_check(save_run,st.session_state.success)

if st.session_state.success and st.session_state.transfer_results:
st.session_state["toast"](":green-background[Find you results on the results page!]", icon='✅')
st.session_state["toast"](":green-background[Find your results on the results page!]", icon='✅')
st.session_state.success = False

st.session_state.response = None
with st.sidebar:
# app_view.st_space(space_width=3)

Expand Down

0 comments on commit 3885fd9

Please sign in to comment.