Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ google-*,
-google-default-arguments,
misc-*,
-misc-confusable-identifiers,
-misc-include-cleaner,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
modernize-*,
Expand All @@ -67,6 +66,7 @@ readability-*,

WarningsAsErrors: '*'

IgnoreHeaders: 'Eigen/.*'

HeaderFilterRegex: '.*'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#pragma once

// define all components
#include "common/common.hpp"
#include "common/component_list.hpp"
// component include
#include "component/appliance.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "../common/enum.hpp"

namespace power_grid_model {
// TODO (nitbharambe) move outside of base.hpp to component
constexpr IntS status_to_int(bool status) { return status ? IntS{1} : IntS{0}; }

class Base {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,16 @@ concept component_c = requires(T t, T const& ct, typename T::UpdateType u, typen
{ ct.inverse(u) } -> std::same_as<typename T::UpdateType>;
};

struct load_appliance_t {};
struct gen_appliance_t {};

template <typename T>
concept appliance_type_tag = std::same_as<T, load_appliance_t> || std::same_as<T, gen_appliance_t>;
template <appliance_type_tag T> constexpr bool is_generator_v = std::same_as<T, gen_appliance_t>;

static_assert(appliance_type_tag<load_appliance_t>);
static_assert(appliance_type_tag<gen_appliance_t>);
static_assert(!is_generator_v<load_appliance_t>);
static_assert(is_generator_v<gen_appliance_t>);

} // namespace power_grid_model
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#pragma once

#include "appliance.hpp"
#include "base.hpp"

#include "../auxiliary/input.hpp"
#include "../auxiliary/output.hpp"
Expand All @@ -17,18 +16,6 @@

namespace power_grid_model {

struct load_appliance_t {};
struct gen_appliance_t {};

template <typename T>
concept appliance_type_tag = std::same_as<T, load_appliance_t> || std::same_as<T, gen_appliance_t>;
template <appliance_type_tag T> constexpr bool is_generator_v = std::same_as<T, gen_appliance_t>;

static_assert(appliance_type_tag<load_appliance_t>);
static_assert(appliance_type_tag<gen_appliance_t>);
static_assert(!is_generator_v<load_appliance_t>);
static_assert(is_generator_v<gen_appliance_t>);

class GenericLoadGen : public Appliance {
public:
using InputType = GenericLoadGenInput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#pragma once

#include "appliance.hpp"
#include "base.hpp"

#include "../auxiliary/input.hpp"
#include "../auxiliary/output.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#pragma once

#include "base.hpp"
#include "regulator.hpp"

#include "../auxiliary/input.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
#include "state_queries.hpp"

#include "../calculation_parameters.hpp"
#include "../component/current_sensor.hpp"
#include "../component/fault.hpp"
#include "../component/load_gen.hpp"
#include "../component/node.hpp"
#include "../component/power_sensor.hpp"
#include "../component/shunt.hpp"
#include "../component/source.hpp"
#include "../component/voltage_sensor.hpp"

#include <concepts>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

#pragma once

#include "../all_components.hpp"
#include "../component/base.hpp"
#include "../component/branch.hpp"
#include "../component/branch3.hpp"
#include "../component/regulator.hpp"
#include "../container.hpp"

namespace power_grid_model::main_core {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,23 @@

#pragma once

#include "../all_components.hpp"
#include "state.hpp"
#include "state_queries.hpp"

#include "../component/appliance.hpp"
#include "../component/base.hpp"
#include "../component/branch.hpp"
#include "../component/branch3.hpp"
#include "../component/current_sensor.hpp"
#include "../component/fault.hpp"
#include "../component/node.hpp"
#include "../component/power_sensor.hpp"
#include "../component/regulator.hpp"
#include "../component/transformer_tap_regulator.hpp"
#include "../component/voltage_sensor.hpp"

#include "../common/iterator_facade.hpp"
#include "../component/component.hpp"

#include <unordered_set>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,57 @@

#pragma once

#include "../all_components.hpp"
#include "../component/component.hpp"
#include "../container.hpp"
#include "state.hpp"
#include "update.hpp"

#include <array>
#include <vector>
namespace power_grid_model::main_core {
namespace power_grid_model {

class Base;
class Node;
class Branch;
class Branch3;
class Appliance;
class GenericLoadGen;
class GenericLoad;
class GenericGenerator;
class GenericPowerSensor;
class GenericVoltageSensor;
class GenericCurrentSensor;
class Regulator;
class Line;
class AsymLine;
class Link;
class GenericBranch;
class Transformer;
class ThreeWindingTransformer;
class Shunt;
class Source;

template <symmetry_tag loadgen_symmetry_, appliance_type_tag appliance_type_> class LoadGen;
using SymGenerator = LoadGen<symmetric_t, gen_appliance_t>;
using AsymGenerator = LoadGen<asymmetric_t, gen_appliance_t>;
using SymLoad = LoadGen<symmetric_t, load_appliance_t>;
using AsymLoad = LoadGen<asymmetric_t, load_appliance_t>;

template <symmetry_tag power_sensor_symmetry_> class PowerSensor;
using SymPowerSensor = PowerSensor<symmetric_t>;
using AsymPowerSensor = PowerSensor<asymmetric_t>;

template <symmetry_tag sym> class VoltageSensor;
using SymVoltageSensor = VoltageSensor<symmetric_t>;
using AsymVoltageSensor = VoltageSensor<asymmetric_t>;
template <symmetry_tag sym> class CurrentSensor;
using SymCurrentSensor = CurrentSensor<symmetric_t>;
using AsymCurrentSensor = CurrentSensor<asymmetric_t>;

class Fault;
class TransformerTapRegulator;

namespace main_core {

namespace detail {

Expand Down Expand Up @@ -126,4 +169,5 @@ struct is_main_model_type<MainModelType<ExtraRetrievableTypes<ETs...>, Component

template <typename T> inline constexpr bool is_main_model_type_v = is_main_model_type<T>::value;

} // namespace power_grid_model::main_core
} // namespace main_core
} // namespace power_grid_model
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@

#pragma once

#include "../component/base.hpp"
#include "../component/branch.hpp"
#include "../component/branch3.hpp"
#include "../component/current_sensor.hpp"
#include "../component/fault.hpp"
#include "../component/load_gen.hpp"
#include "../component/node.hpp"
#include "../component/power_sensor.hpp"
#include "../component/shunt.hpp"
#include "../component/source.hpp"
#include "../component/transformer_tap_regulator.hpp"
#include "../component/voltage_sensor.hpp"
#include "container_queries.hpp"
#include "state.hpp"
#include "state_queries.hpp"

#include "../all_components.hpp"
#include "../component/component.hpp"

#include <concepts>

Expand Down Expand Up @@ -115,14 +127,14 @@ constexpr void produce_output(MainModelState<ComponentContainer> const& state, C

// output node
template <std::derived_from<Node> Component, steady_state_solver_output_type SolverOutputType>
constexpr auto output_result(Node const& node, std::vector<SolverOutputType> const& solver_output, Idx2D math_id) {
constexpr auto output_result(Component const& node, std::vector<SolverOutputType> const& solver_output, Idx2D math_id) {
using sym = typename SolverOutputType::sym;

if (math_id.group == -1) {
return node.get_null_output<sym>();
return node.template get_null_output<sym>();
}
return node.get_output<sym>(solver_output[math_id.group].u[math_id.pos],
solver_output[math_id.group].bus_injection[math_id.pos]);
return node.template get_output<sym>(solver_output[math_id.group].u[math_id.pos],
solver_output[math_id.group].bus_injection[math_id.pos]);
}
template <std::derived_from<Node> Component, short_circuit_solver_output_type SolverOutputType>
inline auto output_result(Component const& node, std::vector<SolverOutputType> const& solver_output, Idx2D math_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

#include "state.hpp"

#include "../all_components.hpp"
#include "../component/branch.hpp"
#include "../component/branch3.hpp"
#include "../component/node.hpp"
#include "../component/regulator.hpp"
#include "../component/transformer.hpp"

namespace power_grid_model::main_core {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@

#include "container_queries.hpp"

#include "../all_components.hpp"
#include "../component/branch.hpp"
#include "../component/branch3.hpp"
#include "../component/current_sensor.hpp"
#include "../component/fault.hpp"
#include "../component/load_gen.hpp"
#include "../component/node.hpp"
#include "../component/power_sensor.hpp"
#include "../component/regulator.hpp"
#include "../component/shunt.hpp"
#include "../component/source.hpp"
#include "../component/voltage_sensor.hpp"

namespace power_grid_model::main_core {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
#include "container_queries.hpp"
#include "core_utils.hpp"

#include "../all_components.hpp"
#include "../auxiliary/dataset.hpp"
#include "../common/iterator_facade.hpp"
#include "../container.hpp"
#include "../component/component.hpp"

#include <map>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma once

#include "all_components.hpp"
#include "job_adapter.hpp"
#include "job_dispatch.hpp"
#include "main_model_impl.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#include "common/timer.hpp"

// component include
#include "all_components.hpp"
#include "auxiliary/dataset.hpp"
#include "auxiliary/input.hpp"
#include "auxiliary/output.hpp"
#include "component/component.hpp"

// math model include
#include "math_solver/math_solver_dispatch.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ Iterative Power Flow
#include "../common/common.hpp"
#include "../common/exception.hpp"
#include "../common/three_phase_tensor.hpp"
#include "../common/timer.hpp"

namespace power_grid_model::math_solver {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ if there are sources
#include "../calculation_parameters.hpp"
#include "../common/common.hpp"
#include "../common/enum.hpp"
#include "../common/exception.hpp"
#include "../common/three_phase_tensor.hpp"
#include "../common/timer.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

#include "../calculation_parameters.hpp"
#include "../common/common.hpp"
#include "../common/exception.hpp"
#include "../common/logging.hpp"
#include "../common/three_phase_tensor.hpp"
#include "../common/timer.hpp"

#include <memory>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ J.L -= -dQ_cal_m/dV
#include "../common/common.hpp"
#include "../common/exception.hpp"
#include "../common/three_phase_tensor.hpp"
#include "../common/timer.hpp"

namespace power_grid_model::math_solver {

Expand Down
6 changes: 6 additions & 0 deletions tests/cpp_unit_tests/test_all_components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
//
// SPDX-License-Identifier: MPL-2.0

#include "power_grid_model/auxiliary/input.hpp"
#include <power_grid_model/component/appliance.hpp>
#include <power_grid_model/component/base.hpp>
#include <power_grid_model/component/branch.hpp>
#include <power_grid_model/component/branch3.hpp>
#include <power_grid_model/component/component.hpp>
#include <power_grid_model/component/fault.hpp>
#include <power_grid_model/component/generic_branch.hpp>
#include <power_grid_model/component/line.hpp>
Expand All @@ -22,6 +25,9 @@

#include <doctest/doctest.h>

#include <concepts>
#include <type_traits>

namespace power_grid_model {

static_assert(component_c<Node>);
Expand Down
Loading
Loading