modifty the code, remove parameter G and set limit for e betwwen 0 to 1: def plot_fitted_flow_rule(confine_stress, compressive_stress):
cs1 = confine_stress
cs2 = confine_stress
cs3 = -np.array(compressive_stress)

ini
Copy
cI1 = cs1 + cs2 + cs3
cJ2 = (1 / 6) * ((cs1 - cs2)**2 + (cs2 - cs3)**2 + (cs1 - cs3)**2)

cp = cI1 / 3
cq = np.sqrt(3 * cJ2)

initial_guess = [1, 30, 0.3]

# Set the lower and upper bounds for the parameters G, phi, and e
lower_bounds = [0, -np.inf, 0]      # Set the lower limit for G, e.g., 0
upper_bounds = [10, np.inf, 1]      # Set the upper limit for G, e.g., 10

popt, pcov = curve_fit(non_associative_flow_rule_fit, cq, cp, p0=initial_guess, maxfev=5000, bounds=(lower_bounds, upper_bounds))

G, phi, e = popt

plt.scatter(cp, cq, label="Data points")

q_fitted = np.linspace(np.min(cq), np.max(cq), 1000)
p_fitted = non_associative_flow_rule_fit(q_fitted, G, phi, e, f=0.9)
plt.plot(p_fitted, q_fitted, label="Fitted Curve", color="red")

plt.title(f"G: {G:.2f}, phi: {phi:.2f}, e: {e:.2f}")

L_p = G - q_fitted / np.tan(np.radians(phi))
# plt.plot(L_p, q_fitted, color="blue")

plt.xlabel("cq")
plt.ylabel("cp")
plt.legend()
plt.grid()
plt.show()