I am trying to rewrite several systems of equations in python, but I have little (very little) experience. I wrote something, but I don’t understand if it’s correct.
Can anyone help?
Here is a photo of the equations:doc
My code:
import numpy as np
from scipy.optimize import fsolve
# Initial data
Ptmax_init = 100
Q_init = 100
e_init = 0.01
r0 = 0.85
S = 0.18
b = 0.045
c0 = 9.8 * 10**3
B = 0.53
th = 0.05
Cr = 6.33 * 10**5
mu = 0.8
Qc = 1.177 * 10**4
h_kr = 0.6
L = 2.5
ec = 0.01
k = 2.81
tang = 0.65
#Equations
def equations(vars):
Ptmax, Q, e = vars
eq1 = Ptmax = Q * ((r0 / (r0 - e)) * ((S - b) / S) * ((2 * c0 * (B + 2 * th) * r0) / (Cr * e) + tang - ((2 * c0 * (B + 2 * th)) / Cr)) + (mu * (b / S)))
eq2 = Q = (Qc + (Ptmax * h_kr / L))
eq3 = e = (ec + (Ptmax * h_kr) / (L * 1.44 * np.sqrt((Cr**2 * Q) / r0 * (1 + np.sqrt(k + 1))**2)**(1/3)))
return [eq1, eq2, eq3]
# Solving
initial_guess = [Ptmax_init, Q_init, e_init]
solution = fsolve(equations, initial_guess, maxfev=150)
Ptmax_sol, Q_sol, e_sol = solution
print(f"Solve: Ptmax = {Ptmax_sol}, Q = {Q_sol}, e = {e_sol}")
New contributor
Leonya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.