Skip to content

Commit 6a3e17a

Browse files
committed
fixed endless SOC iteration for HEVs
1 parent 48fc4f7 commit 6a3e17a

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • fastsim-core/src/simdrive

fastsim-core/src/simdrive/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,21 @@ impl SimDrive {
154154
err
155155
))
156156
})?;
157+
// final SOC, to use as starting SOC for next iteration (if needed)
157158
let soc_final = self
158159
.veh
159160
.res()
160161
.with_context(|| format_dbg!())?
161162
.state
162163
.soc
163164
.clone();
165+
// current iteration number, to use as counter for next iteration (if needed)
166+
let soc_bal_iters = self
167+
.veh
168+
.hev()
169+
.with_context(|| format_dbg!())?
170+
.soc_bal_iters
171+
.clone();
164172
let res_per_fuel = *self
165173
.veh
166174
.res()
@@ -232,6 +240,11 @@ impl SimDrive {
232240
self.veh = veh_init.clone();
233241
// start SOC at previous final value
234242
self.veh.res_mut().with_context(|| format_dbg!())?.state.soc = soc_final;
243+
// keep soc_bal_iters value from previous iteration
244+
self.veh
245+
.hev_mut()
246+
.with_context(|| format_dbg!())?
247+
.soc_bal_iters = soc_bal_iters;
235248
}
236249
}
237250
}

0 commit comments

Comments
 (0)