Derivation of MWR coefficients - adv/diff example

[20]:
import numpy as np
import matplotlib.pyplot as plt
from sympy import *

Collocation method

[22]:
 a2, x, c, K = symbols('a2 x c K')
[23]:
xc      = 0.5 #collocation point
Ri      = c*((1-a2)+2*a2*xc) - K*2*a2
a2      = solve(Ri, a2)
a2
[23]:
[c/(2*K)]

Least Squares method

Try to compute the functional form of the coefficient a2 using the symbolic math package following the example given above.

[1]:
#a2, x, c, K = symbols('a2 x c K')
#Ri          = ???
#Wi          = diff(?,?)
#eq          = integrate(Wi*Ri,(x,0,1))
#a2          = solve(eq, a2)
#a2

[3]:
# hide: the code in this cell is hidden by the author
[3]:
[6*K*c/(12*K**2 + c**2)]

Galerkin method

[27]:
a2, x, c, K = symbols('a2 x c K')
#Ri          = ???
#Wi          = ???
#a2          = ???
# a2
[28]:
# hide: the code in this cell is hidden by the author
[28]:
[c/(2*K)]
[ ]: