Commit 49cab3a8 authored by Gerrit Erichsen's avatar Gerrit Erichsen
Browse files

wip: debugging changes

parent b3abbfea
......@@ -1089,16 +1089,28 @@ void Node::calculateStoragePower(size_t timeStep)
}
//tz - no dicharge when current Level is below target Level
if(m_preferences->createOperationPlan()
&& timeStep != 0
&& m_storage[i]->isLongTermStorage()
&& m_storage[i]->getStorageLevelAtTimeStep(timeStep - 1) < m_storage[i]->getStorageCapacity() * targetStorageLevel)
if (m_preferences->createOperationPlan()
&& timeStep != 0
&& m_storage[i]->isLongTermStorage()
&& m_storage[i]->getStorageLevelAtTimeStep(timeStep - 1)
< m_storage[i]->getStorageCapacity() * targetStorageLevel)
{
storageLoad += 0;
}
else //tz - do as before
{
//power well within range
if (currentResidual >= 0
&& timeStep > 0)
{
cout << "Should discharge with " << currentResidual
<< " at step " << timeStep
<< " in between boundaries "
<< m_storage[i]->getMinPowerDischarge(timeStep) << " MW and "
<< m_storage[i]->getMaxPowerDischarge(timeStep) << " MW with "
<< m_storage[i]->getStorageLevelAtTimeStep(timeStep - 1)
<< " MWh available." << endl;
}
if (currentResidual >= m_storage[i]->getMinPowerDischarge(timeStep)
&& currentResidual < m_storage[i]->getMaxPowerDischarge(timeStep)
&& currentResidual > 0.)
......@@ -1107,6 +1119,7 @@ void Node::calculateStoragePower(size_t timeStep)
m_storage[i]->discharge(powerOfPlant, timeStep);
storageLoad += powerOfPlant;
currentResidual = 0.;
cout << "And got it all away :D" << endl;
}
//power equal or greater than maxPower
else if (currentResidual >= m_storage[i]->getMaxPowerDischarge(timeStep)
......@@ -1118,6 +1131,7 @@ void Node::calculateStoragePower(size_t timeStep)
storageLoad += powerOfPlant;
currentResidual -= powerOfPlant;
if (isCloseEnoughToEqual(currentResidual, 0.)) currentResidual = 0.;
cout << "And covered at least " << powerOfPlant << " MW of it " << endl;
}
//power less than minPower
else if (m_storage[i]->getMaxPowerDischarge(timeStep) > 0.
......@@ -1133,13 +1147,29 @@ void Node::calculateStoragePower(size_t timeStep)
currentResidual = 0.;
}
correctFromStorage(i, timeStep, timeStep);
cout << "And covered even more with " << powerOfPlant << " MW" << endl;
}
else //power less than minimum
{
if (currentResidual >= 0
&& timeStep > 0)
{
cout << "But did nothing!" << endl;
}
storageLoad += 0.;
}
}
}
else if (currentResidual > 0.)
{
cout << "Had to cover residual, of " << currentResidual << " MW. But could not start!"
<< " at step " << timeStep
<< " in between boundaries "
<< m_storage[i]->getMinPowerDischarge(timeStep) << " MW and "
<< m_storage[i]->getMaxPowerDischarge(timeStep) << " MW with "
<< m_storage[i]->getStorageLevelAtTimeStep(timeStep - 1)
<< " MWh available." << endl;
}
}
// if no balance is reached, check if a run-through might cover it
if (false && currentResidual > 0.)
......
......@@ -205,28 +205,31 @@ void Storage::charge(double power, size_t step)
return;
}
//defining helper value, since previous step of first step is last step
double lastStorageLevel;
if (step == 0)
{
lastStorageLevel = m_initialStorageLevel;
}
else
{
lastStorageLevel = m_storageLevel[step - 1];
}
//calculating storage level for step
double lastStorageLevel = (step == 0) ? m_initialStorageLevel : m_storageLevel[step - 1];
// just a pre-caution
if (power > m_maxPowerCharge) power = m_maxPowerCharge;
// storage has enough capacity to take all
if (power * m_preferences->getStepTime() * getEfficiencyCharge(step, power)
<= m_storageCapacity - lastStorageLevel)
{
m_storageLevel[step] = lastStorageLevel
+ power * m_preferences->getStepTime() * getEfficiencyCharge(step, power);
cout << "Charged to " << m_storageLevel[step] << " wtih an efficiency of " << getEfficiencyCharge(step, power) << endl;
m_lastStepOfPower = step;
}
else if (m_storageCapacity - lastStorageLevel > 0.)
else if (m_storageCapacity - lastStorageLevel > getMinPowerCharge(step)
* m_preferences->getStepTime())
{
m_storageLevel[step] = m_storageCapacity;
power = (m_storageCapacity - lastStorageLevel) / m_preferences->getStepTime()
/ getEfficiencyCharge(step, power); //"power" for efficiency not entirely correct, though
double powerReserve = (m_storageCapacity - lastStorageLevel) / m_preferences->getStepTime();
// this **should** be solved iteratively. But to not waste time, we'll take a random
// guess at the efficiency. This should be somewhat accurate enough
power = powerReserve / getEfficiencyCharge(step,
powerReserve
/ m_efficiencyDischarge.getEfficiencyBottomRight()); //"power" for efficiency not entirely correct, though
cout << "Charged to " << m_storageLevel[step] << " wtih an efficiency of " << powerReserve / power << endl;
m_lastStepOfPower = step;
}
else
......@@ -235,7 +238,7 @@ void Storage::charge(double power, size_t step)
}
//setting values accordingly to result
m_load[step] = -power;
if (power > 0) cout << "Charged at " << step << " with " << power << "MW. Now having " << m_storageLevel[step] << "MWh in the bank" << endl;
//if (power > 0) cout << "Charged at " << step << " with " << power << "MW. Now having " << m_storageLevel[step] << "MWh in the bank" << endl;
m_fullLoadHoursCharge += power * m_preferences->getStepTime() / m_nominalPowerCharge;
}
......@@ -503,7 +506,7 @@ double Storage::getMinPowerDischargeConst() const
return m_minPowerDischarge;
}
double Storage::getMinPowerDischarge(int step)
double Storage::getMinPowerDischarge(int step) const
{
//defining helper value, since previous step of first step is last step
if (step > 0 && !isCloseEnoughToEqual(m_gradientDischarge, 0.))
......@@ -519,14 +522,24 @@ double Storage::getMinPowerDischarge(int step)
}
}
double Storage::getMaxPowerDischarge(int step) const
double Storage::getMaxPowerDischarge(size_t step) const
{
//defining helper value, since previous step of first step is last step
double lastStorageLevel = (step == 0) ? m_initialStorageLevel : m_storageLevel[step - 1];
double lastStorageLevel = (step == 0) ? m_initialStorageLevel : m_storageLevel.at(step -1);
double powerLimitFromCapacity = lastStorageLevel / m_preferences->getStepTime();
if (powerLimitFromCapacity < m_minPowerDischarge)
{
if (lastStorageLevel < 0.1 && step > 0)
{
cout << "Had zero storage level at step " << step - 1 << endl;
cout << "the last steps were " << flush;
for (size_t i = 0; i < std::min(step - 1, size_t(10)); i++)
{
cout << m_storageLevel[step - 1 - i] << " " << flush;
}
cout << endl;
}
return 0.;
}
double powerLimitFromLoad = m_maxPowerDischarge;
......@@ -722,7 +735,7 @@ int Storage::getNumberOfStepsWithSameStatusForStep(int step, bool forCharge) con
return counter;
}
double Storage::getStorageLevelAtTimeStep(int step) const
double Storage::getStorageLevelAtTimeStep(size_t step) const
{
return m_storageLevel[step];
}
......
......@@ -72,8 +72,8 @@ public:
double getMaxPowerCharge(int step) const;
double getMaxPowerChargeConst() const {return m_maxPowerCharge;} //tz - simple getter: needed for optimisationSchedule
double getMinPowerDischargeConst() const; //tz - renamed
double getMinPowerDischarge(int step); //tz
double getMaxPowerDischarge(int step) const;
double getMinPowerDischarge(int step) const; //tz
double getMaxPowerDischarge(size_t step) const;
double getMaxPowerDischargeConst() const {return m_maxPowerDischarge;} //tz - simple getter: needed for optimisationSchedule
double getEfficiencyCharge(size_t step, double power) const;
double getEfficiencyDischarge(size_t step, double power) const;
......@@ -135,7 +135,7 @@ public:
int getChargeSameStatusPreviousAtTimeStep(int step) const; //tc - determines status vector and returns the number of same statuses previuos to but including the requested time step of a plant
int getDischargeStatusAtTimeStep(int step) const; //tc - determines status vector and returns the status of a plant at a time step
int getNumberOfStepsWithSameStatusForStep(int step, bool forCharge = true) const; //tc - determines status vector and returns the number of same statuses previuos to but including the requested time step of a plant
double getStorageLevelAtTimeStep(int step) const;
double getStorageLevelAtTimeStep(size_t step) const;
double getTotalPowerFedByPlant() const;
double getTotalPowerConsumption() const;
double getTotalHeatFed() const;
......
......@@ -1066,6 +1066,7 @@ void CharLGui::runAlgorithm()
// CALCULATE ALL OPTIONS //
//////////////////////////////////////
int nMaxThreads = std::max(1, QThreadPool::globalInstance()->maxThreadCount() - 1);
nMaxThreads = 1;
int i = 0;
while (i < nTotalOptions)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment