Skip to content

Commit

Permalink
add temperature tuning and simulations
Browse files Browse the repository at this point in the history
  • Loading branch information
sravanpannala committed Mar 22, 2024
1 parent 07ea85e commit f53fc2a
Show file tree
Hide file tree
Showing 10 changed files with 2,207 additions and 985 deletions.
350 changes: 54 additions & 296 deletions gmproj/cycling_aging/conc_dep_stress.ipynb

Large diffs are not rendered by default.

44 changes: 37 additions & 7 deletions gmproj/cycling_aging/plot_cycling_mech_sei_plating.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,36 @@
"# parameter_values.search(\"diffus\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def plot_cap(all_sumvars_dict1,esoh_data):\n",
" esoh_vars = [\"x_100\", \"y_0\", \"C_n\", \"C_p\", \"Capacity [A.h]\", \"Loss of lithium inventory [%]\"]\n",
" fig, ax = plt.subplots(1,1,figsize=(5,4))\n",
" name = \"Capacity [A.h]\"\n",
" ax.plot(esoh_data[\"N\"],esoh_data[name]/esoh_data[name][0]*100,\"kx\")\n",
" ax.plot(all_sumvars_dict1[\"Cycle number\"],all_sumvars_dict1[name]/all_sumvars_dict1[name][0]*100,\"b--\")\n",
" ax.set_xlabel(\"Cycle number\")\n",
" ax.set_ylabel(\"Capacity Retention [%]\")\n",
" # fig.legend([ \"Data\", leg1, leg2, leg3], \n",
" # loc=\"lower center\",bbox_to_anchor=[0.5,-0.1], ncol=2, fontsize=11)\n",
" fig.tight_layout()\n",
" return fig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cells = [1,4,7,10,13,16]\n",
"cells = [3,6,9,12,15,18]\n",
"cells = [2,5,8,11,14,17]\n",
"cells = [4,5,6]\n",
"# cells = [3,6,9,12,15,18]\n",
"# cells = [2,5,8,11,14,17]\n",
"cells = [4]\n",
"sno = 15\n",
"sim_des = f'cond{sno}'\n",
"# sim_des = sim_des+'_cv'\n",
Expand All @@ -98,7 +118,7 @@
" \"Rest for 10 sec\",\n",
" \"Charge at \"+c_rate_c+\" until 4.2V\", \n",
" \"Hold at 4.2V until C/100\")\n",
" ] *dfe.N.iloc[-1],\n",
" ] *(dfe.N.iloc[-1]+200),\n",
" # ] *40,\n",
" termination=\"50% capacity\",\n",
" # cccv_handling=\"ode\",\n",
Expand Down Expand Up @@ -186,8 +206,18 @@
" check_already_exists=False,\n",
" )\n",
" all_sumvars_dict = cycle_adaptive_simulation_V2(spm, parameter_values, experiment,SOC_0, save_at_cycles=1)\n",
" with open(res_DIR+'fast_sim_'+sim_des+\"_cell_\"+cell_no+'_sum_var.pickle', 'wb') as handle:\n",
" pickle.dump(all_sumvars_dict, handle, protocol=pickle.HIGHEST_PROTOCOL)\n"
" # with open(res_DIR+'fast_sim_'+sim_des+\"_cell_\"+cell_no+'_sum_var.pickle', 'wb') as handle:\n",
" # pickle.dump(all_sumvars_dict, handle, protocol=pickle.HIGHEST_PROTOCOL)\n",
" plot_cap(all_sumvars_dict,dfe)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sfgsfdg"
]
},
{
Expand Down Expand Up @@ -3075,7 +3105,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.13"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
151 changes: 144 additions & 7 deletions gmproj/cycling_aging/plot_saved_simulations.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Plot Saved Simulations"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -63,21 +70,117 @@
"metadata": {},
"outputs": [],
"source": [
"cells = [1,4,7,10,13,16]\n",
"cells = [1,2,3]\n",
"def plotc3_cap(all_sumvars_dict1,all_sumvars_dict2,all_sumvars_dict3,esoh_data,leg1=\"sim1\",leg2=\"sim2\",leg3=\"sim3\"):\n",
" esoh_vars = [\"x_100\", \"y_0\", \"C_n\", \"C_p\", \"Capacity [A.h]\", \"Loss of lithium inventory [%]\"]\n",
" fig, ax = plt.subplots(1,1,figsize=(5,4))\n",
" name = \"Capacity [A.h]\"\n",
" ax.plot(esoh_data[\"N\"],esoh_data[name]/esoh_data[name][0]*100,\"kx\")\n",
" ax.plot(all_sumvars_dict1[\"Cycle number\"],all_sumvars_dict1[name]/all_sumvars_dict1[name][0]*100,\"b--\")\n",
" ax.plot(all_sumvars_dict2[\"Cycle number\"],all_sumvars_dict2[name]/all_sumvars_dict2[name][0]*100,\"r--\")\n",
" ax.plot(all_sumvars_dict3[\"Cycle number\"],all_sumvars_dict3[name]/all_sumvars_dict3[name][0]*100,\"g--\")\n",
"# ax.plot(dfe[\"Ah_th\"],dfe[\"Cap\"]/dfe[\"Cap\"][0]*100,linestyle=\"None\",marker=\"o\",label='_nolegend_',color=colors[i])\n",
" # ax.set_title(split_long_string(name))\n",
" ax.set_xlabel(\"Cycle number\")\n",
" ax.set_ylabel(\"Capacity Retention [%]\")\n",
" # fig.legend([ \"Data\", leg1, leg2, leg3], \n",
" # loc=\"lower center\",bbox_to_anchor=[0.5,-0.1], ncol=2, fontsize=11)\n",
" fig.tight_layout()\n",
" return fig"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cell = 1\n",
"sno = 15\n",
"sim_des = f'cond{sno}'\n",
"cell_no,esoh_data1,dfe_0,dfo_0,N,N_0 = load_data(cell,eSOH_DIR,oCV_DIR)\n",
"with open(res_DIR+'fast_sim_'+sim_des+\"_cell_\"+cell_no+'_sum_var.pickle', 'rb') as handle:\n",
" all_sumvars_dict1 = pickle.load(handle)\n",
"cell = 4\n",
"sno = 15\n",
"sim_des = f'cond{sno}'\n",
"cell_no,esoh_data2,dfe_0,dfo_0,N,N_0 = load_data(cell,eSOH_DIR,oCV_DIR)\n",
"with open(res_DIR+'fast_sim_'+sim_des+\"_cell_\"+cell_no+'_sum_var.pickle', 'rb') as handle:\n",
" all_sumvars_dict2 = pickle.load(handle)\n",
"cell = 3\n",
"sno = 7\n",
"sim_des = f'cond{sno}'\n",
"cell_no,dfe,esoh_data3,dfo_0,N,N_0 = load_data(cell,eSOH_DIR,oCV_DIR)\n",
"with open(res_DIR+'fast_sim_'+sim_des+\"_cell_\"+cell_no+'_sum_var.pickle', 'rb') as handle:\n",
" all_sumvars_dict3 = pickle.load(handle)\n",
"cell = 6\n",
"sno = 7\n",
"sim_des = f'cond{sno}'\n",
"cell_no,dfe,esoh_data4,dfo_0,N,N_0 = load_data(cell,eSOH_DIR,oCV_DIR)\n",
"with open(res_DIR+'fast_sim_'+sim_des+\"_cell_\"+cell_no+'_sum_var.pickle', 'rb') as handle:\n",
" all_sumvars_dict4 = pickle.load(handle)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"esoh_vars = [\"x_100\", \"y_0\", \"C_n\", \"C_p\", \"Capacity [A.h]\", \"Loss of lithium inventory [%]\"]\n",
"fig, ax = plt.subplots(1,1,figsize=(5,4))\n",
"name = \"Capacity [A.h]\"\n",
"ax.plot(esoh_data1[\"N\"],esoh_data1[name]/esoh_data1[name][0]*100,\"kx\",label=\"_nolegend_\")\n",
"ax.plot(esoh_data2[\"N\"],esoh_data2[name]/esoh_data2[name][0]*100,\"kx\",label=\"_nolegend_\")\n",
"ax.plot(esoh_data3[\"N\"],esoh_data3[name]/esoh_data3[name][0]*100,\"kx\",label=\"_nolegend_\")\n",
"ax.plot(esoh_data4[\"N\"],esoh_data4[name]/esoh_data4[name][0]*100,\"kx\",label=\"_nolegend_\")\n",
"ax.plot(all_sumvars_dict1[\"Cycle number\"],all_sumvars_dict1[name]/all_sumvars_dict1[name][0]*100,\"g--\")\n",
"ax.plot(all_sumvars_dict2[\"Cycle number\"],all_sumvars_dict2[name]/all_sumvars_dict2[name][0]*100,\"gv\")\n",
"ax.plot(all_sumvars_dict3[\"Cycle number\"],all_sumvars_dict3[name]/all_sumvars_dict3[name][0]*100,\"r--\")\n",
"ax.plot(all_sumvars_dict4[\"Cycle number\"],all_sumvars_dict4[name]/all_sumvars_dict4[name][0]*100,\"rv\")\n",
"# ax.plot(dfe[\"Ah_th\"],dfe[\"Cap\"]/dfe[\"Cap\"][0]*100,linestyle=\"None\",marker=\"o\",label='_nolegend_',color=colors[i])\n",
"# ax.set_title(split_long_string(name))\n",
"ax.set_xlabel(\"Cycle number\")\n",
"ax.set_ylabel(\"Capacity Retention [%]\")\n",
"fig.legend([\"25degC C/5\", \"25degC 1.5C\",\"45degC C/5\", \"45degC 1.5C\"], \n",
" loc=\"lower center\",bbox_to_anchor=[0.5,-0.1], ncol=2, fontsize=11)\n",
"fig.tight_layout()\n",
"plt.savefig(\"hot_room_cap.png\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sgfsdg"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cells = [3,6,9,12]\n",
"# cells = [3]\n",
"for cell in cells:\n",
" sno = 15\n",
" sno = 1\n",
" sim_des = f'cond{sno}'\n",
" cell_no,dfe,dfe_0,dfo_0,N,N_0 = load_data(cell,eSOH_DIR,oCV_DIR)\n",
" with open(res_DIR+'fast_sim_'+sim_des+\"_cell_\"+cell_no+'_sum_var.pickle', 'rb') as handle:\n",
" data1 = pickle.load(handle)\n",
" sno = 19\n",
" sno = 2\n",
" sim_des = f'cond{sno}'\n",
" with open(res_DIR+'fast_sim_'+sim_des+\"_cell_\"+cell_no+'_sum_var.pickle', 'rb') as handle:\n",
" data2 = pickle.load(handle)\n",
" fig = plotc2_cap(data1,data2,dfe,leg1=\"Old\",leg2=\"0.1*Dsn\");\n",
" sno = 5\n",
" sim_des = f'cond{sno}'\n",
" with open(res_DIR+'fast_sim_'+sim_des+\"_cell_\"+cell_no+'_sum_var.pickle', 'rb') as handle:\n",
" data3 = pickle.load(handle)\n",
" fig = plotc3_cap(data1,data2,data3,dfe,leg1=\"w/o const\",leg2=\"1/2<x<2\",leg3=\"1/2<x<2 beta2 uncons\");\n",
" plt.title(\"Cell: \"+cell_no)\n",
" fig.savefig(fig_DIR +'com_mech_damage_model_cell_'+cell_no+'_cap.png')"
" fig.savefig(fig_DIR +'hot_temp_tune_comp_3_cell_'+cell_no+'_cap.png')"
]
},
{
Expand Down Expand Up @@ -1693,6 +1796,40 @@
" fig.savefig(fig_DIR +'aging_sim_cell_'+cell_no+'_eSOH.png')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sno = 12\n",
"sim_des = f'cond{sno}'\n",
"# cells = [3,6,9,12,15,18]\n",
"cells = [3,6,9,12]\n",
"for cell in cells:\n",
" cell_no,dfe1,dfe_0,dfo_0,N,N_0 = load_data(cell,eSOH_DIR,oCV_DIR)\n",
" with open(res_DIR+'fast_sim_'+sim_des+\"_cell_\"+cell_no+'_sum_var.pickle', 'rb') as handle:\n",
" data1 = pickle.load(handle)\n",
" esoh_data = dfe_0\n",
" all_sumvars_dict1 = data1\n",
" esoh_vars = [\"x_100\", \"y_0\", \"C_n\", \"C_p\", \"Capacity [A.h]\", \"Loss of lithium inventory [%]\"]\n",
" titles = [r\"$x_{100}$\",r\"$y_0$\",r\"$C_n$ [A.h]\",r\"$C_p [A.h]$\", \"Capacity [A.h]\", \"LLI [%]\"]\n",
" fig, axes = plt.subplots(3,2,figsize=(7,7))\n",
" for k, name in enumerate(esoh_vars):\n",
" ax = axes.flat[k]\n",
" ax.plot(esoh_data[\"N\"],esoh_data[name],\"ko\")\n",
" ax.plot(all_sumvars_dict1[\"Cycle number\"],all_sumvars_dict1[name],\"r--\")\n",
" ax.set_title(titles[k])\n",
" # if k ==2 or k==3:\n",
" # ax.set_ylim([3,6.2])\n",
" if k>3:\n",
" ax.set_xlabel(\"Cycle number\")\n",
" fig.legend([\"Data\",\"Sim\"], \n",
" loc=\"lower center\",bbox_to_anchor=[0.5,-0.05], ncol=4, fontsize=11)\n",
" fig.tight_layout()\n",
" fig.savefig(fig_DIR +'aging_sim_cell_'+cell_no+'_eSOH_'+sim_des+'.png')"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -2422,7 +2559,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.13"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
Loading

0 comments on commit f53fc2a

Please sign in to comment.