Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- src/core/applications/conductorbundle.cpp
- +++ src/core/applications/conductorbundle.cpp
- @@ -53,7 +53,7 @@ void ConductorBundle::load(QSettings *settings)
- {
- Application::load(settings);
- - int documentIndex = settings->value("conductorSelectionDocumentId", -1).toInt();
- + int documentIndex = settings->value("meteorologicalDataDocumentId", -1).toInt();
- auto conn = std::make_shared<QMetaObject::Connection>();
- *conn = m_project->connect(m_project, &Project::projectLoad, [this, documentIndex, conn]() {
- m_project->disconnect(*conn);
- @@ -71,7 +71,6 @@ bool ConductorBundle::calculate(QString& error)
- {
- Application::calculate(error);
- -
- ElectricField *electricField = (ElectricField*)m_project->getApplication(Application::App_ElectricField);
- if(!electricField->calculate(error))
- return false;
- @@ -90,6 +89,11 @@ bool ConductorBundle::calculate(QString& error)
- }
- }
- + if(m_meteorologicalDataDocument.expired()) {
- + error += tr("The 'Meteorological data' was not found.");
- + return false;
- + }
- +
- return true;
- }
- --- src/core/applications/conductorbundle.h
- +++ src/core/applications/conductorbundle.h
- @@ -15,9 +15,9 @@ public:
- bool calculate(QString& error);
- - void setConductorSelectionDocument(const DocumentPtr& document) { m_meteorologicalDataDocument = document; }
- + void setMeteorologicalDataDocument(const DocumentPtr& document) { m_meteorologicalDataDocument = document; }
- - DocumentPtr getConductorSelectionDocument() { return m_meteorologicalDataDocument.lock(); }
- + DocumentPtr getMeteorologicalDataDocument() { return m_meteorologicalDataDocument.lock(); }
- private:
- DocumentWeakPtr m_meteorologicalDataDocument;
- --- src/core/applications/substationparameters.cpp
- +++ src/core/applications/substationparameters.cpp
- @@ -3,6 +3,7 @@
- #include <core/project.h>
- #include <core/substation.h>
- #include <core/transmissionline.h>
- +#include <core/groundingsystem.h>
- #include <core/section.h>
- #include <core/tower.h>
- #include <iostream>
- @@ -61,6 +62,7 @@ bool SubstationParameters::calculate(QString& error)
- ElectricParameters *el = (ElectricParameters*)m_project->getApplication(Application::App_ElectricParameters);
- // Calculate shield wires equivalent impedance for every configuration
- +
- for(TransmissionLinePtr tl : m_project->getTransmissionLines()) {
- for(Section *section : tl->getSections())
- el->calculateLongitudinalParameters(section);
- @@ -85,6 +87,7 @@ bool SubstationParameters::calculate(QString& error)
- if(substation->isIgnored())
- continue;
- + std::complex<double> zeq = std::numeric_limits<double>::infinity();
- for(TransmissionLinePtr tl : substation->getTransmissionLines()) {
- bool reverse = tl->getFirstSubstation() == substation;
- @@ -119,6 +122,81 @@ bool SubstationParameters::calculate(QString& error)
- tl->m_equivalentGroundImpedanceFirstSubstation = eqImpedance;
- else
- tl->m_equivalentGroundImpedanceLastSubstation = eqImpedance;
- +
- + zeq = math::parallelImpedance(zeq, eqImpedance);
- + }
- + qDebug() << "real:" << zeq.real() << "img:" << zeq.imag();
- + }
- +
- + //gs
- + for(GroundingSystemPtr gs : m_project->getGroundingSystems()) {
- + if(gs->isIgnored())
- + continue;
- +
- + int i, j;
- + if(gs->canMergeConductors(i, j))
- + m_project->onError(tr("Conductors %1 and %2 can be merged.\nA calculation error might happen if they are overlapping each other.\nIt's recommended to press 'Join' button on data input.").arg(i).arg(j));
- +
- + bool hasResistance = false;
- + for(int i = 0; i < 10; ++i) { // 10 tries to calculate resistance
- + try {
- + hasResistance = gs->calculateResistance(error);
- + break;
- + }
- + catch(std::bad_alloc&) {
- + double length = gs->getSegmentMaximumLength() * 2;
- + m_project->onError(tr("Out of memory. New maximum segment length is %1.").arg(length));
- + gs->setSegmentMaximumLength(QString::number(length));
- + }
- + }
- +
- + if(!hasResistance)
- + return false;
- +
- + //Im = Zeq*ICC/(Rm + Zeq)
- + //gs->setInjectedCurrent(im);
- +
- + for(const Vector3Dd& point : gs->getSurfaceVoltagePoints())
- + gs->getSurfaceVoltage(point);
- +
- + double meshVoltage = gs->getResistance() * gs->getInjectedCurrent();
- +
- + for(SurfaceVoltageProfile<Vector3Dd>& profile : gs->getSurfaceVoltageProfiles()) {
- + Vector3Dd dir = (profile.pf - profile.pi).normalized();
- +
- + profile.maxTouchVoltage = 0;
- + profile.maxStepVoltage = 0;
- +
- + double x0 = 0;
- + double x1 = profile.pi.distanceTo(profile.pf);
- + for(double x = x0; x <= x1; x += profile.precision) {
- + Vector3Dd point = profile.pi + dir * x;
- + double v = gs->getSurfaceVoltage(point);
- +
- + double touchVoltage = std::abs(meshVoltage - v);
- + if(touchVoltage > profile.maxTouchVoltage) {
- + profile.maxTouchVoltage = touchVoltage;
- + profile.maxTouchVoltagePos = point;
- + }
- + }
- +
- + double stepSize = 1; // m
- + x0 = -profile.stepSearchMargin;
- + x1 = profile.pi.distanceTo(profile.pf) + profile.stepSearchMargin;
- + for(double x = x0; x <= x1 - stepSize; x += profile.precision) {
- + Vector3Dd point = profile.pi + dir * x;
- + Vector3Dd pointStep = profile.pi + dir * (x + stepSize);
- +
- + double v = gs->getSurfaceVoltage(point);
- + double vStep = gs->getSurfaceVoltage(pointStep);
- +
- + double stepVoltage = std::abs(vStep - v);
- + if(stepVoltage > profile.maxStepVoltage) {
- + profile.maxStepVoltage = stepVoltage;
- + profile.maxStepVoltagePos1 = point;
- + profile.maxStepVoltagePos2 = pointStep;
- + }
- + }
- }
- }
- return true;
- --- src/views/reportoptionsview.cpp
- +++ src/views/reportoptionsview.cpp
- @@ -26,6 +26,7 @@
- #include <QCheckBox>
- #include <QComboBox>
- #include <QPushButton>
- +#include <QDebug>
- ReportOptionsView::ReportOptionsView(QWidget *parent) :
- QScrollArea(parent)
- @@ -140,6 +141,8 @@ void ReportOptionsView::updateFromProject()
- iterator.value()->setChecked(groundingSystem->isIgnored());
- }
- + bool displayInputsChecked = g_project->getDisplayInput();
- + bool displayTlChecked = g_project->getDisplayTransmissionLines();
- m_displayInput->setChecked(g_project->getDisplayInput());
- m_displayGroundingSystems->setChecked(g_project->getDisplayGroundingSystems());
- m_displayPipelines->setChecked(g_project->getDisplayPipelines());
- @@ -148,6 +151,13 @@ void ReportOptionsView::updateFromProject()
- m_displayCircuits->setChecked(g_project->getDisplayCircuits());
- m_displayShieldWires->setChecked(g_project->getDisplayShieldWires());
- + m_displayGroundingSystems->setEnabled(displayInputsChecked);
- + m_displayPipelines->setEnabled(displayInputsChecked);
- + m_displaySubstations->setEnabled(displayInputsChecked);
- + m_displayTransmissionLines->setEnabled(displayInputsChecked);
- + m_displayCircuits->setEnabled(displayInputsChecked && displayTlChecked);
- + m_displayShieldWires->setEnabled(displayInputsChecked && displayTlChecked);
- +
- Application::ApplicationName app = g_project->getApplicationName();
- if(app == Application::App_AtmosphericDischarges) {
- AtmosphericDischarges *atmosphericDischarges = (AtmosphericDischarges*)g_project->getApplication(Application::App_AtmosphericDischarges);
- @@ -236,6 +246,8 @@ void ReportOptionsView::updateFromProject()
- ElectricMagneticFields *emf = (ElectricMagneticFields*)g_project->getApplication(Application::App_DP_ElectricMagneticFields);
- if(DocumentPtr doc = emf->getConductorSelectionDocument())
- m_conductorSelectionDocument->setCurrentIndex(m_conductorSelectionDocument->findData(doc->getIndex()));
- + else
- + m_conductorSelectionDocument->setCurrentIndex(-1);
- }
- else if(app == Application::App_ConductorBundle) {
- m_meteorologicalDataDocument->clear();
- @@ -243,8 +255,10 @@ void ReportOptionsView::updateFromProject()
- m_meteorologicalDataDocument->addItem(document->getName(), document->getIndex());
- ConductorBundle *cb = (ConductorBundle*)g_project->getApplication(Application::App_ConductorBundle);
- - if(DocumentPtr doc = cb->getConductorSelectionDocument())
- + if(DocumentPtr doc = cb->getMeteorologicalDataDocument())
- m_meteorologicalDataDocument->setCurrentIndex(m_meteorologicalDataDocument->findData(doc->getIndex()));
- + else
- + m_meteorologicalDataDocument->setCurrentIndex(-1);
- }
- }
- @@ -368,11 +382,17 @@ void ReportOptionsView::updateToProject()
- }
- else if(app == Application::App_DP_ElectricMagneticFields) {
- ElectricMagneticFields *emf = (ElectricMagneticFields*)g_project->getApplication(Application::App_DP_ElectricMagneticFields);
- + if(m_conductorSelectionDocument->currentIndex() == -1)
- + emf->setConductorSelectionDocument(nullptr);
- + else
- emf->setConductorSelectionDocument(g_project->getDocument(m_conductorSelectionDocument->currentData().toInt()));
- }
- else if(app == Application::App_ConductorBundle) {
- ConductorBundle *cb = (ConductorBundle*)g_project->getApplication(Application::App_ConductorBundle);
- - cb->setConductorSelectionDocument(g_project->getDocument(m_meteorologicalDataDocument->currentData().toInt()));
- + if(m_meteorologicalDataDocument->currentIndex() == -1)
- + cb->setMeteorologicalDataDocument(nullptr);
- + else
- + cb->setMeteorologicalDataDocument(g_project->getDocument(m_meteorologicalDataDocument->currentData().toInt()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement