Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make maximum dynamic pressure for deployable radiators configurable. #55

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
27 changes: 24 additions & 3 deletions FNPlugin/FNRadiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class FNRadiator : FNResourceSuppliableModule {
[KSPField(isPersistant = false, guiActive = true, guiName = "Upgrade")]
public string upgradeCostStr;

[KSPField(isPersistant = false)]
public float maxQ = 150.0f;
[KSPField(isPersistant = false, guiActive = true, guiName = "Max. Dyn. Press.")]
public string maxQStr;

//public static double stefan_const = 5.6704e-8;
protected static float rad_const_h = 1000;
protected static double alpha = 0.001998001998001998001998001998;
Expand Down Expand Up @@ -136,6 +141,17 @@ public void DeployRadiator() {
if (!isDeployable) {
return;
}
if (vessel.altitude <= PluginHelper.getMaxAtmosphericAltitude(vessel.mainBody)) {
float pressure = (float) FlightGlobals.getStaticPressure (vessel.transform.position);
float dynamic_pressure = (float) (0.5*pressure*1.2041*vessel.srf_velocity.sqrMagnitude);
if (dynamic_pressure >= maxQ) {
ScreenMessages.PostScreenMessage(
"Radiator deployment aborted: Dynamic pressure exceeds part tolerance.",
5.0f,
ScreenMessageStyle.UPPER_CENTER);
return;
}
}
anim [animName].speed = 1f;
anim [animName].normalizedTime = 0f;
anim.Blend (animName, 2f);
Expand Down Expand Up @@ -246,6 +262,7 @@ public override void OnStart(PartModule.StartState state) {


radiatorTempStr = radiatorTemp + "K";
maxQStr = maxQ + " Pa";
this.part.force_activate();
}

Expand Down Expand Up @@ -283,7 +300,7 @@ public override void OnFixedUpdate() {
float conv_power_dissip = 0;
if (vessel.altitude <= PluginHelper.getMaxAtmosphericAltitude(vessel.mainBody)) {
float pressure = (float) FlightGlobals.getStaticPressure (vessel.transform.position);
float dynamic_pressure = (float) (0.5*pressure*1.2041*vessel.srf_velocity.sqrMagnitude/101325.0);
float dynamic_pressure = (float) (0.5*pressure*1.2041*vessel.srf_velocity.sqrMagnitude);
pressure += dynamic_pressure;
float low_temp = FlightGlobals.getExternalTemperature (vessel.transform.position);

Expand All @@ -294,7 +311,7 @@ public override void OnFixedUpdate() {
}
convectedThermalPower = consumeFNResource (conv_power_dissip, FNResourceManager.FNRESOURCE_WASTEHEAT) / TimeWarp.fixedDeltaTime;

if (radiatorIsEnabled && dynamic_pressure > 1.4854428818159388107574636072046e-3 && isDeployable) {
if (radiatorIsEnabled && dynamic_pressure > maxQ && isDeployable) {
part.deactivate();

//part.breakingForce = 1;
Expand Down Expand Up @@ -404,7 +421,11 @@ public override string GetInfo() {
float thermal_power_dissip5 = (float)(GameConstants.stefan_const * radiatorArea * Math.Pow(1800, 4) / 1e6);
float thermal_power_dissip6 = (float)(GameConstants.stefan_const * radiatorArea * Math.Pow(2400, 4) / 1e6);
float thermal_power_dissip7 = (float)(GameConstants.stefan_const * radiatorArea * Math.Pow(3000, 4) / 1e6);
return String.Format("Maximum Waste Heat Radiated\n Base: {0} MW\n Upgraded: {1} MW\n-----\nRadiator Performance at:\n600K: {2} MW\n1200K: {3} MW\n1800K: {4} MW\n2400K: {5} MW\n3000K: {6} MW\n", thermal_power_dissip, thermal_power_dissip2, thermal_power_dissip3, thermal_power_dissip4, thermal_power_dissip5, thermal_power_dissip6, thermal_power_dissip7);
string infoStr = String.Format("Maximum Waste Heat Radiated\n Base: {0} MW\n Upgraded: {1} MW\n-----\nRadiator Performance at:\n600K: {2} MW\n1200K: {3} MW\n1800K: {4} MW\n2400K: {5} MW\n3000K: {6} MW\n", thermal_power_dissip, thermal_power_dissip2, thermal_power_dissip3, thermal_power_dissip4, thermal_power_dissip5, thermal_power_dissip6, thermal_power_dissip7);
if (isDeployable) {
infoStr += String.Format("-----\nBreaks if dynamic pressure exceeds {0} Pa", maxQ);
}
return infoStr;
}

public override int getPowerPriority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ MODULE
upgradedName = Graphene Radiator
upgradedRadiatorTemp = 3500
upgradeTechReq = experimentalElectrics
maxQ = 150
}

RESOURCE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ MODULE
upgradedName = Graphene Radiator
upgradedRadiatorTemp = 3500
upgradeTechReq = experimentalElectrics
maxQ = 150
}

RESOURCE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ MODULE
upgradedName = Graphene Radiator
upgradedRadiatorTemp = 3500
upgradeTechReq = experimentalElectrics
maxQ = 150
}

RESOURCE
Expand Down