import numpy as np
import matplotlib.pyplot as plt
example = "Quadratic"
#############################################################################
# Exact solution
#############################################################################
def exactSolution(x):
if example == "Cubic":
return x * x * x
elif example == "Quartic":
return x * x * x * x
elif example == "Quadratic":
return 1/9 * x * x
elif example == "Linear":
return x
elif example == "Linear-cubic":
return np.where(x < 1.5, x, x + (x-1.5) * (x-1.5) * (x-1.5) )
else:
print("Error: Either provide Linear, Quadratic, Quartic, or Cubic")
sys.exit()
x = np.genfromtxt('x_16.csv',delimiter=',')
u_mscm = np.genfromtxt('u_mscm_n_16_Quadratic.csv',delimiter=',')
u_mdcm = np.genfromtxt('u_mdcm_n_16_Quadratic.csv',delimiter=',')
markers = ['s','o','x','.']
plt.plot(x,exactSolution(x),c="black",label="Exact solution")
plt.plot(x,u_mdcm,c="black",label="MDCM",marker='s',markevery=8)
plt.plot(x,u_mscm,c="black",label="MSCM",marker='o',markevery=8)
plt.grid()
plt.xlabel("$x$")
plt.ylabel("Displacement")
plt.title("Example with quadratic solution with $\delta=1/8$ and $m=2$")
plt.legend()
plt.savefig("quadratic-all-neumann.pdf",bbox_inches='tight')