Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
grupo-Lizarazo-Ortega
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Escuela de Fisica
Cursos
Herramientas Computacionales 23
Tareas
grupo-Lizarazo-Ortega
Commits
9a40eb52
Commit
9a40eb52
authored
1 year ago
by
Alvaro Andres Ortega Rojas
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
3d6e2aa6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Clases/Ultima_clase.ipynb
+160
-0
160 additions, 0 deletions
Clases/Ultima_clase.ipynb
with
160 additions
and
0 deletions
Clases/Ultima_clase.ipynb
0 → 100644
+
160
−
0
View file @
9a40eb52
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "0e0d1267-1436-471a-a773-a1d372db643b",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from scipy.integrate import ode"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "283753af-a6d0-418b-aff8-f3b8aad536b2",
"metadata": {},
"outputs": [],
"source": [
"def rhs_pendulo(t, X, g, L):\n",
" th, w = X\n",
" dth = w\n",
" du = g/L*np.sin(th)\n",
" return [dth, du]\n",
"\n",
"def rhs_lorenz(t, X, a, b, c):\n",
" x, y, z = X\n",
" dx = a*(y - x)\n",
" dy = x*(b - z)\n",
" dz = x*y - c*z\n",
" \n",
" return [dx, dy, dz]"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "10f45dc0-6f1d-4cac-882c-13b3584dc741",
"metadata": {},
"outputs": [],
"source": [
"ti = 0\n",
"tf = 2\n",
"dt = 0.01\n",
"\n",
"th_i = 0.9\n",
"w_i = 0\n",
"\n",
"X_i = [th_i, w_i]\n",
"\n",
"t = [ti]\n",
"th = [th_i]\n",
"w = [w_i]\n",
"\n",
"g = 9.7\n",
"L = 0.2\n",
"\n",
"method = \"dopri5\"\n",
"solver = ode(rhs_pendulo)\n",
"solver.set_integrator(method)\n",
"solver.set_initial_value(X_i, ti)\n",
"solver.set_f_params(g, L)\n",
"\n",
"while solver.t < tf and solver.successful():\n",
" t.append(solver.t+dt)\n",
" th.append(solver.integrate(solver.t+dt)[0])\n",
" w.append(solver.integrate(solver.t+dt)[1])"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "2b317458-a178-419d-8d20-34ac26c7da5b",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 't_z' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[30], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m plt\u001b[38;5;241m.\u001b[39mfigure()\n\u001b[1;32m----> 2\u001b[0m plt\u001b[38;5;241m.\u001b[39mplot(\u001b[43mt_z\u001b[49m, th_z)\n\u001b[0;32m 3\u001b[0m plt\u001b[38;5;241m.\u001b[39mplot(t_V, th_V)\n\u001b[0;32m 4\u001b[0m plt\u001b[38;5;241m.\u001b[39mgrid()\n",
"\u001b[1;31mNameError\u001b[0m: name 't_z' is not defined"
]
},
{
"data": {
"text/plain": [
"<Figure size 640x480 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure()\n",
"plt.plot(t_z, th_z)\n",
"plt.plot(t_V, th_V)\n",
"plt.grid()\n",
"plt.show"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3fd7bf37-3f77-4df0-9f86-2b9dc3a05a6c",
"metadata": {},
"outputs": [],
"source": [
"#Lorenz\n",
"\n",
"ti = 0\n",
"tf = 50\n",
"dt = 0.01\n",
"\n",
"#parametros\n",
"a = 10\n",
"b= 28\n",
"c = 8/3\n",
"\n",
"#condiciones iniciales\n",
"x_i = 1\n",
"y_i = 1\n",
"z_i = 1\n",
"\n",
"X_i = [x_i, y_i, z_i]\n",
"\n",
"#crear la persona que resuelva la ecuacion por tal método\n",
"method = \"Isoda\"\n",
"solver_lorenz = ode(rhs_lorenz)\n",
"solver_lorenz.se"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% 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
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment