Skip to content

Commit

Permalink
Remove workaround for specific parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebhs committed Sep 27, 2024
1 parent 1051fb9 commit ab71ab4
Showing 1 changed file with 3 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.powsybl.commons.config.PlatformConfig;
import com.powsybl.commons.parameters.Parameter;
import com.powsybl.commons.parameters.ParameterScope;
import com.powsybl.iidm.network.TwoSides;
Expand Down Expand Up @@ -79,39 +80,14 @@ public List<String> getProviders() {
}

public static Map<String, List<Parameter>> getSpecificLoadFlowParameters(String providerName) {
Map<String, List<Parameter>> powsyblSpecificLFParameters = LoadFlowProvider.findAll().stream()
return LoadFlowProvider.findAll().stream()
.filter(provider -> providerName == null || provider.getName().equals(providerName))
.map(provider -> {
List<Parameter> params = provider.getSpecificParameters().stream()
List<Parameter> params = provider.getSpecificParameters(PlatformConfig.defaultConfig()).stream()
.filter(p -> p.getScope() == ParameterScope.FUNCTIONAL)
.toList();
return Pair.of(provider.getName(), params);
}).collect(Collectors.toMap(Pair::getLeft, Pair::getRight));

// FIXME: We need to override Powsybl default values in the loadflow-server as up to now we can't override those values through PlatformConfig for the specific parameters.
// To be removed when it's fixed.
changeDefaultValue(powsyblSpecificLFParameters, "OpenLoadFlow", "writeReferenceTerminals", false);
changeDefaultValue(powsyblSpecificLFParameters, "DynaFlow", "mergeLoads", false);

return powsyblSpecificLFParameters;
}

public static void changeDefaultValue(Map<String, List<Parameter>> specificParameters, String providerName, String parameterName, Object defaultValue) {
if (specificParameters.get(providerName) == null) {
return;
}
List<Parameter> providerParams = new ArrayList<>(specificParameters.get(providerName));
providerParams.stream().filter(parameter -> parameterName.equals(parameter.getName())).findAny().ifPresent(parameterToOverride -> {
providerParams.remove(parameterToOverride);
providerParams.add(new Parameter(parameterToOverride.getName(),
parameterToOverride.getType(),
parameterToOverride.getDescription(),
defaultValue,
parameterToOverride.getPossibleValues(),
parameterToOverride.getScope()
));
});
specificParameters.put(providerName, providerParams);
}

@Override
Expand Down

0 comments on commit ab71ab4

Please sign in to comment.