Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- import pandas as pd
- def f(x):
- return alpha * (1 - x) - x * np.exp(-2*epsilon*x)
- def V(x):
- return -alpha*(x - (1/2)*x**2) + (1/4)*(-2 * x * epsilon * np.exp(-2*epsilon*x) - np.exp(-2*epsilon*x)) / (epsilon**2)
- def alpha_st(x):
- return (x * np.exp(-2*epsilon*x)) / (1 - x)
- def sts():
- x = dx
- while x <= (1 - dx):
- if ( (x - dx < 0) and (f(x) > 0) ) or ( (f(x - dx) > 0) and (f(x) < 0) ):
- y.append(x)
- x += dx
- def grafik(x, y):
- plt.title(f"alpha(x)")
- plt.xlabel("alpha")
- plt.ylabel("x")
- plt.grid()
- for i in range(len(x)):
- plt.plot(x[i], y[i], 'o', label=f'epsilon = {i+1}')
- plt.legend()
- plt.show()
- X1 = []
- Y1 = []
- dx = 0.0001
- alpha = 0
- for i in range(1, 7):
- epsilon = i
- y = []
- dx = 0.0001
- alpha = 0
- X = []
- Y = []
- while alpha < 0.15:
- x = 0
- while x <= (1 - dx):
- if (((f(x - dx) < 0) and (f(x) > 0)) or ((f(x - dx) > 0) and (f(x) < 0))):
- X.append(alpha)
- Y.append(x)
- x += dx
- alpha += 0.001
- X1.append(X)
- Y1.append(Y)
- grafik(X1, Y1)
- x_max = []
- y_max = []
- x_min = []
- y_min = []
- eps = np.arange(1, 6, 0.1)
- for epsilon in eps:
- x = 2 * dx
- while x < (1.0 - dx):
- a1 = alpha_st(x - dx)
- a2 = alpha_st(x)
- a3 = alpha_st(x + dx)
- if (a1 < a2) and (a3 < a2):
- x_max.append(a2)
- y_max.append(epsilon)
- if (a1 > a2) and (a3 > a2):
- x_min.append(a2)
- y_min.append(epsilon)
- x += dx
- plt.title(f"Фазова діаграма")
- plt.xlabel("alpha")
- plt.ylabel("eps")
- plt.grid()
- plt.plot(x_max, y_max, label='maximum')
- plt.plot(x_min, y_min, label='minimum')
- plt.legend()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement