Skip to content

Commit

Permalink
delete mat files and fix some erros
Browse files Browse the repository at this point in the history
Signed-off-by: martin.moraga <[email protected]>
  • Loading branch information
martinmoraga committed Mar 26, 2024
1 parent 8bb6d7d commit 9892913
Show file tree
Hide file tree
Showing 34 changed files with 2,018 additions and 2,691 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ class ReducedOrderSynchronGenerator : public MNASimPowerComp<VarType> {

// ### Controllers ###
/// Add automatic voltage regulator
void addExciter(CPS::Base::ExciterParameters exciterParameters,
ExciterType exciterType = ExciterType::DC1Simp);
/// Add automatic voltage regulator
void addExciter(std::shared_ptr<Base::Exciter> exciter);
/// Add power system stabilizer
void addPSS(std::shared_ptr<Base::PSS> PSS);
Expand Down
292 changes: 151 additions & 141 deletions dpsim-models/include/dpsim-models/CIM/Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,153 +37,163 @@ class BaseClass;
#ifdef CGMES_BUILD
#include <UnitMultiplier.hpp>
namespace CIMPP {
class SvVoltage;
class SvPowerFlow;
class ACLineSegment;
class SynchronousMachine;
class ExternalNetworkInjection;
class EnergyConsumer;
class PowerTransformer;
class EquivalentShunt;
class TopologicalNode;
class ConductingEquipment;
class LinearShuntCompensator;
};
class SvVoltage;
class SvPowerFlow;
class ACLineSegment;
class SynchronousMachine;
class ExternalNetworkInjection;
class EnergyConsumer;
class PowerTransformer;
class EquivalentShunt;
class TopologicalNode;
class ConductingEquipment;
class LinearShuntCompensator;
}; // namespace CIMPP
#else
#include <CIMNamespaces.hpp>
#endif

namespace CPS {
namespace CIM {
class InvalidTopology { };

class Reader {
private:
/// CIM logger
Logger::Log mSLog;
/// Log level of components
Logger::Level mComponentLogLevel;
/// Model from CIM++
CIMModel *mModel;
/// System frequency (has to be given to convert between reactances
/// in CIM and inductances used inside the simulation)
Real mFrequency;
/// System angular frequency
Real mOmega;
/// Domain of the simulation components that are created by the reader
Domain mDomain;
/// Type of generator to be instantiated
GeneratorType mGeneratorType;
/// \brief Determines the overall phase configuration of the simulation.
///
/// This can be different from the phase type of an individual node.
PhaseType mPhase;
/// Maps the RID of a topological node to a PowerflowNode which holds its simulation matrix index
/// as given in the component constructors (0 for the first node, -1 or GND for ground).
std::map<String, TopologicalNode::Ptr> mPowerflowNodes;
/// Maps the RID of a ConductingEquipment to a PowerflowEquipment
std::map<String, TopologicalPowerComp::Ptr> mPowerflowEquipment;
/// Maps the RID of a Terminal to a PowerflowTerminal
std::map<String, TopologicalTerminal::Ptr> mPowerflowTerminals;
///
Bool mUseProtectionSwitches = false;

// #### shunt component settings ####
/// activates global shunt capacitor setting
Bool mSetShuntCapacitor = false;
/// global shunt capacitor value
Real mShuntCapacitorValue = -1;
/// activates global shunt resistor setting
Bool mSetShuntConductance = false;
/// global shunt resistor value
Real mShuntConductanceValue = 1e-6;

// #### General Functions ####
/// Resolves unit multipliers.
static Real unitValue(Real value, CIMPP::UnitMultiplier mult);
///
void processSvVoltage(CIMPP::SvVoltage* volt);
///
void processSvPowerFlow(CIMPP::SvPowerFlow* flow);
///
template<typename VarType>
void processTopologicalNode(CIMPP::TopologicalNode* topNode);
///
void addFiles(const fs::path &filename);
/// Adds CIM files to list of files to be parsed.
void addFiles(const std::list<fs::path> &filenames);
/// First, go through all topological nodes and collect them in a list.
/// Since all nodes have references to the equipment connected to them (via Terminals), but not
/// the other way around (which we need for instantiating the components), we collect that information here as well.
void parseFiles();
/// Returns list of components and nodes.
SystemTopology systemTopology();

// #### Mapping Functions ####
/// Returns simulation node index which belongs to mRID.
Matrix::Index mapTopologicalNode(String mrid);
/// Maps CIM components to CPowerSystem components.
TopologicalPowerComp::Ptr mapComponent(BaseClass* obj);
/// Returns an RX-Line.
/// The voltage should be given in kV and the angle in degree.
/// TODO: Introduce different models such as PI and wave model.
TopologicalPowerComp::Ptr mapACLineSegment(CIMPP::ACLineSegment* line);
/// Returns a transformer, either ideal or with RL elements to model losses.
TopologicalPowerComp::Ptr mapPowerTransformer(CIMPP::PowerTransformer *trans);
/// Returns an IdealVoltageSource with voltage setting according to load flow data
/// at machine terminals. The voltage should be given in kV and the angle in degree.
/// TODO: Introduce real synchronous generator models here.
TopologicalPowerComp::Ptr mapSynchronousMachine(CIMPP::SynchronousMachine* machine);
/// Returns an PQload with voltage setting according to load flow data.
/// Currently the only option is to create an RL-load.
/// The voltage should be given in kV and the angle in degree.
/// TODO: Introduce real PQload model here.
TopologicalPowerComp::Ptr mapEnergyConsumer(CIMPP::EnergyConsumer* consumer);
/// Returns an external grid injection.
TopologicalPowerComp::Ptr mapExternalNetworkInjection(CIMPP::ExternalNetworkInjection* extnet);
/// Returns a shunt
TopologicalPowerComp::Ptr mapEquivalentShunt(CIMPP::EquivalentShunt *shunt);
///
TopologicalPowerComp::Ptr mapEquivalentLinearShunt(CIMPP::LinearShuntCompensator *linearShunt);


// #### Helper Functions ####
/// Determine base voltage associated with object
Real determineBaseVoltageAssociatedWithEquipment(CIMPP::ConductingEquipment* equipment);

public:
/// Creates new reader with a name for logging.
/// The first log level is for the reader and the second for the generated components.
Reader(String name,
Logger::Level logLevel = Logger::Level::info,
Logger::Level componentLogLevel = Logger::Level::off);
///
virtual ~Reader();

/// Parses data from CIM files into the CPS data structure
SystemTopology loadCIM(Real systemFrequency, const fs::path &filename, Domain domain = Domain::DP, PhaseType phase = PhaseType::Single,
GeneratorType genType = GeneratorType::None);
/// Parses data from CIM files into the CPS data structure
SystemTopology loadCIM(Real systemFrequency, const std::list<fs::path> &filenames, Domain domain = Domain::DP, PhaseType phase = PhaseType::Single,
GeneratorType genType = GeneratorType::None);
///
SystemTopology loadCIM(Real systemFrequency, const std::list<CPS::String> &filenamesString, Domain domain = Domain::DP, PhaseType phase = PhaseType::Single,
GeneratorType genType = GeneratorType::None);

// #### shunt component settings ####
/// set shunt capacitor value
void setShuntCapacitor(Real v);
/// set shunt conductance value
void setShuntConductance(Real v);
/// If set, some components like loads include protection switches
void useProtectionSwitches(Bool value = true);

//
///
std::map<String, std::vector<CPS::Real>> getPowerFlowResults();
};
}
}
class InvalidTopology {};

class Reader {
private:
/// CIM logger
Logger::Log mSLog;
/// Log level of components
Logger::Level mComponentLogLevel;
/// Model from CIM++
CIMModel *mModel;
/// System frequency (has to be given to convert between reactances
/// in CIM and inductances used inside the simulation)
Real mFrequency;
/// System angular frequency
Real mOmega;
/// Domain of the simulation components that are created by the reader
Domain mDomain;
/// Type of generator to be instantiated
GeneratorType mGeneratorType;
/// \brief Determines the overall phase configuration of the simulation.
///
/// This can be different from the phase type of an individual node.
PhaseType mPhase;
/// Maps the RID of a topological node to a PowerflowNode which holds its simulation matrix index
/// as given in the component constructors (0 for the first node, -1 or GND for ground).
std::map<String, TopologicalNode::Ptr> mPowerflowNodes;
/// Maps the RID of a ConductingEquipment to a PowerflowEquipment
std::map<String, TopologicalPowerComp::Ptr> mPowerflowEquipment;
/// Maps the RID of a Terminal to a PowerflowTerminal
std::map<String, TopologicalTerminal::Ptr> mPowerflowTerminals;
///
Bool mUseProtectionSwitches = false;

// #### shunt component settings ####
/// activates global shunt capacitor setting
Bool mSetShuntCapacitor = false;
/// global shunt capacitor value
Real mShuntCapacitorValue = -1;
/// activates global shunt resistor setting
Bool mSetShuntConductance = false;
/// global shunt resistor value
Real mShuntConductanceValue = 1e-6;

// #### General Functions ####
/// Resolves unit multipliers.
static Real unitValue(Real value, CIMPP::UnitMultiplier mult);
///
void processSvVoltage(CIMPP::SvVoltage *volt);
///
void processSvPowerFlow(CIMPP::SvPowerFlow *flow);
///
template <typename VarType>
void processTopologicalNode(CIMPP::TopologicalNode *topNode);
///
void addFiles(const fs::path &filename);
/// Adds CIM files to list of files to be parsed.
void addFiles(const std::list<fs::path> &filenames);
/// First, go through all topological nodes and collect them in a list.
/// Since all nodes have references to the equipment connected to them (via Terminals), but not
/// the other way around (which we need for instantiating the components), we collect that information here as well.
void parseFiles();
/// Returns list of components and nodes.
SystemTopology systemTopology();

// #### Mapping Functions ####
/// Returns simulation node index which belongs to mRID.
Matrix::Index mapTopologicalNode(String mrid);
/// Maps CIM components to CPowerSystem components.
TopologicalPowerComp::Ptr mapComponent(BaseClass *obj);
/// Returns an RX-Line.
/// The voltage should be given in kV and the angle in degree.
/// TODO: Introduce different models such as PI and wave model.
TopologicalPowerComp::Ptr mapACLineSegment(CIMPP::ACLineSegment *line);
/// Returns a transformer, either ideal or with RL elements to model losses.
TopologicalPowerComp::Ptr mapPowerTransformer(CIMPP::PowerTransformer *trans);
/// Returns an IdealVoltageSource with voltage setting according to load flow data
/// at machine terminals. The voltage should be given in kV and the angle in degree.
/// TODO: Introduce real synchronous generator models here.
TopologicalPowerComp::Ptr
mapSynchronousMachine(CIMPP::SynchronousMachine *machine);
/// Returns an PQload with voltage setting according to load flow data.
/// Currently the only option is to create an RL-load.
/// The voltage should be given in kV and the angle in degree.
/// TODO: Introduce real PQload model here.
TopologicalPowerComp::Ptr mapEnergyConsumer(CIMPP::EnergyConsumer *consumer);
/// Returns an external grid injection.
TopologicalPowerComp::Ptr
mapExternalNetworkInjection(CIMPP::ExternalNetworkInjection *extnet);
/// Returns a shunt
TopologicalPowerComp::Ptr mapEquivalentShunt(CIMPP::EquivalentShunt *shunt);
///
TopologicalPowerComp::Ptr
mapEquivalentLinearShunt(CIMPP::LinearShuntCompensator *linearShunt);

// #### Helper Functions ####
/// Determine base voltage associated with object
Real determineBaseVoltageAssociatedWithEquipment(
CIMPP::ConductingEquipment *equipment);

public:
/// Creates new reader with a name for logging.
/// The first log level is for the reader and the second for the generated components.
Reader(String name, Logger::Level logLevel = Logger::Level::info,
Logger::Level componentLogLevel = Logger::Level::off);
///
virtual ~Reader();

/// Parses data from CIM files into the CPS data structure
SystemTopology loadCIM(Real systemFrequency, const fs::path &filename,
Domain domain = Domain::DP,
PhaseType phase = PhaseType::Single,
GeneratorType genType = GeneratorType::None);
/// Parses data from CIM files into the CPS data structure
SystemTopology loadCIM(Real systemFrequency,
const std::list<fs::path> &filenames,
Domain domain = Domain::DP,
PhaseType phase = PhaseType::Single,
GeneratorType genType = GeneratorType::None);
///
SystemTopology loadCIM(Real systemFrequency,
const std::list<CPS::String> &filenamesString,
Domain domain = Domain::DP,
PhaseType phase = PhaseType::Single,
GeneratorType genType = GeneratorType::None);

// #### shunt component settings ####
/// set shunt capacitor value
void setShuntCapacitor(Real v);
/// set shunt conductance value
void setShuntConductance(Real v);
/// If set, some components like loads include protection switches
void useProtectionSwitches(Bool value = true);

//
///
std::map<String, std::vector<CPS::Real>> getPowerFlowResults();
};
} // namespace CIM
} // namespace CPS

#if defined(BASECLASS_H) && !defined(READER_CPP)
#error "Do not include CIMpp headers into CPS/DPsim headers!"
Expand Down
8 changes: 0 additions & 8 deletions dpsim-models/include/dpsim-models/Components.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@
#include <dpsim-models/DP/DP_Ph1_RXLoadSwitch.h>
#include <dpsim-models/DP/DP_Ph1_ReducedOrderSynchronGeneratorVBR.h>
#include <dpsim-models/DP/DP_Ph1_ResIndSeries.h>
#include <dpsim-models/DP/DP_Ph1_Transformer.h>
#include <dpsim-models/DP/DP_Ph1_VoltageSource.h>
#include <dpsim-models/DP/DP_Ph1_VoltageSourceRamp.h>
#include <dpsim-models/DP/DP_Ph1_VoltageSourceNorton.h>
#include <dpsim-models/DP/DP_Ph1_Shunt.h>
#include <dpsim-models/DP/DP_Ph1_Switch.h>
#include <dpsim-models/DP/DP_Ph1_SynchronGenerator3OrderVBR.h>
Expand Down Expand Up @@ -103,10 +99,6 @@
#include <dpsim-models/EMT/EMT_Ph3_SeriesResistor.h>
#include <dpsim-models/EMT/EMT_Ph3_SeriesSwitch.h>
#include <dpsim-models/EMT/EMT_Ph3_Shunt.h>
#include <dpsim-models/EMT/EMT_Ph3_CurrentSource.h>
#include <dpsim-models/EMT/EMT_Ph3_VoltageSource.h>
#include <dpsim-models/EMT/EMT_Ph3_VoltageSourceNorton.h>
#include <dpsim-models/EMT/EMT_Ph3_ReducedOrderSynchronGeneratorVBR.h>
#include <dpsim-models/EMT/EMT_Ph3_SynchronGenerator3OrderVBR.h>
#include <dpsim-models/EMT/EMT_Ph3_SynchronGenerator4OrderPCM.h>
#include <dpsim-models/EMT/EMT_Ph3_SynchronGenerator4OrderVBR.h>
Expand Down
Loading

0 comments on commit 9892913

Please sign in to comment.