Jump to content

Can I set isp as a function of velocity?


Recommended Posts

I'm altering the config file of an electric propeller engine. It previously would either not get off the ground, or get all the way to orbit. So it needed a reality check.

The physics of a propeller are such that without the compressor jets have efficiency drops off almost linearly with pressure, and also as the propeller blades exceed the speed of sound they become drag devices rather than lift devices. A standard base line seems to be a supersonic buzzing starting at around mach 0.85, net trust dropping to 0 by about mach 0.90 and thrust going negative past that.

Altering the forces is pretty easy using atmCurve{} and velCurve{}. Making sure the engine still draws power is a bit more difficult.

I solved the problem with atmosphere drop off by using atmosphereCurve{} like so.

		name = ModuleEnginesFX
		...

		atmosphereCurve
		{
			key = 0 800 0 1000000
			key = 0.000001 0 0 0.3012048
			key = 0.5 789.496 0.02686068 0.02686068
			key = 20 960 0 0
		}

		// Jet params
		...

		atmCurve
		{
			key = 0 0 0 0
			key = 0.000001 0 0 0.3012048
			key = 0.5 0.98687 0.02686068 0.02686068
			key = 20 1.2 0 0
		}

So that force and efficiency drop at the same time and at the same rate.

I would like to do the same thing with velocity.

Here's what I tried:

		name = ModuleEnginesFX
		...

		velocityCurve
		{
			key = 0 600 0 0
			key = 0.5 800 0 0
			key = 0.85 400 -2.125082 -29.05206
			key = 1 800 0 0
		}

		// Jet params
		...

		velCurve
		{
			key = 0 0.75 0 0
			key = 0.5 1 0 0
			key = 0.85 0.5 -2.125082 -29.05206
			key = 1 -1 0 0
		}

But the game doesn't recognize velocityCurve{} as anything even though I'm fairly sure I've seen it used before. (can't remember where)

As is the game follows velCurve{} by changing the flow of electricity rather than engine efficiency. However it makes no sense to have the propeller tips experiencing extreme supersonic drag at mach 0.90 but not requiring any power to keep moving and even less sense to have the propeller creating drag similar to a 1m parachute at mach 1 and actually be producing electricity.

Is there something small I'm missing in syntax, am I way off the mark, or is this idea impossible using base game mechanics?

 

 

Here's the whole module:

MODULE
{
	name = ModuleEnginesFX
	thrustVectorTransformName = thrustTransform
	exhaustDamage = False
	ignitionThreshold = 0.1
	minThrust = 0
	maxThrust = 50
	heatProduction = 8
	useEngineResponseTime = True
	engineAccelerationSpeed = 20
	engineDecelerationSpeed = 20
	//useVelocityCurve = True
	EngineType = Turbine
	PROPELLANT
	{
		name = ElectricCharge
		ratio = 0.4
		DrawGauge = True
	}
	PROPELLANT
	{
		name = FSCoolant
		ignoreForIsp = True
		ratio = 0.01
	}
    	atmosphereCurve
    	{
		key = 0 800 0 1000000
		key = 0.000001 0 0 0.3012048
		key = 0.5 789.496 0.02686068 0.02686068
		key = 20 960 0 0
    	}

		// Jet params
		atmChangeFlow = False
		useVelCurve = True
		useAtmCurve = True
		flameoutBar = 0.001
		flowCapMult = 1.0
		machHeatMult = 10

		atmCurve
		{
			key = 0 0 0 0
			key = 0.000001 0 0 0.3012048
			key = 0.5 0.98687 0.02686068 0.02686068
			key = 20 1.2 0 0
		}
		velCurve
		{
			key = 0 0.75 0 0
			key = 0.5 1 0 0
			key = 0.85 0.5 -2.125082 -29.05206
			key = 1 -1 0 0
		}
}

 

Link to comment
Share on other sites

The best source of information on this stuff is here but I don't think there's anything in the stock module that allows ISP to be modified by velocity. velocityCurve is not a valid parameter as of 1.0 (it was a parameter pre-1.0 so you will see it mentioned every now and again).

The best way I can see to do this is a separate module that bases power draw on current throttle and any other parameters you want. You'll probably need something custom for that, There aren't many stock modules that vary based on throttle

Link to comment
Share on other sites

 

23 minutes ago, Crzyrndm said:

The best source of information on this stuff is here but I don't think there's anything in the stock module that allows ISP to be modified by velocity. velocityCurve is not a valid parameter as of 1.0 (it was a parameter pre-1.0 so you will see it mentioned every now and again).

The best way I can see to do this is a separate module that bases power draw on current throttle and any other parameters you want. You'll probably need something custom for that, There aren't many stock modules that vary based on throttle

Fair enough.

Where would I find info on how to develop and integrate a new module like the one you suggest?

 

 

Also I could get a similar effect by changing drag on the propeller disk given velocity if that would be easier

Edited by JediMasterSterling1
One more thing
Link to comment
Share on other sites

This should do what you need. You'll need to compile it though (I can't do that atm) and I've probably forgotten something

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using UnityEngine;

namespace ThisIsNotTested
{
    public class ThrottledResourceConsumer : PartModule
    {
        [KSPField]
        public float Rate; // consumption per second at max throttle
      	[KSPField]
      	public string Resource; // the resource to use

        public override void OnStart(StartState state)
        {
            if (!Highlogic.loadedSceneIsFlight)
                return; // do nothing in the editor
            if (part.Modules.GetModules<ModuleEngines>.FirstOrDefault() == null)
              Destroy(this); // only want this module to work on parts that have an engine as well. Kill it if no engine module is present
        }

        public override void OnFixedUpdate()
        {
            if (!Highlogic.loadedSceneIsFlight)
                return; // do nothing in the editor
            // pull EC based on the throttle being used for this vessel
            part.requestResource(Resource, Rate * TimeWarp.fixedDeltaTime * vessel.ctrlState.mainThrottle);
        }
    }
}

And the module manager patch to add it to a part

@PART[<insert your part name here>]
{
	MODULE
    {
    	name = ThrottledResourceConsumer
        Rate = 10 // 10 EC per secon at max throttle
        Resource = ElectricCharge
    }
}
 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...