Commit cb15ba8a authored by Jan Dinkelbach's avatar Jan Dinkelbach
Browse files

improve logging of inverter variables

parent 18be3600
......@@ -124,8 +124,6 @@ int main(int argc, char* argv[]) {
Examples::CIGREMV::logPVAttributes(loggerDP, pv);
loggerDP->addAttribute("pv_pll_output", pv->attribute("pll_output"));
// load step sized in absolute terms
std::shared_ptr<SwitchEvent> loadStepEvent = Examples::createEventAddPowerConsumption("n2", 1-timeStepDP, 100.0e3, systemDP, Domain::DP, loggerDP);
......
......@@ -157,24 +157,26 @@ namespace CIGREMV {
}
void logPVAttributes(DPsim::DataLogger::Ptr logger, CPS::TopologicalPowerComp::Ptr pv) {
// state variables
logger->addAttribute(pv->name() + "_state_" + "p", pv->attribute("p"));
logger->addAttribute(pv->name() + "_state_" + "q", pv->attribute("q"));
logger->addAttribute(pv->name() + "_state_" + "phid", pv->attribute("phid"));
logger->addAttribute(pv->name() + "_state_" + "phiq", pv->attribute("phiq"));
logger->addAttribute(pv->name() + "_state_" + "gammad", pv->attribute("gammad"));
logger->addAttribute(pv->name() + "_state_" + "gammaq", pv->attribute("gammaq"));
// input variables
logger->addAttribute(pv->name() + "_input_" + "Vcdq", pv->attribute("Vcdq"));
logger->addAttribute(pv->name() + "_input_" + "Ircdq", pv->attribute("Ircdq"));
// output variables
logger->addAttribute(pv->name() + "_output_" + "Vsdq", pv->attribute("Vsdq"));
// power controller
std::vector<String> inputNames = { pv->name() + "_powerctrl_input_pref", pv->name() + "_powerctrl_input_qref",
pv->name() + "_powerctrl_input_vcd", pv->name() + "_powerctrl_input_vcq",
pv->name() + "_powerctrl_input_ircd", pv->name() + "_powerctrl_input_ircq"};
logger->addAttribute(inputNames, pv->attribute("powerctrl_inputs"));
std::vector<String> stateNames = { pv->name() + "_powerctrl_state_p", pv->name() + "_powerctrl_state_q",
pv->name() + "_powerctrl_state_phid", pv->name() + "_powerctrl_state_phiq",
pv->name() + "_powerctrl_state_gammad", pv->name() + "_powerctrl_state_gammaq"};
logger->addAttribute(stateNames, pv->attribute("powerctrl_states"));
std::vector<String> outputNames = { pv->name() + "_powerctrl_output_vsd", pv->name() + "_powerctrl_output_vsq"};
logger->addAttribute(outputNames, pv->attribute("powerctrl_outputs"));
// interface variables
logger->addAttribute(pv->name() + "_v_intf", pv->attribute("v_intf"));
logger->addAttribute(pv->name() + "_i_intf", pv->attribute("i_intf"));
// additional variables
logger->addAttribute(pv->name() + "_pll_output", pv->attribute("pll_output"));
logger->addAttribute(pv->name() + "_vsref", pv->attribute("Vsref"));
}
}
......
......@@ -64,6 +64,8 @@ namespace DPsim {
void addAttribute(const String &name, CPS::MatrixRealAttribute::Ptr attr);
void addAttribute(const String &name, CPS::MatrixCompAttribute::Ptr attr, UInt rowsMax = 0, UInt colsMax = 0);
void addAttribute(const String &name, const String &attr, CPS::IdentifiedObject::Ptr obj);
void addAttribute(const std::vector<String> &name, CPS::AttributeBase::Ptr attr);
void addAttribute(const std::vector<String> &name, CPS::MatrixRealAttribute::Ptr attr);
template<typename VarType>
void addNode(typename CPS::SimNode<VarType>::Ptr node) {
......
......@@ -171,6 +171,29 @@ void DataLogger::addAttribute(const String &name, CPS::Attribute<Complex>::Ptr a
mAttributes[name + ".im"] = attrComp->imag();
}
void DataLogger::addAttribute(const std::vector<String> &name, CPS::MatrixRealAttribute::Ptr attr) {
const Matrix &m = attr->get();
auto attrMat = std::static_pointer_cast<CPS::MatrixRealAttribute>(attr);
if (m.rows() == 1 && m.cols() == 1) {
addAttribute(name[0], attrMat->coeff(0, 0));
}
else if (m.cols() == 1) {
for (UInt k = 0; k < m.rows(); k++) {
addAttribute(name[k],
attrMat->coeff(k, 0));
}
}
else {
for (UInt k = 0; k < m.rows(); k++) {
for (UInt l = 0; l < m.cols(); l++) {
addAttribute(name[k*m.cols()+l],
attrMat->coeff(k, l));
}
}
}
}
void DataLogger::addAttribute(const String &name, CPS::MatrixRealAttribute::Ptr attr) {
const Matrix &m = attr->get();
auto attrMat = std::static_pointer_cast<CPS::MatrixRealAttribute>(attr);
......@@ -224,6 +247,15 @@ void DataLogger::addAttribute(const String &name, CPS::MatrixCompAttribute::Ptr
}
}
void DataLogger::addAttribute(const std::vector<String> &name, CPS::AttributeBase::Ptr attr) {
auto realMatAttr = std::dynamic_pointer_cast<CPS::Attribute<MatrixVar<Real>>>(attr);
if (realMatAttr) {
auto realMatAttrCast = std::static_pointer_cast<CPS::MatrixRealAttribute>(attr);
addAttribute(name, realMatAttrCast);
return;
}
}
void DataLogger::addAttribute(const String &name, CPS::AttributeBase::Ptr attr) {
auto intAttr = std::dynamic_pointer_cast<CPS::Attribute<Int>>(attr);
if (intAttr) {
......
Supports Markdown
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