title: Calculating displacement from velocity equation with scipy.integrate.quad in python
body: <p>I am a total beginner in python and I am really stuck in this piece of code.</p>
  <p>The code is a simulation of a rocket launching
  What I want to do is calculate and store the displacement done by the rocket with time.
  To be able to plot displacement vs time.</p>
  <p>The rocket velocity (u_rocket) depends on t and m(t) (m_rocket)
  <a href="https://i.stack.imgur.com/N4Dma.png" rel="nofollow noreferrer">https://i.stack.imgur.com/N4Dma.png</a></p>
  <ul>
  <li>u_e and g are a constant</li>
  <li>m(t) is the current mass of the rocket with equation
  <a href="https://i.stack.imgur.com/wFJaZ.png" rel="nofollow noreferrer">https://i.stack.imgur.com/wFJaZ.png</a></li>
  <li>m(0) is the initial rocket mass (includes the whole fuel)</li>
  <li>m_b is the rocket mass when there's no more fuel</li>
  <li>t_b is the time at which fuel is finished</li>
  </ul>
  <p>I've tried defining u_rocket, but when it's integrated I get -ve values.</p>
  <p>How should I define u_rocket so it takes into consideration m_rocket and t?
  Should I nest m_rocket function inside u_rocket ?</p>
  <pre><code>from scipy.integrate import quad
  import numpy as np
  
  # Constants
  Grav = 9.81
  RocketMass = 1000.0 # Kg          # with no fuel
  JetArea = 0.1**2*np.pi # m^2    
  JetVel = 1500.0 # m/s           # initial jet velocity
  RocketMass_ignition = RocketMass + 1500.0  # mass of rocket a ignition 
  Burnout_time = 31.83 #s
          
  # define the velocity function
  
  def m_rocket(t):
      return RocketMass_ignition*(RocketMass_ignition - RocketMass)*(t/Burnout_time)
      
  def u_rocket(t):
      return -JetVel*np.log(m_rocket(t)/RocketMass_ignition) - Grav*t
      
  i = quad(u_rocket,0,20)
  </code></pre>