Skip to content

Instantly share code, notes, and snippets.

@mjn33
Created July 9, 2015 10:10
Show Gist options
  • Save mjn33/178dcc665fd6963d0984 to your computer and use it in GitHub Desktop.
Save mjn33/178dcc665fd6963d0984 to your computer and use it in GitHub Desktop.
diff --git a/FerramAerospaceResearch/FARAeroComponents/FARVesselAero.cs b/FerramAerospaceResearch/FARAeroComponents/FARVesselAero.cs
index 0aef32d..01361df 100644
--- a/FerramAerospaceResearch/FARAeroComponents/FARVesselAero.cs
+++ b/FerramAerospaceResearch/FARAeroComponents/FARVesselAero.cs
@@ -83,6 +83,11 @@ namespace FerramAerospaceResearch.FARAeroComponents
get { return reynoldsNumber; }
}
+ public string DebugString
+ {
+ get { return _vehicleAero.debugString; }
+ }
+
List<GeometryPartModule> _currentGeoModules;
int geoModulesReady = 0;
diff --git a/FerramAerospaceResearch/FARAeroComponents/VehicleAerodynamics.cs b/FerramAerospaceResearch/FARAeroComponents/VehicleAerodynamics.cs
index 2e37e83..4108925 100644
--- a/FerramAerospaceResearch/FARAeroComponents/VehicleAerodynamics.cs
+++ b/FerramAerospaceResearch/FARAeroComponents/VehicleAerodynamics.cs
@@ -1154,6 +1154,8 @@ namespace FerramAerospaceResearch.FARAeroComponents
}
}
+ public string debugString = "";
+
#region Aerodynamics Calculations
private void CalculateVesselAeroProperties()
@@ -1198,6 +1200,7 @@ namespace FerramAerospaceResearch.FARAeroComponents
List<float> weighting = new List<float>();
HashSet<FARAeroPartModule> tmpAeroModules = new HashSet<FARAeroPartModule>();
_sonicDragArea = 0;
+ debugString = "";
for (int i = 0; i <= numSections; i++) //index in the cross sections
{
@@ -1300,9 +1303,18 @@ namespace FerramAerospaceResearch.FARAeroComponents
cPSonicBackward *= 0.5;
}
+ debugString += "[" + i + "]\n";
+ debugString += string.Format("HDF: {0:F5}, HDFF: {1:F5}, SBD: {2:F5}, HDB: {3:F5}, HDBF: {4:F5}, CPSF: {5:F5}, CPSB: {6:F5}\n",
+ hypersonicDragForward, hypersonicDragForwardFrac, sonicBaseDrag, hypersonicDragBackward,
+ hypersonicDragBackwardFrac, cPSonicForward, cPSonicBackward);
+
+
+
if (sonicBaseDrag > 0) //occurs with increase in area; force applied at 180 AoA
{
+ debugString += "XFP0: " + ((hypersonicDragForward * 0.4f * hypersonicDragForwardFrac) * lowFinenessRatioSubsonicFactor).ToString("F5") + "\n";
xForcePressureAoA0.Add((float)criticalMachNumber, (hypersonicDragForward * 0.4f * hypersonicDragForwardFrac) * lowFinenessRatioSubsonicFactor, 0f, 0f); //hypersonic drag used as a proxy for effects due to flow separation
+ debugString += "XFP180: " + ((sonicBaseDrag * 0.25f - hypersonicDragBackward * 0.4f * hypersonicDragBackwardFrac) * lowFinenessRatioSubsonicFactor).ToString("F5") + "\n";
xForcePressureAoA180.Add((float)criticalMachNumber, (sonicBaseDrag * 0.25f - hypersonicDragBackward * 0.4f * hypersonicDragBackwardFrac) * lowFinenessRatioSubsonicFactor, 0f, 0f);
sonicAoA0Drag = -(float)(cPSonicForward * (curArea - prevArea)) + hypersonicDragForward * 0.2f;
@@ -1313,7 +1325,9 @@ namespace FerramAerospaceResearch.FARAeroComponents
}
else if (sonicBaseDrag < 0)
{
+ debugString += "XFP0: " + ((sonicBaseDrag * 0.25f + hypersonicDragForward * 0.4f * hypersonicDragForwardFrac) * lowFinenessRatioSubsonicFactor).ToString("F5") + "\n";
xForcePressureAoA0.Add((float)criticalMachNumber, (sonicBaseDrag * 0.25f + hypersonicDragForward * 0.4f * hypersonicDragForwardFrac) * lowFinenessRatioSubsonicFactor, 0f, 0f);
+ debugString += "XFP180: " + ((-hypersonicDragBackward * 0.4f * hypersonicDragBackwardFrac) * lowFinenessRatioSubsonicFactor).ToString("F5") + "\n";
xForcePressureAoA180.Add((float)criticalMachNumber, (-hypersonicDragBackward * 0.4f * hypersonicDragBackwardFrac) * lowFinenessRatioSubsonicFactor, 0f, 0f);
sonicAoA0Drag = -(float)(cPSonicForward * (curArea - prevArea)) + sonicBaseDrag + hypersonicDragForward * 0.2f;
@@ -1325,7 +1339,9 @@ namespace FerramAerospaceResearch.FARAeroComponents
}
else
{
+ debugString += "XFP0: " + ((hypersonicDragForward * 0.4f * hypersonicDragForwardFrac) * lowFinenessRatioSubsonicFactor).ToString("F5") + "\n";
xForcePressureAoA0.Add((float)criticalMachNumber, (hypersonicDragForward * 0.4f * hypersonicDragForwardFrac) * lowFinenessRatioSubsonicFactor, 0f, 0f);
+ debugString += "XFP180: " + ((-hypersonicDragBackward * 0.4f * hypersonicDragBackwardFrac) * lowFinenessRatioSubsonicFactor).ToString("F5") + "\n";
xForcePressureAoA180.Add((float)criticalMachNumber, (-hypersonicDragBackward * 0.4f * hypersonicDragBackwardFrac) * lowFinenessRatioSubsonicFactor, 0f, 0f);
sonicAoA0Drag = -(float)(cPSonicForward * (curArea - prevArea)) + hypersonicDragForward * 0.2f;
@@ -1339,7 +1355,9 @@ namespace FerramAerospaceResearch.FARAeroComponents
float diffSonicHyperAoA180 = Math.Abs(sonicAoA180Drag) - Math.Abs(hypersonicDragBackward);
+ debugString += "XFP0: " + sonicAoA0Drag.ToString("F5") + "\n";
xForcePressureAoA0.Add(1f, sonicAoA0Drag, 0, 0);
+ debugString += "XFP180: " + sonicAoA180Drag.ToString("F5") + "\n";
xForcePressureAoA180.Add(1f, sonicAoA180Drag, 0, 0);
xForcePressureAoA0.Add(2f, sonicAoA0Drag * 0.5773503f + (1 - 0.5773503f) * hypersonicDragForward);
diff --git a/FerramAerospaceResearch/FARGUI/FARFlightGUI/FlightGUI.cs b/FerramAerospaceResearch/FARGUI/FARFlightGUI/FlightGUI.cs
index b5d54dc..172fb5d 100644
--- a/FerramAerospaceResearch/FARGUI/FARFlightGUI/FlightGUI.cs
+++ b/FerramAerospaceResearch/FARGUI/FARFlightGUI/FlightGUI.cs
@@ -274,12 +274,15 @@ namespace FerramAerospaceResearch.FARGUI.FARFlightGUI
_flightStatusGUI.Display();
showFlightDataWindow = GUILayout.Toggle(showFlightDataWindow, "Flt Data", buttonStyle, GUILayout.ExpandWidth(true));
showSettingsWindow = GUILayout.Toggle(showSettingsWindow, "Flt Settings", buttonStyle, GUILayout.ExpandWidth(true));
+ if (GUILayout.Button("Debug", buttonStyle, GUILayout.ExpandWidth(true)))
+ Debug.Log(_vesselAero.DebugString);
GUILayout.Label("Flight Assistance Toggles:");
_stabilityAugmentation.Display();
GUILayout.EndVertical();
+
GUI.DragWindow();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment