Advertisement
jukaukor

pallosailio.py

Jan 11th, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. # Vuotava pallosäiliö
  2. # Juhani Kaukoranta 11.1.2024
  3. import numpy as np
  4. from numpy import pi,sqrt,arange
  5. from scipy.integrate import odeint
  6. import matplotlib.pyplot as plt
  7. # Miten säiliö pinta alee ?
  8. # funktio palauttaa korkeuden derivaatan dh/dt
  9. def model(h,t):
  10. A = 0.0001 # reikä m² = 1.0 cm²
  11. R = 0.30 # pallon säde 30 cm = 0.30 m
  12. g = 9.81 # putouskiihtyvyys m/s^2
  13. dhdt = -A*sqrt(2*g)/pi*sqrt(h)/(2*R*h - h**2)
  14. return dhdt
  15.  
  16. h0 = 0.55 # pinnan alkukorkeus m hetkellä t=0
  17. h1 = 0.30 # loppukorkeus
  18. @np.vectorize
  19. def alkupinta(t):
  20. return h0 # pinnan loppukorkeus m
  21. @np.vectorize
  22. def loppupinta(t):
  23. return h1 # pinnan loppukorkeus m
  24. t = arange(0,240,1) # aikaväli 0 - 240 s = 0-4 min
  25. # ratkaistaan ODE eli differentiaaliyhtälö
  26. h = odeint(model,h0,t) # ratkaisee vedenpinnankorkeuden diffyhtälön
  27. # plottaa korkeuden h riippuvuus ajasta t
  28.  
  29. plt.plot(t,h,t,alkupinta(t),t,loppupinta(t))
  30. plt.xlabel('aika t (s)')
  31. plt.ylabel('vedenpinnan korkeus h (m)')
  32. plt.title("Vuotavan pallosäiliön vedenpinnan korkeus")
  33. plt.text(60, .50, r'$alkukorkeus, loppukorkeus=55cm,30cm$')
  34. plt.show()
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement