Skip to content

Commit

Permalink
Planner: update target charge factors for greater 80% (evcc-io#7411)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofyyy authored Apr 14, 2023
1 parent 1d91657 commit 4408343
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions core/loadpoint_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/core/planner"
"github.com/evcc-io/evcc/core/soc"
"golang.org/x/exp/slices"
)

Expand All @@ -25,38 +24,37 @@ func (lp *Loadpoint) setPlanActive(active bool) {

// planRequiredDuration is the estimated total charging duration
func (lp *Loadpoint) planRequiredDuration(maxPower float64) time.Duration {
var requiredDuration time.Duration

if energy, ok := lp.remainingChargeEnergy(); ok {
requiredDuration = time.Duration(energy * 1e3 / maxPower * float64(time.Hour))
} else if lp.socEstimator != nil {
// TODO vehicle soc limit
targetSoc := lp.Soc.target
if targetSoc == 0 {
targetSoc = 100
}
return time.Duration(energy * 1e3 / maxPower * float64(time.Hour))
}

requiredDuration = lp.socEstimator.RemainingChargeDuration(targetSoc, maxPower)
if requiredDuration <= 0 {
return 0
}
if lp.socEstimator == nil {
return 0
}

// anticipate lower charge rates at end of charging curve
var additionalDuration time.Duration
// TODO vehicle soc limit
targetSoc := lp.Soc.target
if targetSoc == 0 {
targetSoc = 100
}

if targetSoc > 80 && maxPower > 15000 {
additionalDuration = 5 * time.Duration(float64(targetSoc-80)/(float64(targetSoc)-lp.vehicleSoc)*float64(requiredDuration))
lp.log.DEBUG.Printf("add additional charging time %v for soc > 80%%", additionalDuration.Round(time.Minute))
} else if targetSoc > 90 && maxPower > 4000 {
additionalDuration = 3 * time.Duration(float64(targetSoc-90)/(float64(targetSoc)-lp.vehicleSoc)*float64(requiredDuration))
lp.log.DEBUG.Printf("add additional charging time %v for soc > 90%%", additionalDuration.Round(time.Minute))
}
requiredDuration := lp.socEstimator.RemainingChargeDuration(targetSoc, maxPower)
if requiredDuration <= 0 {
return 0
}

// anticipate lower charge rates at end of charging curve
var additionalDuration time.Duration

requiredDuration += additionalDuration
if targetSoc > 80 && maxPower > 15000 {
additionalDuration = time.Duration(float64(targetSoc-80) / (float64(targetSoc) - lp.vehicleSoc) * float64(requiredDuration))
lp.log.DEBUG.Printf("add additional charging time %v for soc > 80%%", additionalDuration.Round(time.Minute))
} else if targetSoc > 90 && maxPower > 4000 {
additionalDuration = time.Duration(float64(targetSoc-90) / (float64(targetSoc) - lp.vehicleSoc) * float64(requiredDuration))
lp.log.DEBUG.Printf("add additional charging time %v for soc > 90%%", additionalDuration.Round(time.Minute))
}
requiredDuration = time.Duration(float64(requiredDuration) / soc.ChargeEfficiency)

return requiredDuration
return requiredDuration + additionalDuration
}

func (lp *Loadpoint) GetPlannerUnit() string {
Expand Down

0 comments on commit 4408343

Please sign in to comment.