<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Linear axisymmetric conservative interpolation
We want to construct a linear polynomal through that points $r_i$, $r_{i+1}$ that gives the correct averages,
$r_i$, and $r_{i+1}$ when integrated over the volume, e.g.
$$\frac{1}{r_i \Delta r} \int_{r_{i-1/2}}^{r_{i+1/2}} f(r) r dr = f_i$$
There are 2 unknowns and two constraints
Define the polynomial
Step1:  constraints
Define the constraint equations---here we set them up construct $A$ and $B$ integrals over the 2 control volumes
Step2:  interfaces
Step3:  centers
Step4:  The analytic forms of the integrals
Step5:  Our linear system is now
Step6:  And in pretty form, here's the polynomial
Step7:  Now, evaluate it on the interface
<ASSISTANT_TASK:>
Python Code:
a, b = symbols("a b")
r, r0 = symbols("r r0")
f = a*(r-r0) + b
f
dr = symbols("\Delta")
Explanation: Linear axisymmetric conservative interpolation
We want to construct a linear polynomal through that points $r_i$, $r_{i+1}$ that gives the correct averages,
$r_i$, and $r_{i+1}$ when integrated over the volume, e.g.
$$\frac{1}{r_i \Delta r} \int_{r_{i-1/2}}^{r_{i+1/2}} f(r) r dr = f_i$$
There are 2 unknowns and two constraints
Define the polynomial
End of explanation
f0, fp = symbols("f_i f_{i+1}")
rm12 = r0 - Rational(1,2)*dr
rp12 = r0 + Rational(1,2)*dr
rp32 = r0 + Rational(3,2)*dr
r1 = r0 + dr
Explanation: constraints
Define the constraint equations---here we set them up construct $A$ and $B$ integrals over the 2 control volumes
End of explanation
rm12, rp12, rp32
Explanation: interfaces
End of explanation
r0, r1
A = simplify(integrate(f*r/(r0*dr), (r, rm12, rp12)))
B = simplify(integrate(f*r/(r1*dr), (r, rp12, rp32)))
Explanation: centers
End of explanation
A, B
Explanation: The analytic forms of the integrals
End of explanation
coeffs = solve([A-f0, B-fp], [a,b])
coeffs
Explanation: Our linear system is now:
$$A = f_i$$
$$B = f_{i+1}$$
Now find the coefficients of the polynomial
End of explanation
l = f.subs(a,coeffs[a]).subs(b,coeffs[b])
l
Explanation: And in pretty form, here's the polynomial
End of explanation
a = l.subs(r, rp12)
simplify(a)
Explanation: Now, evaluate it on the interface
End of explanation
<END_TASK>