Jump to content

Adventures in using minThrust


Kerbas_ad_astra

Recommended Posts

In the Modders Notes for KSP 1.2, @JPLRepo says:

  • ModuleEngines now supports Real Fuels-style throttling and rates.

  • ModuleEngines now supports throttle-Isp interactions.

    • Turn on with useThrottleIspCurve = True and set the throttleIspCurve and throttleIspCurveAtmStrength curves.

    • throttleMin is set by minThrust/maxThrust

    • 0 throttle = 0 thrust, else it lerps between minThrust and maxThrust

 

In testing, I'm not seeing it.  When I set minThrust to something nonzero, the engine maintains that thrust, even when held at zero throttle (pressing 'X', moving the thrust limiter to zero), whether useThrottleIspCurve = True or false.  Do I need to set up a throttleIspCurve to drop Isp to zero at zero throttle?

Edited by Kerbas_ad_astra
Retitling, since now I've achieved the behavior and now am looking at its wider implications.
Link to comment
Share on other sites

4 hours ago, Kerbas_ad_astra said:

In the Modders Notes for KSP 1.2, @JPLRepo says:

  • ModuleEngines now supports Real Fuels-style throttling and rates.

  • ModuleEngines now supports throttle-Isp interactions.

    • Turn on with useThrottleIspCurve = True and set the throttleIspCurve and throttleIspCurveAtmStrength curves.

    • throttleMin is set by minThrust/maxThrust

    • 0 throttle = 0 thrust, else it lerps between minThrust and maxThrust

 

In testing, I'm not seeing it.  When I set minThrust to something nonzero, the engine maintains that thrust, even when held at zero throttle (pressing 'X', moving the thrust limiter to zero), whether useThrottleIspCurve = True or false.  Do I need to set up a throttleIspCurve to drop Isp to zero at zero throttle?

Yes you need to define a throttleIspCurve and throttleIspCurveAtmStrength to ModuleEngines in the config file.

Edited by JPLRepo
Link to comment
Share on other sites

Unfortunately, the engine still consumes fuel when it's at zero thrust/Isp.  I see in the API that there are more variables for fuel flow and the like, I'll see if I can play with those to get what I want (minThrust at nonzero throttle, zero thrust and zero fuel consumption at zero/minimum throttle).

Link to comment
Share on other sites

No, setting minFuelFlow isn't doing it. 

In fact, I don't think it's possible in 1.2.1.  Thrust is (by definition) mdot*Isp*g0, and even though I can squash Isp to zero at the appropriate throttle setting, everything for tinkering with mdot is either a global multiplier/limit or linked to air pressure and velocity.  :(  Probably mdot is determined by something like thrust_commanded/(Isp_vac*g0) (and thrust_commanded is clamped between minThrust and maxThrust).

Ideally, it would be nice to have a throttleFlowCurve (and throttleFlowCurveAtmStrength?), much like the distinct atmCurve and atmCurveIsp variables.  (Or just clamp thrust to zero when the throttle is zero/minimized.)

Edited by Kerbas_ad_astra
Link to comment
Share on other sites

Okay, so it may not be possible with config options only, but I've made a simple PartModule that watches the engine module and squashes fuel flow when its throttle is at throttleMin (via multFlow, described as a "Multiplier to final flow as calculated" in the API) and puts it back otherwise.  A search of GitHub indicates that RealFuels maybe used to do this, but I only find a reference to it in a changelog, not in the current source (I guess it's no longer necessary since they're doing their own engine module and solver nowadays).  Still, just in case other modules start tinkering with multFlow, I have my module store the old multFlow when it starts squashing, so it can put it back exactly when the throttle comes back up.

@JPLRepo, one final question: I see in the API that ModifyFlow clamps its output (presumably to ModuleEngines.CLAMP, 1e-5) rather than allowing a return of zero -- what's the reason for this?  If I have my flow-squasher module set multFlow to 1e-5 rather than zero, then even though almost no fuel is flowing, there's still a thrust effect playing.  I can suppress that with the throttleIspCurve above, but then Kerbal Engineer gets confused and thinks there's no delta-V in the stage when the throttle is at throttleMin.  It would be easiest if I could just squash flow all the way to zero (which leaves Isp alone and completely suppresses the exhaust effects), and doing so doesn't seem to cause any problems in testing, but I want to be sure that I won't cause any numerical issues before I move towards a release.

Edit: Actually, KER's delta-V display still gets confused when I squash flow all the way to zero (but not the TWR readouts, which happened when I used the throttleIspCurve).  I'll have to keep tinkering...

Edit 2: KER looks at the engine's throttle to decide how to calculate its flowrate (which then feeds the delta-V calculations).  If the throttle is zero, it uses the engine's "ideal" thrust (i.e. lerping between minFuelFlow and maxFuelFlow by the thrust percentage, or in other words 'what would the thrust and flowrate be at 100% throttle') to calculate flow rate, but otherwise, it uses the engine's actual thrust.  With minThrust, the throttle is never zero, but my fuel flow squasher sets thrust to zero, so KER thinks that the engines just never consume any fuel and never produce any delta-V.  Funnily enough, there's a comment in this part of the code that reads "TODO: This bit doesn't work for RF engines".

Edit 3: I can make this work by adding a check (to KER) to look for my module and respond accordingly (i.e. use the "ideal" calculation if the throttle is at throttleMin, not just zero), but I'm starting to feel like I may be going too far into the tall grass here.

Edit 4: DangIt uses the state of an engine's throttle (zero vs. nonzero) to determine if an engine is active (and thus aging and becoming more subject to failure).  I knew from the beginning that I would need to test with throttle-related mods like ThrottleControlledAvionics to see how they interact with my approach, but this can of worms may be bigger than I had thought.

Edited by Kerbas_ad_astra
Link to comment
Share on other sites

you're way beyond my level of understanding of the issue, but the only thing I would add is that KW Rocketry has SRB's that have a non-zero minThrust and I know we/I ran into issues with them not being throttlable with the in-editor right click GUI slider as well. You can set it, but it has no effect. This was a few KSP versions ago though, so it might have changed.

Link to comment
Share on other sites

  • 1 month later...

@JPLRepo I've tried to mess around with 

        useThrottleIspCurve
        throttleIspCurve
        throttleIspCurveAtmStrength

And I just cannot figure out what the real ingame result is.

Maybe you can help out with a couple of examples.

Maybe we could start with considering an engine in vacuum only. Let say I want to make an engine which run at the "atmosphereCurve"s setting of vacuum when throttle is at 100%, and increase linearly towards 10x efficiency when throttle goes to zero.

My guess would be settings something like this

        atmosphereCurve
        {
            key = 0 5200      //Vacuum ISP for 100% throttle
            key = 1 100
            key = 1.2 0.001
        }
        useThrottleIspCurve = True
        throttleIspCurve
        {
            key = 0 10
            key = 1 1
        }
        throttleIspCurveAtmStrength  //I still don't understand this curve, so I try to get it to be neutral in this example
        {
            100 1
             1 1
            0 1
        }

This does however not yield the result I would expect, I actually cannot figure what it exactly does... Engine still says its ISP is 5200 all the time. KER does calculate that the ISP is increased, but not nearly by 10x.

Edited by Warezcrawler
Link to comment
Share on other sites

On 11/8/2016 at 6:57 PM, Kerbas_ad_astra said:

In the Modders Notes for KSP 1.2, @JPLRepo says:

  • ModuleEngines now supports Real Fuels-style throttling and rates.

  • ModuleEngines now supports throttle-Isp interactions.

    • Turn on with useThrottleIspCurve = True and set the throttleIspCurve and throttleIspCurveAtmStrength curves.

    • throttleMin is set by minThrust/maxThrust

    • 0 throttle = 0 thrust, else it lerps between minThrust and maxThrust

 

In testing, I'm not seeing it.  When I set minThrust to something nonzero, the engine maintains that thrust, even when held at zero throttle (pressing 'X', moving the thrust limiter to zero), whether useThrottleIspCurve = True or false.  Do I need to set up a throttleIspCurve to drop Isp to zero at zero throttle?

Sounds like something they do here but use more less 2 plugins  3 if you count MM

 

Link to comment
Share on other sites

There is no need to involve ModuleManager for having zero thrust at zero throttle with modded throttle limits for stock ModuleEnginesFX. Instead, you can have the throttle limits stored somewhere and temporarily disabled when the throttle(in-game, not player's input) is at 0. This is what this duct tape grade plugin does(source included, licensed under CC-BY-NC-SA 4.0):

Throttle Controlled Shutdown

Hopefully a future patch will make this feature have 0 thrust at 0 throttle by default. Until then I'm using this workaround.

Link to comment
Share on other sites

  • 1 year later...

It's never late for a bit of necroposting )

@NotTheRealRMS , have you ever continued Throttle Controlled Shutdown? I use it with a set of minThrust altering patches and it generally works great, but it also affects solid rockets on decoupling making sepratrons and LES impossible to use properly.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...