From 1d0ef06a385b3e58611ee2258238d13ee4582268 Mon Sep 17 00:00:00 2001 From: Bill Kuker Date: Thu, 2 Dec 2010 01:04:08 +0000 Subject: [PATCH] Added some tests and fix for edge cases where in and out of cored grain are inhibited. Stupid motor design, but whatever --- .../motorsim/grain/CoredCylindricalGrain.java | 18 +++--- .../test/CoredCylindricalGrainTest.java | 60 +++++++++++++++++++ 2 files changed, 69 insertions(+), 9 deletions(-) diff --git a/src/com/billkuker/rocketry/motorsim/grain/CoredCylindricalGrain.java b/src/com/billkuker/rocketry/motorsim/grain/CoredCylindricalGrain.java index 6248239..3fdb4dc 100644 --- a/src/com/billkuker/rocketry/motorsim/grain/CoredCylindricalGrain.java +++ b/src/com/billkuker/rocketry/motorsim/grain/CoredCylindricalGrain.java @@ -144,20 +144,20 @@ public class CoredCylindricalGrain extends ExtrudedGrain implements Validating { } public Amount webThickness() { - if ( innerSurfaceInhibited && outerSurfaceInhibited ){ - return oD; //TODO gotta move this to the end - } + + Amount axial = null; + if ( numberOfBurningEnds(Amount.valueOf(0, SI.MILLIMETER)) != 0 ) + axial = getLength().divide(numberOfBurningEnds(Amount.valueOf(0, SI.MILLIMETER))); Amount radial = null; - if ( !innerSurfaceInhibited && !outerSurfaceInhibited ) + if ( !innerSurfaceInhibited && !outerSurfaceInhibited ){ radial = oD.minus(iD).divide(4); //Outer and inner exposed - else if ( !innerSurfaceInhibited || !outerSurfaceInhibited ) + } else if ( !innerSurfaceInhibited || !outerSurfaceInhibited ){ radial = oD.minus(iD).divide(2); //Outer or inner exposed + } else if ( innerSurfaceInhibited && outerSurfaceInhibited ){ + return axial; + } - Amount axial = null; - - if ( numberOfBurningEnds(Amount.valueOf(0, SI.MILLIMETER)) != 0 ) - axial = getLength().divide(numberOfBurningEnds(Amount.valueOf(0, SI.MILLIMETER))); if ( axial == null ) return radial; diff --git a/test/com/billkuker/rocketry/motorsim/test/CoredCylindricalGrainTest.java b/test/com/billkuker/rocketry/motorsim/test/CoredCylindricalGrainTest.java index e461f55..9bddb05 100644 --- a/test/com/billkuker/rocketry/motorsim/test/CoredCylindricalGrainTest.java +++ b/test/com/billkuker/rocketry/motorsim/test/CoredCylindricalGrainTest.java @@ -50,7 +50,67 @@ public class CoredCylindricalGrainTest extends AbstractRocketTest { assertApproximate(g.webThickness(), Amount.valueOf("50mm")); } + + @Test + public void testWebThicknessSkinny2Ends() throws PropertyVetoException { + CoredCylindricalGrain g = new CoredCylindricalGrain(); + + //thin and long + g.setLength(Amount.valueOf(100, SI.MILLIMETER)); + g.setOD(Amount.valueOf(30, SI.MILLIMETER)); + g.setID(Amount.valueOf(10, SI.MILLIMETER)); + g.setInnerSurfaceInhibited(true); + g.setOuterSurfaceInhibited(true); + + assertApproximate(g.webThickness(), Amount.valueOf("50mm")); + } + + @Test + public void testWebThicknessSkinny1End() throws PropertyVetoException { + CoredCylindricalGrain g = new CoredCylindricalGrain(); + + //thin and long + g.setLength(Amount.valueOf(100, SI.MILLIMETER)); + g.setOD(Amount.valueOf(30, SI.MILLIMETER)); + g.setID(Amount.valueOf(10, SI.MILLIMETER)); + g.setInnerSurfaceInhibited(true); + g.setOuterSurfaceInhibited(true); + g.setForeEndInhibited(true); + + assertApproximate(g.webThickness(), Amount.valueOf("100mm")); + + } + + @Test + public void testWebThicknessFat2Ends() throws PropertyVetoException { + CoredCylindricalGrain g = new CoredCylindricalGrain(); + + g.setLength(Amount.valueOf(100, SI.MILLIMETER)); + g.setOD(Amount.valueOf(60, SI.MILLIMETER)); + g.setID(Amount.valueOf(20, SI.MILLIMETER)); + g.setInnerSurfaceInhibited(true); + g.setOuterSurfaceInhibited(true); + + assertApproximate(g.webThickness(), Amount.valueOf("50mm")); + + } + + @Test + public void testWebThicknessFat1End() throws PropertyVetoException { + CoredCylindricalGrain g = new CoredCylindricalGrain(); + + g.setLength(Amount.valueOf(20, SI.MILLIMETER)); + g.setOD(Amount.valueOf(60, SI.MILLIMETER)); + g.setID(Amount.valueOf(20, SI.MILLIMETER)); + g.setInnerSurfaceInhibited(true); + g.setOuterSurfaceInhibited(true); + g.setForeEndInhibited(true); + + assertApproximate(g.webThickness(), Amount.valueOf("20mm")); + + } + @Test public void testVolume() throws PropertyVetoException { CoredCylindricalGrain g = new CoredCylindricalGrain(); -- 2.47.2