From 29351262b0fcfeed97a1821852203477d3e516ad Mon Sep 17 00:00:00 2001 From: Gautier Bureau Date: Wed, 8 Nov 2023 13:58:41 +0100 Subject: [PATCH] Add and fix some Dynamic simulation solvers parameters. Signed-off-by: Gautier Bureau --- .../solver/IdaSolverInfos.java | 46 ++++++++++ .../solver/SimSolverInfos.java | 88 ++++++++++++++++--- .../DynamicSimulationService.java | 79 ++++++++++++++--- 3 files changed, 190 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/dto/dynamicsimulation/solver/IdaSolverInfos.java b/src/main/java/org/gridsuite/study/server/dto/dynamicsimulation/solver/IdaSolverInfos.java index 818f913b64..0692eafbe5 100644 --- a/src/main/java/org/gridsuite/study/server/dto/dynamicsimulation/solver/IdaSolverInfos.java +++ b/src/main/java/org/gridsuite/study/server/dto/dynamicsimulation/solver/IdaSolverInfos.java @@ -32,4 +32,50 @@ public class IdaSolverInfos extends AbstractSolverInfos { private double absAccuracy; private double relAccuracy; + + private double fnormtolAlg; + + private double initialaddtolAlg; + + private double scsteptolAlg; + + private double mxnewtstepAlg; + + private int msbsetAlg; + + private int mxiterAlg; + + private int printflAlg; + + private double fnormtolAlgJ; + + private double initialaddtolAlgJ; + + private double scsteptolAlgJ; + + private double mxnewtstepAlgJ; + + private int msbsetAlgJ; + + private int mxiterAlgJ; + + private int printflAlgJ; + + private double fnormtolAlgInit; + + private double initialaddtolAlgInit; + + private double scsteptolAlgInit; + + private double mxnewtstepAlgInit; + + private int msbsetAlgInit; + + private int mxiterAlgInit; + + private int printflAlgInit; + + private int maximumNumberSlowStepIncrease; + + private double minimalAcceptableStep; } diff --git a/src/main/java/org/gridsuite/study/server/dto/dynamicsimulation/solver/SimSolverInfos.java b/src/main/java/org/gridsuite/study/server/dto/dynamicsimulation/solver/SimSolverInfos.java index b69d3719c8..9b724e0629 100644 --- a/src/main/java/org/gridsuite/study/server/dto/dynamicsimulation/solver/SimSolverInfos.java +++ b/src/main/java/org/gridsuite/study/server/dto/dynamicsimulation/solver/SimSolverInfos.java @@ -22,29 +22,95 @@ @Setter public class SimSolverInfos extends AbstractSolverInfos { + public static final String H_MIN = "hMin"; + public static final String H_MAX = "hMax"; + public static final String K_REDUCE_STEP = "kReduceStep"; + // Important note: must using @JsonProperty to precise property's name when serialize/deserialize // fields which begin by a minuscule following by a majuscule, for example 'hMxxx', otherwise jackson // mapper will serialize as 'hmxxx' by default - @JsonProperty("hMin") + @JsonProperty(H_MIN) private double hMin; - @JsonProperty("hMax") + @JsonProperty(H_MAX) private double hMax; - @JsonProperty("kReduceStep") + @JsonProperty(K_REDUCE_STEP) private double kReduceStep; - @JsonProperty("nEff") - private int nEff; + private int maxNewtonTry; - @JsonProperty("nDeadband") - private int nDeadband; + private String linearSolverName; - private int maxRootRestart; + private double fnormtol; - private int maxNewtonTry; + private double initialaddtol; - private String linearSolverName; + private double scsteptol; + + private double mxnewtstep; + + private int msbset; + + private int mxiter; + + private int printfl; + + private boolean optimizeAlgebraicResidualsEvaluations; + + private boolean skipNRIfInitialGuessOK; + + private boolean enableSilentZ; + + private boolean optimizeReinitAlgebraicResidualsEvaluations; + + private String minimumModeChangeTypeForAlgebraicRestoration; + + private String minimumModeChangeTypeForAlgebraicRestorationInit; + + private double fnormtolAlg; + + private double initialaddtolAlg; + + private double scsteptolAlg; + + private double mxnewtstepAlg; + + private int msbsetAlg; + + private int mxiterAlg; + + private int printflAlg; + + private double fnormtolAlgJ; + + private double initialaddtolAlgJ; + + private double scsteptolAlgJ; + + private double mxnewtstepAlgJ; + + private int msbsetAlgJ; + + private int mxiterAlgJ; + + private int printflAlgJ; + + private double fnormtolAlgInit; + + private double initialaddtolAlgInit; + + private double scsteptolAlgInit; + + private double mxnewtstepAlgInit; + + private int msbsetAlgInit; + + private int mxiterAlgInit; + + private int printflAlgInit; + + private int maximumNumberSlowStepIncrease; - private boolean recalculateStep; + private double minimalAcceptableStep; } diff --git a/src/main/java/org/gridsuite/study/server/service/dynamicsimulation/DynamicSimulationService.java b/src/main/java/org/gridsuite/study/server/service/dynamicsimulation/DynamicSimulationService.java index 1926a8a46f..da7ed991ed 100644 --- a/src/main/java/org/gridsuite/study/server/service/dynamicsimulation/DynamicSimulationService.java +++ b/src/main/java/org/gridsuite/study/server/service/dynamicsimulation/DynamicSimulationService.java @@ -92,27 +92,82 @@ static DynamicSimulationParametersInfos fromEntity(DynamicSimulationParametersEn static DynamicSimulationParametersInfos getDefaultDynamicSimulationParameters() { // these parameters are taken from solver.par file in dynamic simulation server IdaSolverInfos idaSolver = new IdaSolverInfos(); - idaSolver.setId("1"); + idaSolver.setId("IDA"); idaSolver.setType(SolverTypeInfos.IDA); - idaSolver.setOrder(1); - idaSolver.setInitStep(0.000001); - idaSolver.setMinStep(0.000001); + idaSolver.setOrder(2); + idaSolver.setInitStep(1.e-7); + idaSolver.setMinStep(1.e-7); idaSolver.setMaxStep(10); - idaSolver.setAbsAccuracy(0.0001); - idaSolver.setRelAccuracy(0.0001); + idaSolver.setAbsAccuracy(1.e-4); + idaSolver.setRelAccuracy(1.e-4); + idaSolver.setFnormtolAlg(1.e-4); + idaSolver.setInitialaddtolAlg(1); + idaSolver.setScsteptolAlg(1.e-4); + idaSolver.setMxnewtstepAlg(10000); + idaSolver.setMsbsetAlg(5); + idaSolver.setMxiterAlg(30); + idaSolver.setPrintflAlg(0); + idaSolver.setFnormtolAlgJ(1.e-4); + idaSolver.setInitialaddtolAlgJ(1); + idaSolver.setScsteptolAlgJ(1.e-4); + idaSolver.setMxnewtstepAlgJ(10000); + idaSolver.setMsbsetAlgJ(1); + idaSolver.setMxiterAlgJ(50); + idaSolver.setPrintflAlgJ(0); + idaSolver.setFnormtolAlgInit(1.e-4); + idaSolver.setInitialaddtolAlgInit(1); + idaSolver.setScsteptolAlgInit(1.e-4); + idaSolver.setMxnewtstepAlgInit(10000); + idaSolver.setMsbsetAlgInit(1); + idaSolver.setMxiterAlgInit(50); + idaSolver.setPrintflAlgInit(0); + idaSolver.setMinimalAcceptableStep(1.e-8); + idaSolver.setMaximumNumberSlowStepIncrease(40); SimSolverInfos simSolver = new SimSolverInfos(); - simSolver.setId("3"); + simSolver.setId("SIM"); simSolver.setType(SolverTypeInfos.SIM); - simSolver.setHMin(0.000001); + simSolver.setHMin(0.001); simSolver.setHMax(1); simSolver.setKReduceStep(0.5); - simSolver.setNEff(10); - simSolver.setNDeadband(2); - simSolver.setMaxRootRestart(3); simSolver.setMaxNewtonTry(10); simSolver.setLinearSolverName("KLU"); - simSolver.setRecalculateStep(false); + simSolver.setFnormtol(1.e-3); + simSolver.setInitialaddtol(1); + simSolver.setScsteptol(1.e-3); + simSolver.setMxnewtstep(10000); + simSolver.setMsbset(0); + simSolver.setMxiter(15); + simSolver.setPrintfl(0); + simSolver.setOptimizeAlgebraicResidualsEvaluations(true); + simSolver.setSkipNRIfInitialGuessOK(true); + simSolver.setEnableSilentZ(true); + simSolver.setOptimizeReinitAlgebraicResidualsEvaluations(true); + simSolver.setMinimumModeChangeTypeForAlgebraicRestoration("ALGEBRAIC_J_UPDATE"); + simSolver.setMinimumModeChangeTypeForAlgebraicRestorationInit("ALGEBRAIC_J_UPDATE"); + simSolver.setFnormtolAlg(1.e-3); + simSolver.setInitialaddtolAlg(1); + simSolver.setScsteptolAlg(1.e-3); + simSolver.setMxnewtstepAlg(10000); + simSolver.setMsbsetAlg(5); + simSolver.setMxiterAlg(30); + simSolver.setPrintflAlg(0); + simSolver.setFnormtolAlgJ(1.e-3); + simSolver.setInitialaddtolAlgJ(1); + simSolver.setScsteptolAlgJ(1.e-3); + simSolver.setMxnewtstepAlgJ(10000); + simSolver.setMsbsetAlgJ(1); + simSolver.setMxiterAlgJ(50); + simSolver.setPrintflAlgJ(0); + simSolver.setFnormtolAlgInit(1.e-3); + simSolver.setInitialaddtolAlgInit(1); + simSolver.setScsteptolAlgInit(1.e-3); + simSolver.setMxnewtstepAlgInit(10000); + simSolver.setMsbsetAlgInit(1); + simSolver.setMxiterAlgInit(50); + simSolver.setPrintflAlgInit(0); + simSolver.setMinimalAcceptableStep(1.e-3); + simSolver.setMaximumNumberSlowStepIncrease(40); List solvers = List.of(idaSolver, simSolver);