commit
78e3931c9e
@ -1494,7 +1494,7 @@ class SimulationConditionsHandler extends AbstractElementHandler {
|
||||
} else if (element.equals("atmosphere")) {
|
||||
atmosphereHandler.storeSettings(conditions, warnings);
|
||||
} else if (element.equals("timestep")) {
|
||||
if (Double.isNaN(d)) {
|
||||
if (Double.isNaN(d) || d <= 0 ) {
|
||||
warnings.add("Illegal time step defined, ignoring.");
|
||||
} else {
|
||||
conditions.setTimeStep(d);
|
||||
|
@ -440,7 +440,7 @@ public abstract class FinSet extends ExternalComponent {
|
||||
|
||||
double da = (y0 + y1) * (x1 - x0) / 2;
|
||||
finArea += da;
|
||||
if (Math.abs(y0 - y1) < 0.00001) {
|
||||
if (Math.abs(y0 + y1) < 0.00001) {
|
||||
finCGx += (x0 + x1) / 2 * da;
|
||||
finCGy += y0 / 2 * da;
|
||||
} else {
|
||||
|
@ -139,7 +139,8 @@ public class RK4SimulationStepper extends AbstractSimulationStepper {
|
||||
double[] dt = new double[8];
|
||||
Arrays.fill(dt, Double.MAX_VALUE);
|
||||
|
||||
dt[0] = status.getSimulationConditions().getTimeStep();
|
||||
// If the user selected a really small timestep, use MIN_TIME_STEP instead.
|
||||
dt[0] = MathUtil.max(status.getSimulationConditions().getTimeStep(),MIN_TIME_STEP);
|
||||
dt[1] = maxTimeStep;
|
||||
dt[2] = status.getSimulationConditions().getMaximumAngleStep() / store.lateralPitchRate;
|
||||
dt[3] = Math.abs(MAX_ROLL_STEP_ANGLE / store.flightConditions.getRollRate());
|
||||
|
@ -1,6 +1,8 @@
|
||||
package net.sf.openrocket.rocketcomponent;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
@ -11,6 +13,7 @@ import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet.CrossSection;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet.TabRelativePosition;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.LineStyle;
|
||||
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
||||
|
||||
@ -18,6 +21,151 @@ import org.junit.Test;
|
||||
|
||||
public class FinSetTest extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void testTrapezoidCGComputation() {
|
||||
|
||||
{
|
||||
// This is a simple square fin with sides of 1.0.
|
||||
TrapezoidFinSet fins = new TrapezoidFinSet();
|
||||
fins.setFinCount(1);
|
||||
fins.setFinShape(1.0, 1.0, 0.0, 1.0, .005);
|
||||
|
||||
Coordinate coords = fins.getCG();
|
||||
assertEquals(1.0, fins.getFinArea(), 0.001);
|
||||
assertEquals(0.5, coords.x, 0.001);
|
||||
assertEquals(0.5, coords.y, 0.001);
|
||||
}
|
||||
|
||||
{
|
||||
// This is a trapezoid. Height 1, root 1, tip 1/2 no sweep.
|
||||
// It can be decomposed into a rectangle followed by a triangle
|
||||
// +---+
|
||||
// | \
|
||||
// | \
|
||||
// +------+
|
||||
TrapezoidFinSet fins = new TrapezoidFinSet();
|
||||
fins.setFinCount(1);
|
||||
fins.setFinShape(1.0, 0.5, 0.0, 1.0, .005);
|
||||
|
||||
Coordinate coords = fins.getCG();
|
||||
assertEquals(0.75, fins.getFinArea(), 0.001);
|
||||
assertEquals(0.3889, coords.x, 0.001);
|
||||
assertEquals(0.4444, coords.y, 0.001);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFreeformCGComputation() throws Exception {
|
||||
|
||||
{
|
||||
// This is a trapezoid. Height 1, root 1, tip 1/2 no sweep.
|
||||
// It can be decomposed into a rectangle followed by a triangle
|
||||
// +---+
|
||||
// | \
|
||||
// | \
|
||||
// +------+
|
||||
FreeformFinSet fins = new FreeformFinSet();
|
||||
fins.setFinCount(1);
|
||||
Coordinate[] points = new Coordinate[] {
|
||||
new Coordinate(0,0),
|
||||
new Coordinate(0,1),
|
||||
new Coordinate(.5,1),
|
||||
new Coordinate(1,0)
|
||||
};
|
||||
fins.setPoints(points);
|
||||
Coordinate coords = fins.getCG();
|
||||
assertEquals(0.75, fins.getFinArea(), 0.001);
|
||||
assertEquals(0.3889, coords.x, 0.001);
|
||||
assertEquals(0.4444, coords.y, 0.001);
|
||||
}
|
||||
|
||||
{
|
||||
// This is the same trapezoid as previous free form, but it has
|
||||
// some extra points along the lines.
|
||||
FreeformFinSet fins = new FreeformFinSet();
|
||||
fins.setFinCount(1);
|
||||
Coordinate[] points = new Coordinate[] {
|
||||
new Coordinate(0,0),
|
||||
new Coordinate(0,.5),
|
||||
new Coordinate(0,1),
|
||||
new Coordinate(.25,1),
|
||||
new Coordinate(.5,1),
|
||||
new Coordinate(.75,.5),
|
||||
new Coordinate(1,0)
|
||||
};
|
||||
fins.setPoints(points);
|
||||
Coordinate coords = fins.getCG();
|
||||
assertEquals(0.75, fins.getFinArea(), 0.001);
|
||||
assertEquals(0.3889, coords.x, 0.001);
|
||||
assertEquals(0.4444, coords.y, 0.001);
|
||||
}
|
||||
|
||||
{
|
||||
// This is the same trapezoid as previous free form, but it has
|
||||
// some extra points which are very close to previous points.
|
||||
// in particular for points 0 & 1,
|
||||
// y0 + y1 is very small.
|
||||
FreeformFinSet fins = new FreeformFinSet();
|
||||
fins.setFinCount(1);
|
||||
Coordinate[] points = new Coordinate[] {
|
||||
new Coordinate(0,0),
|
||||
new Coordinate(0,1E-15),
|
||||
new Coordinate(0,1),
|
||||
new Coordinate(1E-15,1),
|
||||
new Coordinate(.5,1),
|
||||
new Coordinate(.5,1-1E-15),
|
||||
new Coordinate(1,1E-15),
|
||||
new Coordinate(1,0)
|
||||
};
|
||||
fins.setPoints(points);
|
||||
Coordinate coords = fins.getCG();
|
||||
assertEquals(0.75, fins.getFinArea(), 0.001);
|
||||
assertEquals(0.3889, coords.x, 0.001);
|
||||
assertEquals(0.4444, coords.y, 0.001);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFreeFormCGWithNegativeY() throws Exception {
|
||||
// This particular fin shape is currently not allowed in OR since the y values are negative
|
||||
// however, it is possible to convert RockSim files and end up with fins which
|
||||
// have negative y values.
|
||||
|
||||
// A user submitted an ork file which could not be simulated because the fin
|
||||
// was constructed on a tail cone. It so happened that for one pair of points
|
||||
// y_n = - y_(n+1) which caused a divide by zero and resulted in CGx = NaN.
|
||||
|
||||
// This Fin set is constructed to have the same problem. It is a square and rectagle
|
||||
// where the two trailing edge corners of the rectangle satisfy y_0 = -y_1
|
||||
//
|
||||
// +---------+
|
||||
// | |
|
||||
// | |
|
||||
// +----+ |
|
||||
// | |
|
||||
// | |
|
||||
// +----+
|
||||
|
||||
FreeformFinSet fins = new FreeformFinSet();
|
||||
fins.setFinCount(1);
|
||||
Coordinate[] points = new Coordinate[] {
|
||||
new Coordinate(0,0),
|
||||
new Coordinate(0,1),
|
||||
new Coordinate(2,1),
|
||||
new Coordinate(2,-1),
|
||||
new Coordinate(1,-1),
|
||||
new Coordinate(1,0)
|
||||
};
|
||||
fins.setPoints(points);
|
||||
Coordinate coords = fins.getCG();
|
||||
assertEquals(3.0, fins.getFinArea(), 0.001);
|
||||
assertEquals(3.5/3.0, coords.x, 0.001);
|
||||
assertEquals(0.5/3.0, coords.y, 0.001);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testFreeformConvert() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user