mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-12 05:35:31 +00:00
Fixed runtime errors in testORCPerformanceCurve. Calculation following.
This commit is contained in:
1 parent
0dcaf9d2be
commit
28a6ecfb7b
4 files changed
+23
-18
No files matched your search
+8
-5
@@ -24,12 +24,14 @@ import com.sap.sailing.domain.orc.impl.ORCCertificateImporterJSON;
|
||||
import com.sap.sailing.domain.orc.impl.ORCPerformanceCurveCourseImpl;
|
||||
import com.sap.sailing.domain.orc.impl.ORCPerformanceCurveImpl;
|
||||
import com.sap.sailing.domain.orc.impl.ORCPerformanceCurveLegImpl;
|
||||
import com.sap.sse.common.Distance;
|
||||
import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.Speed;
|
||||
import com.sap.sse.common.impl.DegreeBearingImpl;
|
||||
|
||||
public class TestORCPerformanceCurve {
|
||||
|
||||
// for the usage of
|
||||
private final boolean collectErrors = true;
|
||||
|
||||
private static ORCPerformanceCurveCourse course;
|
||||
@@ -128,16 +130,17 @@ public class TestORCPerformanceCurve {
|
||||
Double accuracy = 0.1;
|
||||
ORCCertificateImpl certificate = (ORCCertificateImpl) importer.getCertificate("GER 5549");
|
||||
ORCPerformanceCurveImpl performanceCurve = (ORCPerformanceCurveImpl) certificate.getPerformanceCurve(course);
|
||||
double courseLengthNauticalMiles = course.getTotalLength().getNauticalMiles();
|
||||
|
||||
assertEquals( 11.5, performanceCurve.getImpliedWind(performanceCurve.getAllowancePerCourse(new KnotSpeedImpl( 11.5))).getKnots(), accuracy);
|
||||
assertEquals(17.23, performanceCurve.getImpliedWind(performanceCurve.getAllowancePerCourse(new KnotSpeedImpl(17.23))).getKnots(), accuracy);
|
||||
assertEquals( 18, performanceCurve.getImpliedWind(performanceCurve.getAllowancePerCourse(new KnotSpeedImpl( 18))).getKnots(), accuracy);
|
||||
|
||||
assertEquals( 450, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(450))).asSeconds(), accuracy);
|
||||
assertEquals( 500, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(500))).asSeconds(), accuracy);
|
||||
assertEquals( 600, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(600))).asSeconds(), accuracy);
|
||||
assertEquals( 700, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(700))).asSeconds(), accuracy);
|
||||
assertEquals( 750, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(750))).asSeconds(), accuracy);
|
||||
assertEquals( 450, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(450).times(courseLengthNauticalMiles))).asSeconds(), accuracy);
|
||||
assertEquals( 500, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(500).times(courseLengthNauticalMiles))).asSeconds(), accuracy);
|
||||
assertEquals( 600, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(600).times(courseLengthNauticalMiles))).asSeconds(), accuracy);
|
||||
assertEquals( 700, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(700).times(courseLengthNauticalMiles))).asSeconds(), accuracy);
|
||||
assertEquals( 750, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(750).times(courseLengthNauticalMiles))).asSeconds(), accuracy);
|
||||
}
|
||||
|
||||
// Tests for a Implied Wind calculation for a simple predefined course. The solutions are extracted from the provided ORC TestPCS.exe application.
|
||||
|
||||
@@ -40,17 +40,13 @@ public interface ORCCertificate {
|
||||
* Returns the GPH value for the {@link Competitor}. The GPH value represents the overall performance of the boat.
|
||||
* The value itself is again an allowance (in seconds per nautical mile) and could be used as a ToD Factor.
|
||||
* Most of the times it is used to divide a big fleet into similar fast divisions.
|
||||
*
|
||||
* @return double value in seconds per nautical mile
|
||||
*/
|
||||
public double getGPH();
|
||||
|
||||
/**
|
||||
* Returns the CDL (Class Division Length) value for the {@link Competitor}. This value is another (and newer) approach to rate the overall performance of different boats.
|
||||
* The different division intervals are - in contrast to the intervals of the GPH - set by the Offshore Race Committee and not by the national association for a uniform handling.
|
||||
* The higher the value, the higher the overall performance.
|
||||
*
|
||||
* @return double value in meter
|
||||
* The higher the value, the higher the overall performance, it is measured in meters.
|
||||
*/
|
||||
public double getCDL();
|
||||
|
||||
|
||||
+13
-7
@@ -176,25 +176,31 @@ public class ORCPerformanceCurveImpl implements Serializable, ORCPerformanceCurv
|
||||
}
|
||||
|
||||
@Override
|
||||
public Speed getImpliedWind(Duration time) throws MaxIterationsExceededException, FunctionEvaluationException{
|
||||
public Speed getImpliedWind(Duration totalTime) throws MaxIterationsExceededException, FunctionEvaluationException{
|
||||
PolynomialFunction workingFunction;
|
||||
double timePerNauticalMileInSeconds = totalTime.divide(course.getTotalLength().getNauticalMiles()).asSeconds();
|
||||
double[] allowancesInSeconds = new double[functionImpliedWindToAllowance.getKnots().length];
|
||||
|
||||
// TODO Corner cases for Allowance > Allowance(20kt) or Allowance < Allowance(6kt)
|
||||
|
||||
for (int i = 0; i < allowancesInSeconds.length; i++) {
|
||||
for(int i = 0; i < allowancesInSeconds.length; i++) {
|
||||
allowancesInSeconds[i] = functionImpliedWindToAllowance.value(functionImpliedWindToAllowance.getKnots()[i]);
|
||||
}
|
||||
|
||||
// Corner cases for Allowance > Allowance(20kt) or Allowance < Allowance(6kt)
|
||||
if(timePerNauticalMileInSeconds >= allowancesInSeconds[allowancesInSeconds.length - 1]) {
|
||||
return new KnotSpeedImpl(6);
|
||||
} else if (timePerNauticalMileInSeconds >= allowancesInSeconds[0]) {
|
||||
return new KnotSpeedImpl(20);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while(i < allowancesInSeconds.length && time.asSeconds() <= allowancesInSeconds[i]) {
|
||||
while(i < allowancesInSeconds.length && timePerNauticalMileInSeconds >= allowancesInSeconds[i]) {
|
||||
i += 1;
|
||||
}
|
||||
i -= 1;
|
||||
workingFunction = functionImpliedWindToAllowance.getPolynomials()[i];
|
||||
|
||||
//PolynomialFunction which will be solved by the Newton Approach
|
||||
PolynomialFunction subtractedFunction = workingFunction.subtract(new PolynomialFunction(new double[] {time.asSeconds()}));
|
||||
PolynomialFunction subtractedFunction = workingFunction.subtract(new PolynomialFunction(new double[] {timePerNauticalMileInSeconds}));
|
||||
NewtonSolver solver = new NewtonSolver();
|
||||
solver.setAbsoluteAccuracy(0.000001);
|
||||
//TODO Comment for the special treatment of the solver
|
||||
@@ -207,7 +213,7 @@ public class ORCPerformanceCurveImpl implements Serializable, ORCPerformanceCurv
|
||||
public Duration getAllowancePerCourse(Speed impliedWind) {
|
||||
// TODO Corner cases for ImpliedWind > 20kt or ImpliedWind < 6kt
|
||||
try {
|
||||
return Duration.ONE_SECOND.times(functionImpliedWindToAllowance.value(impliedWind.getKnots()));
|
||||
return Duration.ONE_SECOND.times(functionImpliedWindToAllowance.value(impliedWind.getKnots()) * course.getTotalLength().getNauticalMiles());
|
||||
} catch (ArgumentOutsideDomainException e) {
|
||||
// TODO Auto-generated catch block
|
||||
// TODO Create senseful Exception Handling for this class, Logging ...
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ public class ORCPerformanceCurveLegImpl implements ORCPerformanceCurveLeg {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ORCPerformanceCurveLegImpl [length=" + length.getNauticalMiles() + " nm, twa=" + twa.getDegrees() + "°]";
|
||||
return "ORCPerformanceCurveLegImpl [length=" + length.getNauticalMiles() + " nm, twa=" + twa.getDegrees() + "°]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user