Skip to content

Commit

Permalink
ksp 1.0 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
camlost2 committed May 2, 2015
1 parent 6aec631 commit 119880a
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 41 deletions.
Binary file modified GameData/AJE/Plugins/AJE.dll
Binary file not shown.
4 changes: 0 additions & 4 deletions Source/AJE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
<Reference Include="Assembly-CSharp">
<HintPath>D:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="FerramAerospaceResearch, Version=0.14.5.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\GameData\FerramAerospaceResearch\Plugins\FerramAerospaceResearch.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>D:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
Expand Down
Binary file modified Source/AJE.v12.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion Source/AJEInlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void FixedUpdate()
{
if (HighLogic.LoadedSceneIsEditor)
return;
if (vessel.mainBody.atmosphereContainsOxygen == false || part.vessel.altitude > vessel.mainBody.maxAtmosphereAltitude)
if (vessel.mainBody.atmosphereContainsOxygen == false || part.vessel.altitude > vessel.mainBody.atmosphereDepth)
{
return;
}
Expand Down
31 changes: 19 additions & 12 deletions Source/AJEModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@ public void Start()
engine = new EngineWrapper(part);
engine.idle = 1f;
engine.IspMultiplier = 1f;
engine.useVelocityCurve = false;
engine.atmChangeFlow = false;
engine.useVelCurve = false;
engine.useAtmCurve = false;
engine.machLimit = 99999;
engine.machHeatMult = 1;
engine.ThrustUpperLimit = maxThrust;
// bool DREactive = AssemblyLoader.loadedAssemblies.Any(
// a => a.assembly.GetName().Name.Equals("DeadlyReentry.dll", StringComparison.InvariantCultureIgnoreCase));
if (TIT > part.maxTemp)
part.maxTemp = TIT;
engine.heatProduction = part.maxTemp * 0.1f;
// engine.heatProduction = (float)part.maxTemp * 0.1f;
aje = new AJESolver();
aje.InitializeOverallEngineData(
Area,
Expand Down Expand Up @@ -120,9 +124,9 @@ public void FixedUpdate()
return;
if (engine.type == EngineWrapper.EngineType.NONE || !engine.EngineIgnited)
return;
if (vessel.mainBody.atmosphereContainsOxygen == false || part.vessel.altitude > vessel.mainBody.maxAtmosphereAltitude)
if (vessel.mainBody.atmosphereContainsOxygen == false || part.vessel.altitude > vessel.mainBody.atmosphereDepth)
{
engine.SetThrust(0);
engine.SetEngineParams(0, 1000);
return;
}

Expand All @@ -131,13 +135,16 @@ public void FixedUpdate()

if(CPR == 1 && aje.GetM0()<0.3)//ramjet
{
engine.SetThrust(0);
engine.SetIsp(1000);
engine.SetEngineParams(0, 1000);
}
else
{
engine.SetThrust((float)aje.GetThrust() / 1000f * Arearatio);
engine.SetIsp((float)aje.GetIsp());
float t = (float)aje.GetThrust() / 1000f * Arearatio; //in kN
float isp = (float)aje.GetIsp();
float ff = t / 9.801f / isp;
engine.SetEngineParams(ff, isp);
// engine.SetThrust((float)aje.GetThrust() / 1000f * Arearatio);
// engine.SetIsp((float)aje.GetIsp());
}
float fireflag = (float)aje.GetT3()/maxT3;
if (fireflag > 0.8f )
Expand Down Expand Up @@ -184,10 +191,10 @@ public void UpdateInletEffects()

public void UpdateFlightCondition(double altitude, double vel, CelestialBody body)
{
double p0 = FlightGlobals.getStaticPressure(altitude, body);
double t0 = FlightGlobals.getExternalTemperature((float)altitude, body) + 273.15;
double p0 = FlightGlobals.getStaticPressure(altitude, body);//in Kpa
double t0 = FlightGlobals.getExternalTemperature(altitude, body);//in Kelvin

This comment has been minimized.

Copy link
@blowfishpro

blowfishpro May 2, 2015

Collaborator

temperature is now location and time-of-day dependent. Use vessel.atmosphericTemperature instead

Environment = p0.ToString("N2") + " Kpa;" + t0.ToString("N2") + " K ";

Environment = p0.ToString("N2") + " Atm;" + t0.ToString("N2") + " K ";
if (CPR != 1)
{
float requiredThrottle = (int)(vessel.ctrlState.mainThrottle * engine.thrustPercentage); //0-100
Expand All @@ -206,7 +213,7 @@ public void UpdateFlightCondition(double altitude, double vel, CelestialBody bod
}

aje.SetTPR(OverallTPR);
aje.CalculatePerformance(p0 * 101.3, t0, vel, (actualThrottle + 1) / 100);
aje.CalculatePerformance(p0, t0, vel, (actualThrottle + 1) / 100);

}

Expand Down
21 changes: 12 additions & 9 deletions Source/AJEPropeller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ public override void OnStart(StartState state)
engine = new EngineWrapper(part);
engine.IspMultiplier = IspMultiplier;
engine.idle = idle;
engine.useVelocityCurve = false;
engine.useVelCurve = false;
engine.useAtmCurve = false;
engine.ThrustUpperLimit = maxThrust;
engine.useEngineResponseTime = false;

Expand Down Expand Up @@ -226,21 +227,23 @@ public void FixedUpdate()
return;
if (engine.type == EngineWrapper.EngineType.NONE || !engine.EngineIgnited)
return;
if ((!vessel.mainBody.atmosphereContainsOxygen && useOxygen) || part.vessel.altitude > vessel.mainBody.maxAtmosphereAltitude)
if ((!vessel.mainBody.atmosphereContainsOxygen && useOxygen) || part.vessel.altitude > vessel.mainBody.atmosphereDepth)
{
engine.SetThrust(0);
engine.SetEngineParams(0, 1000);
return;
}
// for RPM handling - bool throttleCut = (object)vessel != null && vessel.ctrlState.mainThrottle <= 0;
pistonengine._boost = boost;
pistonengine._mixture = mixture;
pistonengine._volEfficMult = VolETweak;

density = ferram4.FARAeroUtil.GetCurrentDensity(part.vessel, out speedOfSound);
temperature = (float)FlightGlobals.getExternalTemperature(vessel.altitude, vessel.mainBody);
pressure = FlightGlobals.getStaticPressure(vessel.altitude, vessel.mainBody); // include dynamic pressure
density = FlightGlobals.getAtmDensity(pressure, temperature,vessel.mainBody);
v = Vector3.Dot(vessel.srf_velocity, -part.FindModelTransform(engine.thrustVectorTransformName).forward.normalized);
pressure = FlightGlobals.getStaticPressure(vessel.altitude, vessel.mainBody) * 101325f; // include dynamic pressure
pressure *= 1000f;//kpa to pa

float dynPressure = 0.5f * (float)density * v * v;
temperature = FlightGlobals.getExternalTemperature((float)vessel.altitude, vessel.mainBody) + CTOK;
float acturalThrottle = (int)(vessel.ctrlState.mainThrottle * engine.thrustPercentage) / 100f;
if (acturalThrottle < 0.1f)
acturalThrottle = 0.1f;
Expand Down Expand Up @@ -299,9 +302,9 @@ public void FixedUpdate()
}
// thrust in kgf divided by kg mdot
isp = thrustOut * 1000 / 9.80665f / fuelFlow;
engine.SetThrust(thrustOut);
engine.SetIsp(isp);

// engine.SetThrust(thrustOut);
// engine.SetIsp(isp);
engine.SetEngineParams(fuelFlow/1000, isp);
//Vector3d v1 = part.FindModelTransform("thrustTransform").forward;
//v1 = vessel.ReferenceTransform.InverseTransformDirection(v1)*100;
//Vector3d v2 = vessel.srf_velocity;
Expand Down
17 changes: 10 additions & 7 deletions Source/AJERotor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public override void OnStart(StartState state)
engine = new EngineWrapper(part);
engine.IspMultiplier = IspMultiplier;
engine.idle = idle;
engine.useVelocityCurve = false;
engine.useVelCurve = false;
engine.useAtmCurve = false;
engine.ThrustUpperLimit = maxThrust;
float omega = rpm * 0.1047f;
// power *= 745.7f;
Expand All @@ -69,9 +70,9 @@ public void FixedUpdate()
return;
if (engine.type == EngineWrapper.EngineType.NONE || !engine.EngineIgnited)
return;
if ((!vessel.mainBody.atmosphereContainsOxygen && useOxygen) || part.vessel.altitude > vessel.mainBody.maxAtmosphereAltitude)
if ((!vessel.mainBody.atmosphereContainsOxygen && useOxygen) || part.vessel.altitude > vessel.mainBody.atmosphereDepth)
{
engine.SetThrust(0);
engine.SetEngineParams(0, 1000);
return;
}

Expand All @@ -84,15 +85,17 @@ public void FixedUpdate()



float density = (float)ferram4.FARAeroUtil.GetCurrentDensity(part.vessel.mainBody, (float)part.vessel.altitude);
float pressure = (float)FlightGlobals.getStaticPressure(vessel.altitude, vessel.mainBody); // include dynamic pressure
float temperature = (float)FlightGlobals.getExternalTemperature((float)vessel.altitude, vessel.mainBody);
float density = (float)FlightGlobals.getAtmDensity(pressure, temperature, vessel.mainBody);

aje.calc(density, vx, vz, weight*9.801f);


engine.SetThrust(aje.lift / 1000f);
// engine.SetThrust(aje.lift / 1000f);
float isp = aje.lift / 9.801f / BSFC / aje.power;
engine.SetIsp(isp);

// engine.SetIsp(isp);
engine.SetEngineParams(aje.lift / 1000 / 9.801f / isp, isp);
ShaftPower = ((int)(aje.power / 745.7f)).ToString() + "HP";

if (sas != null)
Expand Down
Loading

0 comments on commit 119880a

Please sign in to comment.