Skip to content

Instantly share code, notes, and snippets.

@alphaville
Created October 27, 2020 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alphaville/01171902213ee49779cc1500ac8e6e1e to your computer and use it in GitHub Desktop.
Save alphaville/01171902213ee49779cc1500ac8e6e1e to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
# constant control action:
u = 0.5
# define the system dynamics
def system_dynamics(_t, z):
return [z[1],
-z[0]*z[1] + u]
t_final = 4
z_init = [1, 1]
solution = solve_ivp(system_dynamics, [0, t_final], z_init,
t_eval=np.linspace(0, t_final, 100))
plt.plot(solution.t, solution.y.T)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment