From 7676b9b674ffc268d8c67915b8e54f44d22449fa Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Wed, 4 May 2022 10:25:46 -0600 Subject: [PATCH] check for tubes with inner radius of 0; set pressure drag to 0 and set a warning --- core/resources/l10n/messages.properties | 1 + .../src/net/sf/openrocket/aerodynamics/Warning.java | 1 + .../openrocket/aerodynamics/barrowman/TubeCalc.java | 13 ++++++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 0b0465672..793192541 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -1759,6 +1759,7 @@ Warning.ZERO_RADIUS_BODY = Zero length bodies may not result in accurate simulat Warning.TUBE_STABILITY = Tube fin stability calculations may not be accurate. Warning.TUBE_SEPARATION = Space between tube fins may not result in accurate simulations. Warning.TUBE_OVERLAP = Overlapping tube fins may not result in accurate simulations. +Warning.ZERO_INNER_RADIUS = Tube with inner radius 0 may not result in accurate simulations. ! Scale dialog ScaleDialog.lbl.scaleRocket = Entire rocket diff --git a/core/src/net/sf/openrocket/aerodynamics/Warning.java b/core/src/net/sf/openrocket/aerodynamics/Warning.java index 0653b1a3e..fb91ad967 100644 --- a/core/src/net/sf/openrocket/aerodynamics/Warning.java +++ b/core/src/net/sf/openrocket/aerodynamics/Warning.java @@ -395,4 +395,5 @@ public abstract class Warning { public static final Warning TUBE_STABILITY = new Other(trans.get("Warning.TUBE_STABILITY")); public static final Warning TUBE_SEPARATION = new Other(trans.get("Warning.TUBE_SEPARATION")); public static final Warning TUBE_OVERLAP = new Other(trans.get("Warning.TUBE_OVERLAP")); + public static final Warning ZERO_INNER_RADIUS = new Other(trans.get("Warning.ZERO_INNER_RADIUS")); } diff --git a/core/src/net/sf/openrocket/aerodynamics/barrowman/TubeCalc.java b/core/src/net/sf/openrocket/aerodynamics/barrowman/TubeCalc.java index 60117d808..8f63730fc 100644 --- a/core/src/net/sf/openrocket/aerodynamics/barrowman/TubeCalc.java +++ b/core/src/net/sf/openrocket/aerodynamics/barrowman/TubeCalc.java @@ -1,6 +1,7 @@ package net.sf.openrocket.aerodynamics.barrowman; import net.sf.openrocket.aerodynamics.FlightConditions; +import net.sf.openrocket.aerodynamics.Warning; import net.sf.openrocket.aerodynamics.WarningSet; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.Tube; @@ -34,10 +35,16 @@ public abstract class TubeCalc extends RocketComponentCalc { // Volume flow rate final double Q = conditions.getVelocity() * refArea; - // pressure drop - final double deltap = 1.6 * Math.pow(Q, 1.85) * length / + // pressure drop. + final double deltap; + if (refArea == 0) { + warnings.add(Warning.ZERO_INNER_RADIUS); + deltap = 0; + } else { + deltap = 1.6 * Math.pow(Q, 1.85) * length / (Math.pow(diameter, 5) * conditions.getAtmosphericConditions().getPressure()); - + } + // convert to CD and return return deltap * refArea / conditions.getRefArea(); }