Skip to content

Commit

Permalink
Corrected AM reaction rate, included option to choose CCDischarge or …
Browse files Browse the repository at this point in the history
…CCCV, resolves #29
  • Loading branch information
LorenaH84 committed Mar 5, 2024
1 parent a287ec5 commit e8ba95e
Show file tree
Hide file tree
Showing 18 changed files with 201 additions and 165 deletions.
3 changes: 2 additions & 1 deletion flask_api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ RUN jill install 1.10.0 --confirm
# RUN julia --project=/app -e 'using Pkg; Pkg.precompile();'

RUN julia -e 'using Pkg; Pkg.add(PackageSpec(;name = "PythonCall",version = "0.9.14"))'
RUN julia -e 'using Pkg; Pkg.add(PackageSpec(;name = "JSON",version = "0.21.4"))'
RUN julia -e 'using Pkg; Pkg.add(PackageSpec(;url="https://github.com/BattMoTeam/BattMo.jl.git", rev="cccv"))'
RUN julia -e 'using Pkg; Pkg.add(PackageSpec(;name = "JSON",version = "0.21.4"))'

#RUN julia -e 'using Pkg; Pkg.add(PackageSpec(;name = "BattMo",version = "0.1.6"))'
#RUN julia -e 'using Pkg; Pkg.add("BattMo")'
RUN julia -e 'using Pkg; Pkg.add(PackageSpec(;name = "Jutul",version = "0.2.23"))'
Expand Down
6 changes: 6 additions & 0 deletions flask_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ def run_julia(q_in,q_out):

# Define the Julia code to execute
julia_code = f"runP2DBattery.runP2DBatt(\"{file_name}\")"

# try:
log_messages, number_of_states, cell_voltage, cell_current, time_values, negative_electrode_grid, negative_electrode_grid_bc, electrolyte_grid, electrolyte_grid_bc, positive_electrode_grid, positive_electrode_grid_bc, negative_electrode_concentration, electrolyte_concentration, positive_electrode_concentration, negative_electrode_potential, electrolyte_potential, positive_electrode_potential = jl.seval(julia_code)

print("The simulation has completed {} time steps.".format(number_of_states))
# except:
# print("The simulation has failed.")
# log_messages, number_of_states, cell_voltage, cell_current, time_values, negative_electrode_grid, negative_electrode_grid_bc, electrolyte_grid, electrolyte_grid_bc, positive_electrode_grid, positive_electrode_grid_bc, negative_electrode_concentration, electrolyte_concentration, positive_electrode_concentration, negative_electrode_potential, electrolyte_potential, positive_electrode_potential = ([0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0])
# return log_messages, number_of_states, cell_voltage, cell_current, time_values, negative_electrode_grid, negative_electrode_grid_bc, electrolyte_grid, electrolyte_grid_bc, positive_electrode_grid, positive_electrode_grid_bc, negative_electrode_concentration, electrolyte_concentration, positive_electrode_concentration, negative_electrode_potential, electrolyte_potential, positive_electrode_potential

# Converting data to python objects
negative_electrode_concentration = [jl.Py(subarray).to_numpy() for subarray in negative_electrode_concentration],
Expand Down
2 changes: 1 addition & 1 deletion streamlit/app_scripts/app_calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def validate_volume_fraction(vf_sum,category_display_name,_tab):
for id, value in vf_sum.items():
vf_summing += value
if vf_summing != 1.0:
_tab.warning("The sum of the '%s' material volume fractions is not equal to 1." % (category_display_name))
_tab.warning("The sum of the '%s' material mass fractions is not equal to 1." % (category_display_name))

@st.cache_data
def calc_density_mix(vf, density):
Expand Down
228 changes: 126 additions & 102 deletions streamlit/app_scripts/app_view.py

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions streamlit/app_scripts/match_json_LD.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def get_dict_from_has_quantitative(has_quantitative):
for item in has_quantitative:

if type(item) != str:

item_value_type = item.get("value", {}).get("@type", None)
if item_value_type == "emmo:Numerical":
new_dict[item.get("label")] = {
Expand Down Expand Up @@ -156,7 +157,7 @@ def get_batt_mo_dict_from_gui_dict(gui_dict):
"NegativeElectrode": {
"Coating":{
"thickness": json_ld.ne.properties.get("coating_thickness").get("value")*10**(-6),
"N": json_ld.ne.am.get("number_of_discrete_cells_electrode").get("value"),
"N": json_ld.ne.am.get("number_of_discrete_cells_particle_radius").get("value"),
"effectiveDensity": 1900, # calculated_values["effective_density"]["negative_electrode"],
"bruggemanCoefficient": json_ld.ne.properties.get("bruggeman_coefficient").get("value"),
"ActiveMaterial": {
Expand Down Expand Up @@ -217,7 +218,7 @@ def get_batt_mo_dict_from_gui_dict(gui_dict):
"PositiveElectrode": {
"Coating":{
"thickness": json_ld.pe.properties.get("coating_thickness").get("value")*10**(-6),
"N": json_ld.pe.am.get("number_of_discrete_cells_electrode").get("value"),
"N": json_ld.pe.am.get("number_of_discrete_cells_particle_radius").get("value"),
"effectiveDensity": 3500, #calculated_values["effective_density"]["positive_electrode"],
"bruggemanCoefficient": json_ld.pe.properties.get("bruggeman_coefficient").get("value"),
"ActiveMaterial": {
Expand Down Expand Up @@ -324,8 +325,8 @@ def get_batt_mo_dict_from_gui_dict(gui_dict):
"Control": {
"controlPolicy": json_ld.protocol.get("protocol_name"),
"initialControl": json_ld.protocol.get("initial_step_type"),
#"numberOfCycles": json_ld.protocol.get("number_of_cycles").get("value"),
#"CRate": json_ld.protocol.get("c_rate").get("value"),
"numberOfCycles": json_ld.protocol.get("number_of_cycles").get("value"),
"CRate": json_ld.protocol.get("c_rate").get("value"),
"DRate": json_ld.protocol.get("d_rate").get("value"),
"lowerCutoffVoltage": json_ld.protocol.get("lower_cutoff_voltage").get("value"),
"rampupTime" : 0.1,
Expand Down
Binary file modified streamlit/database/BattMo_gui.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"density": 2260.0,
"number_of_electrons_transferred": 1,
"activation_energy_of_reaction": 35000.0,
"reaction_rate_constant": 6.48e-7,
"reaction_rate_constant": 6.716e-12,
"maximum_lithium_stoichiometry": 0.9014,
"minimum_lithium_stoichiometry": 0.0279,
"open_circuit_potential": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"activation_energy_of_diffusion": 5e3,
"diffusion_pre_exponential_factor": 3.9e-14,
"particle_radius": 1e-6,
"number_of_discrete_cells_electrode": 10,
"number_of_discrete_cells_particle_radius": 10,
"specific_heat_capacity": 632,
"thermal_conductivity": 1.04
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"density": 4950,
"number_of_electrons_transferred": 1,
"activation_energy_of_reaction":17800,
"reaction_rate_constant": 3.42e-6,
"reaction_rate_constant": 3.545e-11,
"maximum_lithium_stoichiometry": 0.2661,
"minimum_lithium_stoichiometry": 0.9084,
"open_circuit_potential": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"activation_energy_of_diffusion": 5e3,
"diffusion_pre_exponential_factor": 1e-14,
"particle_radius": 1e-6,
"number_of_discrete_cells_electrode": 10,
"number_of_discrete_cells_particle_radius": 10,
"specific_heat_capacity": 700,
"thermal_conductivity": 2.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"material": false,
"Header": {},
"Parameters": {
"protocol_name": "CCDischarge",
"initial_step_type": "discharging",
"number_of_cycles": 1,
"d_rate": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Name": "CCDischarge",
"Category": "protocol",
"component": "protocol_properties",
"material": false,
"Header": {},
"Parameters": {
"initial_step_type": "discharging",
"d_rate": 1,
"lower_cutoff_voltage": 2.4,
"upper_cutoff_voltage": 4.1,
"d_idt_limit": 0.01,
"d_edt_limit": 0.01
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"display_name": "Diffusion pre exponential factor"
},
"number_of_discrete_cells_electrode": {
"model_name": "p2d_p3d_p4d",
"model_name": "p3d_p4d",
"par_class": "non_material",
"difficulty": "advanced",
"context_type": "emmo:NumberOfEntities",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
"Type": "template",
"Name": "protocol_full_template",
"Parameters": {
"protocol_name": {
"model_name": "p2d_p3d_p4d",
"par_class": "non_material",
"difficulty": "advanced",
"description": "",
"is_shown_to_user": true,
"type": "str",
"display_name": "Protocol name"
},
"initial_step_type": {
"model_name": "p2d_p3d_p4d",
"par_class": "non_material",
Expand All @@ -21,7 +12,7 @@
"display_name": "Initial step type"
},
"number_of_cycles": {
"model_name": "p3d_p4d",
"model_name": "p2d_p3d_p4d",
"par_class": "non_material",
"difficulty": "basis",
"context_type": "emmo:NumberOfEntities",
Expand All @@ -39,7 +30,7 @@
"d_rate": {
"model_name": "p2d_p3d_p4d",
"par_class": "non_material",
"difficulty": "advanced",
"difficulty": "basis",
"context_type_iri":"https://w3id.org/emmo/domain/electrochemistry#electrochemistry_25e20915_c35d_4bee_ad31_736235a79780",
"max_value": 10,
"min_value": 0.01,
Expand All @@ -52,9 +43,9 @@
"display_name": "Crate"
},
"c_rate": {
"model_name": "p3d_p4d",
"model_name": "p2d_p3d_p4d",
"par_class": "non_material",
"difficulty": "advanced",
"difficulty": "basis",
"context_type_iri":"https://w3id.org/emmo/domain/electrochemistry#electrochemistry_e1fd84eb_acdb_4b2c_b90c_e899d552a3ee",
"max_value": 10,
"min_value": 0.01,
Expand Down
8 changes: 5 additions & 3 deletions streamlit/input_files/battmo_formatted_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"density": 2260.0,
"numberOfElectronsTransferred": 1,
"activationEnergyOfReaction": 35000.0,
"reactionRateConstant": 6.48e-07,
"reactionRateConstant": 6.716e-12,
"guestStoichiometry100": 0.9014,
"guestStoichiometry0": 0.0279,
"chargeTransferCoefficient": 0.5,
Expand Down Expand Up @@ -81,7 +81,7 @@
"density": 4950.0,
"numberOfElectronsTransferred": 1,
"activationEnergyOfReaction": 17800.0,
"reactionRateConstant": 3.42e-06,
"reactionRateConstant": 3.545e-11,
"guestStoichiometry100": 0.2661,
"guestStoichiometry0": 0.9084,
"chargeTransferCoefficient": 0.5,
Expand Down Expand Up @@ -167,8 +167,10 @@
"initT": 298.15,
"include_current_collectors": false,
"Control": {
"controlPolicy": "CCDischarge",
"controlPolicy": "CCCV",
"initialControl": "discharging",
"numberOfCycles": 1,
"CRate": 1.0,
"DRate": 1.0,
"lowerCutoffVoltage": 2.4,
"rampupTime": 0.1,
Expand Down
63 changes: 31 additions & 32 deletions streamlit/input_files/linked_data_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"@type": "None",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 6.48e-07
"hasNumericalData": 6.716e-12
},
"unit": {
"label": "MolePerSquareMetrePerSecond",
Expand Down Expand Up @@ -287,19 +287,6 @@
"@type": "emmo:ReciprocalSecond"
}
},
{
"label": "number_of_discrete_cells_electrode",
"@type": "https://w3id.org/emmo#EMMO_41efdf5d_0c9c_4ea0_bb65_f8236e663be5",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 10
},
"unit": {
"label": "UnitOne",
"symbol": "1",
"@type": "emmo:UnitOne"
}
},
{
"label": "particle_radius",
"@type": "https://w3id.org/emmo#EMMO_32dcd601_47c7_4028_b7fa_5e972ae57f12",
Expand Down Expand Up @@ -671,7 +658,7 @@
"@type": "None",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 3.42e-06
"hasNumericalData": 3.545e-11
},
"unit": {
"label": "MolePerSquareMetrePerSecond",
Expand Down Expand Up @@ -795,19 +782,6 @@
"@type": "emmo:ReciprocalSecond"
}
},
{
"label": "number_of_discrete_cells_electrode",
"@type": "https://w3id.org/emmo#EMMO_41efdf5d_0c9c_4ea0_bb65_f8236e663be5",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 10
},
"unit": {
"label": "UnitOne",
"symbol": "1",
"@type": "emmo:UnitOne"
}
},
{
"label": "particle_radius",
"@type": "https://w3id.org/emmo#EMMO_32dcd601_47c7_4028_b7fa_5e972ae57f12",
Expand Down Expand Up @@ -1472,11 +1446,16 @@
}
},
{
"label": "protocol_name",
"@type": "None",
"label": "number_of_cycles",
"@type": "https://w3id.org/emmo#EMMO_41efdf5d_0c9c_4ea0_bb65_f8236e663be5",
"value": {
"@type": "emmo:String",
"hasStringData": "CCDischarge"
"@type": "emmo:Numerical",
"hasNumericalData": 1
},
"unit": {
"label": "UnitOne",
"symbol": "1",
"@type": "emmo:UnitOne"
}
},
{
Expand All @@ -1492,6 +1471,26 @@
"@type": "emmo:UnitOne"
}
},
{
"label": "c_rate",
"@type": "https://w3id.org/emmo/domain/electrochemistry#electrochemistry_e1fd84eb_acdb_4b2c_b90c_e899d552a3ee",
"value": {
"@type": "emmo:Numerical",
"hasNumericalData": 1.0
},
"unit": {
"label": "UnitOne",
"symbol": "1",
"@type": "emmo:UnitOne"
}
},
{
"label": "protocol_name",
"value": {
"@type": "emmo:String",
"hasStringData": "CCCV"
}
},
{
"label": "lower_cutoff_voltage",
"@type": "https://w3id.org/emmo/domain/electrochemistry#electrochemistry_534dd59c_904c_45d9_8550_ae9d2eb6bbc9",
Expand Down
Binary file modified streamlit/output_files/battmo_results
Binary file not shown.
6 changes: 3 additions & 3 deletions streamlit/output_files/indicator_values.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Cell": {
"cellMass": {
"value": 34.64493824,
"value": 34.66146224,
"unit": "g"
},
"nominalCellCapacity": {
Expand All @@ -15,7 +15,7 @@
},
"NegativeElectrode": {
"massLoading": {
"value": 14.9872,
"value": 15.0484,
"unit": "mg(cm)\u207b\u00b2"
},
"thickness": {
Expand All @@ -27,7 +27,7 @@
"unit": "1"
},
"specificCapacity": {
"value": 1116.0263763796381,
"value": 1120.5836528712066,
"unit": "mAh"
},
"ActiveMaterial": {
Expand Down

0 comments on commit e8ba95e

Please sign in to comment.