Skip to content

Commit

Permalink
factorize code
Browse files Browse the repository at this point in the history
Signed-off-by: VIDAL Didier (Externe) <[email protected]>
  • Loading branch information
vidaldid-rte committed Apr 2, 2024
1 parent 82d556b commit bc362fd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
public abstract class AbstractHvdcAcEmulationFlowEquationTerm extends AbstractElementEquationTerm<LfHvdc, AcVariableType, AcEquationType> {

static final double EPSILON = 0.1;

protected final Variable<AcVariableType> ph1Var;

protected final Variable<AcVariableType> ph2Var;
Expand Down Expand Up @@ -74,6 +72,28 @@ protected double boundedP(double rawP, double ph1, double ph2) {
}
}

/**
* Returns a "corrected value for k that is
* the droop factor between tetaMin and tetaMax
* 0 in a resonable range above tetaMin and tetaMax
* the slot between pMax and P0 for larger angle differences to help convergence
* @param ph1
* @param ph2
* @return
*/
protected double pseudoK(double rawP, double ph1, double ph2) {
double boundedP = boundedP(rawP, ph1, ph2);
double factor = k;
double teta = ph1 - ph2;
// for large values of teta return a value that helps convergence
if (teta > tetaMax) {
factor = teta < tetaMax * 2 ? 0 : boundedP / (teta - tetaZero);
} else if (teta < tetaMin) {
factor = teta > tetaMin * 2 ? 0 : boundedP / (teta - tetaZero);
}
return factor;
}

protected double ph1() {
return sv.get(ph1Var.getRow());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,7 @@ private boolean isInOperatingRange(double rawP) {

protected double dp1dph1(double ph1, double ph2) {
double rawP = rawP(ph1, ph2);
double boundedP = boundedP(rawP, ph1, ph2);
double factor = k;
double teta = ph1 - ph2;
// for large values of teta return a value that helps convergence
if (teta > tetaMax) {
factor = teta < tetaMax * 2 ? 0 : (boundedP - p0) / (teta - tetaZero);
} else if (teta < tetaMin) {
factor = teta > tetaMin * 2 ? 0 : (p0 - boundedP) / (teta - tetaZero);
}
double factor = pseudoK(rawP, ph1, ph2);
return (isController(rawP) ? 1 : getVscLossMultiplier()) * factor;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,7 @@ private boolean isInOperatingRange(double rawP) {

private double dp2dph1(double ph1, double ph2) {
double rawP = rawP(ph1, ph2);
double boundedP = boundedP(rawP, ph1, ph2);
double factor = k;
double teta = ph1 - ph2;
// for large values of teta return a value that helps convergence
if (teta > tetaMax) {
factor = teta < tetaMax * 2 ? 0 : (boundedP - p0) / (teta - tetaZero);
} else if (teta < tetaMin) {
factor = teta > tetaMin * 2 ? 0 : (p0 - boundedP) / (teta - tetaZero);
}
double factor = pseudoK(rawP, ph1, ph2);
return -(isController(rawP) ? 1 : getVscLossMultiplier()) * factor;
}

Expand Down

0 comments on commit bc362fd

Please sign in to comment.