Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix clang compilation and FPGA integration #293

Merged
merged 8 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/build_test_linux_rocky.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,37 @@ jobs:
path: ${{ github.workspace }}/build
key: build-cache-rocky-${{ github.sha }}

linux-rocky-clang:
name: Build on Rocky Linux using Clang
runs-on: ubuntu-latest
container: sogno/dpsim:dev-rocky
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Create Build Environment
run: mkdir build

- name: Configure CMake
shell: bash
working-directory: ${{ github.workspace }}/build
run: cmake $GITHUB_WORKSPACE -DFETCH_SPDLOG=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DWITH_PYBIND=OFF

- name: Build every target
shell: bash
working-directory: ${{ github.workspace }}/build
run: cmake --build .
env:
MAKEFLAGS: "-j2"

- name: Cache build directory
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/build
key: build-cache-rocky-${{ github.sha }}

profiling:
name: Build with Profiling options
runs-on: ubuntu-latest
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 @@ -99,8 +99,6 @@ class ReducedOrderSynchronGenerator : public MNASimPowerComp<VarType> {
protected:
using MNASimPowerComp<VarType>::mRightVector;
using MNASimPowerComp<VarType>::mIntfVoltage;
using MNASimPowerComp<VarType>::MnaPreStep;
using MNASimPowerComp<VarType>::MnaPostStep;

///
ReducedOrderSynchronGenerator(String uid, String name,
Expand All @@ -112,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 @@ -138,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
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
Loading
Loading