Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/private-core-…
Browse files Browse the repository at this point in the history
…module

Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
  • Loading branch information
mgovers committed Nov 7, 2024
2 parents 9198dcd + 0f8ccb7 commit faec0f6
Show file tree
Hide file tree
Showing 12 changed files with 534 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black-jupyter
- repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
2 changes: 1 addition & 1 deletion docs/user_manual/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The base type for all power-grid-model components.

If a component update is uniform and is updating all the elements with the same component type, IDs can be omitted or set to `nan`s. In any other case, the IDs need to be present in the update dataset, but cannot be changed.

Uniform component updates are ones that update the same number of component elements across scenarios. By definition, a dense update is always uniform, hence the IDs can always be optional; whereas for a sparse update, the IDs can only be optional if the index pointer is given as an arithmetic sequence of all elements (i.e. a sparse representation of a dense buffer). An example of the usage of optional IDs is given in [Power Flow Example](./Power%20Flow%20Example.ipynb)
Uniform component updates are ones that update the same number of component of the same type across scenarios. By definition, a dense update is always uniform, hence the IDs can always be optional; whereas for a sparse update, the IDs can only be optional if the index pointer is given as an arithmetic sequence of all elements (i.e. a sparse representation of a dense buffer). An example of the usage of optional IDs is given in [Power Flow Example](./Power%20Flow%20Example.ipynb)

#### Steady state output and Short circuit output

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ template <dataset_type_tag dataset_type_> class Dataset {
}

// get individual dataset from batch
Dataset get_individual_scenario(Idx scenario)
Dataset get_individual_scenario(Idx scenario) const
requires(!is_indptr_mutable_v<dataset_type>)
{
using AdvanceablePtr = std::conditional_t<is_data_mutable_v<dataset_type>, char*, char const*>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace detail {
template <component_c Component, forward_iterator_like<typename Component::UpdateType> ForwardIterator, typename Func>
requires std::invocable<std::remove_cvref_t<Func>, typename Component::UpdateType, Idx2D const&>
inline void iterate_component_sequence(Func&& func, ForwardIterator begin, ForwardIterator end,
std::vector<Idx2D> const& sequence_idx) {
std::span<Idx2D const> sequence_idx) {
assert(std::distance(begin, end) >= static_cast<ptrdiff_t>(sequence_idx.size()));

Idx seq = 0;
Expand All @@ -36,12 +36,12 @@ inline void get_component_sequence(MainModelState<ComponentContainer> const& sta
ForwardIterator end, OutputIterator destination, Idx n_comp_elements) {
using UpdateType = typename Component::UpdateType;

if (n_comp_elements == na_Idx) {
if (n_comp_elements < 0) {
std::ranges::transform(begin, end, destination, [&state](UpdateType const& update) {
return get_component_idx_by_id<Component>(state, update.id);
});
} else {
assert(std::distance(begin, end) <= n_comp_elements || begin == end);
assert(std::distance(begin, end) <= n_comp_elements);
std::ranges::transform(
begin, end, destination,
[group = get_component_group_idx<Component>(state), index = 0](auto const& /*update*/) mutable {
Expand Down Expand Up @@ -71,7 +71,7 @@ template <component_c Component, class ComponentContainer,
requires model_component_state_c<MainModelState, ComponentContainer, Component>
inline UpdateChange update_component(MainModelState<ComponentContainer>& state, ForwardIterator begin,
ForwardIterator end, OutputIterator changed_it,
std::vector<Idx2D> const& sequence_idx) {
std::span<Idx2D const> sequence_idx) {
using UpdateType = typename Component::UpdateType;

UpdateChange state_changed;
Expand Down Expand Up @@ -110,7 +110,7 @@ template <component_c Component, class ComponentContainer,
std::output_iterator<typename Component::UpdateType> OutputIterator>
requires model_component_state_c<MainModelState, ComponentContainer, Component>
inline void update_inverse(MainModelState<ComponentContainer> const& state, ForwardIterator begin, ForwardIterator end,
OutputIterator destination, std::vector<Idx2D> const& sequence_idx) {
OutputIterator destination, std::span<Idx2D const> sequence_idx) {
using UpdateType = typename Component::UpdateType;

detail::iterate_component_sequence<Component>(
Expand Down
Loading

0 comments on commit faec0f6

Please sign in to comment.