2013-03-20 27 views
6

chciałem przechowywać różne etapy integracji podejmowane przez samą solver kiedy ja to nazywam:Python - scipy: Moduł Oda: problem włączeniu opcji stopniową solver

solver1.integrate(t_end) 

Więc zrobiłem pętlę while i włączył opcję kroku ustawienie jej wartość True:

while solver1.successful() and solver1.t < t0+dt: 
    solver1.integrate(t_end,step=True) 
    time.append(solver1.t) 

Następnie wykreślić y, wynik integracji i tu mój problem. Mam niestabilności, które pojawiają się w obszarze zlokalizowany:

y enabling the step option of the solver

myślałem, że to ze względu na pętli czy coś takiego więc sprawdziłem wynik usuwania step:

while solver1.successful() and solver1.t < t0+dt: 
    solver1.integrate(t_end) 

i zaskoczenia. .. mam poprawny wynik:

y disabling the step option of the solver

Jest to zamknąć e dziwna sytuacja ... Byłbym wdzięczny, gdyby ktoś z waszych ludzi pomógł mi w rozwiązaniu tego problemu.

EDIT:

Aby ustawić solver zrobić:

solver1 = ode(y_dot,jac).set_integrator('vode',with_jacobian=True) 
solver1.set_initial_value(x0,t0) 

I zapisać wynik używając .append()

+0

Can pokazujesz więcej kodu, jak skonfigurować solver i zapisać wynik dla kreślenia? – silvado

+0

Oczywiście, właśnie zredagowałem moje pytanie. – kuider

+0

Nadal nie pokazałeś, jak faktycznie przechowujesz bieżący stan ODE, który nanosisz, zakładając, że wykresy pokazują jedną ze zmiennych stanu ODE. – Nikolas

Odpowiedz

2

Po ustawieniu step=True jesteś pośrednio dając vode._integrator.runner (A Fortran podprogram) instrukcja użycia itask=2, a wartością domyślną jest itask=1. Można uzyskać więcej szczegółów na temat tego runner robi:

r._integrator.runner? 

W scipy dokumentacji 0.12.0 nie znajdziesz wyjaśnienia na temat tego, co dzieje się na różnych itask=1 lub itask=2, but you can find it here:

ITASK = An index specifying the task to be performed. 
!   Input only. ITASK has the following values and meanings. 
!   1 means normal computation of output values of y(t) at 
!    t = TOUT(by overshooting and interpolating). 
!   2 means take one step only and return. 
!   3 means stop at the first internal mesh point at or 
!    beyond t = TOUT and return. 
!   4 means normal computation of output values of y(t) at 
!    t = TOUT but without overshooting t = TCRIT. 
!    TCRIT must be input as RUSER(1). TCRIT may be equal to 
!    or beyond TOUT, but not behind it in the direction of 
!    integration. This option is useful if the problem 
!    has a singularity at or beyond t = TCRIT. 
!   5 means take one step, without passing TCRIT, and return. 
!    TCRIT must be input as RUSER(1).