Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @lazyglobal off.
- function calc_deltav_vacuum_all
- {
- parameter ves is ship.
- local deltaV to 0.
- local stageCounter to ves:stagenum.
- // The parts begin from bottom to top, the stageNum begins from top to bottom.
- // "calc_deltav_vacuum_stage" expects the part logic. So we count from 0 up.
- local currentStage to 0.
- local totalWetmass to 0.
- until stageCounter = -1
- {
- local calcDeltaVResult to calc_deltav_vacuum_stage(currentStage, ves, totalWetmass).
- local returnDeltaV to calcDeltaVResult[0].
- set totalWetmass to totalWetmass + calcDeltaVResult[1].
- set deltaV to deltaV + returnDeltaV.
- set stageCounter to stageCounter - 1.
- set currentStage to currentStage + 1.
- }
- print "Total delta v of vessel is " + round(deltaV) + " m/s".
- return deltaV.
- }
- function calc_deltav_vacuum_stage
- {
- parameter currentStage.
- parameter ves is ship.
- parameter upperWetMass is 0.
- // HACK: Workaround mapping
- set currentStage to currentStage - 1.
- local totalIsp to 0.
- local totalWetmass to upperWetMass.
- local totalDrymass to upperWetMass.
- local parts to ves:parts.
- for part in parts
- {
- // HACK: Workaround because engine were always one stage too high
- if (part:typename = "engine" and (part:stage - 1) = currentStage)
- {
- print "Part on stage: " + (currentStage + 1) + " is (engine) " + part:name.
- set totalIsp to totalIsp + part:visp.
- set totalWetmass to totalWetmass + part:mass.
- set totalDrymass to totalDrymass + part:drymass.
- }
- else if (part:stage = currentStage and part:typename <> "engine")
- {
- print "Part on stage: " + (currentStage + 1) + " is " + part:name.
- set totalWetmass to totalWetmass + part:mass.
- set totalDrymass to totalDrymass + part:drymass.
- }
- }
- if (totalIsp = 0 or totalWetmass = 0 or totalDrymass = 0)
- {
- print "DeltaV of stage " + (currentStage + 1) + " is 0 m/s".
- return list(0, 0).
- }
- local deltaV to (totalIsp * constant:g0 * ln(totalWetmass / totalDrymass)).
- print "totalIsp of stage " + (currentStage + 1) + " is " + round(totalIsp).
- print "totalWetmass of stage " + (currentStage + 1) + " is " + round(totalWetmass, 2).
- print "DeltaV of stage " + (currentStage + 1) + " is " + round(deltaV) + " m/s".
- return list(deltaV, totalWetmass).
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement