All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.powsybl.loadflow.LoadFlowProvider Maven / Gradle / Ivy

There is a newer version: 6.5.1
Show newest version
/**
 * Copyright (c) 2019, RTE (http://www.rte-france.com)
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * SPDX-License-Identifier: MPL-2.0
 */
package com.powsybl.loadflow;

import com.google.common.collect.Lists;
import com.powsybl.commons.Versionable;
import com.powsybl.commons.config.ModuleConfig;
import com.powsybl.commons.config.PlatformConfig;
import com.powsybl.commons.config.PlatformConfigNamedProvider;
import com.powsybl.commons.extensions.Extension;
import com.powsybl.commons.extensions.ExtensionJsonSerializer;
import com.powsybl.commons.parameters.ConfiguredParameter;
import com.powsybl.commons.parameters.Parameter;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.computation.ComputationManager;
import com.powsybl.iidm.network.Network;

import java.util.*;
import java.util.concurrent.CompletableFuture;

/**
 * Service Provider Interface for loadflow implementations.
 *
 * 

A loadflow provider is required to implement the main method {@link #run}, in charge of actually * running a loadflow and updating the network variant with computed physical values. * *

It may, additionally, provide methods to support implementation-specific parameters. * Specific parameters should be implemented as an implementation of {@link Extension}. * *

    *
  • In order to support JSON serialization for those specific parameters, * implementing {@link #getSpecificParametersSerializer()} is required.
  • *
  • In order to support loading specific parameters from platform configuration, * implementing {@link #loadSpecificParameters(PlatformConfig)} is required.
  • *
* * @author Geoffroy Jamgotchian {@literal } */ public interface LoadFlowProvider extends Versionable, PlatformConfigNamedProvider { static List findAll() { return Lists.newArrayList(ServiceLoader.load(LoadFlowProvider.class, LoadFlowProvider.class.getClassLoader())); } /** * Run a loadflow on variant {@code workingVariantId} of {@code network} delegating external program execution to * {@code computationManager} if necessary and using loadflow execution {@code parameters}. This method is expected * to be stateless so that it can be call simultaneously with different arguments (a different network for instance) * without any concurrency issue. * * @param network the network * @param computationManager a computation manager to external program execution * @param workingVariantId variant id of the network * @param parameters load flow execution parameters * @param reportNode the reportNode used for functional logs * @return a {@link CompletableFuture} on {@link LoadFlowResult] */ CompletableFuture run(Network network, ComputationManager computationManager, String workingVariantId, LoadFlowParameters parameters, ReportNode reportNode); /** * Get specific parameters class. * * @return The specific parameters class */ Optional>> getSpecificParametersClass(); /** * The serializer for implementation-specific parameters, or {@link Optional#empty()} if the implementation * does not have any specific parameters, or does not support JSON serialization. * *

Note that the actual serializer type should be {@code ExtensionJsonSerializer} * where {@code MyParametersExtension} is the specific parameters class. * * @return The serializer for implementation-specific parameters. */ Optional getSpecificParametersSerializer(); /** * Reads implementation-specific parameters from platform config, or return {@link Optional#empty()} * if the implementation does not have any specific parameters, or does not support loading from config. * * @return The specific parameters read from platform config. */ Optional> loadSpecificParameters(PlatformConfig config); /** * Reads implementation-specific parameters from a Map, or return {@link Optional#empty()} * if the implementation does not have any specific parameters, or does not support loading from config. * * @return The specific parameters read from Map. */ Optional> loadSpecificParameters(Map properties); /** * Create a `Map` of parameter name / `String` value from implementation-specific parameters. * If the implementation does not have any specific parameters, `Map` is empty. * * @param extension the specific parameters * @return A `Map` of parameter name / `String` value */ Map createMapFromSpecificParameters(Extension extension); /** * Updates implementation-specific parameters from a Map. */ void updateSpecificParameters(Extension extension, Map properties); /** * Get the parameters of the parameters extension associated with this provider. * * @return the parameters of the parameters extension associated with this provider. */ List getSpecificParameters(); /** * Retrieves the parameters of the extension associated with this provider, * incorporating any overrides from the PlatformConfig. * * @return The parameters of the associated extension with overrides applied from PlatformConfig. */ default List getSpecificParameters(PlatformConfig platformConfigConfig) { return ConfiguredParameter.load(getSpecificParameters(), getModuleConfig(platformConfigConfig).orElse(null)); } /** * Retrieves the configuration of the specific module for this provider from the provided PlatformConfig. * * @param platformConfig The platform configuration containing potential module configurations. * @return An Optional containing the ModuleConfig if present, otherwise an empty Optional. */ default Optional getModuleConfig(PlatformConfig platformConfig) { throw new UnsupportedOperationException("Not implemented"); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy