Search code examples
pythonphysics

Calculating delta-v gives negative result


I'm trying to design my own model rocket completely by myself, but when I'm trying to calculate delta-v using the Tsiolkovsky equation, my code only gives negative answers.

I thought it may be down to my rocket not being powerful enough to have any delta-v so I used a real life example (Saturn V) and it gave an accurate result but still in negatives (first stage: -2000 delta-v).

This is my code:

import math
netMass = int(input('what is the  total mass of the rocket: '))
dryMass = int(input('what is the empty mass of the rocket: '))
Isp = int(input('what is the Isp of the engine: '))
fuelMass = netMass - dryMass
Δv = Isp*9.8*math.log(float(dryMass/netMass))
print(Δv)

I also don't have Numpy at my disposal so can only use the math library.


Solution

  • In the Tsiolkovsky rocket equation, the ratio which should be used is wet mass (or initial total mass) to dry mass (or final total mass). The code then should be

    import math
    netMass = int(input('what is the  total mass of the rocket: '))
    dryMass = int(input('what is the empty mass of the rocket: '))
    Isp = int(input('what is the Isp of the engine: '))
    fuelMass = netMass - dryMass
    Δv = Isp*9.8*math.log(float(netMass/dryMass))
    print(Δv)
    

    Which will give you the correct (positive) value for an ideal rocket in a vacuum.