Skip to content

Commit

Permalink
confidence in results regained
Browse files Browse the repository at this point in the history
  • Loading branch information
mleot committed Mar 26, 2024
1 parent 96b37a3 commit 99604f4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
23 changes: 15 additions & 8 deletions ecm/__funcs__.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def setup_geometry(net, dtheta, spacing, length_3d):
rPs = geo["pore.arc_index"][net["throat.conns"]]
sameR = rPs[:, 0] == rPs[:, 1]
geo["throat.area"] = spacing * length_3d
geo['throat.xarea'] = length_3d * geo['throat.radial_position'] * drad
geo["throat.electrode_height"] = geo["throat.radial_position"] * drad
geo["throat.area"][sameR] = geo["throat.electrode_height"][sameR] * length_3d
geo["throat.volume"] = 0.0
Expand Down Expand Up @@ -235,7 +236,7 @@ def apply_heat_source(project, Q):
phys = project.physics()["phys_01"]
spm_Ts = net.throats("spm_resistor")
phys["throat.heat_source"] = 0.0
phys["throat.heat_source"][spm_Ts] = Q
phys["throat.heat_source"][spm_Ts] = Q * 2
phys.add_model(
propname="pore.heat_source",
model=op.models.misc.from_neighbor_throats,
Expand All @@ -248,7 +249,7 @@ def apply_heat_source_lp(project, Q):
# The SPMs are defined at the throat but the pores represent the
# Actual electrode volume so need to interpolate for heat sources
phys = project.physics()["phys_01"]
phys["throat.heat_source"] = Q * 2
phys["throat.heat_source"] = Q
phys.add_model(
propname="pore.heat_source",
model=op.models.misc.from_neighbor_throats,
Expand All @@ -268,7 +269,7 @@ def run_step_transient(project, time_step, BC_value, cp, rho, third=False, **kwa
phase = project.phases()["phase_01"]
phys = project.physics()["phys_01"]
phys["pore.A1"] = 0.0
Q_spm = phys["pore.heat_source"] * net["pore.volume"] * len(net['pore.volume'])
Q_spm = phys["pore.heat_source"] #* net["pore.volume"] #* len(net['pore.volume'])
# print(Q_spm.max(), Q_spm.min())
# print('total W heat produced',Q_spm.sum())
# print('total pore volume', net["pore.volume"].sum())
Expand All @@ -287,6 +288,7 @@ def run_step_transient(project, time_step, BC_value, cp, rho, third=False, **kwa
phys["pore.A2"] = (Q_spm) / (cp * rho)
# Heat Source
T0 = phase["pore.temperature"]
print(T0.max(), T0.min())
t_step = float(time_step / kwargs['t_slice'])
phys.add_model(
"pore.source",
Expand All @@ -301,15 +303,17 @@ def run_step_transient(project, time_step, BC_value, cp, rho, third=False, **kwa
phase=phase,
conductance="throat.conductance",
quantity="pore.temperature",
pore_volume="pore.volume",
t_initial=0.0,
t_final=time_step,
t_step=t_step,
t_output=t_step,
t_output=time_step,
t_tolerance=1e-9,
t_precision=kwargs['t_precision'],
rxn_tolerance=1e-9,
t_scheme="implicit",
)
print(phase['throat.conductance'].max(),phase['throat.conductance'].min())
alg.set_IC(values=T0)
bulk_Ps = net.pores("free_stream", mode="not")
alg.set_source("pore.source", bulk_Ps)
Expand All @@ -321,6 +325,9 @@ def run_step_transient(project, time_step, BC_value, cp, rho, third=False, **kwa
Ps = net.pores("free_stream")
alg.set_value_BC(Ps, values=BC_value)
alg.run()

# plt.plot(alg["pore.temperature"])
# plt.show()
# print(
# "Max Temp",
# np.around(alg["pore.temperature"].max(), 3),
Expand Down Expand Up @@ -560,10 +567,10 @@ def lump_thermal_props(param):
for j, l in enumerate(layers):
all_props[i][j] = param[l + " " + prop]
# Break them up
lens = all_props[:, 0]
rhos = all_props[:, 1]
Cps = all_props[:, 2]
ks = all_props[:, 3]
lens = all_props[0,:]
rhos = all_props[1,:]
Cps = all_props[2,:]
ks = all_props[3,:]
# Lumped props
rho_lump = np.sum(lens * rhos) / np.sum(lens)
Cp_lump = np.sum(lens * rhos * Cps) / np.sum(lens * rhos)
Expand Down
8 changes: 5 additions & 3 deletions ecm/__liionsolve__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def run_simulation_lp(parameter_values, experiment, initial_soc, project, **kwar
# print("Total Electrode Height", np.around(np.sum(electrode_heights), 2), "m")
# Take I_app from first command of the experiment
proto = lp.generate_protocol_from_experiment(experiment)

I_app = proto[0]
I_typical = I_app / Nspm

Expand Down Expand Up @@ -116,7 +117,8 @@ def run_simulation_lp(parameter_values, experiment, initial_soc, project, **kwar
###########################################################################
# New Liionpack code #
###########################################################################
dim_time_step = 10
dim_time_step = experiment.period
print(dim_time_step)
neg_econd, pos_econd = ecm.cc_cond(project, parameter_values)
Rs = 1e-2 # series resistance
Ri = 90 # initial guess for internal resistance
Expand Down Expand Up @@ -154,7 +156,7 @@ def run_simulation_lp(parameter_values, experiment, initial_soc, project, **kwar
setup_only=True,
)
# Qvar = "Volume-averaged total heating [W.m-3]"
Qvar = "X-averaged total heating [W.m-3]"
Qvar = "Total heating [W]"
Qid = np.argwhere(np.asarray(manager.variable_names) == Qvar).flatten()[0]
lp.logger.notice("Starting initial step solve")
vlims_ok = True
Expand Down Expand Up @@ -224,7 +226,7 @@ def run_simulation_lp(parameter_values, experiment, initial_soc, project, **kwar
setup_only=True,
)
# Qvar = "Volume-averaged total heating [W.m-3]"
Qvar = "X-averaged total heating [W.m-3]"
Qvar = "Total heating [W]"
Qid = np.argwhere(np.asarray(manager.variable_names) == Qvar).flatten()[0]
lp.logger.notice("Starting step solve")
vlims_ok = True
Expand Down
2 changes: 1 addition & 1 deletion ecm/autofit_jellyroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def get_spiral_params(parameter_values, form_factor='18650', positive_tab=None,
else:
raise ValueError("form_factor must be '18650', '21700' or 'pouch'")

# parameter_values.update({'Electrode height [m]': length3d})
parameter_values.update({'Electrode height [m]': length_3d})

Nlayers, L = calculate_spiral(inner_diameter, outer_diameter, spacing)

Expand Down

0 comments on commit 99604f4

Please sign in to comment.