Jump to content

[All OS] [Python3.x] FireMarshal - quick and easy delta-v - [github]


draeath

Recommended Posts

Hi folks! Here's my first tool for KSP. It does what it says on the tin - give it data, and it gives you other data ;)

Specifically you provide vessel information and a desired delta-V, and it gives you back the burn time, mass change, and what fuel you'll have remaining. For fuel, if you do not know the mass - take the tank wet mass, subtract the dry mass. Then divide by the number of 'units' stored - this will give you the mass per unit for that fuel type. Be sure to combine any components used - for example, you would combine liquid fuel and oxidizer and consider it to be a single unified "fuel" since it's the mixture that's expended.

It may not be obvious, but this works for using RCS as well - just look up the thrust and Isp of each RCS cluster that would be used and input them as "engines" - for fuel mass, use the combined monopropellant across all of your enabled RCS tanks.

This was written for Python 3, so I can claim no support for Python 2. You can try, at your own risk. The license is in the script, hard to miss.

Feedback (and someone verifying my math) is highly appreciated :)

Note that you can use this for real rocketry as well, if you tweak standard_gravity to the real-world value in m/s2 - though of course there's no warranty that this program won't cause half the city to catch fire or the like.

Example session:

C:\Users\draeath\Desktop>python KSP-FireMarshal.py

Welcome! This utility will compute burn time and fuel usage for a given delta-v.

Tip: Mg = metric ton = 1000kg
Tip: combine expended resources for these calculations. (eg fuel+oxi)
Tip: liquid fuel and oxidizer mass is 5kg per unit.
Tip: monopropellant mass is 4kg per unit.
Tip: specify only the fuel mass for the current stage.
Tip: (wet_mass - dry_mass) / capacity = mass per unit

Desired delta-v in m/s? 500
Vessel mass in Mg? 5
Fuel mass in Mg? 2.5

Thrust and Isp entry will loop - make one entry per engine.
Provide value of 0 to stop adding engines.
Engine 1 thrust in kN? 25
Engine 1 specific impulse in seconds? 800
Engine 2 thrust in kN? 10
Engine 2 specific impulse in seconds? 350
Engine 3 thrust in kN? 10
Engine 3 specific impulse in seconds? 350
Engine 4 thrust in kN? 100
Engine 4 specific impulse in seconds? 280
Engine 5 thrust in kN? 0

Calculated thrust: 145.0
Calculated specific impulse: 325.4509

Burn time: 15.96 sec.
Initial mass: 5.0 Mg.
Final mass: 4.276 Mg.
Fuel spent: 0.724 Mg.
Fuel remaining: 1.776 Mg.

Press any key to continue . . .

C:\Users\draeath\Desktop>

Code is on github

Changes:

1.0 - initial release.

1.1 - added support for multiple engines.

1.1b - fixed derp - we only iterate through engines once now.

1.1c - tweaked tips

see github for any future updates

Edited by draeath
updated
Link to comment
Share on other sites

What about division? At some point / as it is now was //.

Though TBH I'd be more concerned about input() vs raw_input().

That said wasn't there official wrapper/conversion scripts?

I'm still a python newbie TBH, even though I first started flirting with it back in 2.4 - but what can I say... I'm looking prograde ;)

EDIT: / vs // shouldn't matter as I use floats in the math. import() does, however, as in 2.x there is effectively an eval() in there (dangerous!). Finally, there seems to be a backwards converter similar to the forwards one.

Edited by draeath
Link to comment
Share on other sites

  • 2 weeks later...

Thanks for writing it in python 3! I always try to push python 3, but not so many people like it. Just a few changes I would make:

1) Why use 'system("pause")'? Just let the script exit on its own.

2) Please use git. I would love to contribute to the source, and would love to see histories for the code and everything.

3) @dewin: print() works in python 2 as well as python 3, It's just that 'print "foo"' doesn't work in python 3.

4) Have you thought about passing it craft files and just parsed the data from there? (I might like to contribute some stuff, if you're okay with that)

5) Needs some knowledge of staging, unless the different engines are actually different stages.

Just some thoughts.

Link to comment
Share on other sites

Thanks for the feedback :)

1) For most Windows users, if one was to just double-click the .py it would close immediatly upon output. The pause is there to give them a chance to read the data.

2) I can certainly put it up somewhere. I don't however use git (use hg), and I'm not sure how bitbucket handles public users.

3) yep

4) That's way over my head at this point. I've no problems with your adding stuff if you want, just stick to the (not actually very restrictive :P) license. There won't be any changes between what's there now and what I put up in version control, so no need to wait if you don't want to.

5) The trouble is that staging will change the mass during the burn. I don't know how to handle that... and TBH this can already be handled by considering the stages as separate burns, and putting in your vessel mass appropriately. Just combine the burn times for each stage you calculate. As with 4) I'm perfectly OK with people having a stab at it themselves.

EDIT: done, it's up on github. There's really no reason I can't use git instead of hg, they are close enough to each other - at least as far as my usage goes.

Edited by draeath
pushed to git
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...