Skip to content
Snippets Groups Projects
Commit 9a40eb52 authored by Alvaro Andres Ortega Rojas's avatar Alvaro Andres Ortega Rojas
Browse files

Upload New File

parent 3d6e2aa6
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:0e0d1267-1436-471a-a773-a1d372db643b tags:
``` python
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import ode
```
%% Cell type:code id:283753af-a6d0-418b-aff8-f3b8aad536b2 tags:
``` python
def rhs_pendulo(t, X, g, L):
th, w = X
dth = w
du = g/L*np.sin(th)
return [dth, du]
def rhs_lorenz(t, X, a, b, c):
x, y, z = X
dx = a*(y - x)
dy = x*(b - z)
dz = x*y - c*z
return [dx, dy, dz]
```
%% Cell type:code id:10f45dc0-6f1d-4cac-882c-13b3584dc741 tags:
``` python
ti = 0
tf = 2
dt = 0.01
th_i = 0.9
w_i = 0
X_i = [th_i, w_i]
t = [ti]
th = [th_i]
w = [w_i]
g = 9.7
L = 0.2
method = "dopri5"
solver = ode(rhs_pendulo)
solver.set_integrator(method)
solver.set_initial_value(X_i, ti)
solver.set_f_params(g, L)
while solver.t < tf and solver.successful():
t.append(solver.t+dt)
th.append(solver.integrate(solver.t+dt)[0])
w.append(solver.integrate(solver.t+dt)[1])
```
%% Cell type:code id:2b317458-a178-419d-8d20-34ac26c7da5b tags:
``` python
plt.figure()
plt.plot(t_z, th_z)
plt.plot(t_V, th_V)
plt.grid()
plt.show
```
%% Output
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[30], line 2
1 plt.figure()
----> 2 plt.plot(t_z, th_z)
3 plt.plot(t_V, th_V)
4 plt.grid()
NameError: name 't_z' is not defined
%% Cell type:code id:3fd7bf37-3f77-4df0-9f86-2b9dc3a05a6c tags:
``` python
#Lorenz
ti = 0
tf = 50
dt = 0.01
#parametros
a = 10
b= 28
c = 8/3
#condiciones iniciales
x_i = 1
y_i = 1
z_i = 1
X_i = [x_i, y_i, z_i]
#crear la persona que resuelva la ecuacion por tal método
method = "Isoda"
solver_lorenz = ode(rhs_lorenz)
solver_lorenz.se
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment