Jump to content

Launch Efficiency Exercise [Updated for 0.21.1]


Recommended Posts

I thought I would offer an update on my progress since I do not have a video to post as of yet. I realized that I could find mech jeb's optimal trajectory for this particular rocket if I ran a few hundred test flight and recorded the data and plotted using Excel and Maple. That said I also realized that in actuality even with hundreds of test flight I was only going to get close the the Ideal trajectories. since I am still keeping the number of variable to 3, more on those in a bit. In reality there of many variable not the least of which many are derivatives including da/dt and dm/dt respectively. Where a=acceleration, and m=mass thus dT/dt=change in acceleration with respect to time and dm/dt=change in mass with respect to time. There are also many other variable, including d(u)/dh=change in resistive force with respect to height, and once you throw in a more complex rocket with multiple stages,you really start feeling overwhelmed. I am absolutely certain that their is a overarching function that could be made that would calculate the exact ideal path no matter the rocket, I also know for a staged rocket it would have to involve the step function. More on that here. But frankly I am at a loss as to how to proceed further in finding an idea function. (if it could be found mechjeb could be made to launch along a path Ideal for any rocket instead of some meen best path.)

All that said, the three variable I am allowing to change are curve % Curve end altitude and curve start altitude.( it should be noted that da/dt and dm/dt also change but at the same rate i.e. max rate this rocket allows) I will hopefully find an optimal curve by the end of the week (no sooner I fear) and it will only be good for this rocket. But since I find this fun I hope I won't tire of it before I am done with my tests.

I'm actually tempted to code this up to find a theoretical upper bound and see what the actual optimal profile looks like, in terms of pitch and thrust vs time. I had started on some similar code to find optimal landing profiles, was originally starting with airless bodies and single-stage vehicles for simplicity. Adding atmospheric drag and altitude-varying Isp (and flipping the initial and final conditions to do ascent instead of landing) shouldn't be too much more complex, given how much we know about KSP's atmosphere model.

The nonlinear dynamics involved mean there likely is not a simple closed-form expression that represents the optimal profile. But if we discretize over time and solve numerically for the inputs at each point over a given time horizon, there are good algorithms for at least getting locally optimal solutions. Multi-start or other heuristics could give us some indication of how susceptible this problem is to local optima.

Edited by tavert
Link to comment
Share on other sites

Here's my shot at this. Orbital info is in the top right, so I hope that's ok! Figured I'd just use one screen if it's all the same. Should be a score of 8.97. I want to get into the double digits, so I'll be spending some more time on this one.

screenshot201.png

Link to comment
Share on other sites

I made another attempt myself this morning. Clearly I still have some work to do to be competitive, but this result should move me up a couple of places in the rankings:

WvXUsAn.png

9bObNPY.png

I appreciate the effort you are making, Tarmenius, to host this challenge. It is shaping up to be a good one. If tavert is able to complete his calculations, this challenge could stand alongside Closette's Mini-challenge: max altitude with this supplied spacecraft challenge as one of the best ever.

Also, I agree with Gigaplex777 that it would be nice to have some indication in the results about who used MechJeb's autopilot, MechJeb's information panels and who flew vanilla. Not because the results should be segregated for any reason, but because it would result in an "at a glance" summary of the relative performance of MechJeb vs. hand flying. Clearly, MechJeb's autopilot has improved a lot since a year ago when I hosted the "Optimal Ascent Profile for this spacecraft" challenge. That alone is notable.

Link to comment
Share on other sites

Thanks for the support, PakledHostage, I appreciate it. And you make an excellent point on noting the use of MechJeb's auto-pilot and information panels. I hadn't thought of it that way before, but it makes good sense. I will make the additions accordingly.

Orbital info is in the top right, so I hope that's ok! Figured I'd just use one screen if it's all the same.

That works just fine! Congrats on a great first entry!

Link to comment
Share on other sites

Multi-start or other heuristics could give us some indication of how susceptible this problem is to local optima.

My gut says this problem is littered with local optima. I spent a ton of time iterating profile % and accel limit around a 4.5-5km gravity turn start, and thought I had the optimum dialed in until you posted your 8.25km one blowing mine away. Could be they're only local 1D optima though, and there's always a gradient in some direction if you include enough variables...

I totally understand your impulse to code it up, tavert - hell, I share it. But I'm holding off because KSP's aero model is currently so totally broken. You can't get any guidance or governing equations from real-life research, and you'd have to back out KSP's aero code from many many trials.

Link to comment
Share on other sites

I totally understand your impulse to code it up, tavert - hell, I share it. But I'm holding off because KSP's aero model is currently so totally broken. You can't get any guidance or governing equations from real-life research, and you'd have to back out KSP's aero code from many many trials.

While I agree that KSP's aero model is badly broken, it is well understood by the KSP community. Have a look at the Mini-challenge: max altitude with this supplied spacecraft thread that I mentioned above. The aerodynamic drag was determined by Closette, Kosmo-not, et al in that thread as follows:

In-game aerodynamic drag equation:

zIuDg.jpg

where:

m is the instantaneous total spacecraft mass

Cd is the 'mass-weighted average of all the parts maximum_drag factors'

The 'mass-weighted average of all the parts maximum_drag factors' is defined as:

4xklX.jpg

where:

n is the number of individual components in the stack

mj are the individual masses of each of the spacecraft components (from the VAB)

Cdj are the individual drag coefficients of the spacecraft components (from the VAB)

Kerbin\'s atmospheric density (rho in the drag equation above) can be approximated as:

RPgG6.jpg

where:

Altitude is in metres.

Link to comment
Share on other sites

Another try from me, improved slightly!

screenshot212.png

What's interesting, for those of you keeping score, is that I tried tavert's numbers in MechJeb, and I got totally cruddy results. I may have botched the max accel switch (this is why I use MechJeb, because I can't focus on stuff like this), so there could be that error. But I don't think it would have worked well anyway, judging by my tests. I think this is about the max for me without some serious testing, and I don't have the patience anymore! :D

I might try a few semi-manual tries. I think I can tweak some more out of it if MJ wasn't following the curve so much. It's almost like it's a binary solution for efficiency, maybe separated at around 30,000-35,000 meters. MJ works great up to about 35,000-40,000 and then it tries to finish out the curve and gets inefficient up there. Cutting back to lower accel at that point didn't make a difference (in fact it hurt my results). The specific impulse higher than 35,000 meters is essentially the max for the engine anyway, so the only reason to throttle back is to try and counteract any drag left. It's a balance of getting clear of the atmosphere (less drag) and enduring more gravity losses (time spent with a vertical vector). The math is too tedious for me, so I leave it to you guys!

Link to comment
Share on other sites

I tend to think of the drag value for each part as being in m^2/kg. Then you can use the standard formula:

drag = 0.5 Cd A rho v^2

Where Cd = 0.008, dimensionless; A is the drag value time mass of the part, which ends up being in m^2, and v is the speed in m/s.

I'm working on the intuition that the best ascent path maximizes the current speed, subject to drag and gravity loss being equal. That is the intuition that says you should climb vertically at terminal velocity; switching all the forces and speeds to a 2-vector, I'm hoping to have this spit out the absolute optimal path (the control variable is the thrust, which like everything else is a vector). No proofs yet... Maybe Wednesday?

Link to comment
Share on other sites

Some sexy looking math up there.

Oh man., my heart was beating going to circularize this thing

A vanilla run for me. Worth two 10s. ;) 10.10

khiyBjR.png

Went for more speed on the first vert ascent (after watching your video metaphor, thanks) , then made my way to the horizon by 35 km I think, at reducing throttle. Finally just pulsing to keep Ap above 74km, finally let it fall to about 73 km remembering that it usually raised anyway by prolonged 'impulse' burns.

Link to comment
Share on other sites

In-game aerodynamic drag equation:

zIuDg.jpg

Right. Because drag is proportional to mass. :confused:

Good to know it's well understood anyway! I didn't realize it had been analyzed to that level.

Link to comment
Share on other sites

It's proportional to cross-section area, which is somewhat related to mass. Linearly related if you build a thin saucer -- and, in fact, that's what an asparagus design is! The bigger failing of the drag model is that you just sum up the parts, regardless of their configuration.

Link to comment
Share on other sites

Another try from me, improved slightly!

<snip>

What's interesting, for those of you keeping score, is that I tried tavert's numbers in MechJeb, and I got totally cruddy results. I may have botched the max accel switch (this is why I use MechJeb, because I can't focus on stuff like this), so there could be that error. But I don't think it would have worked well anyway, judging by my tests. I think this is about the max for me without some serious testing, and I don't have the patience anymore! :D

I might try a few semi-manual tries. I think I can tweak some more out of it if MJ wasn't following the curve so much. It's almost like it's a binary solution for efficiency, maybe separated at around 30,000-35,000 meters. MJ works great up to about 35,000-40,000 and then it tries to finish out the curve and gets inefficient up there. Cutting back to lower accel at that point didn't make a difference (in fact it hurt my results). The specific impulse higher than 35,000 meters is essentially the max for the engine anyway, so the only reason to throttle back is to try and counteract any drag left. It's a balance of getting clear of the atmosphere (less drag) and enduring more gravity losses (time spent with a vertical vector). The math is too tedious for me, so I leave it to you guys!

Try with corrective steering off! Since this challenge craft has good TWR, corrective steering is probably hurting more than helping here.

The lower acceleration limit at high altitude only gave me another 0.01 fuel, so it was quite minor. I found it got the periapsis higher before apoapsis reached 74 km, so I lost a tiny bit less to gravity while coasting to apoapsis. You don't want to let time to apoapsis get too high either.

I'm working on the intuition that the best ascent path maximizes the current speed, subject to drag and gravity loss being equal. That is the intuition that says you should climb vertically at terminal velocity; switching all the forces and speeds to a 2-vector, I'm hoping to have this spit out the absolute optimal path (the control variable is the thrust, which like everything else is a vector). No proofs yet... Maybe Wednesday?

I was thinking something along those lines too initially, but watching the drag acceleration during my good flights, it dropped below 9.8 m/s^2 quite a bit quicker than my horizontal speed was reducing the effective gravity via centripetal acceleration. Though I bet that intuitive version would work better than MechJeb's current "limit to terminal velocity" which only considers vertical speed.

Edited by tavert
Link to comment
Share on other sites

Congratulations, honolululu on making the Double-Digit Club!

If I made a little jpeg or gif for those of you who break 10, would that be something you'd want to put in your signatures? I'd like to reward such exceptional efficiency with something more than just a place on the scoreboard.

Link to comment
Share on other sites

I know that recoding MechJeb to limit to terminal speed (rather than the current effect of limiting to about 10% above terminal speed in the vertical dimension, ignoring horizontal speed) saves about 40 m/s on a high TWR spacecraft, using all the default MechJeb settings. I lost that code, but it was fairly straightforward.

Link to comment
Share on other sites

Congratulations, honolululu on making the Double-Digit Club!

If I made a little jpeg or gif for those of you who break 10, would that be something you'd want to put in your signatures? I'd like to reward such exceptional efficiency with something more than just a place on the scoreboard.

I'm certainly quite chuffed about it. :) I did have some ribbons, but took out my sig when spoilers broke. Maybe save the gif for the next release contest is my vote. Not done with this one yet hopefully though.

Link to comment
Share on other sites

Woohoo! I made it to double digits!

screenshot216.png

I almost didn't believe it! I did a hybrid between manual and MechJeb. I used MechJeb for limiting the throttle and the orbital info, but the actual piloting was manual. So, here's to breaking your categories! :wink:

Link to comment
Share on other sites

What I found out was that the autopilot was costing me too much delta-v. For most of that run I was just letting the rocket naturally arc over for the gravity turn. I had marks I wanted to hit, so I adjusted as needed. Made for the horizon at around 45,000 m and cut the accel to 12.5 m/s^2.

If anyone wants my flight profile, I'll post it up here. I'm sure that number can be broken, because I overshot the apoapsis by a good bit.

Link to comment
Share on other sites

Still, even with the Ap overshoot, you managed to save about 11 m/s on that flight. Steering losses were reduced by 12 m/s, gravity losses by 4, but your drag losses increased by 7.

I'd love to see the profile you flew. I could certainly stand to refine my ascent a bit :)

Link to comment
Share on other sites

I'd love to see the profile you flew. I could certainly stand to refine my ascent a bit :)

I basically had goals to hit for each flight level I hit. I started the gravity turn at 6000m, I believe. (it might have been 5000m, I did so many I forgot!) The degrees of pitch at a certain altitude went as follows:

6000 m = start (80 deg)

9000 m = 70 deg

12,000 = 60

15,000 = 50

20,000 = 40

25k = 30

30k = 20

35k = 10

40k = 5

45k = 0 (i.e. "Bring me that horizon")

As I said in my previous post, I tried not to touch the controls at all. If you put your nose on the outer ring of the velocity vector you tend to arc over like this naturally. I had to hold in a few spots and push it over in a few others, but for the most part once I started the turn it went happily where I wanted it.

I set MJ to limit accel to terminal velocity and 22.5, so you hit 22.5 m/s^2 accel just before you begin the gravity turn, which prevents MJ from messing up your horizontal terminal velocity. Once I was done with the gravity turn, I changed the max accel to 12.5 (highlight the 2, hit 1). I stayed on the horizon line until the apoapsis reached 74 (which I actually missed, was busy looking at the fuel remaining!). At this point you're probably around 50k-52k, so you've got a minute of upper atmosphere coasting to do. Since I overshot, I didn't need to pulse to ensure the apoapsis stayed high enough. I let MechJeb do the circularization burn to only 74.1 km.

Don't have any vids or anything, so I hope the description makes sense!

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...