Skip to content

Instantly share code, notes, and snippets.

@ikirill

ikirill/q.py Secret

Created December 16, 2018 17:23
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 ikirill/cd286cd22e73a343f97dcd1145dc958c to your computer and use it in GitHub Desktop.
Save ikirill/cd286cd22e73a343f97dcd1145dc958c to your computer and use it in GitHub Desktop.
import numpy as np
import scipy
from scipy.integrate import solve_bvp
P = 0.49
def rhs(x, y, p):
λ1 = p[0]
return np.vstack((y[1, :], -np.pi*np.cos(np.pi*y[0, :]) / (2 * λ1), y[1, :]**2))
def bc(ya, yb, p):
return np.array([ya[0], yb[0] - 0.5, ya[2], yb[2] - P])
def main():
x0 = np.linspace(0, 0.5, 32)
y0 = np.vstack((x0, np.ones_like(x0), x0))
sol = solve_bvp(rhs, bc, x0, y0, p=np.array([0.23]))
print(sol)
print(sol.success)
return sol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment