Skip to content

Commit

Permalink
fix clang compiler errors.
Browse files Browse the repository at this point in the history
there are some pretty significant mistakes that I fixed here. For example in most models clone was implemented such that it didn't properly used polymorphism.

Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
  • Loading branch information
n-eiling committed May 13, 2024
1 parent ea4b1db commit 9067341
Show file tree
Hide file tree
Showing 77 changed files with 315 additions and 313 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_test_linux_rocky.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
key: build-cache-rocky-${{ github.sha }}

linux-rocky-clang:
name: Build on Rocky Linux
name: Build on Rocky Linux using Clang
runs-on: ubuntu-latest
container: sogno/dpsim:dev-rocky
steps:
Expand Down
4 changes: 2 additions & 2 deletions dpsim-models/include/dpsim-models/Attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ class AttributeStatic : public Attribute<T>,
throw TypeException();
}

virtual std::shared_ptr<T> asRawPointer() { return this->mData; }
virtual std::shared_ptr<T> asRawPointer() override { return this->mData; }

virtual void appendDependencies(AttributeBase::Set *deps) override {
deps->insert(this->shared_from_this());
Expand Down Expand Up @@ -649,7 +649,7 @@ class AttributeDynamic : public Attribute<T>,
}
}

virtual std::shared_ptr<T> asRawPointer() {
virtual std::shared_ptr<T> asRawPointer() override {
for (typename AttributeUpdateTaskBase<T>::Ptr task : updateTasksOnGet) {
task->executeUpdate(this->mData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class ReducedOrderSynchronGenerator : public MNASimPowerComp<VarType> {
///
virtual void initializeResistanceMatrix() = 0;
///
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;
/// Function to initialize the specific variables of each SG model
virtual void specificInitialization() = 0;
/// Model specific step
Expand All @@ -136,7 +136,8 @@ class ReducedOrderSynchronGenerator : public MNASimPowerComp<VarType> {
Attribute<Matrix>::Ptr &leftVector) final;
virtual void mnaCompPostStep(const Matrix &leftVector) = 0;
/// Stamps system matrix
virtual void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) = 0;
virtual void
mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override = 0;
/// Model flag indicating whether the machine is modelled as Norton or Thevenin equivalent
Bool mModelAsNortonSource;
// Model flag indicating the SG order to be used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class AvVoltageSourceInverterDQ

// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;
/// Setter for general parameters of inverter
void setParameters(Real sysOmega, Real sysVoltNom, Real Pref, Real Qref);
/// Setter for parameters of control loops
Expand Down
10 changes: 5 additions & 5 deletions dpsim-models/include/dpsim-models/DP/DP_Ph1_Capacitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ class Capacitor : public MNASimPowerComp<Complex>,
Capacitor(String name, Logger::Level logLevel = Logger::Level::off)
: Capacitor(name, name, logLevel) {}

SimPowerComp<Complex>::Ptr clone(String name);
SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;
///
void initialize(Matrix frequencies);
void initialize(Matrix frequencies) override;

// #### MNA section ####
/// Initializes internal variables of the component
Expand All @@ -56,9 +56,9 @@ class Capacitor : public MNASimPowerComp<Complex>,
Real omega, Real timeStep,
std::vector<Attribute<Matrix>::Ptr> leftVector) override;
/// Stamps system matrix
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix);
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
void mnaCompApplySystemMatrixStampHarm(SparseMatrixRow &systemMatrix,
Int freqIdx);
Int freqIdx) override;
/// Stamps right side (source) vector
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
void mnaCompApplyRightSideVectorStampHarm(Matrix &rightVector) override;
Expand Down
12 changes: 6 additions & 6 deletions dpsim-models/include/dpsim-models/DP/DP_Ph1_CurrentSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ class CurrentSource : public MNASimPowerComp<Complex>,

void setParameters(Complex current);

SimPowerComp<Complex>::Ptr clone(String copySuffix);
SimPowerComp<Complex>::Ptr clone(String copySuffix) override;

// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;

// #### MNA section ####
///
void mnaCompInitialize(Real omega, Real timeStep,
Attribute<Matrix>::Ptr leftVector);
Attribute<Matrix>::Ptr leftVector) override;
/// Stamps system matrix
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) {}
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override {}
/// Stamps right side (source) vector
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector);
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
///
void mnaCompUpdateVoltage(const Matrix &leftVector);
void mnaCompUpdateVoltage(const Matrix &leftVector) override;

/// Add MNA pre step dependencies
void mnaCompAddPreStepDependencies(
Expand Down
18 changes: 9 additions & 9 deletions dpsim-models/include/dpsim-models/DP/DP_Ph1_Inductor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ class Inductor : public MNASimPowerComp<Complex>,

// #### General ####
/// Return new instance with the same parameters
SimPowerComp<Complex>::Ptr clone(String name);
SimPowerComp<Complex>::Ptr clone(String name) override;
/// Initializes state variables considering the number of frequencies
void initialize(Matrix frequencies);
void initialize(Matrix frequencies) override;
/// Initializes states from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;

// #### MNA section ####
/// Initializes MNA specific variables
Expand All @@ -60,9 +60,9 @@ class Inductor : public MNASimPowerComp<Complex>,
Real omega, Real timeStep,
std::vector<Attribute<Matrix>::Ptr> leftVectors) override;
/// Stamps system matrix
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix);
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
void mnaCompApplySystemMatrixStampHarm(SparseMatrixRow &systemMatrix,
Int freqIdx);
Int freqIdx) override;
/// Stamps right side (source) vector
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
void mnaCompApplyRightSideVectorStampHarm(Matrix &rightVector) override;
Expand Down Expand Up @@ -90,10 +90,10 @@ class Inductor : public MNASimPowerComp<Complex>,
Attribute<Matrix>::Ptr &leftVector) override;

// #### Tearing methods ####
void mnaTearInitialize(Real omega, Real timestep);
void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix);
void mnaTearApplyVoltageStamp(Matrix &voltageVector);
void mnaTearPostStep(Complex voltage, Complex current);
void mnaTearInitialize(Real omega, Real timestep) override;
void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) override;
void mnaTearApplyVoltageStamp(Matrix &voltageVector) override;
void mnaTearPostStep(Complex voltage, Complex current) override;

class MnaPreStepHarm : public Task {
public:
Expand Down
22 changes: 12 additions & 10 deletions dpsim-models/include/dpsim-models/DP/DP_Ph1_Inverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ class Inverter : public MNASimPowerComp<Complex>,

// #### General ####
///
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;
///
void initialize(Matrix frequencies);
void initialize(Matrix frequencies) override;
///
void setParameters(const std::vector<Int> &carrierHarms,
const std::vector<Int> &modulHarms, Real inputVoltage,
Expand All @@ -108,17 +108,19 @@ class Inverter : public MNASimPowerComp<Complex>,
// #### MNA Functions ####
/// Initializes internal variables of the component
void mnaCompInitialize(Real omega, Real timeStep,
Attribute<Matrix>::Ptr leftVector);
void mnaCompInitializeHarm(Real omega, Real timeStep,
std::vector<Attribute<Matrix>::Ptr> leftVectors);
Attribute<Matrix>::Ptr leftVector) override;
void mnaCompInitializeHarm(
Real omega, Real timeStep,
std::vector<Attribute<Matrix>::Ptr> leftVectors) override;
/// Stamps system matrix
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix);
void mnaCompApplySystemMatrixStamp(SparseMatrixRow &systemMatrix) override;
void mnaCompApplySystemMatrixStampHarm(SparseMatrixRow &systemMatrix,
Int freqIdx);
Int freqIdx) override;
/// Stamps right side (source) vector
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector);
void mnaCompApplyRightSideVectorStampHarm(Matrix &rightVector);
void mnaCompApplyRightSideVectorStampHarm(Matrix &sourceVector, Int freqIdx);
void mnaCompApplyRightSideVectorStamp(Matrix &rightVector) override;
void mnaCompApplyRightSideVectorStampHarm(Matrix &rightVector) override;
void mnaCompApplyRightSideVectorStampHarm(Matrix &sourceVector,
Int freqIdx) override;
/// Add MNA pre step dependencies
void mnaCompAddPreStepDependencies(
AttributeBase::List &prevStepDependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ class NetworkInjection : public CompositePowerComp<Complex>,
NetworkInjection(String name, Complex voltage,
Logger::Level logLevel = Logger::Level::off);
///
SimPowerComp<Complex>::Ptr clone(String name);
SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;
/// Setter for reference voltage and frequency with a sine wave generator
/// This will initialize the values of mVoltageRef and mSrcFreq to match the given parameters
/// However, the attributes can be modified during the simulation to dynamically change the magnitude, frequency, and phase of the sine wave.
Expand Down Expand Up @@ -97,9 +97,9 @@ class NetworkInjection : public CompositePowerComp<Complex>,
// #### DAE Section ####
/// Residual function for DAE Solver
void daeResidual(double ttime, const double state[], const double dstate_dt[],
double resid[], std::vector<int> &off);
double resid[], std::vector<int> &off) override;
///Voltage Getter
Complex daeInitialize();
Complex daeInitialize() override;
};
} // namespace Ph1
} // namespace DP
Expand Down
4 changes: 2 additions & 2 deletions dpsim-models/include/dpsim-models/DP/DP_Ph1_PQLoadCS.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class PQLoadCS : public CompositePowerComp<Complex>,
Real nomVolt, Logger::Level logLevel = Logger::Level::off);

void setParameters(Real activePower, Real reactivePower, Real nomVolt);
SimPowerComp<Complex>::Ptr clone(String name);
SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;

// #### MNA section ####
/// MNA pre and post step operations
Expand Down
18 changes: 9 additions & 9 deletions dpsim-models/include/dpsim-models/DP/DP_Ph1_PiLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ class PiLine : public CompositePowerComp<Complex>,
PiLine(String name, Logger::Level logLevel = Logger::Level::off)
: PiLine(name, name, logLevel) {}

SimPowerComp<Complex>::Ptr clone(String copySuffix);
SimPowerComp<Complex>::Ptr clone(String copySuffix) override;

// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;

// #### MNA section ####
/// Updates internal current variable of the component
void mnaCompUpdateCurrent(const Matrix &leftVector);
void mnaCompUpdateCurrent(const Matrix &leftVector) override;
/// Updates internal voltage variable of the component
void mnaCompUpdateVoltage(const Matrix &leftVector);
void mnaCompUpdateVoltage(const Matrix &leftVector) override;
/// MNA pre and post step operations
void mnaParentPreStep(Real time, Int timeStepCount) override;
void mnaParentPostStep(Real time, Int timeStepCount,
Expand All @@ -75,11 +75,11 @@ class PiLine : public CompositePowerComp<Complex>,
AttributeBase::List &modifiedAttributes,
Attribute<Matrix>::Ptr &leftVector) override;

MNAInterface::List mnaTearGroundComponents();
void mnaTearInitialize(Real omega, Real timeStep);
void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix);
void mnaTearApplyVoltageStamp(Matrix &voltageVector);
void mnaTearPostStep(Complex voltage, Complex current);
MNAInterface::List mnaTearGroundComponents() override;
void mnaTearInitialize(Real omega, Real timeStep) override;
void mnaTearApplyMatrixStamp(SparseMatrixRow &tearMatrix) override;
void mnaTearApplyVoltageStamp(Matrix &voltageVector) override;
void mnaTearPostStep(Complex voltage, Complex current) override;
};
} // namespace Ph1
} // namespace DP
Expand Down
2 changes: 1 addition & 1 deletion dpsim-models/include/dpsim-models/DP/DP_Ph1_RXLoad.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RXLoad : public CompositePowerComp<Complex>,

// #### General ####
/// Initialize component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;
/// Set model specific parameters
void setParameters(Real activePower, Real ReactivePower, Real volt);

Expand Down
2 changes: 1 addition & 1 deletion dpsim-models/include/dpsim-models/DP/DP_Ph1_RXLoadSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class RXLoadSwitch : public CompositePowerComp<Complex>,

// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;
/// Sets model specific parameters
void setParameters(Real activePower, Real reactivePower, Real nomVolt,
Real openResistance, Real closedResistance,
Expand Down
4 changes: 2 additions & 2 deletions dpsim-models/include/dpsim-models/DP/DP_Ph1_RxLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class RxLine : public CompositePowerComp<Complex>,
RxLine(String name, Logger::Level logLevel = Logger::Level::off)
: RxLine(name, name, logLevel) {}

SimPowerComp<Complex>::Ptr clone(String name);
SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;

// #### MNA section ####
void mnaCompUpdateVoltage(const Matrix &leftVector) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SynchronGenerator4OrderPCM
SynchronGenerator4OrderPCM(const String &name,
Logger::Level logLevel = Logger::Level::off);
///
SimPowerComp<Complex>::Ptr clone(const String &name);
SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General Functions ####
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SynchronGenerator4OrderTPM
SynchronGenerator4OrderTPM(String name,
Logger::Level logLevel = Logger::Level::off);
///
SimPowerComp<Complex>::Ptr clone(String name);
SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General Functions ####
/// Initializes component from power flow data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SynchronGenerator6OrderPCM
SynchronGenerator6OrderPCM(const String &name,
Logger::Level logLevel = Logger::Level::off);
///
SimPowerComp<Complex>::Ptr clone(const String &name);
SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General Functions ####
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class SynchronGeneratorIdeal : public CompositePowerComp<Complex>,
SynchronGeneratorIdeal(String name,
Logger::Level logLevel = Logger::Level::off);

SimPowerComp<Complex>::Ptr clone(String name);
SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General ####
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;

// #### MNA section ####
/// MNA pre step operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SynchronGeneratorTrStab : public CompositePowerComp<Complex>,
Logger::Level logLevel = Logger::Level::off)
: SynchronGeneratorTrStab(name, name, logLevel) {}

SimPowerComp<Complex>::Ptr clone(String name);
SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General Functions ####
/// Flags to modify model behavior
Expand All @@ -89,7 +89,7 @@ class SynchronGeneratorTrStab : public CompositePowerComp<Complex>,
///
void step(Real time);
///
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;

// #### MNA Functions ####
/// Initializes variables of component
Expand Down
4 changes: 2 additions & 2 deletions dpsim-models/include/dpsim-models/DP/DP_Ph1_Transformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Transformer : public CompositePowerComp<Complex>,
Transformer(String name, Logger::Level logLevel = Logger::Level::off)
: Transformer(name, name, logLevel) {}

SimPowerComp<Complex>::Ptr clone(String name);
SimPowerComp<Complex>::Ptr clone(String name) override;

// #### General ####
/// Defines component parameters
Expand All @@ -69,7 +69,7 @@ class Transformer : public CompositePowerComp<Complex>,
Real ratioAbs, Real ratioPhase, Real resistance,
Real inductance);
/// Initializes component from power flow data
void initializeFromNodesAndTerminals(Real frequency);
void initializeFromNodesAndTerminals(Real frequency) override;

// #### MNA section ####
/// Initializes internal variables of the component
Expand Down
Loading

0 comments on commit 9067341

Please sign in to comment.