[Scipy-tickets] [SciPy] #1708: scipy.integrate.odeint will work with values in scientific notation but not values that are written out.

SciPy Trac scipy-tickets@scipy....
Tue Jul 24 17:43:30 CDT 2012


#1708: scipy.integrate.odeint will work with values in scientific notation but not
values that are written out.
-------------------------------------+--------------------------------------
 Reporter:  jgarc063                 |       Owner:  somebody   
     Type:  defect                   |      Status:  new        
 Priority:  normal                   |   Milestone:  Unscheduled
Component:  scipy.integrate          |     Version:  0.9.0      
 Keywords:  Odeint, scipy.integrate  |  
-------------------------------------+--------------------------------------
 First system info:
 Ubuntu 10.04
 Python 3.1.2
 Scipy 0.9.0
 Matplotlib 1.1.0(unofficial version ported through a sprint)

 In the code below I've seperated the offending section. In the section
 shown variable alpha is set to 3*10^4 and the code works giving the
 expected responsed of an RLC circuit. However if I alternatively set alpha
 to 30000 the response returned by odeint is incorrect. Additionally if I
 set alpha to 3.2*10^4 the script won't even run. I also tried 3e4 and that
 doesnt give the proper results either.

 Thank you for your consideration.

 Best Regards,
 Jorge Garcia
 ___________________________________________________________
 import numpy as np
 import math as m
 import matplotlib.pyplot as plt
 from scipy.integrate import odeint

 #Differential equation values
 w02 = 16*10^8      #Resonant Frequency a little over 10hz
 alpha = 5*10^4       #Neper Frequency adjusted for each graph
 I = 0.024           #Source Current

 #Solve system of equations dy/dt = f(y,t)
 def f(y, t):
     x2i = y[0]
     x1i = y[1]
     #Model equation
     x2prime = w02*(I-x1i)-2*alpha*x2i
     x1prime = x2i
     return [x2prime, x1prime]

 #initial conditions
 x20 = 0
 x10 = 0
 y0 = [x20, x10] #initial condition vector
 t = np.linspace(0, 5, 10000)

 #plot results
 plt.figure
 plt.title('Current Step Response')

 #solve the ODEs
 soln = odeint(f, y0, t)
 V = soln[:, 1]
 plt.plot(t, V, label='overdamped')
 #----------------------------------------- LOOK HERE
 alpha = 3*10^4
 soln = odeint(f, y0, t)
 V = soln[:, 1]
 plt.plot(t, V, label='underdamped')
 #----------------------------------------- LOOK HERE
 alpha = 4*10^4
 soln = odeint(f, y0, t)
 V = soln[:, 1]
 plt.plot(t, V, label='critically damped')

 g=[]
 for element in t:
     g.append(I*0.9)

 plt.plot(t, g, label='90% value')

 plt.legend(loc=0)
 plt.xlabel('Time(100us)')
 plt.ylabel('Current(mA)')

 plt.grid(True)

 plt.show()
 _________________________________________________________

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1708>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list