Example #1
0
func createStaticPower(dynamicPower *dynamic.Power, schedule *time.Schedule,
	config *config.StaticPower) (*static.Power, error) {

	if config.Contribution < 0.0 || config.Contribution >= 1.0 {
		return nil, errors.New("the contribution of the static power is invalid")
	}

	nominal := config.Contribution / (1.0 - config.Contribution) *
		support.Average(dynamicPower.Distribute(schedule))

	if nominal == 0.0 || len(config.Temperature) == 0 || len(config.Coefficient) == 0 {
		log.Printf("The static-power model is disabled.")
		config.Temperature = []float64{0.0, 1.0}
		config.Coefficient = []float64{0.0, 0.0}
	}

	return static.New(nominal, config.Temperature, config.Coefficient), nil
}
Example #2
0
func computeDynamicPower(dynamicPower *dynamic.Power,
	schedule *time.Schedule, Δt float64) []float64 {

	return dynamicPower.Sample(schedule, Δt, uint(schedule.Span/Δt))
}