In [1]:
%matplotlib inline
from sympy import *
init_printing(use_unicode=True)
In [2]:
r, u, v, c, r_c, u_c, v_c, E, p, r_p, u_p, v_p, e, a, b, q, b_0, b_1, b_2, b_3, q_0, q_1, q_2, q_3, q_4, q_5 = symbols('r u v c r_c u_c v_c E p r_p u_p v_p e a b q b_0 b_1 b_2 b_3 q_0 q_1 q_2 q_3 q_4 q_5')
In [3]:
gamma = symbols('gamma',positive=True)
In [4]:
f2 = ((1/2)*r_c*c**2+(1/4)*u_c*c**4+(1/6)*v_c*c**6+(1/2)*r_p*p**2
+(1/4)*u_p*p**4+(1/6)*v_p*p**6-E*p-gamma*c*p-e*c**2*p**2)
nsimplify(f2)
Out[4]:
In [5]:
E_c = solve(f2.diff(p),E)[0]
E_c
Out[5]:
In [6]:
p_min = nsimplify(solve(f2.diff(c),p)[0])
p_min
Out[6]:
In [7]:
E_c = nsimplify(E_c.subs(p,p_min))
E_c
Out[7]:
In [8]:
series(E_c,c,n=7)
Out[8]:
In [9]:
Etrun = a*c+b*c**3+q*c**5
In [10]:
solve(Etrun.diff(c),c)
Out[10]:
In [11]:
c_L = solve(Etrun.diff(c),c)[1]
c_U = solve(Etrun.diff(c),c)[3]
c_L,c_U
Out[11]:
In [12]:
E_L = simplify(Etrun.subs(c,c_U))
E_U = simplify(Etrun.subs(c,c_L))
In [13]:
E_L,E_U
Out[13]:
In [8]:
rc = (gamma**2+a*gamma)/r_p
B = (r_p*u_c/gamma+u_p*(r_c/gamma)**3-2*e*r_c/gamma-2*e*r_p*r_c**2/gamma**3)
Q = ((2*e*r_c)**2/gamma**3+8*r_p*e**2*r_c**3/gamma**5-2*e*u_c/gamma
-4*e*r_c*r_p*u_c/gamma**3-6*e*u_p*r_c**4/gamma**5+r_p*v_c/gamma
+3*u_c*u_p*r_c**2/gamma**3+v_p*(r_c/gamma)**5)
In [9]:
collect(expand(B.subs(r_c,rc)),a)
Out[9]:
In [10]:
collect(expand(Q.subs(r_c,rc)),a)
Out[10]:
In [11]:
b0 = (u_p*(gamma/r_p)**3-4*e*gamma/r_p+u_c*r_p/gamma)
b1 = (3*u_p*gamma**2/r_p**3-6*e/r_p)
b2 = (3*u_p*gamma/r_p**3-2*e/(gamma*r_p))
b3 = u_p/r_p**3
q0 = (v_p*(gamma/r_p)**5-6*e*u_p*gamma**3/r_p**4+3*(gamma/r_p**2)*(4*e**2+u_c*u_p)-6*e*u_c/gamma+v_c*r_p/gamma)
q1 = (5*v_p*gamma**4/r_p**5-24*e*u_p*gamma**2/r_p**4+2*(16*e**2+3*u_c*u_p)/r_p**2-4*e*u_c/gamma**2)
q2 = (10*v_p*gamma**3/r_p**5-36*e*u_p*gamma/r_p**4+(28*e**2+3*u_c*u_p)/(gamma*r_p**2))
q3 = (10*v_p*gamma**2/r_p**5-24*e*u_p/r_p**4+8*(e/(gamma*r_p))**2)
q4 = (5*v_p*gamma/r_p**5-6*e*u_p/(r_p**4*gamma))
q5 = v_p/r_p**5
In [12]:
uc = solve(b0-b_0,u_c)[0]
up = solve(b3-b_3,u_p)[0]
vc = solve(q0-q_0,v_c)[0]
vp = solve(q5-q_5,v_p)[0]
In [13]:
replacements = [(v_p,vp),(u_p,up),(u_c,uc)]
In [16]:
vc = simplify(vc.subs([i for i in replacements]))
In [17]:
expand(vc)
Out[17]:
In [18]:
uc = simplify(uc.subs([i for i in replacements]))
In [19]:
expand(uc)
Out[19]:
In [20]:
up
Out[20]:
In [21]:
vp
Out[21]:
In [22]:
b0
Out[22]:
In [23]:
b1 = simplify(b1.subs(u_p,up))
In [24]:
b1
Out[24]:
In [25]:
b2 = simplify(b2.subs(u_p,up))
In [26]:
b2
Out[26]:
In [27]:
b3
Out[27]:
In [28]:
B_a = b_0+b1*a+b2*a**2+b_3*a**3
In [29]:
B_a
Out[29]:
In [30]:
q0
Out[30]:
In [33]:
q1 = simplify(q1.subs([i for i in replacements]))
In [34]:
q1
Out[34]:
In [37]:
q2 = q2.subs([i for i in replacements])
In [38]:
expand(q2)
Out[38]:
In [39]:
q3 = simplify(q3.subs([i for i in replacements]))
In [40]:
q3
Out[40]:
In [41]:
q4 = simplify(q4.subs([i for i in replacements]))
In [42]:
q4
Out[42]:
In [43]:
Q_a = q_0+q1*a+q2*a**2+q3*a**3+q4*a**4+q_5*a**5
In [44]:
collect(expand(Q_a),a)
Out[44]:
In [45]:
series(B_a**2-(20*a*Q_a/9),a,n=7)
Out[45]:
In [ ]: