31 lines
785 B
Python
31 lines
785 B
Python
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
analytical_func = lambda x: 1 - (1 - np.exp(-10))*x - np.exp(-10*x)
|
|
|
|
def main():
|
|
for i in range(7):
|
|
x = []
|
|
y = []
|
|
x.append(0.)
|
|
y.append(0.)
|
|
with open(f"output/general/out_{10**(i+1)}.txt", "r") as f:
|
|
lines = f.readlines()
|
|
for line in lines:
|
|
x_i, y_i = line.strip().split(",")
|
|
x.append(float(x_i))
|
|
y.append(float(y_i))
|
|
|
|
x.append(1.)
|
|
y.append(0.)
|
|
|
|
plt.plot(x, y, label=f"n$_{{steps}} = 10^{i+1}$")
|
|
|
|
x = np.linspace(0, 1, 1001)
|
|
plt.plot(x, analytical_func(x), label=f"u$_{{exact}}$")
|
|
plt.legend()
|
|
plt.savefig("../latex/images/problem7.pdf")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|