Skip to content

Commit

Permalink
Fix SOC sign error (#1303)
Browse files Browse the repository at this point in the history
* fix sign error

* Undo double negative, add sanity tests

* run black

---------

(cherry picked from commit 021fb14)
  • Loading branch information
dallan-keylogic authored and lbianchi-lbl committed Dec 14, 2023
1 parent 654ac71 commit ce7f71a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def mass_transfer_coeff(b, t, iz, i):
@self.Constraint(tset, iznodes, comps)
def material_flux_x0_eqn(b, t, iz, i):
return (
-b.material_flux_x0[t, iz, i] / b.mass_transfer_coeff[t, iz, i]
b.material_flux_x0[t, iz, i] / b.mass_transfer_coeff[t, iz, i]
== b.conc_mol_comp_deviation_x0[t, iz, i]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,43 @@ def test_initialization_cell_voltage_drop_custom(model_vdc):
assert approx(0.3094487) == pyo.value(cell.oxygen_outlet.mole_frac_comp[0, "O2"])
assert approx(0.690551) == pyo.value(cell.oxygen_outlet.mole_frac_comp[0, "N2"])

for iz in cell.iznodes:
# H2O is consumed at fuel electrode, concentration at electrode surface
# should be less than that in channel, and concentration at TPB should
# be less than that at the surface
assert pyo.value(cell.fuel_channel.conc_mol_comp_deviation_x1[0, iz, "H2O"]) < 0
assert (
pyo.value(
cell.fuel_electrode.conc_mol_comp_deviation_x1[0, iz, "H2O"]
- cell.fuel_channel.conc_mol_comp_deviation_x1[0, iz, "H2O"]
)
< 0
)
# H2 is produced at fuel electrode, concentration at electrode surface
# should be greater than that in channel, and concentration at TPB should
# be greater than that at the surface
assert pyo.value(cell.fuel_channel.conc_mol_comp_deviation_x1[0, iz, "H2"]) > 0
assert (
pyo.value(
cell.fuel_electrode.conc_mol_comp_deviation_x1[0, iz, "H2"]
- cell.fuel_channel.conc_mol_comp_deviation_x1[0, iz, "H2"]
)
> 0
)
# O2 is produced at oxygen electrode, concentration at electrode surface
# should be greater than that in channel, and concentration at TPB should
# be greater than that at the surface
assert (
pyo.value(cell.oxygen_channel.conc_mol_comp_deviation_x0[0, iz, "O2"]) > 0
)
assert (
pyo.value(
cell.oxygen_electrode.conc_mol_comp_deviation_x0[0, iz, "O2"]
- cell.oxygen_channel.conc_mol_comp_deviation_x0[0, iz, "O2"]
)
> 0
)

# Test whether unfixed degrees of freedom remain unfixed
cell.potential.unfix()
cell.fuel_inlet.temperature[0].unfix()
Expand Down Expand Up @@ -790,5 +827,5 @@ def test_model_replication_voltage_drop_custom(model_vdc):
m = model_func()
out = kazempoor_braun_replication(m)
# Uncomment to recreate cached data
# for i, df in enumerate(out):
# df.to_csv(os.sep.join([data_cache, f"case_{i+1}_interconnect.csv"]))
for i, df in enumerate(out):
df.to_csv(os.sep.join([data_cache, f"case_{i+1}_interconnect.csv"]))

0 comments on commit ce7f71a

Please sign in to comment.