Commit f6a34d19 authored by Gerrit Erichsen's avatar Gerrit Erichsen
Browse files

Added BiomassTableModel

parent 55035812
......@@ -17,6 +17,7 @@ CONFIG += USE_CPLEX
SOURCES += main.cpp\
CharLGui.cpp \
Models/BiomassTableModel.cpp \
Preferences.cpp \
PreferencesDialog.cpp \
Models/AbstractCharLTableModel.cpp \
......@@ -46,6 +47,7 @@ SOURCES += main.cpp\
HEADERS += CharLGui.h \
AbstractPlantTableModel.h \
Models/BiomassTableModel.h \
Preferences.h \
PreferencesDialog.h \
Models/AbstractCharLTableModel.h \
......
......@@ -218,7 +218,7 @@ bool AbstractCharLItem::load2DFile(QString fileName, EfficiencyField & field)
{
ok = false;
line = file.readLine();
if (!line.startsWith("#"))
if (!line.startsWith("#") && !line.simplified().isEmpty())
{
if (xAxis.size() == 0) //start data case
{
......@@ -278,9 +278,10 @@ bool AbstractCharLItem::load2DFile(QString fileName, EfficiencyField & field)
{
overallOk = false;
}
values.push_back(valueRow);
valueRow.clear();
}
if (valueRow.size() != xAxis.size()) overallOk = false;
values.push_back(valueRow);
valueRow.clear();
}
else
{
......@@ -290,6 +291,8 @@ bool AbstractCharLItem::load2DFile(QString fileName, EfficiencyField & field)
}
}
file.close();
if (values.size() != yAxis.size()) return false;
field.setData(xAxis, yAxis, values);
}
catch (...)
{
......
This diff is collapsed.
#ifndef BIOMASSTABLEMODEL_H
#define BIOMASSTABLEMODEL_H
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// Part of the CharL GUI
///
/// created : 01/2020
/// created by: Gerrit Erichsen
/// filled with life by: Gerrit Erichsen
/// _________________________________________________________________________________________________________
/// Change-Log:
///
/// _________________________________________________________________________________________________________
/// Description:
///
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <QtCore>
#include <QItemDelegate>
#include <QDomDocument>
#include "AbstractPlantTableModel.h"
class BiomassTableItem : public AbstractPlantTableItem
{
public:
//////////////////////////////////////////////////////////////////////////////
/// \brief Constructors and operator=
/// The main-constructor is usable as empty constructor or partially
/// loaded in the order of the table, except for the vector-parameters.
/// These are loaded from the fileName(s) given.
/// Then there is the copy-constructor which is needed for easy vector-use.
/// Additionally there is the equals operator=, which is basically the
/// copy-constructor, to allow updates and an easy use
//////////////////////////////////////////////////////////////////////////////
BiomassTableItem(QString name = "",
double gradient = 0.,
double unitSize = 0.,
double fermenterEfficiency = 0.,
QString efficiencyFile = "",
double timeHot = 0.,
double timeWarm = 0.,
double timeCold = 0.,
double minDownTime = 0.,
QString fuelType = QString(),
double fuelCost = 0.,
double investCost = 0.,
double fixedOM_Cost = 0.,
double specificOM_Cost = 0.,
double investCostStorage = 0.,
double omCostStorage = 0.,
double investCostFermenter = 0.,
double omCostFermenter = 0.,
int lifeTime = 1);
// get-Funktionen
///////////////////////////////////////////////////////////////////////////
/// \brief get-Funktionen
/// Usual access functions that return a copied value of the parameters
///////////////////////////////////////////////////////////////////////////
double getFermenterEfficiency() const {return m_fermenterEfficiency;}
double getPowerGradient() const {return m_powerGradient;}
double getTypicalUnitSize() const {return m_typicalUnitSize;}
QString getEfficiencyFile() const {return m_efficiencyFile;}
std::vector<std::pair<double, double>> getEfficiencyCurve() const;
QString getFuelType() const {return m_fuelType;}
double getStartUpTimeCold() const {return m_startUpTimeCold;}
double getStartUpTimeWarm() const {return m_startUpTimeWarm;}
double getStartUpTimeHot() const {return m_startUpTimeHot;}
double getMinDownTime() const {return m_minDownTime;} //tz
double getSpecificFuelCost() const {return m_specificFuelCost;}
double getInvestCostStorage() const {return m_specInvestCostStorage;}
double getInvestCostFermenter() const {return m_specInvestCostFermenter;}
double getOaMCostStorage() const {return m_specFixOaMCostStorage;}
double getOaMCostFermenter() const {return m_specFixOaMCostFermenter;}
// set-Funktionen
//////////////////////////////////////////////////////////////////////
/// \brief set-Funktionen
/// Used to set the subsequent parameter to a new value. For that
/// an inline implementation seemed acceptable. Exceptions from the
/// inline implementation are commented in the cpp file
//////////////////////////////////////////////////////////////////////
void setFermenterEfficiency(double eta) {m_fermenterEfficiency = eta;}
void setPowerGradient(double gradient) {m_powerGradient = gradient;}
void setTypicalUnitSize(double size) {m_typicalUnitSize = size;}
bool setEfficiencyFile(QString fileName);
void setFuelType(QString type) {if (!type.isEmpty()) m_fuelType = type;}
void setStartUpTimeCold(double timeCold) {m_startUpTimeCold = timeCold;}
void setStartUpTimeWarm(double timeWarm) {m_startUpTimeWarm = timeWarm;}
void setStartUpTimeHot(double timeHot) {m_startUpTimeHot = timeHot;}
void setMinDownTime(double downTime) {m_minDownTime = downTime;} //tz
void setSpecificFuelCost(double fuelCost) {m_specificFuelCost = fuelCost;}
void setInvestCostStorage(double investCost) {m_specInvestCostStorage = investCost;}
void setInvestCostFermenter(double investCost) {m_specInvestCostFermenter = investCost;}
void setOaMCostStorage(double fixOaM) {m_specFixOaMCostStorage = fixOaM;}
void setOaMCostFermenter(double fixOaM) {m_specFixOaMCostFermenter = fixOaM;}
private:
//technical
double m_fermenterEfficiency; // Efficiency of fermenter creating biogas in; - (W_th / W_th)
double m_powerGradient; // Maximal gradient plant can realise in %_Pn/min
double m_typicalUnitSize; // Typical power size of unit in MW
QString m_efficiencyFile; // File for efficiency curve
QVector<std::pair<double,double>> m_efficiencyCurve; // Efficiency of power block; in - (W_el / W_th) over relative grid load in -
QString m_fuelType;
//start-related
double m_startUpTimeHot; // Start up time of plant from just slightly cooled down state in h
double m_startUpTimeWarm; // Start up time of plant from cooled down but still warm state in h
double m_startUpTimeCold; // Start up time of plant from cooled down state in h
double m_minDownTime; // tz - Minimum downtime after shutdown in h
//economical
double m_specificFuelCost; // Specific cost of fuel in €/MWh_th; currently used to determine which plant covers residual load first
double m_specInvestCostStorage;
double m_specInvestCostFermenter;
double m_specFixOaMCostStorage;
double m_specFixOaMCostFermenter;
};
class BiomassTableModel : public AbstractPlantTableModel
{
Q_OBJECT
public:
BiomassTableModel(QObject * parent = nullptr);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
virtual QVariant data(const QModelIndex &index, int role) const override;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override;
virtual void addItem(const AbstractCharLItem & item) override;
virtual bool addItem(const QStringList & entries) override;
virtual void addItem(const BiomassTableItem & item);
virtual bool removeItem(const QModelIndex &index) override;
virtual const AbstractCharLItem * getItem(int row) const override;
virtual void clearData() override;
private:
QVector<BiomassTableItem> m_data;
};
#endif // BIOMASSTABLEMODEL_H
......@@ -68,12 +68,11 @@ bool ConventionalTableItem::setEfficiencyFile(QString fileName)
{
if (fileName != "")
{
m_efficiencyFile = fileName;
if (loadFile(m_efficiencyFile, m_efficiencyCurve))
if (loadFile(fileName, m_efficiencyCurve))
{
m_efficiencyFile = fileName;
return true;
}
m_efficiencyFile = "";
}
else
{
......@@ -404,7 +403,7 @@ bool ConventionalTableModel::setData(const QModelIndex &index, const QVariant &v
{
if (m_displayEconomics)
{
m_data[index.row()].setSpecificFuelCost(newValue);
m_data[index.row()].setSpecInvestCost(newValue);
}
else
{
......@@ -419,7 +418,7 @@ bool ConventionalTableModel::setData(const QModelIndex &index, const QVariant &v
{
if (m_displayEconomics)
{
m_data[index.row()].setSpecInvestCost(newValue);
m_data[index.row()].setSpecFixOaMCost(newValue);
}
else
{
......@@ -434,7 +433,7 @@ bool ConventionalTableModel::setData(const QModelIndex &index, const QVariant &v
{
if (m_displayEconomics)
{
m_data[index.row()].setSpecFixOaMCost(newValue);
m_data[index.row()].setSpecVarOaMCost(newValue);
}
else
{
......@@ -449,7 +448,7 @@ bool ConventionalTableModel::setData(const QModelIndex &index, const QVariant &v
newValue = value.toString().replace(",", ".").toDouble(&ok);
if (ok)
{
m_data[index.row()].setSpecVarOaMCost(newValue);
m_data[index.row()].setHotStartCost(newValue);
}
}
else if (!m_data[index.row()].setEfficiencyFile(value.toString()))
......@@ -464,7 +463,7 @@ bool ConventionalTableModel::setData(const QModelIndex &index, const QVariant &v
{
if (m_displayEconomics)
{
m_data[index.row()].setHotStartCost(newValue);
m_data[index.row()].setWarmStartCost(newValue);
}
else
{
......@@ -479,7 +478,7 @@ bool ConventionalTableModel::setData(const QModelIndex &index, const QVariant &v
{
if (m_displayEconomics)
{
m_data[index.row()].setWarmStartCost(newValue);
m_data[index.row()].setColdStartCost(newValue);
}
else
{
......@@ -514,7 +513,7 @@ bool ConventionalTableModel::setData(const QModelIndex &index, const QVariant &v
newValue = value.toString().replace(",", ".").toDouble(&ok);
if (ok)
{
m_data[index.row()].setColdStartCost(newValue);
m_data[index.row()].setMinDownTime(newValue);
emit dataChanged(index, index);
}
break;
......
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