Class SimpsonRuleCumulativeEnergyCalculator
- java.lang.Object
-
- de.fzi.power.interpreter.calculators.energy.AbstractCumulativeEnergyCalculator
-
- de.fzi.power.interpreter.calculators.energy.SimpsonRuleCumulativeEnergyCalculator
-
public class SimpsonRuleCumulativeEnergyCalculator extends AbstractCumulativeEnergyCalculator
This class contains an implementation of Simpson's rule for numerical integration given a series of sampling points and a sampling rate (more precisely, the temporal difference between two consecutive sampling points).
This implementation is tailored to calculating cumulative energy consumption based on power consumption samples. For details about Simpson's rule, cf.calculateNextInternal()
.- See Also:
AbstractCumulativeEnergyCalculator
-
-
Constructor Summary
Constructors Constructor Description SimpsonRuleCumulativeEnergyCalculator()
Initializes a new instance of theSimpsonRuleCumulativeEnergyCalculator
class.SimpsonRuleCumulativeEnergyCalculator(javax.measure.Measurable<javax.measure.quantity.Duration> samplingPeriod, javax.measure.Measurable<javax.measure.quantity.Duration> initialOffset)
Initializes a new instance of theSimpsonRuleCumulativeEnergyCalculator
class with given sampling period and initial offset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.jscience.physics.amount.Amount<javax.measure.quantity.Energy>
calculateInitValue(int initValueIndex)
Method to be implemented by subclasses which contains the initialization steps.protected org.jscience.physics.amount.Amount<javax.measure.quantity.Energy>
calculateNextInternal()
Calculates the next energy sample, i.e., does the next integration step using Simpson's rule.
That is, for all energy samplesy[i]
it holds:
y[i] = y[i-2] + weighting * (x[i] + 4 * x[i-1] + x[i-2])
wherex[i], x[i-1], x[i-2]
are the most recent power samples
andweighting = samplingPeriod / 3
.void
setSamplingPeriod(javax.measure.Measurable<javax.measure.quantity.Duration> samplingPeriod)
Sets the sampling period, i.e., the temporal difference between the next consecutive power samples.-
Methods inherited from class de.fzi.power.interpreter.calculators.energy.AbstractCumulativeEnergyCalculator
calculateNext, getCurrentlyStoredEnergySamplesCount, getCurrentlyStoredPowerSamplesCount, getDefaultResultUnit, getEnergySample, getInitialOffset, getMostRecentEnergySample, getMostRecentPowerSample, getOldestEnergySample, getOldestPowerSample, getPowerSample, getResultUnit, getSamplingPeriod, reset, setOffset
-
-
-
-
Constructor Detail
-
SimpsonRuleCumulativeEnergyCalculator
public SimpsonRuleCumulativeEnergyCalculator()
Initializes a new instance of theSimpsonRuleCumulativeEnergyCalculator
class.
-
SimpsonRuleCumulativeEnergyCalculator
public SimpsonRuleCumulativeEnergyCalculator(javax.measure.Measurable<javax.measure.quantity.Duration> samplingPeriod, javax.measure.Measurable<javax.measure.quantity.Duration> initialOffset)
Initializes a new instance of theSimpsonRuleCumulativeEnergyCalculator
class with given sampling period and initial offset.- Parameters:
samplingPeriod
- AMeasurable
denoting the sampling period, i.e., the temporal difference between two consecutive power samples.initialOffset
- AMeasurable
denoting the temporal offset of the first power sample, i.e., the point in time it was taken.- Throws:
IllegalArgumentException
- AnIllegalArgumentException
is thrown in one of the following cases:samplingPeriod
isnull
or does not represent a positive durationinitialOffset
isnull
or represents a negative duration
- See Also:
SimpsonRuleCumulativeEnergyCalculator()
,AbstractCumulativeEnergyCalculator.getDefaultResultUnit()
,AbstractCumulativeEnergyCalculator.setOffset(Measurable)
,setSamplingPeriod(Measurable)
,AbstractCumulativeEnergyCalculator.getResultUnit()
-
-
Method Detail
-
setSamplingPeriod
public void setSamplingPeriod(javax.measure.Measurable<javax.measure.quantity.Duration> samplingPeriod)
Description copied from class:AbstractCumulativeEnergyCalculator
Sets the sampling period, i.e., the temporal difference between the next consecutive power samples. This might be useful if the sampling points are not equidistant.- Overrides:
setSamplingPeriod
in classAbstractCumulativeEnergyCalculator
- Parameters:
samplingPeriod
- AMeasurable
denoting the sampling period, i.e., the temporal difference between two consecutive power samples.
-
calculateNextInternal
protected org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> calculateNextInternal()
Calculates the next energy sample, i.e., does the next integration step using Simpson's rule.
That is, for all energy samplesy[i]
it holds:
y[i] = y[i-2] + weighting * (x[i] + 4 * x[i-1] + x[i-2])
wherex[i], x[i-1], x[i-2]
are the most recent power samples
andweighting = samplingPeriod / 3
.- Specified by:
calculateNextInternal
in classAbstractCumulativeEnergyCalculator
- Returns:
- An
Amount
denoting the calculated energy sampley[i]
.
-
calculateInitValue
protected org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> calculateInitValue(int initValueIndex)
Description copied from class:AbstractCumulativeEnergyCalculator
Method to be implemented by subclasses which contains the initialization steps.- Specified by:
calculateInitValue
in classAbstractCumulativeEnergyCalculator
- Parameters:
initValueIndex
- The number of the init step.- Returns:
- The energy sample calculated by the init step.
-
-