From: Bill Kuker Date: Wed, 22 Apr 2009 20:44:11 +0000 (+0000) Subject: Added some fun motor examples X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=431d4e160cb1f01e60ab4cf606e2e667a82ce980;p=sw%2Fmotorsim Added some fun motor examples --- diff --git a/.fatjar b/.fatjar index 8ef928c..906b714 100644 --- a/.fatjar +++ b/.fatjar @@ -1,10 +1,10 @@ #Fat Jar Configuration File -#Thu Apr 16 10:44:22 EDT 2009 +#Mon Apr 20 13:05:59 EDT 2009 onejar.license.required=true manifest.classpath= manifest.removesigners=true onejar.checkbox=false -jarname=MotorSim-0.1.jar +jarname=MotorSim-0.2.jar manifest.mergeall=true manifest.mainclass=com.billkuker.rocketry.motorsim.visual.CrappyEditor manifest.file= diff --git a/MotorSim-0.2.jar b/MotorSim-0.2.jar new file mode 100644 index 0000000..e4a3553 Binary files /dev/null and b/MotorSim-0.2.jar differ diff --git a/src/com/billkuker/rocketry/motorsim/motors/example/CSlot.java b/src/com/billkuker/rocketry/motorsim/motors/example/CSlot.java new file mode 100644 index 0000000..bcb71eb --- /dev/null +++ b/src/com/billkuker/rocketry/motorsim/motors/example/CSlot.java @@ -0,0 +1,55 @@ +package com.billkuker.rocketry.motorsim.motors.example; + +import java.awt.Shape; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Rectangle2D; + +import javax.measure.unit.SI; + +import org.jscience.physics.amount.Amount; + +import com.billkuker.rocketry.motorsim.Burn; +import com.billkuker.rocketry.motorsim.ConvergentDivergentNozzle; +import com.billkuker.rocketry.motorsim.CylindricalChamber; +import com.billkuker.rocketry.motorsim.Motor; +import com.billkuker.rocketry.motorsim.fuel.KNSU; +import com.billkuker.rocketry.motorsim.grain.ExtrudedShapeGrain; + +public class CSlot extends Motor { + public CSlot() { + setName("C-Slot"); + setFuel(new KNSU()); + + CylindricalChamber c = new CylindricalChamber(); + c.setLength(Amount.valueOf(150, SI.MILLIMETER)); + c.setID(Amount.valueOf(50, SI.MILLIMETER)); + setChamber(c); + + setGrain(new ExtrudedShapeGrain() { + { + try { + Shape outside = new Ellipse2D.Double(0, 0, 30, 30); + xsection.add(outside); + xsection.inhibit(outside); + xsection.subtract(new Rectangle2D.Double(12.5,13, 5, 30)); + setLength(Amount.valueOf(150, SI.MILLIMETER)); + setForeEndInhibited(false); + setAftEndInhibited(false); + } catch (Exception e) { + throw new Error(e); + } + } + }); + + ConvergentDivergentNozzle n = new ConvergentDivergentNozzle(); + n.setThroatDiameter(Amount.valueOf(7, SI.MILLIMETER)); + n.setExitDiameter(Amount.valueOf(10, SI.MILLIMETER)); + n.setEfficiency(.85); + setNozzle(n); + } + + public static void main(String args[]){ + new Burn(new CSlot()); + } + +} diff --git a/src/com/billkuker/rocketry/motorsim/motors/example/EndBurner.java b/src/com/billkuker/rocketry/motorsim/motors/example/EndBurner.java new file mode 100644 index 0000000..180b3d5 --- /dev/null +++ b/src/com/billkuker/rocketry/motorsim/motors/example/EndBurner.java @@ -0,0 +1,47 @@ +package com.billkuker.rocketry.motorsim.motors.example; + +import java.awt.Shape; +import java.awt.geom.Rectangle2D; + +import javax.measure.unit.SI; + +import org.jscience.physics.amount.Amount; + +import com.billkuker.rocketry.motorsim.ConvergentDivergentNozzle; +import com.billkuker.rocketry.motorsim.CylindricalChamber; +import com.billkuker.rocketry.motorsim.Motor; +import com.billkuker.rocketry.motorsim.fuel.KNSU; +import com.billkuker.rocketry.motorsim.grain.RotatedShapeGrain; + +public class EndBurner extends Motor { + public EndBurner() { + setName("End Burner"); + setFuel(new KNSU()); + + CylindricalChamber c = new CylindricalChamber(); + c.setLength(Amount.valueOf(150, SI.MILLIMETER)); + c.setID(Amount.valueOf(50, SI.MILLIMETER)); + setChamber(c); + + setGrain(new RotatedShapeGrain() { + { + try { + Shape outside = new Rectangle2D.Double(0, 0, 15, 70); + shape.add(outside); + shape.inhibit(outside); + shape.subtract(new Rectangle2D.Double(0, 50, 5, 70)); + shape.subtract(new Rectangle2D.Double(0, 70, 15, 10)); + } catch (Exception e) { + throw new Error(e); + } + } + }); + + ConvergentDivergentNozzle n = new ConvergentDivergentNozzle(); + n.setThroatDiameter(Amount.valueOf(4, SI.MILLIMETER)); + n.setExitDiameter(Amount.valueOf(9, SI.MILLIMETER)); + n.setEfficiency(.85); + setNozzle(n); + } + +} diff --git a/src/com/billkuker/rocketry/motorsim/motors/kuker/RotatedTest.java b/src/com/billkuker/rocketry/motorsim/motors/kuker/RotatedTest.java deleted file mode 100644 index bc8550b..0000000 --- a/src/com/billkuker/rocketry/motorsim/motors/kuker/RotatedTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.billkuker.rocketry.motorsim.motors.kuker; - -import java.beans.PropertyVetoException; - -import javax.measure.unit.SI; - -import org.jscience.physics.amount.Amount; - -import com.billkuker.rocketry.motorsim.Burn; -import com.billkuker.rocketry.motorsim.ConvergentDivergentNozzle; -import com.billkuker.rocketry.motorsim.CylindricalChamber; -import com.billkuker.rocketry.motorsim.Motor; -import com.billkuker.rocketry.motorsim.fuel.KNSU; -import com.billkuker.rocketry.motorsim.grain.CoredCylindricalGrain; -import com.billkuker.rocketry.motorsim.grain.MultiGrain; -import com.billkuker.rocketry.motorsim.grain.RotatedShapeGrain; -import com.billkuker.rocketry.motorsim.visual.BurnPanel; - -public class RotatedTest extends Motor { - public RotatedTest(){ - setName("R-Test"); - setFuel(new KNSU()); - - CylindricalChamber c = new CylindricalChamber(); - c.setLength(Amount.valueOf(200, SI.MILLIMETER)); - c.setID(Amount.valueOf(25, SI.MILLIMETER)); - setChamber(c); - - - setGrain( RotatedShapeGrain.DEFAULT_GRAIN ); - - ConvergentDivergentNozzle n = new ConvergentDivergentNozzle(); - n.setThroatDiameter(Amount.valueOf(5.962, SI.MILLIMETER)); - n.setExitDiameter(Amount.valueOf(13.79, SI.MILLIMETER)); - n.setEfficiency(.85); - setNozzle(n); - } - - public static void main(String args[]) throws Exception{ - RotatedTest m = new RotatedTest(); - Burn b = new Burn(m); - new BurnPanel(b).showAsWindow(); - } -} diff --git a/src/com/billkuker/rocketry/motorsim/visual/CrappyEditor.java b/src/com/billkuker/rocketry/motorsim/visual/CrappyEditor.java index aca1bfb..315d4a9 100644 --- a/src/com/billkuker/rocketry/motorsim/visual/CrappyEditor.java +++ b/src/com/billkuker/rocketry/motorsim/visual/CrappyEditor.java @@ -28,24 +28,26 @@ import com.billkuker.rocketry.motorsim.RocketScience.UnitPreference; import com.billkuker.rocketry.motorsim.fuel.KNSU; import com.billkuker.rocketry.motorsim.grain.CoredCylindricalGrain; import com.billkuker.rocketry.motorsim.grain.MultiGrain; -import com.billkuker.rocketry.motorsim.grain.RotatedShapeGrain; import com.billkuker.rocketry.motorsim.io.MotorIO; +import com.billkuker.rocketry.motorsim.motors.example.CSlot; +import com.billkuker.rocketry.motorsim.motors.example.EndBurner; public class CrappyEditor extends JFrame { - JTabbedPane tabs = new JTabbedPane(); + JTabbedPane tabs; public CrappyEditor() { setTitle("MotorSim v0.2"); setSize(1024, 768); setDefaultCloseOperation(DISPOSE_ON_CLOSE); - setContentPane(tabs); + try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e1) { e1.printStackTrace(); } - + tabs = new JTabbedPane(); + setContentPane(tabs); tabs.addTab("Edit", new Editor(defaultMotor())); } @@ -57,6 +59,7 @@ public class CrappyEditor extends JFrame { setLayout(new BorderLayout()); add(text, BorderLayout.CENTER); JPanel buttons = new JPanel(new FlowLayout()); + buttons.add(new JButton("Burn!") { { addActionListener(new ActionListener() { @@ -66,6 +69,8 @@ public class CrappyEditor extends JFrame { }); } }); + + JRadioButton s, n; buttons.add(s = new JRadioButton("SI")); buttons.add(n = new JRadioButton("NonSI")); @@ -83,6 +88,27 @@ public class CrappyEditor extends JFrame { UnitPreference.preference = UnitPreference.NONSI; } }); + + buttons.add(new JButton("End Burner Example") { + { + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + tabs.addTab(getText(), new BurnPanel(new Burn(new EndBurner()))); + } + }); + } + }); + + buttons.add(new JButton("C-Slot Example") { + { + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + tabs.addTab(getText(), new BurnPanel(new Burn(new CSlot()))); + } + }); + } + }); + add(buttons, BorderLayout.SOUTH); text.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML); @@ -134,6 +160,7 @@ public class CrappyEditor extends JFrame { return m; } + public static void main(String args[]) { new CrappyEditor().show();