55 lambd=SX.sym(
"lambda")
59 x_all = vertcat(x,u,y,v)
66 X_ = [3,-1.0/3,4,1.0/4]
67 XDOT_ = [-1.0/3,1147.0/240,1.0/4,-653.0/180]
72 ode = vertcat(u,lambd*x,v,lambd*y+g)
74 dae = {
'x':x_all,
'z':z_all,
'p':p_all,
'ode':ode,
'alg':alg}
75 f = Function(
'f', [x_all, z_all, p_all], [ode, alg], [
'x',
'z',
'p'], [
'ode',
'alg'])
79 res = f(p=P_, x=X_, z=Z_)
86 j = jacobian(alg,lambd)
96 I =
integrator(
'I',
'idas', dae, {
'calc_ic':
False,
'init_xdot':XDOT_})
102 I(p=P_, x0=X_, z0=Z_)
103 except Exception
as e:
108 ode = vertcat(u,lambd*x)
109 alg = vertcat(x**2+y**2-L**2, u*x+v*y,u**2-g*y+v**2+L**2*lambd)
111 z_all = vertcat(y,v,lambd)
112 dae = {
'x':x_all,
'z':z_all,
'p':p_all,
'ode':ode,
'alg':alg}
113 f = Function(
'f', [x_all, z_all, p_all], [ode, alg], [
'x',
'z',
'p'], [
'ode',
'alg'])
119 XDOT_ = [-1.0/3,1147.0/240]
120 Z_ = [4,1.0/4,1147.0/720]
124 res = f(p=P_, x=X_, z=Z_)
130 J = f.factory(
'J', f.name_in(), [
'jac:alg:z'])
131 res = J(p=P_, x=X_, z=Z_)
132 print(array(res[
"jac_alg_z"]))
138 I =
integrator(
'I',
'idas', dae, {
't0':0,
'tf':1,
'init_xdot':XDOT_})
139 res = I(p=P_, x0=X_, z0=Z_)
153 I(p=P_, x0=X_, z0=Z_)
154 except Exception
as e: